0

so i was following along an dll injection tutorial on yt, and it gave me some errors when trying to compile.

1.unresolved external symbol "unsigned __int64 __cdecl Detours::X64::DetourFunction(unsigned __int64,unsigned __int64,enum Detours::X64Option)" (?DetourFunction@X64@Detours@@YA_K_K0W4X64Option@2@@Z) referenced in function "unsigned long __cdecl mainThread(void *)"

 CODE TO ERROR:


  DWORD WINAPI mainThread(PVOID base) {
void* d3d9Device[119];

if(GetD3D9Device(d3d9Device, sizeof(d3d9Device))){
    oEndScene = (EndScene)Detours::X64::DetourFunction((uintptr_t)d3d9Device[42], (uintptr_t)hkEndScene);//here
}

while (true) {
    if (GetAsyncKeyState(VK_F10)) {
        CleanUpDeviceD3D();
        FreeLibraryAndExitThread(static_cast<HMODULE>(base),1);
    }
}

FreeLibraryAndExitThread(static_cast<HMODULE>(base), 1);

} 2. unresolved external symbol Direct3DCreate9 referenced in function "bool __cdecl GetD3D9Device(void * *,unsigned __int64)"

CODE TO ERROR:


bool GetD3D9Device(void **pTable, size_t size) {
if (!pTable) {
    return false;
}

g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); //here

on the first error, the tutorial stated you should use the following syntax:

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

however detours doesnt have uint8_t for me and some forums online said to use uintptr_t. but i still get the error. ive tried looking at my includes for lib and release in detours but it still says unresolved external symbol even after including the folder where Detoursx64.cpp is present.

any help ise appreciated.

  • For error #2, did you link to `D3d9.lib` like the documentation tells you for `Direct3DCreate9` here: [https://learn.microsoft.com/en-us/windows/win32/api/d3d9/nf-d3d9-direct3dcreate9](https://learn.microsoft.com/en-us/windows/win32/api/d3d9/nf-d3d9-direct3dcreate9) – drescherjm Jan 04 '22 at 19:53
  • For the first error its probably this: [https://stackoverflow.com/questions/67463804/how-to-include-microsoft-detours-library-in-visual-studio](https://stackoverflow.com/questions/67463804/how-to-include-microsoft-detours-library-in-visual-studio) – drescherjm Jan 04 '22 at 19:55
  • `uint8_t` would be a compiler error / missing include: [https://en.cppreference.com/w/cpp/types/integer](https://en.cppreference.com/w/cpp/types/integer) – drescherjm Jan 04 '22 at 19:56
  • @drescherjm i have already added the path to the d3d9.lib file to the library dirs. (Microsoft DirectX SDK %28June 2010%29\Lib\x64 – dead gunner Jan 04 '22 at 21:33
  • @drescherjm and the first error solution you gave just gave me more compile errors – dead gunner Jan 04 '22 at 22:01

1 Answers1

0

you need to compile Detours as x86 and use the release folder instead of compiling detours as x64