mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Use const in memaddr.cpp where its supposed to be.
This commit is contained in:
parent
838c183b10
commit
7eb6952df0
@ -43,13 +43,13 @@ void CNetMessages_Attach()
|
||||
{
|
||||
auto SVCPrint = &SVC_Print::Process;
|
||||
auto SVCUserMessage = &SVC_UserMessage::Process;
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID&)SVCPrint, (LPVOID*)&SVC_Print_Process, 3);
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID&)SVCUserMessage, (LPVOID*)&SVC_UserMessage_Process, 3);
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID&)SVCPrint, 3, (LPVOID*)&SVC_Print_Process);
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID&)SVCUserMessage, 3, (LPVOID*)&SVC_UserMessage_Process);
|
||||
}
|
||||
|
||||
void CNetMessages_Detach()
|
||||
{
|
||||
void* hkRestore = nullptr;
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID)SVC_Print_Process, (LPVOID*)&hkRestore, 3);
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID)SVC_UserMessage_Process, (LPVOID*)&hkRestore, 3);
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID)SVC_Print_Process, 3, (LPVOID*)&hkRestore);
|
||||
CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID)SVC_UserMessage_Process, 3, (LPVOID*)&hkRestore);
|
||||
}
|
@ -116,15 +116,15 @@ public:
|
||||
}
|
||||
|
||||
bool CheckOpCodes(const vector<uint8_t> vOpcodeArray) const;
|
||||
void Patch(vector<uint8_t> vOpcodes) const;
|
||||
void Patch(const vector<uint8_t> vOpcodeArray) const;
|
||||
void PatchString(const string& svString) const;
|
||||
CMemory FindPattern(const string& svPattern, const Direction searchDirect = Direction::DOWN, const int opCodesToScan = 512, const ptrdiff_t occurence = 1) const;
|
||||
CMemory FindPatternSelf(const string& svPattern, const Direction searchDirect = Direction::DOWN, const int opCodesToScan = 512, const ptrdiff_t occurence = 1);
|
||||
CMemory FollowNearCall(ptrdiff_t opcodeOffset = 0x1, ptrdiff_t nextInstructionOffset = 0x5) const;
|
||||
CMemory FollowNearCallSelf(ptrdiff_t opcodeOffset = 0x1, ptrdiff_t nextInstructionOffset = 0x5);
|
||||
CMemory ResolveRelativeAddress(ptrdiff_t registerOffset = 0x0, ptrdiff_t nextInstructionOffset = 0x4) const;
|
||||
CMemory ResolveRelativeAddressSelf(ptrdiff_t registerOffset = 0x0, ptrdiff_t nextInstructionOffset = 0x4);
|
||||
static void HookVirtualMethod(uintptr_t virtualTable, void* pHookMethod, void** ppOriginalMethod, ptrdiff_t methodIndex);
|
||||
CMemory FollowNearCall(const ptrdiff_t opcodeOffset = 0x1, const ptrdiff_t nextInstructionOffset = 0x5) const;
|
||||
CMemory FollowNearCallSelf(const ptrdiff_t opcodeOffset = 0x1, const ptrdiff_t nextInstructionOffset = 0x5);
|
||||
CMemory ResolveRelativeAddress(const ptrdiff_t registerOffset = 0x0, const ptrdiff_t nextInstructionOffset = 0x4) const;
|
||||
CMemory ResolveRelativeAddressSelf(const ptrdiff_t registerOffset = 0x0, const ptrdiff_t nextInstructionOffset = 0x4);
|
||||
static void HookVirtualMethod(const uintptr_t virtualTable, const void* pHookMethod, const ptrdiff_t methodIndex, void** ppOriginalMethod);
|
||||
|
||||
private:
|
||||
uintptr_t ptr = 0;
|
||||
|
@ -33,19 +33,19 @@ bool CMemory::CheckOpCodes(const vector<uint8_t> vOpcodeArray) const
|
||||
// Purpose: patch array of opcodes starting from current address
|
||||
// Input : vOpcodeArray -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMemory::Patch(vector<uint8_t> vOpcodes) const
|
||||
void CMemory::Patch(const vector<uint8_t> vOpcodeArray) const
|
||||
{
|
||||
DWORD oldProt = NULL;
|
||||
|
||||
SIZE_T dwSize = vOpcodes.size();
|
||||
SIZE_T dwSize = vOpcodeArray.size();
|
||||
VirtualProtect(reinterpret_cast<void*>(ptr), dwSize, PAGE_EXECUTE_READWRITE, &oldProt); // Patch page to be able to read and write to it.
|
||||
|
||||
for (int i = 0; i < vOpcodes.size(); i++)
|
||||
for (int i = 0; i < vOpcodeArray.size(); i++)
|
||||
{
|
||||
*reinterpret_cast<uint8_t*>(ptr + i) = vOpcodes[i]; // Write opcodes to Address.
|
||||
*reinterpret_cast<uint8_t*>(ptr + i) = vOpcodeArray[i]; // Write opcodes to Address.
|
||||
}
|
||||
|
||||
dwSize = vOpcodes.size();
|
||||
dwSize = vOpcodeArray.size();
|
||||
VirtualProtect(reinterpret_cast<void*>(ptr), dwSize, oldProt, &oldProt); // Restore protection.
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ CMemory CMemory::FindPatternSelf(const string& svPattern, const Direction search
|
||||
// nextInstructionOffset -
|
||||
// Output : CMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
CMemory CMemory::FollowNearCall(ptrdiff_t opcodeOffset, ptrdiff_t nextInstructionOffset) const
|
||||
CMemory CMemory::FollowNearCall(const ptrdiff_t opcodeOffset, const ptrdiff_t nextInstructionOffset) const
|
||||
{
|
||||
return ResolveRelativeAddress(opcodeOffset, nextInstructionOffset);
|
||||
}
|
||||
@ -184,7 +184,7 @@ CMemory CMemory::FollowNearCall(ptrdiff_t opcodeOffset, ptrdiff_t nextInstructio
|
||||
// nextInstructionOffset -
|
||||
// Output : CMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
CMemory CMemory::FollowNearCallSelf(ptrdiff_t opcodeOffset, ptrdiff_t nextInstructionOffset)
|
||||
CMemory CMemory::FollowNearCallSelf(const ptrdiff_t opcodeOffset, const ptrdiff_t nextInstructionOffset)
|
||||
{
|
||||
return ResolveRelativeAddressSelf(opcodeOffset, nextInstructionOffset);
|
||||
}
|
||||
@ -195,7 +195,7 @@ CMemory CMemory::FollowNearCallSelf(ptrdiff_t opcodeOffset, ptrdiff_t nextInstru
|
||||
// nextInstructionOffset -
|
||||
// Output : CMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
CMemory CMemory::ResolveRelativeAddress(ptrdiff_t registerOffset, ptrdiff_t nextInstructionOffset) const
|
||||
CMemory CMemory::ResolveRelativeAddress(const ptrdiff_t registerOffset, const ptrdiff_t nextInstructionOffset) const
|
||||
{
|
||||
// Skip register.
|
||||
uintptr_t skipRegister = ptr + registerOffset;
|
||||
@ -216,7 +216,7 @@ CMemory CMemory::ResolveRelativeAddress(ptrdiff_t registerOffset, ptrdiff_t next
|
||||
// nextInstructionOffset -
|
||||
// Output : CMemory
|
||||
//-----------------------------------------------------------------------------
|
||||
CMemory CMemory::ResolveRelativeAddressSelf(ptrdiff_t registerOffset, ptrdiff_t nextInstructionOffset)
|
||||
CMemory CMemory::ResolveRelativeAddressSelf(const ptrdiff_t registerOffset, const ptrdiff_t nextInstructionOffset)
|
||||
{
|
||||
// Skip register.
|
||||
uintptr_t skipRegister = ptr + registerOffset;
|
||||
@ -240,7 +240,7 @@ CMemory CMemory::ResolveRelativeAddressSelf(ptrdiff_t registerOffset, ptrdiff_t
|
||||
// pOriginalMethod -
|
||||
// Output : void** via pOriginalMethod
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMemory::HookVirtualMethod(uintptr_t virtualTable, void* pHookMethod, void** ppOriginalMethod, ptrdiff_t methodIndex)
|
||||
void CMemory::HookVirtualMethod(const uintptr_t virtualTable, const void* pHookMethod, const ptrdiff_t methodIndex, void** ppOriginalMethod)
|
||||
{
|
||||
DWORD oldProt = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user