本帖最后由 mcawxd 于 2009-11-10 16:39:25 编辑

解决方案 »

  1.   

    不知道你是不是说窗口出现就注入?如果是那就下WH_CBT钩子
      

  2.   

    http://hi.baidu.com/sadusaga/blog/item/50e300de400b7052cdbf1a1b.html
      

  3.   

    WH_CBT钩子捕获窗口创建,然后对目标进程注入
    CreateRemoteThread
    http://hi.baidu.com/hurryhx/blog/item/8c09a67760151819b051b9eb.html
      

  4.   

    WH_CBT钩子函数中WPARAM参数就是窗口的句柄
    通过GetWindowThreadProcessId获得它对应的进程ID,然后你可以注入了。怎么注入进程就不用我教你了吧
      

  5.   

    #include <windows.h>
    #pragma data_seg(".Seg")
    HWND g_hWnd=NULL;
    HHOOK g_hHook = NULL;
    HMODULE g_hInst = NULL;
    #pragma data_seg()
    #pragma comment(linker,"/section:.Seg,RWS")
    BOOL WINAPI DllMain(
    HINSTANCE hinstDLL,  // handle to the DLL module
    DWORD fdwReason,     // reason for calling function
    LPVOID lpvReserved   // reserved
    )
    {
    g_hInst=hinstDLL;
    return true;
    }LRESULT CALLBACK CBTProc(
     int nCode,      // hook code
     WPARAM wParam,  // depends on hook code
     LPARAM lParam   // depends on hook code
     )
    {
    HWND   hWnd=NULL; 
    TCHAR  cap[31]={0}; 
    switch(nCode)
    {
    case HCBT_CREATEWND:
    hWnd=(HWND)wParam;  
    ::GetWindowText(hWnd,cap,31); 
    break;
    case HCBT_ACTIVATE:
    break;
    }
    return CallNextHookEx(g_hHook, nCode, wParam, lParam);
    }void InstallCBTHook()
    {
    if(g_hHook==NULL)
    g_hHook=SetWindowsHookEx(WH_CBT,CBTProc,g_hInst,0);
    }
    我在CBTProc里下了断点,随便打开一个程序怎么不执行啊。只有点自已程序窗口的时候才被断下。我用的是全局钩子啊。怎么回事啊?
      

  6.   

    调试全局钩子的两种方式:1.用内核调试器,在Dll上下断点(比如说Softice、Windbg、Syser等)
    2.Ring3调试器的话,只能在调试进程的Dll上断点,因此即使别的进程执行了该Dll的代码也不会中断,这时候使用Log进行调试就比较必要了
      

  7.   

    DLLMain写规范点,然后在PROCESS_ATTACH里面写InstallCBTHook()你这么写肯定不行的啊.