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