1
0
mirror of synced 2024-11-14 23:07:36 +01:00

Merge pull request #185 from mrexodia/pattern-hits-aslr

Save hints as RVA to prevent crashes on ASLR binaries
This commit is contained in:
Poliwrath 2021-09-14 16:08:09 -04:00 committed by GitHub
commit db441edb0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,6 +44,8 @@ static void Citizen_PatternSaveHint(uint64_t hash, uintptr_t hint)
modPath += "\\";
}
hint -= (uintptr_t)GetModuleHandle(NULL);
std::string hintsFile = modPath + "hints.dat";
FILE* hints = fopen(hintsFile.c_str(), "ab");
@ -313,6 +315,7 @@ namespace hook
std::string hintsFile = modPath + "hints.dat";
FILE* hints = fopen(hintsFile.c_str(), "rb");
bool deleteHints = false;
if (hints)
{
@ -324,11 +327,23 @@ namespace hook
fread(&hash, 1, sizeof(hash), hints);
fread(&hint, 1, sizeof(hint), hints);
hook::pattern::hint(hash, hint);
if (hint < 0xFFFFFFFF)
{
hook::pattern::hint(hash, (uintptr_t)GetModuleHandle(NULL) + hint);
}
else
{
deleteHints = true;
}
}
fclose(hints);
}
if (deleteHints)
{
remove(hintsFile.c_str());
}
}
void pattern::hint(uint64_t hash, uintptr_t address)