1

I need to hook 10/20 functions like these:

static void* __cdecl HookFunction1(char *FileName, int a2, int a3, int a4);


 __declspec(naked)  void HookFunction2(char  *Src, int pedx, int 
    
    a3, int a4, int a5, int a6);
    
 static BOOL HookFunction3(int a1, DWORD *a2, DWORD *a3, int a4, char a5, int a6);

and I use this code:

switch (int iD)
{
case 1

    DetourAttach(&(LPVOID&)AddressOfHook, &HookFunction1);

case 2
   DetourAttach(&(LPVOID&)AddressOfHook, &HookFunction2);

case 3
   DetourAttach(&(LPVOID&)AddressOfHook, &HookFunction3);
.....
}

but I like to not repeat x times "DetourAttach" and I like do to something like this:

switch (int iD)
{
case 1

    HookFunction = &HookFunction1;

case 2
    HookFunction = &HookFunction2;

case 3
   HookFunction = &HookFunction3;
.....
}

DetourAttach(&(LPVOID&)AddressOfHook, &HookFunction);

I ask if there is a easy way to do this becouse is more flexible.

Thanks !!

1 Answer 1

1

I have solved myself.

PVOID HookFunction;

HookFunction = (PVOID)HookFunction1;

and

DetourAttach(&(LPVOID&)AddressOfHook, HookFunction);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.