25 Commits

Author SHA1 Message Date
Kawe Mazidjatari
144d5f62e1 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2024-04-05 16:41:09 +02:00
Kawe Mazidjatari
3831058f81 New method for IDetour
This will deprecate IDetour::Attach and IDetour::Detatch. This should reduce the chances of potential errors caused by using the wrong function in the wrong method (e.g. using DetourAttach in IDetour::Detatch).
2024-04-05 16:41:09 +02:00
Kawe Mazidjatari
c1bdb54b6b Remove asserts from Microsoft Detours wrappers
Intermittently causes compile errors, the asserts should be added in the implementation file instead.
2023-07-20 21:59:25 +02:00
Kawe Mazidjatari
a2d30e45f9 Add asserts to detours
This is to make it easy to catch detour errors.
2023-07-19 15:53:20 +02:00
Kawe Mazidjatari
2ca1a290e2 Revert back to using verctors for detours
Enabling LTCG caused the emplacement order to be different, which is most likely due to additional optimizations for the binary search logic. Reverted to fix this bug.
2023-07-03 15:37:25 +02:00
Kawe Mazidjatari
7762c4b2ce Light refactor of the IDetour interface
- Use std::map for mapping vtables to interface objects, previously done with a set and a vector.
- Objects are no longer inline, which significantly reduced output code size as all redundant dynamic initializers (created for each translation unit) have been pruned.
2023-07-03 13:37:41 +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
9f44bcc818 Treat compiler warnings as errors
Treat them as errors globally. Most of the time a warning is a bug, or problem in code that could be solved in a different (better) manner. Thirdparty code have this disabled. The warnings as errors option can be globally disabled through the CMake GUI, but this is not recommended.
2023-05-15 09:44:26 +02:00
Kawe Mazidjatari
6a86ae2606 Cleanup CMakeLists files
Light cleanup in CMakeLists files. Split protocols and improve filter names.
2023-05-14 17:36:08 +02:00
Kawe Mazidjatari
de02febdc0 Fix assert failure in netconsole caused by AddDetour
Remove extraneous register call for detour callbacks.
2023-05-13 14:05:08 +02:00
Kawe Mazidjatari
8dbc2024c6 CMake code improvements
Use the 'add_module' macro to add modules without creating duplicate code. This macro also takes a reuse PCH as parameter, so modules that need a precompiled header, could reuse those from different targets that compile them. This commit also restructures the group order of the generated solution files for easier code navigation.
2023-05-13 00:14:53 +02:00
Kawe Mazidjatari
f120354e96 Initial port to CMake
* All libraries have been isolated from each other, and build into separate artifacts.
* Project has been restructured to support isolating libraries.
* CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example).
* Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp).

TODO:
* Add a batch file to autogenerate all projects.
* Add support for dedicated server.
* Add support for client dll.

Bugs:
* Game crashes on the title screen after the UI script compiler has finished (root cause unknown).
* Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
2023-05-10 00:05:38 +02:00
Kawe Mazidjatari
ae431c6ac2 /W4: Fix unreferenced symbol warnings
Fix verbose unreferenced symbol warnings.
2023-04-02 17:02:04 +02:00
Kawe Mazidjatari
7cc58a642f Rename and mark detour globals as static
Renamed to 'g_DetourVector' and 'g_DetourSet', marked as static.
2023-04-01 13:17:23 +02:00
Kawe Mazidjatari
e0fa00abf5 Update Microsoft Detours to latest 2023-01-27 00:51:22 +01:00
Kawe Mazidjatari
f47fb63e5f Fix dedicated server compile errors
Huge cleanup for dedicated. All patches in 'opcodes.cpp' are now directly applied to the executable, and kept as reference in the source file. The patch logic is commented. Any other patches for the dedicated server executable should be documented in the patch file found in 'r5dev/resource/patch'.
2023-01-26 02:59:50 +01:00
Kawe Mazidjatari
532ada48e0 Only run duplicate checks in debug
Duplicate checks are only performed in debug builds, if a duplicate is encountered, a bug in code has been found and has to be solved (do not call REGISTER from headers for example).
2023-01-25 19:22:05 +01:00
Kawe Mazidjatari
d20250e436 Heavy output code cleanup
Only add to detour if the VFTable pointer didn't exist yet. Not declaring these in the anonymous namespace significantly reduces code size and unnecessary memory allocations. We might want to consider refactoring this, although it will probably require a big change.
2022-11-27 15:01:55 +01:00
Kawe Mazidjatari
81dcfa60a0 Cleanup 2022-05-13 17:51:01 +02:00
Kawe Mazidjatari
3144227ec8 Update GetAdr implementations to feature spdlog
Fixed all alignments and reduced code verbosity
2022-05-13 14:53:25 +02:00
Kawe Mazidjatari
e1f5e7d46b Un-hardcode all CHostState dependencies
The SDK now works on executables with ASLR enabled.
!TODO: Dedicated.
2022-04-12 02:48:46 +02:00
Kawe Mazidjatari
092b7e9d43 Start of migration to IDetour interface
Migrating to this to initialize all patterns and prototypes in Systems_Init() instead.
This should make debugging missing/not found patterns easier and allow for opting out variable/constant search (some of these require other patterns to be found, thus resulting in seg faults..).

Also added check to detect if user has a eligible CPU to run this SDK.
The game requires SSE and SSE2 instruction sets. Our SDK requires this too due to the use of SSE intrinsics, so we cannot let the game handle this. We have to check it ourselves.
2022-04-11 01:44:30 +02:00
Amos
b80be10c4d Compile LZHAM with the solution. Fix missing detours files for sdklauncher 2022-01-06 15:08:39 +01:00
Amos
a0b7bbf366 Compile Microsoft Detours with the solution 2022-01-06 02:22:28 +01:00
Amos
d5b2e58dae Code base refactor + major performance and readability improvement. Read description for details.
* Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable.
* Document most functions with valve style 'Purpose' blocks.
* Rename variables to match the rest of the codebase and Valve's naming convention.
* Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK.

* Obtain globals or pointers directly instead of waiting for runtime initialized data.
* Dynamically search for all functions and globals (this doesn't count for dedicated yet!).
* Initialize most in-SDK variables.

* Move certain prints and other utilities under ConVars to reduce verbosity and increase performance.
* Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future.
* Type global var pointers appropriately if class or type is known and implemented.
* Forward declare 'CClient' class to avoid having 2 'g_pClient' copies.
* Add IDA's pseudo definitions for easier prototyping with decompiled assembly code.

* RPAK decompress Command callback implementation.
* Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\').

* VPK decompress Command callback implementation.
* Move CRC32 ands Adler32 to implementation files.

* Server will print out more details about the connecting client.

* Upgrade ImGui lib to v1.86.
* Don't compile id3dx.h for dedicated.
* Don't compile id3dx.cpp for dedicated
* Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console

* Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors.
* Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up.
* Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00