mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-23 05:45:37 +08:00
padding
This commit is contained in:
parent
05de2db240
commit
5a8d299812
@ -2,58 +2,59 @@
|
||||
#define __LUNA_PSPUILTS_H
|
||||
namespace ppsspp
|
||||
{
|
||||
|
||||
struct emfuncinfo{
|
||||
uint64_t type;
|
||||
int argidx;int padding;
|
||||
void* hookfunc;
|
||||
void* filterfun;
|
||||
const char* _id;
|
||||
};
|
||||
|
||||
struct emfuncinfo
|
||||
{
|
||||
uint64_t type;
|
||||
int argidx;
|
||||
int padding;
|
||||
void *hookfunc;
|
||||
void *filterfun;
|
||||
const char *_id;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
bool InsertPPSSPPcommonhooks();
|
||||
|
||||
|
||||
#ifndef _WIN64
|
||||
namespace{
|
||||
int PPSSPP_VERSION[4] = { 0, 9, 8, 0 }; // 0.9.8 by default
|
||||
|
||||
enum : DWORD {
|
||||
PPSSPP_MEMORY_SEARCH_STEP_98 = 0x01000000
|
||||
, PPSSPP_MEMORY_SEARCH_STEP_99 = 0x00050000
|
||||
//, step = 0x1000 // step must be at least 0x1000 (offset in SearchPattern)
|
||||
//, step = 0x00010000 // crash otoboku PSP on 0.9.9 since 5pb is wrongly inserted
|
||||
};
|
||||
|
||||
|
||||
|
||||
ULONG SafeMatchBytesInPSPMemory(LPCVOID pattern, DWORD patternSize, DWORD start = MemDbg::MappedMemoryStartAddress, DWORD stop = MemDbg::MemoryStopAddress)
|
||||
namespace
|
||||
{
|
||||
|
||||
ULONG step = PPSSPP_VERSION[1] == 9 && PPSSPP_VERSION[2] == 8 ? PPSSPP_MEMORY_SEARCH_STEP_98 : PPSSPP_MEMORY_SEARCH_STEP_99;
|
||||
return _SafeMatchBytesInMappedMemory(pattern, patternSize, XX, start, stop, step);
|
||||
}
|
||||
int PPSSPP_VERSION[4] = {0, 9, 8, 0}; // 0.9.8 by default
|
||||
|
||||
|
||||
|
||||
|
||||
ULONG SafeMatchBytesInPS2Memory(LPCVOID pattern, DWORD patternSize)
|
||||
{
|
||||
// PCSX2 memory range
|
||||
// ds: begin from 0x20000000
|
||||
// cs: begin from 0x30000000
|
||||
enum : ULONG {
|
||||
//start = MemDbg::MappedMemoryStartAddress // 0x01000000
|
||||
start = 0x30000000 // larger than PSP to skip the garbage memory
|
||||
, stop = 0x40000000 // larger than PSP as PS2 has larger memory
|
||||
, step = 0x00010000 // smaller than PPS
|
||||
//, step = 0x00050000 // the same as PPS
|
||||
enum : DWORD
|
||||
{
|
||||
PPSSPP_MEMORY_SEARCH_STEP_98 = 0x01000000,
|
||||
PPSSPP_MEMORY_SEARCH_STEP_99 = 0x00050000
|
||||
//, step = 0x1000 // step must be at least 0x1000 (offset in SearchPattern)
|
||||
//, step = 0x00010000 // crash otoboku PSP on 0.9.9 since 5pb is wrongly inserted
|
||||
};
|
||||
return _SafeMatchBytesInMappedMemory(pattern, patternSize, XX, start, stop, step);
|
||||
}
|
||||
|
||||
ULONG SafeMatchBytesInPSPMemory(LPCVOID pattern, DWORD patternSize, DWORD start = MemDbg::MappedMemoryStartAddress, DWORD stop = MemDbg::MemoryStopAddress)
|
||||
{
|
||||
|
||||
ULONG step = PPSSPP_VERSION[1] == 9 && PPSSPP_VERSION[2] == 8 ? PPSSPP_MEMORY_SEARCH_STEP_98 : PPSSPP_MEMORY_SEARCH_STEP_99;
|
||||
return _SafeMatchBytesInMappedMemory(pattern, patternSize, XX, start, stop, step);
|
||||
}
|
||||
|
||||
ULONG SafeMatchBytesInPS2Memory(LPCVOID pattern, DWORD patternSize)
|
||||
{
|
||||
// PCSX2 memory range
|
||||
// ds: begin from 0x20000000
|
||||
// cs: begin from 0x30000000
|
||||
enum : ULONG
|
||||
{
|
||||
// start = MemDbg::MappedMemoryStartAddress // 0x01000000
|
||||
start = 0x30000000 // larger than PSP to skip the garbage memory
|
||||
,
|
||||
stop = 0x40000000 // larger than PSP as PS2 has larger memory
|
||||
,
|
||||
step = 0x00010000 // smaller than PPS
|
||||
//, step = 0x00050000 // the same as PPS
|
||||
//, step = 0x1000 // step must be at least 0x1000 (offset in SearchPattern)
|
||||
};
|
||||
return _SafeMatchBytesInMappedMemory(pattern, patternSize, XX, start, stop, step);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -183,12 +183,13 @@ void Send(char **stack, uintptr_t address)
|
||||
if (recordsAvailable <= 0)
|
||||
return;
|
||||
for (int i = -registers; i < 10; ++i)
|
||||
for (auto padding : {uintptr_t{}, sp.padding})
|
||||
{
|
||||
DoSend(i, address, stack[i], padding);
|
||||
}
|
||||
{
|
||||
DoSend(i, address, stack[i], 0);
|
||||
if (sp.padding)
|
||||
DoSend(i, address, stack[i], sp.padding);
|
||||
}
|
||||
}
|
||||
void SafeSendJitVeh(hook_stack *stack, uintptr_t address, uintptr_t em_addr, JITTYPE jittype)
|
||||
void SafeSendJitVeh(hook_stack *stack, uintptr_t address, uintptr_t em_addr, JITTYPE jittype, uintptr_t padding)
|
||||
{
|
||||
__try
|
||||
{
|
||||
@ -215,6 +216,8 @@ void SafeSendJitVeh(hook_stack *stack, uintptr_t address, uintptr_t em_addr, JIT
|
||||
return;
|
||||
}
|
||||
DoSend(i, address, str, 0, jittype, em_addr);
|
||||
if (padding)
|
||||
DoSend(i, address, str, padding, jittype, em_addr);
|
||||
}
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
@ -222,7 +225,7 @@ void SafeSendJitVeh(hook_stack *stack, uintptr_t address, uintptr_t em_addr, JIT
|
||||
}
|
||||
}
|
||||
std::unordered_map<uintptr_t, uint64_t> addresscalledtime;
|
||||
bool SendJitVeh(PCONTEXT context, uintptr_t address, uintptr_t em_addr, JITTYPE jittype)
|
||||
bool SendJitVeh(PCONTEXT context, uintptr_t address, uintptr_t em_addr, JITTYPE jittype, uintptr_t padding)
|
||||
{
|
||||
if (safeautoleaveveh)
|
||||
return true;
|
||||
@ -236,7 +239,7 @@ bool SendJitVeh(PCONTEXT context, uintptr_t address, uintptr_t em_addr, JITTYPE
|
||||
addresscalledtime[address] = tm;
|
||||
auto stack = std::make_unique<hook_stack>();
|
||||
context_get(stack.get(), context);
|
||||
SafeSendJitVeh(stack.get(), address, em_addr, jittype);
|
||||
SafeSendJitVeh(stack.get(), address, em_addr, jittype, padding);
|
||||
return true;
|
||||
}
|
||||
std::vector<uintptr_t> GetFunctions(uintptr_t module)
|
||||
@ -473,7 +476,7 @@ void SearchForHooks(SearchParam spUser)
|
||||
if(addr.second.second>sp.maxAddress||addr.second.second<sp.minAddress)continue;
|
||||
i+=1;
|
||||
//addresses.push_back(addr.first);
|
||||
if(add_veh_hook((void*)addr.first,std::bind(SendJitVeh,std::placeholders::_1,addr.first,addr.second.second,addr.second.first)))
|
||||
if(add_veh_hook((void*)addr.first,std::bind(SendJitVeh,std::placeholders::_1,addr.first,addr.second.second,addr.second.first,sp.padding)))
|
||||
successaddr.push_back(addr.first);
|
||||
if (i % 2500 == 0) ConsoleOutput(HOOK_SEARCH_INITIALIZING, 1 + 98. * i / jitaddr2emuaddr.size());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user