mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
Updated Patternies
This commit is contained in:
parent
eb2172945b
commit
986f802131
2 changed files with 17 additions and 24 deletions
|
@ -119,8 +119,8 @@ public:
|
|||
return (TReturn*)(m_begin + rva);
|
||||
}
|
||||
|
||||
explicit executable_meta(void* module)
|
||||
: m_begin((uintptr_t)module)
|
||||
explicit executable_meta(uintptr_t module)
|
||||
: m_begin(module)
|
||||
{
|
||||
PIMAGE_DOS_HEADER dosHeader = getRVA<IMAGE_DOS_HEADER>(0);
|
||||
PIMAGE_NT_HEADERS ntHeader = getRVA<IMAGE_NT_HEADERS>(dosHeader->e_lfanew);
|
||||
|
@ -149,7 +149,9 @@ void pattern::Initialize(std::string_view pattern)
|
|||
|
||||
#if PATTERNS_USE_HINTS
|
||||
// if there's hints, try those first
|
||||
if (m_module == GetModuleHandle(nullptr))
|
||||
#if PATTERNS_CAN_SERIALIZE_HINTS
|
||||
if (m_rangeStart == reinterpret_cast<uintptr_t>(GetModuleHandle(nullptr)))
|
||||
#endif
|
||||
{
|
||||
auto range = getHints().equal_range(m_hash);
|
||||
|
||||
|
@ -179,7 +181,7 @@ void pattern::EnsureMatches(uint32_t maxCount)
|
|||
}
|
||||
|
||||
// scan the executable for code
|
||||
executable_meta executable = m_rangeStart != 0 && m_rangeEnd != 0 ? executable_meta(m_rangeStart, m_rangeEnd) : executable_meta(m_module);
|
||||
executable_meta executable = m_rangeStart != 0 && m_rangeEnd != 0 ? executable_meta(m_rangeStart, m_rangeEnd) : executable_meta(m_rangeStart);
|
||||
|
||||
auto matchSuccess = [&] (uintptr_t address)
|
||||
{
|
||||
|
|
|
@ -34,14 +34,13 @@ namespace hook
|
|||
// sets the base to the process main base
|
||||
void set_base();
|
||||
|
||||
template<typename T>
|
||||
inline T* getRVA(uintptr_t rva)
|
||||
inline uintptr_t getRVA(uintptr_t rva)
|
||||
{
|
||||
set_base();
|
||||
#ifdef _M_IX86
|
||||
return (T*)(baseAddressDifference + 0x400000 + rva);
|
||||
return static_cast<uintptr_t>(baseAddressDifference + 0x400000 + rva);
|
||||
#elif defined(_M_AMD64)
|
||||
return (T*)(0x140000000 + rva);
|
||||
return static_cast<uintptr_t>(baseAddressDifference(0x140000000 + rva);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -78,20 +77,12 @@ namespace hook
|
|||
|
||||
bool m_matched = false;
|
||||
|
||||
union
|
||||
{
|
||||
void* m_module;
|
||||
struct
|
||||
{
|
||||
uintptr_t m_rangeStart;
|
||||
uintptr_t m_rangeEnd;
|
||||
};
|
||||
};
|
||||
|
||||
protected:
|
||||
void Initialize(std::string_view pattern);
|
||||
uintptr_t m_rangeStart;
|
||||
uintptr_t m_rangeEnd;
|
||||
|
||||
private:
|
||||
void Initialize(std::string_view pattern);
|
||||
|
||||
bool ConsiderHint(uintptr_t offset);
|
||||
|
||||
void EnsureMatches(uint32_t maxCount);
|
||||
|
@ -101,8 +92,8 @@ namespace hook
|
|||
return m_matches[index];
|
||||
}
|
||||
|
||||
inline pattern(void* module)
|
||||
: m_module(module), m_rangeEnd(0)
|
||||
inline pattern(uintptr_t module)
|
||||
: pattern( module, 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -113,13 +104,13 @@ namespace hook
|
|||
|
||||
public:
|
||||
pattern(std::string_view pattern)
|
||||
: pattern(getRVA<void>(0))
|
||||
: pattern(getRVA(0))
|
||||
{
|
||||
Initialize(std::move(pattern));
|
||||
}
|
||||
|
||||
inline pattern(void* module, std::string_view pattern)
|
||||
: pattern(module)
|
||||
: pattern(reinterpret_cast<uintptr_t>(module))
|
||||
{
|
||||
Initialize(std::move(pattern));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue