mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-27 15:54:03 +08:00
fix
This commit is contained in:
parent
28c141e29f
commit
cf342364fc
@ -190,12 +190,7 @@ bool yuzusuyu::attach_function()
|
|||||||
hpinternal.jittype=JITTYPE::YUZU;
|
hpinternal.jittype=JITTYPE::YUZU;
|
||||||
NewHook(hpinternal,op.hookname);
|
NewHook(hpinternal,op.hookname);
|
||||||
}();
|
}();
|
||||||
[&](){
|
delayinsertNewHook(em_address);
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
@ -333,12 +333,7 @@ bool hookPPSSPPDoJit(){
|
|||||||
hpinternal.jittype=JITTYPE::PPSSPP;
|
hpinternal.jittype=JITTYPE::PPSSPP;
|
||||||
NewHook(hpinternal,op.hookname);
|
NewHook(hpinternal,op.hookname);
|
||||||
}();
|
}();
|
||||||
[&](){
|
delayinsertNewHook(em_address);
|
||||||
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");
|
||||||
};
|
};
|
||||||
|
@ -175,9 +175,7 @@ int HookStrLen(HookParam* hp,BYTE* data){
|
|||||||
static std::mutex maplock;
|
static std::mutex maplock;
|
||||||
void jitaddraddr(uintptr_t em_addr,uintptr_t jitaddr,JITTYPE jittype){
|
void jitaddraddr(uintptr_t em_addr,uintptr_t jitaddr,JITTYPE jittype){
|
||||||
std::lock_guard _(maplock);
|
std::lock_guard _(maplock);
|
||||||
if(emuaddr2jitaddr.find(em_addr)==emuaddr2jitaddr.end())
|
emuaddr2jitaddr[em_addr]={jittype,jitaddr};
|
||||||
emuaddr2jitaddr[em_addr]={jittype,{}};
|
|
||||||
emuaddr2jitaddr[em_addr].second.insert(jitaddr);
|
|
||||||
jitaddr2emuaddr[jitaddr]={jittype,em_addr};
|
jitaddr2emuaddr[jitaddr]={jittype,em_addr};
|
||||||
}
|
}
|
||||||
bool NewHook_1(HookParam& hp, LPCSTR lpname)
|
bool NewHook_1(HookParam& hp, LPCSTR lpname)
|
||||||
@ -204,25 +202,34 @@ bool NewHook_1(HookParam& hp, LPCSTR lpname)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static std::mutex delayinsertlock;
|
||||||
|
void delayinsertadd(HookParam hp,std::string name){
|
||||||
|
std::lock_guard _(maplock);
|
||||||
|
delayinserthook[hp.emu_addr]={name,hp};
|
||||||
|
ConsoleOutput(INSERTING_HOOK, name.c_str());
|
||||||
|
}
|
||||||
|
void delayinsertNewHook(uintptr_t em_address){
|
||||||
|
if(delayinserthook.find(em_address)==delayinserthook.end())return;
|
||||||
|
std::lock_guard _(maplock);
|
||||||
|
auto h=delayinserthook[em_address];
|
||||||
|
delayinserthook.erase(em_address);
|
||||||
|
NewHook(h.second,h.first.c_str());
|
||||||
|
}
|
||||||
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()){
|
if(emuaddr2jitaddr.find(hp.emu_addr)==emuaddr2jitaddr.end()){
|
||||||
delayinserthook[hp.emu_addr]={name,hp};
|
delayinsertadd(hp,name);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
strcpy(hp.function,"");
|
strcpy(hp.function,"");
|
||||||
wcscpy(hp.module,L"");
|
wcscpy(hp.module,L"");
|
||||||
hp.type &= ~MODULE_OFFSET;
|
hp.type &= ~MODULE_OFFSET;
|
||||||
hp.type &= ~FUNCTION_OFFSET;
|
|
||||||
auto succ=false;
|
hp.address=emuaddr2jitaddr[hp.emu_addr].second;
|
||||||
for(auto __x: emuaddr2jitaddr[hp.emu_addr].second){
|
hp.jittype=emuaddr2jitaddr[hp.emu_addr].first;
|
||||||
hp.address=__x;
|
return NewHook_1(hp,name);
|
||||||
hp.jittype=emuaddr2jitaddr[hp.emu_addr].first;
|
|
||||||
succ|=NewHook_1(hp,name);
|
|
||||||
}
|
|
||||||
return succ;
|
|
||||||
}
|
}
|
||||||
void RemoveHook(uint64_t addr, int maxOffset)
|
void RemoveHook(uint64_t addr, int maxOffset)
|
||||||
{
|
{
|
||||||
|
@ -19,11 +19,13 @@ inline SearchParam spDefault;
|
|||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
int HookStrLen(HookParam*,BYTE* data);
|
int HookStrLen(HookParam*,BYTE* data);
|
||||||
inline std::unordered_map<uintptr_t,std::pair<JITTYPE,std::set<uintptr_t> > >emuaddr2jitaddr;
|
inline std::unordered_map<uintptr_t,std::pair<JITTYPE,uintptr_t>>emuaddr2jitaddr;
|
||||||
inline std::unordered_map<uintptr_t,std::pair<JITTYPE,uintptr_t>>jitaddr2emuaddr;
|
inline std::unordered_map<uintptr_t,std::pair<JITTYPE,uintptr_t>>jitaddr2emuaddr;
|
||||||
void jitaddraddr(uintptr_t em_addr,uintptr_t jitaddr,JITTYPE);
|
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;
|
inline std::map<uintptr_t,std::pair<std::string,HookParam>>delayinserthook;
|
||||||
|
void delayinsertadd(HookParam,std::string);
|
||||||
|
void delayinsertNewHook(uintptr_t);
|
Loading…
Reference in New Issue
Block a user