aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/sigscanning.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-08-24 00:32:31 +0100
committerGitHub <noreply@github.com>2022-08-24 00:32:31 +0100
commitf9bc3c9d1834cb8bd5f872b749b057c33e8b0102 (patch)
treee96e2da0d95798dd42eddf644a82a74555db858f /NorthstarDedicatedTest/sigscanning.cpp
parent812893d8219daa60f5b5b7fd22cbd6b175603399 (diff)
downloadNorthstarLauncher-f9bc3c9d1834cb8bd5f872b749b057c33e8b0102.tar.gz
NorthstarLauncher-f9bc3c9d1834cb8bd5f872b749b057c33e8b0102.zip
Adjust folder structure (#242)
* Adjust folder structure * change launcher directory name
Diffstat (limited to 'NorthstarDedicatedTest/sigscanning.cpp')
-rw-r--r--NorthstarDedicatedTest/sigscanning.cpp41
1 files changed, 0 insertions, 41 deletions
diff --git a/NorthstarDedicatedTest/sigscanning.cpp b/NorthstarDedicatedTest/sigscanning.cpp
deleted file mode 100644
index 761f9f08..00000000
--- a/NorthstarDedicatedTest/sigscanning.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "pch.h"
-#include "sigscanning.h"
-#include <map>
-
-// 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 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;
- VirtualQuery(moduleHandle, &mem, sizeof(mem));
-
- IMAGE_DOS_HEADER* dos = (IMAGE_DOS_HEADER*)mem.AllocationBase;
- IMAGE_NT_HEADERS* pe = (IMAGE_NT_HEADERS*)((unsigned char*)dos + dos->e_lfanew);
-
- return pe->OptionalHeader.SizeOfImage;
-}
-
-void* FindSignature(std::string dllName, const char* sig, const char* mask)
-{
- HMODULE module = GetModuleHandleA(dllName.c_str());
-
- unsigned char* dllAddress = (unsigned char*)module;
- unsigned char* dllEnd = dllAddress + GetModuleLength(module);
-
- size_t sigLength = strlen(mask);
-
- for (auto i = dllAddress; i < dllEnd - sigLength + 1; i++)
- {
- int j = 0;
- for (; j < sigLength; j++)
- if (mask[j] != '?' && sig[j] != i[j])
- break;
-
- if (j == sigLength) // loop finished of its own accord
- return i;
- }
-
- return nullptr;
-}