CALLBACK未由SetTimer执行

时间:2012-12-10 21:25:23

标签: c++ winapi

好吧我已经为d3d9制作了我的代理,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;
    }
}

0 个答案:

没有答案