Search code examples
c++dlldetours

Trying to write a DLL for wallhack usw


I'm trying to write a DLL file that I can inject into a game. I'm pretty far but when I try to compile the code I always get the error

Error LNK2001 Unresolved external symbol "" unsigned char * __cdecl Detours :: X86 :: DetourFunction (unsigned char *, unsigned char *, enum Detours :: X86Option) "(? DetourFunction @ X86 @ Detours @@ YAPAEPAE0W4X86Option @ 2 @@ Z ) ". 

The detours folder I use is from here: https://github.com/Nukem9/detours

but the Detours.h file was broken because I couldn't use uint8_t so I replaced the code in there with the code from that file: https://github.com/Nukem9/VMWareClient/blob/master/vmware_client/detours/Detours.h The codline where I think the problem is:

oEndScene = (EndScene)Detours::X86::DetourFunction((uint8_t*)d3d9Device[42], (uint8_t*)hkEndScene);

but for those who are interested, I can post the whole code here. Just tell me in the comments. The whole code is 256 lines long


Solution

  • You can't just replace function definition:

    uintptr_t DetourFunction(uintptr_t Target, uintptr_t Detour, X86Option Options = X86Option::USE_JUMP);
    

    with

    uint8_t     *DetourFunction(uint8_t *Target, uint8_t *Detour, X86Option Options = X86Option::USE_JUMP);
    

    Why can't you use uint8_t? Can't you just add:

    typedef unsigned char      uint8_t;