mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-01 08:43:01 +05:00
Updated Memory
This commit is contained in:
parent
e44ad21204
commit
fe37899ac1
1 changed files with 53 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#ifndef _MEMORY_NO_CRT
|
#ifndef _MEMORY_NO_CRT
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
@ -523,6 +524,14 @@ namespace Memory
|
||||||
func = Func(*(ptrdiff_t*)((intptr_t)address+1) + (intptr_t)address + 5);
|
func = Func(*(ptrdiff_t*)((intptr_t)address+1) + (intptr_t)address + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0)
|
||||||
|
{
|
||||||
|
uintptr_t addr;
|
||||||
|
ReadCall( address, addr );
|
||||||
|
return reinterpret_cast<void*>( addr + offset );
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _MEMORY_NO_CRT
|
#ifndef _MEMORY_NO_CRT
|
||||||
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
||||||
{
|
{
|
||||||
|
@ -531,6 +540,13 @@ namespace Memory
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline AT Verify(AT address, uintptr_t expected)
|
||||||
|
{
|
||||||
|
assert( uintptr_t(address) == expected );
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
namespace DynBase
|
namespace DynBase
|
||||||
{
|
{
|
||||||
template<typename T, typename AT>
|
template<typename T, typename AT>
|
||||||
|
@ -571,11 +587,23 @@ namespace Memory
|
||||||
Memory::ReadCall(DynBaseAddress(address), func);
|
Memory::ReadCall(DynBaseAddress(address), func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0)
|
||||||
|
{
|
||||||
|
return Memory::ReadCallFrom(DynBaseAddress(address), offset);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _MEMORY_NO_CRT
|
#ifndef _MEMORY_NO_CRT
|
||||||
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
||||||
{
|
{
|
||||||
return Memory::MemEquals(DynBaseAddress(address), std::move(val));
|
return Memory::MemEquals(DynBaseAddress(address), std::move(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline AT Verify(AT address, uintptr_t expected)
|
||||||
|
{
|
||||||
|
return Memory::Verify(address, DynBaseAddress(expected));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -636,6 +664,12 @@ namespace Memory
|
||||||
Memory::ReadCall(address, func);
|
Memory::ReadCall(address, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0)
|
||||||
|
{
|
||||||
|
return Memory::ReadCallFrom(address, offset);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _MEMORY_NO_CRT
|
#ifndef _MEMORY_NO_CRT
|
||||||
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
||||||
{
|
{
|
||||||
|
@ -643,6 +677,12 @@ namespace Memory
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline AT Verify(AT address, uintptr_t expected)
|
||||||
|
{
|
||||||
|
return Memory::Verify(address, expected);
|
||||||
|
}
|
||||||
|
|
||||||
namespace DynBase
|
namespace DynBase
|
||||||
{
|
{
|
||||||
template<typename T, typename AT>
|
template<typename T, typename AT>
|
||||||
|
@ -683,12 +723,25 @@ namespace Memory
|
||||||
Memory::ReadCall(DynBaseAddress(address), func);
|
Memory::ReadCall(DynBaseAddress(address), func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0)
|
||||||
|
{
|
||||||
|
Memory::ReadCallFrom(DynBaseAddress(address), offset);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _MEMORY_NO_CRT
|
#ifndef _MEMORY_NO_CRT
|
||||||
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
inline bool MemEquals(uintptr_t address, std::initializer_list<uint8_t> val)
|
||||||
{
|
{
|
||||||
return Memory::MemEquals(DynBaseAddress(address), std::move(val));
|
return Memory::MemEquals(DynBaseAddress(address), std::move(val));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template<typename AT>
|
||||||
|
inline AT Verify(AT address, uintptr_t expected)
|
||||||
|
{
|
||||||
|
return Memory::Verify(address, DynBaseAddress(expected));
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue