21 Commits

Author SHA1 Message Date
Kawe Mazidjatari
5eb784a882 FileSystem: add standalone implementation
Standalone FileSystem implementation, allowing SDK code to be used in tools without adjusting them as the vtables remain identical. NOTE that this reimplementation is partial and only contains the reading and writing of files to/from buffers or disk as that's what we are mainly interested at. We can always implement the other methods when needed.

NOTE: the filesystem singleton accessor (CFileSystem_Stdio* FileSystem()) has been moved to an implementation file instead of being inline as this would allow existing code to link to the tools implementation instead.
2024-04-05 17:42:55 +02:00
Kawe Mazidjatari
edc52ad669 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-04-05 17:19:32 +02:00
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
5f64cd83d8 Fix FileSystem size integer truncation
The implementation in the engine always took/returned signed 64bit size types, but I made a mistake when reversing the virtual function table. All types have been changed to what they should be (mostly signed 64bit, very few unsigned), and usage in-SDK has been adjusted accordingly.
2023-08-09 14:43:54 +02:00
Kawe Mazidjatari
94939b5b40 Mark filesystem singleton getter inline 2023-05-06 21:56:59 +02:00
Kawe Mazidjatari
a618990937 Detour code refactor
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.

TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
2023-01-25 02:26:52 +01:00
Kawe Mazidjatari
2501c37044 Globally convert all byte patterns to strings
These get reconverted to masked byte patterns at runtime. With the signature map cache system, this will only happen when building the cache.
2022-12-01 22:44:55 +01:00
Kawe Mazidjatari
aa72579656 Heavy FileSystem upgrades
Implement VFTable's to interface with engine (for the most part mapped out, only the new VPK methods needs further reversing).
This exposes a good majority of the FileSystem implementation of the engine, to the SDK.
2022-08-13 11:24:55 +02:00
Kawe Mazidjatari
9bf7660138 FileSystem improvements
* Added method 'FPrintf'.
* Shifted indexes back by 2 if <GAMEDLL_S3 (Anything <S3 doesn't have the 2 FeatureFlags initialization methods which shifts everything past index 10 back by 2).
2022-08-12 15:51:04 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Kawe Mazidjatari
87e3313e22 FileSystem improvements
Deref g_pFullFileSystem (most engine functions use this pointer instead of the direct address of g_pFileSystem_Stdio).
2022-06-16 21:19:04 +02:00
Kawe Mazidjatari
4cf43e0d61 Fix invalid pointer for 'VPK_Mount_f'
g_pFullFileSystem is a pointer to g_pFileSystem_Stdio in the compiled module.
Inherit CBaseFileSystem for CFileSystem_Stdio (second VFTable pointer).
Additional cleanup.
2022-06-12 12:14:31 +02:00
Kawe Mazidjatari
dbec823be6 FileSystem improvements
* Added vftable interface for 'IFileSystem::RemoveSearchPath'.
* Added hook for 'CBaseFileSystem::AddSearchPath'.
* Added hook for 'CBaseFileSystem::RemoveSearchPath'.
* Added method in KeyValues for loading a KV file and parsing it via the game exe (loads from cache, vpk and disk).
* Added method in KeyValues to parse GameInfo.txt when the engine loads this.
2022-05-28 02:05:54 +02:00
Kawe Mazidjatari
52b8755219 FileSystem improvements
* Added proper pointer to g_pFileSystem_Stdio.
* Renamed existing one to g_pFullFileSystem (correct name).
* Obtain g_pFileSystem from the same constructor as g_pFileSystem_Stdio.
2022-05-27 22:38:49 +02:00
Kawe Mazidjatari
d1402a7465 General cleanup and improvements
Hook CPakFile::Unload() and track when mp_lobby is unloaded.
Removed duplicate pointers for MOD_ProcessPakQueue().
Use DWORD for thread id comparison in MOD_ProcessPakQueue().
Use RPakHandle_t for all RPak handles.
2022-05-16 20:44:19 +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
e32cc6ae6a Code overhaul
Moved every pattern to IDetour interface. This allows for debugging patterns scans more easily, and create threads during pattern searching (Operation is now fired in APIENTRY).

Also cleaned up some unused code/extraneous comments.
Slightly increased performance by purging duplicate patterns.
Made variable search less dependent from other results (except if pattern-to-scan results is within the same header)
2022-04-18 03:35:08 +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
Kawe Mazidjatari
e2f06a8a68 Massive performance improvements
Inline every signature defined in the SDK (previously each translation unit had its own copy of the signature and function prototype). DLL init is near instant now (85% speed improvements).
2022-04-09 02:18:57 +02:00
Kawe Mazidjatari
aa57170e0d Start of pattern search refactor 2022-04-09 01:14:22 +02:00
Kawe Mazidjatari
6a46486e99 See description
* Added 2 new FileSystem pointers with new features in their classes.
* Register all factory instances created by the GameDLL in the SDK.
* Added new command 'fs_mount_vpk' to mount a specified VPK file.
* Renamed 'fs_decompress_pak' to 'fs_unpack_vpk'.
* Some renaming of Factory and VPK types.
* Some light optimizations/cleanup.
2022-04-09 00:59:42 +02:00