remove hookfun

This commit is contained in:
恍兮惚兮 2024-02-17 14:33:26 +08:00
parent 98e5f7c82b
commit b217875c8c
5 changed files with 30 additions and 34 deletions

View File

@ -169,16 +169,7 @@
* 011318EC 8B7B 0C MOV EDI,DWORD PTR DS:[EBX+0xC]
*/
namespace { // unnamed
bool BootupGDIHook(hook_stack* stack, HookParam *hp)
{
DWORD arg2 = stack->stack[2];
if ((arg2 & 0xffff0000)) { // if arg2 high bits are there, this is new Bootup game
hp->type |= DATA_INDIRECT;
hp->offset = get_stack(3);
hp->split = get_reg(regs::ebx);
}
return false; // run once and stop hooking
}
bool InsertBootupGDIHook()
{
bool widechar = true;
@ -203,7 +194,17 @@ bool InsertBootupGDIHook()
hp.split = get_reg(regs::edx);
else
hp.split = get_stack(1);
hp.hook_fun = BootupGDIHook; // adjust hook parameter at runtime
hp.text_fun =
[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len)
{
DWORD arg2 = stack->stack[2];
if ((arg2 & 0xffff0000)) { // if arg2 high bits are there, this is new Bootup game
hp->type |= DATA_INDIRECT;
hp->offset = get_stack(3);
hp->split = get_reg(regs::ebx);
}
hp->text_fun=nullptr;
};
ConsoleOutput("INSERT BootupGDI");

View File

@ -909,19 +909,6 @@ bool NewKiriKiriZHook(DWORD addr)
}
bool KiriKiriZHook1(hook_stack* stack, HookParam *)
{
DWORD addr = stack->stack[0]; // retaddr
addr = MemDbg::findEnclosingAlignedFunction(addr, 0x400); // range is around 0x377c50 - 0x377a40 = 0x210
if (!addr) {
ConsoleOutput("KiriKiriZ: failed to find enclosing function");
return false; // stop looking
}
NewKiriKiriZHook(addr);
ConsoleOutput("KiriKiriZ1 inserted");
return false; // stop looking
}
bool InsertKiriKiriZHook1()
{
ULONG addr = MemDbg::findCallerAddressAfterInt3((DWORD)::GetGlyphOutlineW, processStartAddress, processStopAddress);
@ -932,8 +919,20 @@ bool InsertKiriKiriZHook1()
HookParam hp;
hp.address = addr;
hp.type = HOOK_EMPTY;
hp.hook_fun = KiriKiriZHook1;
hp.text_fun =
[](hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len)
{
hp->text_fun=nullptr;
hp->type=HOOK_EMPTY;
DWORD addr = stack->stack[0]; // retaddr
addr = MemDbg::findEnclosingAlignedFunction(addr, 0x400); // range is around 0x377c50 - 0x377a40 = 0x210
if (!addr) {
ConsoleOutput("KiriKiriZ: failed to find enclosing function");
return;
}
NewKiriKiriZHook(addr);
ConsoleOutput("KiriKiriZ1 inserted");
};
ConsoleOutput("INSERT KiriKiriZ1 empty hook");
return NewHook(hp, "KiriKiriZ Hook");

View File

@ -120,18 +120,15 @@ void TextHook::Send(uintptr_t lpDataBase)
if (!current_trigger_fun(location, stack->ebp, stack->esp)) trigger_fun = current_trigger_fun;
#endif
if (hp.type & HOOK_EMPTY) __leave; // jichi 10/24/2014: dummy hook only for dynamic hook
size_t lpCount = 0;
uintptr_t lpSplit = 0,
lpRetn = stack->retaddr,
plpdatain=(lpDataBase + hp.offset),
lpDataIn=*(uintptr_t*)plpdatain;
// jichi 10/24/2014: generic hook function
if (hp.hook_fun && !hp.hook_fun(stack, &hp)) hp.hook_fun = nullptr;
if (hp.type & HOOK_EMPTY) __leave; // jichi 10/24/2014: dummy hook only for dynamic hook
bool isstring=false;
auto use_custom_embed_fun=(hp.type&EMBED_ABLE)&&!(hp.type&EMBED_BEFORE_SIMPLE);
if(use_custom_embed_fun)
{

View File

@ -287,7 +287,7 @@ namespace
if (hp.type & FULL_STRING) HCode += L'F';
if (hp.type & NO_CONTEXT) HCode += L'N';
if (hp.text_fun || hp.filter_fun || hp.hook_fun) HCode += L'X'; // no AGTH equivalent
if (hp.text_fun || hp.filter_fun) HCode += L'X'; // no AGTH equivalent
if (hp.codepage != 0 && !(hp.type & CODEC_UTF16||hp.type & CODEC_UTF32)) HCode += std::to_wstring(hp.codepage) + L'#';

View File

@ -87,7 +87,6 @@ struct HookParam
DWORD user_value; // 7/20/2014: jichi additional parameters for PSP games
ALIGNPTR(uint64_t __2,void(*text_fun)(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len))
ALIGNPTR(uint64_t __3,bool(*filter_fun)(void* data, size_t* len, HookParam* hp)); // jichi 10/24/2014: Add filter function. Return false to skip the text
ALIGNPTR(uint64_t __4,bool(*hook_fun)(hook_stack* stack, HookParam* hp)); // jichi 10/24/2014: Add generic hook function, return false if stop execution.
ALIGNPTR(uint64_t __6,bool (*hook_before)(hook_stack* stack,void* data, size_t* len,uintptr_t*role));
ALIGNPTR(uint64_t __7,void (*hook_after)(hook_stack* stack,void* data, size_t len));
ALIGNPTR(uint64_t __8,uintptr_t hook_font);