Attaching a DLL to a Game

515 Views Asked by At

I would like to attach my DLL to a game to add more features.

The DLL is 95% done, the problem is in finding the best and easy way to load this DLL from within the game.

My idea is to use this technique:

dinput_ori.dll (old dll)
dinput.dll (my dll that points to dinput_ori.dll)

I don't need to access any members of original DLL, but only load my new DLL.

I am searching for a generic DLL source code that can do the following:

bool WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{

    std::string DLLFileOri = "dinput_ori.dll";

    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        // Load dll

        LoadOriDll(DLLFileOri);

        MsgBox("This DLL was loaded.");

        break;

    case DLL_PROCESS_DETACH:

        // Close the DLL
        
        UnloadOriDll(DLLFileOri);

        break;
    }

    return true;
}

In this case the name of my DLL is "dinput.dll".

Is there a generic source code that can do this ?

Thanks!

0

There are 0 best solutions below