2980 Commits

Author SHA1 Message Date
Kawe Mazidjatari
91ec38645c Formatting improvements in init.cpp
Make it easier to read on a vertical monitor.
2023-06-19 15:12:46 +02:00
Kawe Mazidjatari
0f9d12d506 Always pad 'build_id' field by 10
This is to maintain alignment, may it ever change.
2023-06-19 14:18:30 +02:00
Kawe Mazidjatari
a9338455aa Fix ImGui window procedure handler crash on shutdown
When and after 'Host_Shutdown()' is called, the window handle is still valid, thus the handler still gets called. This gets destroyed in 'OnShutdown()' called from 'CEngineAPI::RunListenServer()'. But we do shutdown the ImGui implementation in 'Host_Shutdown()'... Therefore, we should check if the implementation is initialized or not before running the window procedure handler.
2023-06-19 14:03:23 +02:00
Kawe Mazidjatari
abe68def03 CMDLCache code improvements
Slightly mapped out the CMDLCache class, to the point the pointers to its members are no longer needed. Also fixed a bug were the studiodata pointer was dereferenced before checking if its not null, this check did exist, but was performed too late. Fully implemented the CUtlDict class for m_MDLDict. Slightly optimized the initialization of the error model handles.
2023-06-19 13:53:56 +02:00
Kawe Mazidjatari
2cfed900d0 Add full CUtlDict implementation
CUtlDict from the SourceSDK.
2023-06-19 11:23:22 +02:00
Kawe Mazidjatari
a68a0c511a Log the SDK's 'build_id' under the emblem 2023-06-19 10:58:12 +02:00
Kawe Mazidjatari
acb68a559a Light optimization in engine logger sink
Only copy the string buffer our once.
2023-06-19 01:51:25 +02:00
Kawe Mazidjatari
d2fca23cf5 Fix typo in address logger
Technically not a pointer internally.
2023-06-19 01:46:05 +02:00
Kawe Mazidjatari
f024db1477 Use correct address logger
Should use the function logger instead.
2023-06-19 01:45:25 +02:00
Kawe Mazidjatari
18e4a262c8 Fix double crash dialog boxes bug
This occurs when the game's unhandled exception handler is getting called after ours. both will create a crashmsg process. This happened as CCrashHandler::End() was called before the in-game exception filter was fired, and therefore CCrashHandler::Handled would return false, and this fire the in-game exception filter. This commit removes the additional check, we just use our vectored exception handler entirely over the game's one, as this one captures everything an unhandled exception handler will capture, and more. The 'Handled' function/fields in CCrashHandler have been renamed to 'Handling', as this is a more appropriate name.
2023-06-19 01:35:10 +02:00
Kawe Mazidjatari
97a6b8b5cc Make CCrashHandler getters/setters inline
These could be just inline.
2023-06-19 01:19:47 +02:00
Kawe Mazidjatari
2ae1f88311 Improve crash handler file formatting
Only display hex comment on decimal ALU register if its above 9, and format it as such that it fits perfectly next to a register that is equal or lower than one million. Added additional comments.
2023-06-19 01:18:27 +02:00
Kawe Mazidjatari
f87fb2b2d6 Fix shutdown crash on debug builds
The destruction of these crashed due to dereferencing an invalid pointer. Not making them inline fixes the problem. This problem only occurred on debug builds, other build configurations were not affected.
2023-06-18 23:55:58 +02:00
Kawe Mazidjatari
165d80c541 Fix rare ImGui crash on shutdown
The 'DirectX_Init()' call was performed late in code, shortly after the window has been created (at this point all device objects and window handles are valid), but the 'DirectX_Shutdown()' call was performed on DLL_DETACH, which was way too late, as the objects were already destroyed at this point. This wasn't an issue before, as we created our own objects in the old DX code. But due to optimizations, we were using the same pointers as the game (noticeable performance boost), but did not adjust the shutdown to accommodate the changes. The shutdown is now performed while the device objects and window handles are valid. Code has been tested on Nvidia and AMD systems, and has confirmed to fix the aforementioned issues.
2023-06-18 22:16:43 +02:00
Kawe Mazidjatari
d5039de251 Make inline
Make them inline as these are just single member getters/setters.
2023-06-18 22:06:25 +02:00
Kawe Mazidjatari
b7cf2c6f64 Cleanup ImGui shutdown
Move to separate function.
2023-06-18 17:50:11 +02:00
Kawe Mazidjatari
b8304e116c Sync wrong field name with IDB
Synced with correct field name.
2023-06-18 17:21:25 +02:00
Kawe Mazidjatari
a33f569ad5 Proper fix for playlists reloading on disconnect
This fixes a crash/exception that would occur when getting disconnected from your own listenserver due to the playlists reload task dispatch. Moving this to client only code, in the disconnect routine (post disconnect) fixes this problem.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
f5151a74cf Add comments to 'SV_CheckForBan'
Some stuff was unclear and took a minute to understand again, these comments fixes this problem.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
efe119a5f2 Remove unnecessary parentheses from check in 'CHostState::FrameUpdate'
Unnecessary.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
0a6fc26529 Comment assert out
Verbose, libcurl free's null blocks.
2023-06-18 12:06:28 +02:00
Kawe Mazidjatari
4f7280ab4c Make inline
These type of functions should always be inline.
2023-06-18 01:25:49 +02:00
Kawe Mazidjatari
32c0e20e76 Init cURL with custom memory callbacks 2023-06-18 01:16:58 +02:00
Kawe Mazidjatari
982fe66570 Add memory callbacks similar to the game's implementation
Required for overriding memalloc callbacks in libraries to feature the game's implementation instead. Named using the 'R_' prefix, as the 'V_' versions were already used.
2023-06-18 01:16:24 +02:00
Kawe Mazidjatari
c8648b9289 Fix typo
Typo.
2023-06-17 16:31:45 +02:00
Kawe Mazidjatari
b64897d4c1 Remove extraneous cURL compile option
Because already set from global CMake init.
2023-06-17 16:31:26 +02:00
Kawe Mazidjatari
7691fa1b5f Light console optimizations 2023-06-17 16:30:10 +02:00
Kawe Mazidjatari
788f38b428 Adjust cURL compile options
- Disable function inlining entirely, this allows for much easier hooking between engine and SDK code (the compiled code is now identical between engine and SDK, except that the SDK has all relevant security problems patched as per https://curl.se/docs/vuln-7.54.0.html).
- Enable buffer security checks to avoid potential remote attacks.
2023-06-17 01:07:07 +02:00
Kawe Mazidjatari
3f8baf6f68 Allow setting compile options for specific targets
Previously, it was all controlled from the global init (applied to all projects), but some projects need different options. With these changes, you can disable the common options applied in the 'add_module' macro, and set your own if desired.
2023-06-17 00:45:27 +02:00
Kawe Mazidjatari
c6f25432fd Undo ImGui shutdown patch, and add missing/reorder shutdown calls
The shutdown patch from commit '48c2401c' created another bug where all inputs get collated, and once drawn, emitted to the ImGui interfaces. The patch has been undone, and the 'ImGui_ImplDX11_Shutdown()' call has been placed before 'ImGui_ImplWin32_Shutdown()', as this was how it was performed according to the official documentation and examples provided by Dear ImGui. The call 'ImGui::DestroyContext()' has also been added (taken from the examples). Removed redundant static global bool.
2023-06-16 23:16:02 +02:00
Kawe Mazidjatari
2ad72b9f8f Improve ImGui shader string literals
Remove all useless indentation characters, change to static char array, use sizeof operator instead of strlen.
2023-06-16 23:11:42 +02:00
Kawe Mazidjatari
f6e6f834ce Enable cURL IPv6 2023-06-16 23:09:38 +02:00
Kawe Mazidjatari
48c2401cf9 Fix rare crash on Dear ImGui shutdown
Fix a rare crash that occurs in AMD driver code, when ImGui shutdown was called. The crash did not occur if the library was shutdown after having rendered one of the ImGui panels for one frame. The fix is to just never call 'ImGui_ImplDX11_NewFrame()', 'ImGui_ImplWin32_NewFrame()' and 'ImGui::NewFrame()', 'ImGui::EndFrame()', 'ImGui::Render()' if none of the windows are visible. code has been tested on a system that would trigger the crash, and after the patch, the crash no longer happened.
2023-06-15 21:33:37 +02:00
Kawe Mazidjatari
51ea9c7c4f CUserCmd hardening
Fix several exploitable bugs in the CUserCmd class. Some of these have been used to exploit/cheat in-game. Fixes contain:
- Camera position clamping (the only patch that hasn't been tested yet!)
- Weapon activity exploit, allowing player to infinitely throw ordnances, and perform other 'cheats'.
- Akimbo exploit + server crasher, allowing client to set multiple inventory weapons as active. The active weapon index bounds were also not checked, a properly crafter CUserCmd message would therefore be able to crash the server.

Note that this does not fix all issues related to the UserCmd class; further reversing and testing revealed there is more to be fixed, these fixes will get implemented with a future commit.
2023-06-13 17:43:32 +02:00
Kawe Mazidjatari
96ab1f1af0 Use explicit cast for CUtlBuffer ctor 2023-06-13 17:09:07 +02:00
Kawe Mazidjatari
4090757035 Fix CVE-2023-27533
Merge: curl/curl@538b1e79a6
2023-06-13 16:49:15 +02:00
Kawe Mazidjatari
1d570a82d8 Fix CVE-2022-43552
Merge: curl/curl@4f20188ac6
2023-06-13 16:18:00 +02:00
Kawe Mazidjatari
634a4739db Fix CVE-2022-32221
Merge: curl/curl@a64e3e5993
2023-06-13 15:35:04 +02:00
Kawe Mazidjatari
0cbdc982fd Fix CVE-2022-35252
Merge: curl/curl@8dfc93e573
2023-06-13 15:31:23 +02:00
Kawe Mazidjatari
e9ba4540cd Fix CVE-2022-27774
Merge: curl/curl@139a54ed0a
Note: protocol compare couldn't be added, as this would require adding a new member in the state structure, and therefore, break compatibility with the structures in the compiled executable (breaking the ability to hook any of its code). This fix should be sufficient however.
2023-06-13 13:02:04 +02:00
Kawe Mazidjatari
926a34dbbb Fix CVE-2022-22576
Merge: curl/curl@852aa5ad35
2023-06-13 12:20:54 +02:00
Kawe Mazidjatari
8b24c4f7d8 Fix CVE-2021-22947
Merge: curl/curl@8ef147c436
2023-06-13 12:08:13 +02:00
Kawe Mazidjatari
f545af934a Fix CVE-2021-22946
Merge: curl/curl@364f174724
2023-06-13 11:38:31 +02:00
Kawe Mazidjatari
9529519fa3 Fix CVE-2021-22925
Merge: curl/curl@894f6ec730
2023-06-13 11:30:39 +02:00
Kawe Mazidjatari
44650ac245 Fix CVE-2021-22898
Merge: curl/curl@39ce47f219
2023-06-13 09:47:07 +02:00
Kawe Mazidjatari
b7cca52067 Fix CVE-2021-22876
Merge: curl/curl@7214288898
Note: The 'CURLU' class does not exist in this particular version of curl, therefore, an alternative approach has been incorporated to mitigate the issue. Code has been tested, and the issue has been fixed.
2023-06-13 09:45:16 +02:00
Kawe Mazidjatari
d177ecdb0a Fix CVE-2020-8286
Merge: curl/curl@d9d0167278
2023-06-13 01:35:15 +02:00
Kawe Mazidjatari
c38a5f214f Fix CVE-2020-8285
Merge: curl/curl@69a358f218
Note: due to the many updates between the curl version this has been fixed in, and the one used in the SDK, the function was slightly different. The code has been tested however, after implementing the fix for this particular version of the library, the code appears to work perfectly with the vuln being fixed (tested on an FTP server with 10k files in the directory).
2023-06-13 00:38:35 +02:00
Kawe Mazidjatari
5a9711878b Fix CVE-2020-8284
Merge: curl/curl@ec9cc725d5
2023-06-12 22:26:53 +02:00
Kawe Mazidjatari
d10b544f74 Fix CVE-2020-8231
Merge: curl/curl@3c9e021f86
Note: Member order in 'connfind' has been left identical, except for that 'found' (now 'id_tofind') is a long. Code however, should pad it to a 4 byte boundary. Size of 'UrlState' has also remained unchanged, the 'connectdata' member has been renamed to 'lastconnect_id', and its type has been changed to 'long'. Additional padding has been incorporated to make sure the structure's size remains the same as that of the game, may we ever hook compiled code with ours.
2023-06-12 22:20:39 +02:00