mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-09-17 23:40:42 +02:00
Add client and debug utilities + cleanup
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Internals
|
||||
BOOL IsBadReadPtrV2(void* ptr);
|
||||
BOOL FileExists(const char* szPath);
|
||||
MODULEINFO GetModuleInfo(const char* szModule);
|
||||
DWORD64 FindPatternSIMD(const char* szModule, const unsigned char* szPattern, const char* szMask);
|
||||
|
@@ -13,6 +13,22 @@ BOOL FileExists(const char* szPath)
|
||||
return std::filesystem::exists(szPath);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For checking if pointer is valid or bad.
|
||||
BOOL IsBadReadPtrV2(void* ptr)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi = { 0 };
|
||||
if (::VirtualQuery(ptr, &mbi, sizeof(mbi)))
|
||||
{
|
||||
DWORD mask = (PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);
|
||||
bool b = !(mbi.Protect & mask);
|
||||
// check the page is not a guard page
|
||||
if (mbi.Protect & (PAGE_GUARD | PAGE_NOACCESS)) b = true;
|
||||
return b;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For getting information about the executing module.
|
||||
MODULEINFO GetModuleInfo(const char* szModule)
|
||||
|
Reference in New Issue
Block a user