首页
社区
课程
招聘
[求助]关于HOOK游戏并在游戏中创建新进程显示窗口???(VC)
发表于: 2007-8-17 16:50 12726

[求助]关于HOOK游戏并在游戏中创建新进程显示窗口???(VC)

2007-8-17 16:50
12726
现在正在学习游戏外挂,以下是我写的代码,我以计算器为例,已经成功HOOK入计算器进程,并在新线程内建立非模态对话框,建立成功,但不响应消息,希望能得到帮助,谢谢大家!!!

[课程]FART 脱壳王!加量不加价!FART作者讲授!

上传的附件:
收藏
免费 0
支持
分享
最新回复 (13)
雪    币: 205
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
你想得到什么帮助?
最好把程序代码一块贴出来.
2007-8-27 13:37
0
雪    币: 401
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
以下是DLL文件DLL.cpp

#define HOOKGAME  extern "C" _declspec(dllexport)
#include "dll.h"
#include "resource.h"

#pragma data_seg("YXJH")
HHOOK hhook=NULL;

#pragma data_seg()

#pragma comment(linker, "/SECTION:YXJH,rws")

HINSTANCE hinst;

HANDLE handle=NULL;
HWND m_hwnd;
HWND hwnd;

BOOL CALLBACK DialogProc(
  HWND hwndDlg,  // handle to dialog box
  UINT uMsg,     // message
  WPARAM wParam, // first message parameter
  LPARAM lParam  // second message parameter
)
{
        switch(uMsg)
        {
        case WM_DESTROY:
                PostQuitMessage(0);
        case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                case IDOK:
                        PostQuitMessage(0);
                        break;
                }
        default:
                return false;
        }
        return true;
}

DWORD WINAPI ThreadProc(
  LPVOID lpParameter   // thread data
)
{
        MSG msg;
        //HWND hwnd=FindWindow(NULL,"计算器");
        m_hwnd=CreateDialogParam(hinst,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,(DLGPROC)DialogProc,NULL);       
        while(GetMessage(&msg,NULL,0,0));
        {
                if(m_hwnd==0 || !IsDialogMessage(m_hwnd,&msg))
                {
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                }
        }
        return 0;
}

BOOL WINAPI DllMain(
  HINSTANCE hinstDLL,  // handle to DLL module
  DWORD fdwReason,     // reason for calling function
  LPVOID lpvReserved   // reserved
)
{       
        switch(fdwReason)
        {
        case DLL_PROCESS_ATTACH:
        break;
        }
        hinst=hinstDLL;
        return true;
}

LRESULT CALLBACK KeyboardProc(
  int code,       // hook code
  WPARAM wParam,  // virtual-key code
  LPARAM lParam   // keystroke-message information
)
{
               
        if(VK_NUMPAD6==wParam)
        {
                        DWORD ThreadId;
                        handle=        CreateThread(NULL,0,ThreadProc,NULL,0,&ThreadId);
                        return 1;
        }
        return CallNextHookEx(hhook,code,wParam,lParam);
       
}

void InstallHook()
{
        DWORD ProcessId;
        hwnd=FindWindow(NULL,"计算器");
        if(hwnd)
        hhook=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,hinst,GetWindowThreadProcessId(FindWindow(NULL,"计算器"),&ProcessId));
}

void UnstallHook()
{
        UnhookWindowsHookEx(hhook);
}

以下是DLL.h

#include <windows.h>

#ifndef HOOKGAME
#define HOOKGAME extern "C" _declspec(dllimport)
#endif

HOOKGAME void InstallHook();
HOOKGAME void UnstallHook();

然后随便做了个EXE来启动HOOK,这是我用来HOOK游戏并在游戏内部创建一个新线,并新建一个对话框,但对话框没是建立了,但不能响应消息,请大大们不吝指教!!谢谢!!!
2007-8-27 21:49
0
雪    币: 8149
活跃值: (1875)
能力值: ( LV8,RANK:122 )
在线值:
发帖
回帖
粉丝
4
不用搞什么线程里建立窗口,直接Dll中建立非模态窗口就行啦
2007-8-27 22:07
0
雪    币: 401
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
不用搞什么线程里建立窗口,直接Dll中建立非模态窗口就行啦
我开始也是跟你这样想的,但我试过也不行,到百度查了很多资料,都说用UI线程,但线程应该在MFC才分UI的吧?那WIN32呢?我看过一编资料,用MFC来HOOK的,在就HOOK后按下一个键就创建窗口,他是成功的,但在WIN32里又怎么实现呢?
2007-8-29 09:16
0
雪    币: 437
活跃值: (273)
能力值: ( LV12,RANK:240 )
在线值:
发帖
回帖
粉丝
6
直接用MFC 在DLL呼出窗口方便多了
2007-8-29 09:20
0
雪    币: 321
活跃值: (271)
能力值: ( LV13,RANK:1050 )
在线值:
发帖
回帖
粉丝
7
我已经帮你调好。如果需要加我qq:391136515. 我传给你。
2007-8-29 13:27
0
雪    币: 217
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
大大,拿出来分享下多好!
2007-8-30 16:39
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
while(GetMessage(&msg,NULL,0,0));
此处多了一个';'号吧!!
2007-9-5 12:53
0
雪    币: 248
活跃值: (18)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
10
#define HOOKGAME  extern "C" _declspec(dllexport)
#include "dll.h"
#include "resource.h"

#pragma data_seg("YXJH")
HHOOK hhook=NULL;

#pragma data_seg()

#pragma comment(linker, "/SECTION:YXJH,rws")

HINSTANCE hinst;

HANDLE handle=NULL;
HWND m_hwnd;
HWND hwnd;

BOOL CALLBACK DialogProc(
  HWND hwndDlg,  // handle to dialog box
  UINT uMsg,     // message
  WPARAM wParam, // first message parameter
  LPARAM lParam  // second message parameter
)
{
  switch(uMsg)
  {
  case WM_DESTROY:
    PostQuitMessage(0);
  case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case IDOK:
      PostQuitMessage(0);
      break;
    }
  default:
    return false;
  }
  return true;
}

DWORD WINAPI ThreadProc(
  LPVOID lpParameter   // thread data
)
{
  MSG msg;
  //HWND hwnd=FindWindow(NULL,"计算器");
  m_hwnd=CreateDialogParam(hinst,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,(DLGPROC)DialogProc,NULL);
  ShowWindow(m_hwnd, SW_SHOW);
  
  while(GetMessage(&msg,NULL,0,0));
  {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
  }
  FreeLibraryAndExitThread(hinst, 0);
  return 0;
}

BOOL WINAPI DllMain(
  HINSTANCE hinstDLL,  // handle to DLL module
  DWORD fdwReason,     // reason for calling function
  LPVOID lpvReserved   // reserved
)
{  
  switch(fdwReason)
  {
  case DLL_PROCESS_ATTACH:
  {
          DisableThreadLibraryCalls(hinstDLL);
          char szModName[MAX_PATH] = {0};
          GetModuleFileName(hinstDll, szModName, sizeof(szModName));
          LoadLibrary(szModName);
          UnstallHook();
            DWORD ThreadId;
      handle=  CreateThread(NULL,0,ThreadProc,NULL,0,&ThreadId);
      CloseHandle(handle);
  }
  break;
  }
  hinst=hinstDLL;
  return true;
}

LRESULT CALLBACK KeyboardProc(
  int code,       // hook code
  WPARAM wParam,  // virtual-key code
  LPARAM lParam   // keystroke-message information
)
{
  return CallNextHookEx(hhook,code,wParam,lParam);  
}

void InstallHook()
{
  DWORD ProcessId;
  hwnd=FindWindow(NULL,"计算器");
  if(hwnd)
  hhook=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,hinst,GetWindowThreadProcessId(FindWindow(NULL,"计算器"),&ProcessId));
}

void UnstallHook()
{
  UnhookWindowsHookEx(hhook);
}
2007-9-5 13:22
0
雪    币: 401
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
11
无名指,你好,hinstDll是什么?是不是我定义的hinst?我改成hinst不行,请指教
2007-9-7 15:23
0
雪    币: 325
活跃值: (97)
能力值: ( LV13,RANK:530 )
在线值:
发帖
回帖
粉丝
12
好像应该调用一下
DefWindowProc Function

--------------------------------------------------------------------------------

The DefWindowProc function calls the default window procedure to provide default processing for any window messages that an application does not process. This function ensures that every message is processed. DefWindowProc is called with the same parameters received by the window procedure.

Syntax

LRESULT DefWindowProc(          HWND hWnd,
    UINT Msg,
    WPARAM wParam,
    LPARAM lParam
);
Parameters

hWnd
[in] Handle to the window procedure that received the message.
Msg
[in] Specifies the message.
wParam
[in] Specifies additional message information. The content of this parameter depends on the value of the Msg parameter.
lParam
[in] Specifies additional message information. The content of this parameter depends on the value of the Msg parameter.
Return Value

The return value is the result of the message processing and depends on the message.

这个
2007-9-8 21:18
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
呵呵,就因为多这个;,你调了好久了吧,可见细心很重要啊
2008-1-12 19:33
0
雪    币: 201
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
14
Form=new TForm(NULL);
Form->ShowModal();
delete Form;

DLL调出窗口,但是调用该DLL的程序就失去响应了,如果要调出窗口,且调用该DLL的程序不失去响应了,该怎么写?

上面是BCB的东西。。。
2008-1-12 21:44
0
游客
登录 | 注册 方可回帖
返回
//