mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-01 16:53:01 +05:00
Updated Patterns
This commit is contained in:
parent
a0fd40d44d
commit
1a8bb9dd6c
2 changed files with 6 additions and 35 deletions
|
@ -45,12 +45,9 @@ typedef basic_fnv_1<fnv_prime, fnv_offset_basis> fnv_1;
|
||||||
|
|
||||||
namespace hook
|
namespace hook
|
||||||
{
|
{
|
||||||
ptrdiff_t baseAddressDifference;
|
ptrdiff_t pattern::get_process_base()
|
||||||
|
|
||||||
// sets the base to the process main base
|
|
||||||
void set_base()
|
|
||||||
{
|
{
|
||||||
set_base((uintptr_t)GetModuleHandle(nullptr));
|
return ptrdiff_t(GetModuleHandle(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,13 +109,13 @@ private:
|
||||||
uintptr_t m_begin;
|
uintptr_t m_begin;
|
||||||
uintptr_t m_end;
|
uintptr_t m_end;
|
||||||
|
|
||||||
public:
|
|
||||||
template<typename TReturn, typename TOffset>
|
template<typename TReturn, typename TOffset>
|
||||||
TReturn* getRVA(TOffset rva)
|
TReturn* getRVA(TOffset rva)
|
||||||
{
|
{
|
||||||
return (TReturn*)(m_begin + rva);
|
return (TReturn*)(m_begin + rva);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
explicit executable_meta(uintptr_t module)
|
explicit executable_meta(uintptr_t module)
|
||||||
: m_begin(module)
|
: m_begin(module)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,34 +16,6 @@
|
||||||
|
|
||||||
namespace hook
|
namespace hook
|
||||||
{
|
{
|
||||||
extern ptrdiff_t baseAddressDifference;
|
|
||||||
|
|
||||||
// sets the base address difference based on an obtained pointer
|
|
||||||
inline void set_base(uintptr_t address)
|
|
||||||
{
|
|
||||||
#ifdef _M_IX86
|
|
||||||
uintptr_t addressDiff = (address - 0x400000);
|
|
||||||
#elif defined(_M_AMD64)
|
|
||||||
uintptr_t addressDiff = (address - 0x140000000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// pointer-style cast to ensure unsigned overflow ends up copied directly into a signed value
|
|
||||||
baseAddressDifference = *(ptrdiff_t*)&addressDiff;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sets the base to the process main base
|
|
||||||
void set_base();
|
|
||||||
|
|
||||||
inline uintptr_t getRVA(uintptr_t rva)
|
|
||||||
{
|
|
||||||
set_base();
|
|
||||||
#ifdef _M_IX86
|
|
||||||
return static_cast<uintptr_t>(baseAddressDifference + 0x400000 + rva);
|
|
||||||
#elif defined(_M_AMD64)
|
|
||||||
return static_cast<uintptr_t>(baseAddressDifference(0x140000000 + rva);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
class pattern_match
|
class pattern_match
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -81,6 +53,8 @@ namespace hook
|
||||||
uintptr_t m_rangeEnd;
|
uintptr_t m_rangeEnd;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static ptrdiff_t get_process_base();
|
||||||
|
|
||||||
void Initialize(std::string_view pattern);
|
void Initialize(std::string_view pattern);
|
||||||
|
|
||||||
bool ConsiderHint(uintptr_t offset);
|
bool ConsiderHint(uintptr_t offset);
|
||||||
|
@ -104,7 +78,7 @@ namespace hook
|
||||||
|
|
||||||
public:
|
public:
|
||||||
pattern(std::string_view pattern)
|
pattern(std::string_view pattern)
|
||||||
: pattern(getRVA(0))
|
: pattern(get_process_base())
|
||||||
{
|
{
|
||||||
Initialize(std::move(pattern));
|
Initialize(std::move(pattern));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue