-
Notifications
You must be signed in to change notification settings - Fork 1
Session/agent 0d19c700 7fb5 44d4 ab75 2b8ab9741f18 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ static ID3D11RenderTargetView* g_render_target_view = nullptr; | |
| static WNDPROC g_original_wnd_proc = nullptr; | ||
| static bool g_initialized = false; | ||
| static bool g_show_menu = true; | ||
| static HMODULE g_h_module = nullptr; | ||
|
|
||
| // ============================================================================ | ||
| // HOOKS | ||
|
|
@@ -76,7 +77,8 @@ static HRESULT __stdcall HookedPresent(IDXGISwapChain* swap_chain, UINT sync_int | |
| ImGui_ImplWin32_Init(g_hwnd); | ||
| ImGui_ImplDX11_Init(g_device, g_context); | ||
|
|
||
| // Subclass window | ||
| // Subclass window - declare WndProc first | ||
| extern LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); | ||
| g_original_wnd_proc = reinterpret_cast<WNDPROC>( | ||
| SetWindowLongPtr(g_hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc))); | ||
|
Comment on lines
+80
to
83
|
||
|
|
||
|
|
@@ -328,8 +330,6 @@ DWORD WINAPI MainThread(LPVOID) { | |
| return 0; | ||
| } | ||
|
|
||
| static HMODULE g_h_module = nullptr; | ||
|
|
||
| BOOL APIENTRY DllMain(HMODULE h_module, DWORD reason, LPVOID reserved) { | ||
| if (reason == DLL_PROCESS_ATTACH) { | ||
| g_h_module = h_module; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -137,22 +137,22 @@ void SkinChanger::Shutdown() { | |||||||||||||||||
| static uintptr_t GetInventoryManager() { | ||||||||||||||||||
| if (!SkinChanger::s_fn_inventory_manager) return 0; | ||||||||||||||||||
| using Fn = uintptr_t(__fastcall*)(); | ||||||||||||||||||
| __try { return ((Fn)SkinChanger::s_fn_inventory_manager)(); } | ||||||||||||||||||
| __except (EXCEPTION_EXECUTE_HANDLER) { return 0; } | ||||||||||||||||||
| try { return ((Fn)SkinChanger::s_fn_inventory_manager)(); } | ||||||||||||||||||
| catch (...) { return 0; } | ||||||||||||||||||
|
Comment on lines
+140
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Using C++ try/catch instead of SEH __try/__except may no longer guard against access violations. Previously this used
Comment on lines
+140
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing Structured Exception Handling (
Comment on lines
+140
to
+141
|
||||||||||||||||||
| try { return ((Fn)SkinChanger::s_fn_inventory_manager)(); } | |
| catch (...) { return 0; } | |
| __try { | |
| return ((Fn)SkinChanger::s_fn_inventory_manager)(); | |
| } | |
| __except (EXCEPTION_EXECUTE_HANDLER) { | |
| return 0; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Same SEH vs C++ exception handling concern for econ item creation and attribute setting.
This function (and SetDynamicAttributeValue, ApplyGloves, SetModel, SetMeshGroupMask) now uses try/catch (...) instead of __try/__except. If these engine function pointers can raise SEH faults (e.g., due to engine changes or invalid state), C++ exceptions will not catch them and the process may crash. To maintain the previous fault-tolerance, either keep SEH around these calls or document and enforce that only C++ exceptions can be thrown here (via build config/contracts).
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above: C++ catch(...) will not intercept SEH faults from calling a potentially-invalid scanned function pointer, so this no longer provides crash protection. Prefer keeping the original __try/__except guard (or add /EHa / SEH translator if you intend to rely on catch(...)).
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above: this try/catch won’t catch structured exceptions (e.g., access violations) thrown by the engine call, so the guard is ineffective with the current exception model. Consider reverting to __try/__except for this boundary call, or introduce explicit SEH translation in the build/runtime.
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ catch(...) here won’t catch access violations from the engine call unless you compile with /EHa or install an SEH-to-C++ translator. This code previously used SEH to prevent crashes; consider reverting to __try/__except around this external call boundary.
| try { ((Fn)s_fn_set_mesh_group_mask)(view_model, 1); } | |
| catch (...) {} | |
| __try { | |
| ((Fn)s_fn_set_mesh_group_mask)(view_model, 1); | |
| } __except (EXCEPTION_EXECUTE_HANDLER) { | |
| } |
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try/catch guard around this scanned function pointer call will not catch SEH exceptions (e.g., AV) with the current build configuration, so it won’t prevent hard crashes. Please restore __try/__except (or add /EHa / SEH translation) for these engine boundary calls.
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above: catch(...) won’t intercept structured exceptions from this engine call without /EHa or an SEH translator, so the crash-guard behavior has effectively been removed. Consider reverting to __try/__except around this call site.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,17 @@ | ||
| #pragma once | ||
|
|
||
| #include <Windows.h> | ||
| #include <windows.h> | ||
| #include <cstdint> | ||
| #include <cstddef> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| namespace cs2 { | ||
|
|
||
| template<typename T> | ||
| inline T CallVFunc(void* thisptr, size_t index, auto&&... args) { | ||
| using Fn = T(__thiscall*)(void*, decltype(args)...); | ||
| return (*reinterpret_cast<Fn**>(thisptr))[index](thisptr, args...); | ||
| template<typename T, size_t Index, typename... Args> | ||
| inline T CallVFunc(void* thisptr, Args&&... args) { | ||
| using Fn = T(__thiscall*)(void*, std::remove_reference_t<Args>...); | ||
| return (*reinterpret_cast<Fn**>(thisptr))[Index](thisptr, std::forward<Args>(args)...); | ||
|
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of using Fn = T(__thiscall*)(void*, Args...);
return (*reinterpret_cast<Fn**>(thisptr))[Index](thisptr, std::forward<Args>(args)...); |
||
| } | ||
|
|
||
| struct SOID_t { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declaring an
externfunction inside a function body is generally discouraged as it obscures dependencies and can make the code harder to maintain. It is better to declareWndProcat the top of the file or in a shared header file.