1

好吧,我已经为 d3d9 制作了我的 proxydll,dll 本身可以工作,我可以确认它已加载到进程中,因为创建了一个黄色矩形。

问题是我调用了 SetTimer 但没有调用我的回调,该怎么办?

我可以听到两声 MessageBeep 的声音,但没有声音,我在游戏中的钱保持为 0。

这是我的代码:

// global variables
#pragma data_seg (".d3d9_shared")
myIDirect3DDevice9* gl_pmyIDirect3DDevice9;
myIDirect3D9*       gl_pmyIDirect3D9;
HINSTANCE           gl_hOriginalDll;
HINSTANCE           gl_hThisInstance;
#pragma data_seg ()

UINT                TimmerID = 0;
#define ProcessTickID (1337)
VOID CALLBACK ProcessTickMain(HWND x, UINT y, UINT_PTR z, DWORD w);

BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    // to avoid compiler lvl4 warnings
    LPVOID lpDummy = lpReserved;
    lpDummy = NULL;

    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH: InitInstance(hModule); break;
        case DLL_PROCESS_DETACH: ExitInstance(); break;

        case DLL_THREAD_ATTACH:  break;
        case DLL_THREAD_DETACH:  break;
    }
    return TRUE;
}

void InitInstance(HANDLE hModule)
{
    OutputDebugString("PROXYDLL: InitInstance called.\r\n");

    // Initialisation
    gl_hOriginalDll        = NULL;
    gl_hThisInstance       = NULL;
    gl_pmyIDirect3D9       = NULL;
    gl_pmyIDirect3DDevice9 = NULL;


    // Storing Instance handle into global var
    gl_hThisInstance = (HINSTANCE)  hModule;
    MessageBeep(0xFFFFFFFF);
    //TimmerID = SetTimer((HWND)Address::Game::MainWindowHandle,ProcessTickID,5,ProcessTickMain);
    TimmerID = SetTimer((HWND)gl_hThisInstance,ProcessTickID,5,ProcessTickMain);
    MessageBeep(0xFFFFFFFF);
}

VOID CALLBACK ProcessTickMain(HWND x, UINT y, UINT_PTR z, DWORD w)
{
    int * ptr = (int*)Address::Ped::Money;
    ptr += 1;
    MessageBeep(0xFFFFFFFF);
}

void ExitInstance()
{
    KillTimer((HWND)gl_hThisInstance,ProcessTickID);
    OutputDebugString("PROXYDLL: ExitInstance called.\r\n");

    // Release the system's d3d9.dll
    if (gl_hOriginalDll)
    {
        ::FreeLibrary(gl_hOriginalDll);
        gl_hOriginalDll = NULL;
    }
}
4

0 回答 0