Hooking with DLL/ASI

269 views Asked by At

Good afternoon all, I have a slight problem.

I'm using Microsoft Detours 3.0 to hook a game, call my function and change some data.

Now, When I load the game, it's like my ASI file doesn't even exist.

Now, I'm wondering weather this is because I'm hooking the wrong address or the way I've wrote the hook does not work.

Here's my Dllmain:

BOOL APIENTRY dllmain(HINSTANCE hinstDLL, DWORD nReason, LPVOID lpvReserved)
{
    switch(nReason)
    {
        case DLL_PROCESS_ATTACH:
            OriginalFunction = (int(_cdecl*)(int))DetourFunction((PBYTE)GameLoading, (PBYTE)ChangeLoadingBarColor);
        case DLL_PROCESS_DETACH:
            break;
        case DLL_THREAD_ATTACH:
            break;
        case DLL_THREAD_DETACH:
            break;
    }
    return TRUE;
}

My Hook function is here:

BYTE ChangeLoadingBarColor(int a, DWORD Bar_color_R,DWORD Bar_color_G,DWORD Bar_color_B,BYTE Bar_color_set_R,BYTE Bar_color_set_G,BYTE Bar_color_set_B)
{
    return *(BYTE*)Bar_color_R;
    return *(BYTE*)Bar_color_G;
    return *(BYTE*)Bar_color_B;
    *(BYTE*)Bar_color_R = Bar_color_set_R;
    *(BYTE*)Bar_color_G = Bar_color_set_G;
    *(BYTE*)Bar_color_B = Bar_color_set_B;
    return OriginalFunction(a);
}

And here's the defined addresses and pointer to the original function:

DWORD Bar_color_R = 0x4A6B80;
DWORD Bar_color_G = 0x4A6B7E;
DWORD Bar_color_B = 0x4A6B7C;
DWORD Bar_color_set_R = {5};
DWORD Bar_color_set_G = {54};
DWORD Bar_color_set_B = {250};
DWORD GameLoading = 0x587F00;
int (_cdecl* OriginalFunction) (int);

Is my code correctly hooking the specified GameLoading address or is it wrong?

0

There are 0 answers