Merge pull request #185 from mrexodia/pattern-hits-aslr
Save hints as RVA to prevent crashes on ASLR binaries
This commit is contained in:
commit
db441edb0a
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user