mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-12-25 12:44:13 +08:00
fix
Update veh_hook.cpp
This commit is contained in:
parent
7cde15f054
commit
28c141e29f
@ -171,9 +171,11 @@ bool yuzusuyu::attach_function()
|
|||||||
auto descriptor = *argidx(stack,idxDescriptor); // r8
|
auto descriptor = *argidx(stack,idxDescriptor); // r8
|
||||||
auto entrypoint = *argidx(stack,idxEntrypoint); // r9
|
auto entrypoint = *argidx(stack,idxEntrypoint); // r9
|
||||||
auto em_address = *(uintptr_t*)descriptor;
|
auto em_address = *(uintptr_t*)descriptor;
|
||||||
|
if(!entrypoint)return;
|
||||||
jitaddraddr(em_address,entrypoint,JITTYPE::YUZU);
|
jitaddraddr(em_address,entrypoint,JITTYPE::YUZU);
|
||||||
|
[&](){
|
||||||
auto em_address_off=em_address- 0x80004000;
|
auto em_address_off=em_address- 0x80004000;
|
||||||
if(emfunctionhooks.find(em_address_off)==emfunctionhooks.end() || !entrypoint)return;
|
if(emfunctionhooks.find(em_address_off)==emfunctionhooks.end())return;
|
||||||
auto op=emfunctionhooks.at(em_address_off);
|
auto op=emfunctionhooks.at(em_address_off);
|
||||||
if(!(checkiscurrentgame(op)))return;
|
if(!(checkiscurrentgame(op)))return;
|
||||||
|
|
||||||
@ -187,7 +189,13 @@ bool yuzusuyu::attach_function()
|
|||||||
hpinternal.padding=op.padding;
|
hpinternal.padding=op.padding;
|
||||||
hpinternal.jittype=JITTYPE::YUZU;
|
hpinternal.jittype=JITTYPE::YUZU;
|
||||||
NewHook(hpinternal,op.hookname);
|
NewHook(hpinternal,op.hookname);
|
||||||
|
}();
|
||||||
|
[&](){
|
||||||
|
if(delayinserthook.find(em_address)==delayinserthook.end())return;
|
||||||
|
auto h=delayinserthook[em_address];
|
||||||
|
delayinserthook.erase(em_address);
|
||||||
|
NewHook(h.second,h.first.c_str());
|
||||||
|
}();
|
||||||
};
|
};
|
||||||
return NewHook(hp,"YuzuDoJit");
|
return NewHook(hp,"YuzuDoJit");
|
||||||
}
|
}
|
||||||
|
@ -293,13 +293,12 @@ bool hookPPSSPPDoJit(){
|
|||||||
hpinternal.user_value=hp->user_value;
|
hpinternal.user_value=hp->user_value;
|
||||||
hpinternal.address=stack->retaddr;
|
hpinternal.address=stack->retaddr;
|
||||||
hpinternal.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
|
hpinternal.text_fun=[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
|
||||||
|
auto em_address=*(uintptr_t*)(hp->user_value);
|
||||||
|
[&](){
|
||||||
auto ret=stack->RETADDR;
|
auto ret=stack->RETADDR;
|
||||||
if(breakpoints.find(ret)!=breakpoints.end())return;
|
if(breakpoints.find(ret)!=breakpoints.end())return;
|
||||||
breakpoints.insert(ret);
|
breakpoints.insert(ret);
|
||||||
|
|
||||||
auto em_address=*(uintptr_t*)(hp->user_value);
|
|
||||||
|
|
||||||
jitaddraddr(em_address,ret,JITTYPE::PPSSPP);
|
jitaddraddr(em_address,ret,JITTYPE::PPSSPP);
|
||||||
|
|
||||||
if(emfunctionhooks.find(em_address)==emfunctionhooks.end())return;
|
if(emfunctionhooks.find(em_address)==emfunctionhooks.end())return;
|
||||||
@ -333,6 +332,13 @@ bool hookPPSSPPDoJit(){
|
|||||||
hpinternal.padding=op.padding;
|
hpinternal.padding=op.padding;
|
||||||
hpinternal.jittype=JITTYPE::PPSSPP;
|
hpinternal.jittype=JITTYPE::PPSSPP;
|
||||||
NewHook(hpinternal,op.hookname);
|
NewHook(hpinternal,op.hookname);
|
||||||
|
}();
|
||||||
|
[&](){
|
||||||
|
if(delayinserthook.find(em_address)==delayinserthook.end())return;
|
||||||
|
auto h=delayinserthook[em_address];
|
||||||
|
delayinserthook.erase(em_address);
|
||||||
|
NewHook(h.second,h.first.c_str());
|
||||||
|
}();
|
||||||
};
|
};
|
||||||
static auto once=NewHook(hpinternal,"DoJitPtrRet");
|
static auto once=NewHook(hpinternal,"DoJitPtrRet");
|
||||||
};
|
};
|
||||||
|
@ -207,7 +207,11 @@ bool NewHook_1(HookParam& hp, LPCSTR lpname)
|
|||||||
bool NewHook(HookParam hp, LPCSTR name){
|
bool NewHook(HookParam hp, LPCSTR name){
|
||||||
if(hp.address)
|
if(hp.address)
|
||||||
return NewHook_1(hp,name);
|
return NewHook_1(hp,name);
|
||||||
if(emuaddr2jitaddr.find(hp.emu_addr)==emuaddr2jitaddr.end())return false;
|
//下面的是手动插入
|
||||||
|
if(emuaddr2jitaddr.find(hp.emu_addr)==emuaddr2jitaddr.end()){
|
||||||
|
delayinserthook[hp.emu_addr]={name,hp};
|
||||||
|
return false;
|
||||||
|
}
|
||||||
strcpy(hp.function,"");
|
strcpy(hp.function,"");
|
||||||
wcscpy(hp.module,L"");
|
wcscpy(hp.module,L"");
|
||||||
hp.type &= ~MODULE_OFFSET;
|
hp.type &= ~MODULE_OFFSET;
|
||||||
|
@ -25,3 +25,5 @@ void jitaddraddr(uintptr_t em_addr,uintptr_t jitaddr,JITTYPE);
|
|||||||
|
|
||||||
void context_get(hook_stack*,PCONTEXT);
|
void context_get(hook_stack*,PCONTEXT);
|
||||||
void context_set(hook_stack*,PCONTEXT);
|
void context_set(hook_stack*,PCONTEXT);
|
||||||
|
|
||||||
|
inline std::map<uintptr_t,std::pair<std::string,HookParam>>delayinserthook;
|
@ -38,7 +38,8 @@ bool add_veh_hook(void* origFunc, newFuncType newFunc, DWORD hook_type)
|
|||||||
}
|
}
|
||||||
void repair_origin(veh_node_t *node){
|
void repair_origin(veh_node_t *node){
|
||||||
DWORD _p;
|
DWORD _p;
|
||||||
VirtualProtect(node->origFunc, sizeof(int), PAGE_EXECUTE_READWRITE, &_p);
|
if(!VirtualProtect(node->origFunc, sizeof(int), PAGE_EXECUTE_READWRITE, &_p))
|
||||||
|
return;
|
||||||
memcpy((void*)node->origFunc, (const void*)(&node->origBaseByte), sizeof(char));
|
memcpy((void*)node->origFunc, (const void*)(&node->origBaseByte), sizeof(char));
|
||||||
VirtualProtect(node->origFunc, sizeof(int), node->OldProtect, &_p);
|
VirtualProtect(node->origFunc, sizeof(int), node->OldProtect, &_p);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user