Search code examples
c++dllinjectdll-injection

When I inject the DLL into an existing process, DLLMain doesn't do anything


So I'm trying to make a game cheat (for learning purposes) and I'm using Counter Strike Global Offensive as the Target and I'm using -insecure launch option which doesn't allow me to go to any secure servers and thus I can only use the cheat in singleplayer to not ruin other's game.

I use GuidedHacking's injector (GH_Injector) to inject my DLL to the game's process. The cheat is INTERNAL (modifying memory directly)

I've tried to inject but when I inject the DLL for testing purposes I've added MessageBox() to show after injection, but that doesnt show up. To be exact nothing happens but the dll is injected and im sure because when i try with different injector the other injector gives out error that this dll is already injected (gives error code for occupied memory space)

Here is the code that I've got:

#include "stdafx.h"

BOOL WINAPI ATTACH() {
    MessageBox(NULL, "test", "test", MB_OK); // This here doesnt show up ever.. But it should
    DWORD dwClient = (DWORD)GetModuleHandle("client_panorama.dll"); // gets the base address of the module (dll) i want
    Beep(750, 100); // used for testing
    while (!GetAsyncKeyState(VK_DELETE)) {
        *(BYTE*)(dwClient + hazedumper::signatures::dwForceJump) = 6; // should jump ingame
    }
    FreeLibraryAndExitThread(NULL, 0); // want to make "uninject" but idk how and im testing
    Beep(750, 500); // used for testing
    return 0;
}

BOOL WINAPI DLLMain(HMODULE hInstanceDLL, DWORD fdwReason, LPVOID lpvReserved) {
    switch (fdwReason) {
    case DLL_PROCESS_ATTACH:
        CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ATTACH, NULL, 0, NULL);
        break;

    case DLL_PROCESS_DETACH:
        break;

    case DLL_THREAD_ATTACH:
        break;

    case DLL_THREAD_DETACH:
        break;
    }
    return TRUE;
}

Solution

  • Okay, a VERY, VERY dumb mistake from my part.. Everything I wrote was actually working, but my signature was messed up DllMain is written with capital D and M, and everything else lower-case, I've made it with capital L's... I feel dumb...