diff options
Diffstat (limited to 'NorthstarDedicatedTest/sigscanning.cpp')
-rw-r--r-- | NorthstarDedicatedTest/sigscanning.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/NorthstarDedicatedTest/sigscanning.cpp b/NorthstarDedicatedTest/sigscanning.cpp index c75c80f0..761f9f08 100644 --- a/NorthstarDedicatedTest/sigscanning.cpp +++ b/NorthstarDedicatedTest/sigscanning.cpp @@ -5,7 +5,7 @@ // note: sigscanning is only really intended to be used for resolving stuff like shared function definitions // we mostly use raw function addresses for stuff -size_t GetDLLLength(HMODULE moduleHandle) +size_t GetModuleLength(HMODULE moduleHandle) { // based on sigscn code from ttf2sdk, which is in turn based on CSigScan from https://wiki.alliedmods.net/Signature_Scanning MEMORY_BASIC_INFORMATION mem; @@ -19,12 +19,14 @@ size_t GetDLLLength(HMODULE moduleHandle) void* FindSignature(std::string dllName, const char* sig, const char* mask) { - HMODULE dllAddress = GetModuleHandleA(dllName.c_str()); - char* dllEnd = (char*)(dllAddress + GetDLLLength(dllAddress)); + HMODULE module = GetModuleHandleA(dllName.c_str()); + + unsigned char* dllAddress = (unsigned char*)module; + unsigned char* dllEnd = dllAddress + GetModuleLength(module); size_t sigLength = strlen(mask); - for (char* i = (char*)dllAddress; i < dllEnd - sigLength; i++) + for (auto i = dllAddress; i < dllEnd - sigLength + 1; i++) { int j = 0; for (; j < sigLength; j++) @@ -32,7 +34,7 @@ void* FindSignature(std::string dllName, const char* sig, const char* mask) break; if (j == sigLength) // loop finished of its own accord - return (void*)i; + return i; } return nullptr; |