Hi everyone, im trying to get some arguments from a function. But i couldnt hook this function;
What is the right way to do this ? Thanks all!
Code:
module_addr = 0x123456;
module_instance = reinterpret_cast<DWORD>(module_addr);
typedef bool(__thiscall* tModuleFunc)(void* This, int arg1, int arg2);
static DWORD func_addr = 0x112233;
static tModuleFunc ModuleFunc;
ModuleFunc = (tModuleFunc)(func_addr);
void ShowArgs(int arg1, int arg2){
std::cout << arg1= << arg1 << std::endl;
std::cout << arg2= << arg2 << std::endl;
}
static bool CallModuleFunc(int arg1, int arg2)
{
try
{
return ModuleFunc((void*)module_instance, arg1, arg2);
}
catch (...)
{
return false;
}
}
static bool HookCallModuleFunc(int arg1, int arg2)
{
try
{
ShowArgs(arg1, arg2);
return ModuleFunc((void*)module_instance, arg1, arg2);
}
catch (...)
{
return false;
}
}