1 // dchk64.cpp :
\83A
\83v
\83\8a\83P
\81[
\83V
\83\87\83\93\82Ì
\83G
\83\93\83g
\83\8a \83|
\83C
\83\93\83g
\82ð
\92è
\8b`
\82µ
\82Ü
\82·
\81B
6 #include "../../DCHookTest/HookLoader.h"
7 #include "../DCHook64.h"
9 #define MAX_LOADSTRING 100
11 //
\83O
\83\8d\81[
\83o
\83\8b\95Ï
\90\94:
12 HINSTANCE hInst; //
\8c»
\8dÝ
\82Ì
\83C
\83\93\83^
\81[
\83t
\83F
\83C
\83X
13 TCHAR szTitle[MAX_LOADSTRING]; //
\83^
\83C
\83g
\83\8b \83o
\81[
\82Ì
\83e
\83L
\83X
\83g
14 TCHAR szWindowClass[MAX_LOADSTRING]; //
\83\81\83C
\83\93 \83E
\83B
\83\93\83h
\83E
\83N
\83\89\83X
\96¼
16 const char *StrDCHOOKDLL = "DKPUHK64.dll";
17 THookLoader HookDll(StrDCHOOKDLL);
20 HWND hwndParent = NULL;
22 bool WindowsNT = true;
29 void dbw( const char *format, ... );
31 //
\82±
\82Ì
\83R
\81[
\83h
\83\82\83W
\83\85\81[
\83\8b\82É
\8aÜ
\82Ü
\82ê
\82é
\8aÖ
\90\94\82Ì
\90é
\8c¾
\82ð
\93]
\91\97\82µ
\82Ü
\82·:
32 ATOM MyRegisterClass(HINSTANCE hInstance);
33 BOOL InitInstance(HINSTANCE, LPTSTR lpCmdLine, int);
35 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
37 int atox( const TCHAR *str, TCHAR **next );
39 int APIENTRY _tWinMain(HINSTANCE hInstance,
40 HINSTANCE hPrevInstance,
44 UNREFERENCED_PARAMETER(hPrevInstance);
45 //UNREFERENCED_PARAMETER(lpCmdLine);
50 //
\83O
\83\8d\81[
\83o
\83\8b\95¶
\8e\9a\97ñ
\82ð
\8f\89\8aú
\89»
\82µ
\82Ä
\82¢
\82Ü
\82·
\81B
51 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
52 LoadString(hInstance, IDC_DCHK64, szWindowClass, MAX_LOADSTRING);
53 MyRegisterClass(hInstance);
55 //
\83A
\83v
\83\8a\83P
\81[
\83V
\83\87\83\93\82Ì
\8f\89\8aú
\89»
\82ð
\8eÀ
\8ds
\82µ
\82Ü
\82·:
56 if (!InitInstance (hInstance, lpCmdLine, nCmdShow))
61 hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DCHK64));
63 //
\83\81\83C
\83\93 \83\81\83b
\83Z
\81[
\83W
\83\8b\81[
\83v:
64 while (GetMessage(&msg, NULL, 0, 0))
66 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
68 TranslateMessage(&msg);
69 DispatchMessage(&msg);
75 return (int) msg.wParam;
81 //
\8aÖ
\90\94: MyRegisterClass()
83 //
\96Ú
\93I:
\83E
\83B
\83\93\83h
\83E
\83N
\83\89\83X
\82ð
\93o
\98^
\82µ
\82Ü
\82·
\81B
85 //
\83R
\83\81\83\93\83g:
87 //
\82±
\82Ì
\8aÖ
\90\94\82¨
\82æ
\82Ñ
\8eg
\82¢
\95û
\82Í
\81A'RegisterClassEx'
\8aÖ
\90\94\82ª
\92Ç
\89Á
\82³
\82ê
\82½
88 // Windows 95
\82æ
\82è
\91O
\82Ì Win32
\83V
\83X
\83e
\83\80\82Æ
\8cÝ
\8a·
\82³
\82¹
\82é
\8fê
\8d\87\82É
\82Ì
\82Ý
\95K
\97v
\82Å
\82·
\81B
89 //
\83A
\83v
\83\8a\83P
\81[
\83V
\83\87\83\93\82ª
\81A
\8aÖ
\98A
\95t
\82¯
\82ç
\82ê
\82½
90 //
\90³
\82µ
\82¢
\8c`
\8e®
\82Ì
\8f¬
\82³
\82¢
\83A
\83C
\83R
\83\93\82ð
\8eæ
\93¾
\82Å
\82«
\82é
\82æ
\82¤
\82É
\82·
\82é
\82É
\82Í
\81A
91 //
\82±
\82Ì
\8aÖ
\90\94\82ð
\8cÄ
\82Ñ
\8fo
\82µ
\82Ä
\82
\82¾
\82³
\82¢
\81B
93 ATOM MyRegisterClass(HINSTANCE hInstance)
97 wcex.cbSize = sizeof(WNDCLASSEX);
99 wcex.style = CS_HREDRAW | CS_VREDRAW;
100 wcex.lpfnWndProc = WndProc;
103 wcex.hInstance = hInstance;
104 wcex.hIcon = NULL; //LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PDHK64));
106 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
107 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
109 wcex.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW);
110 wcex.hbrBackground = NULL; //(HBRUSH)(COLOR_WINDOW+1);
112 wcex.lpszMenuName = NULL; //MAKEINTRESOURCE(IDC_PDHK64);
113 wcex.lpszClassName = szWindowClass;
114 wcex.hIconSm = NULL; //LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
116 return RegisterClassEx(&wcex);
120 //
\8aÖ
\90\94: InitInstance(HINSTANCE, LPTSTR, int)
122 //
\96Ú
\93I:
\83C
\83\93\83X
\83^
\83\93\83X
\83n
\83\93\83h
\83\8b\82ð
\95Û
\91¶
\82µ
\82Ä
\81A
\83\81\83C
\83\93 \83E
\83B
\83\93\83h
\83E
\82ð
\8dì
\90¬
\82µ
\82Ü
\82·
\81B
124 //
\83R
\83\81\83\93\83g:
126 //
\82±
\82Ì
\8aÖ
\90\94\82Å
\81A
\83O
\83\8d\81[
\83o
\83\8b\95Ï
\90\94\82Å
\83C
\83\93\83X
\83^
\83\93\83X
\83n
\83\93\83h
\83\8b\82ð
\95Û
\91¶
\82µ
\81A
127 //
\83\81\83C
\83\93 \83v
\83\8d\83O
\83\89\83\80 \83E
\83B
\83\93\83h
\83E
\82ð
\8dì
\90¬
\82¨
\82æ
\82Ñ
\95\
\8e¦
\82µ
\82Ü
\82·
\81B
129 BOOL InitInstance(HINSTANCE hInstance, LPTSTR lpCmdLine, int nCmdShow)
131 hInst = hInstance; //
\83O
\83\8d\81[
\83o
\83\8b\95Ï
\90\94\82É
\83C
\83\93\83X
\83^
\83\93\83X
\8f\88\97\9d\82ð
\8ai
\94[
\82µ
\82Ü
\82·
\81B
133 TCHAR ModuleName[_MAX_PATH];
134 GetModuleFileName(NULL, ModuleName, sizeof(ModuleName)/sizeof(TCHAR));
135 hMutex = CreateMutex(NULL, FALSE, ModuleName);
136 if (GetLastError()==ERROR_ALREADY_EXISTS){
137 return FALSE; // dup launched
141 const int width = 800;
142 const int height = 400;
145 const int height = 0;
148 hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
149 CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL);
156 hwndParent = (HWND)(LONG_PTR)atox(lpCmdLine, NULL);
157 //DBW("hwndParent=%d", (int)(LONG_PTR)hwndParent);
159 PostMessage(hwndParent, UM_SHORTCUT, SCINX_NOTIFY64, (LPARAM)hWnd);
164 ShowWindow(hWnd, nCmdShow);
180 //
\8aÖ
\90\94: WndProc(HWND, UINT, WPARAM, LPARAM)
182 //
\96Ú
\93I:
\83\81\83C
\83\93 \83E
\83B
\83\93\83h
\83E
\82Ì
\83\81\83b
\83Z
\81[
\83W
\82ð
\8f\88\97\9d\82µ
\82Ü
\82·
\81B
184 // WM_COMMAND -
\83A
\83v
\83\8a\83P
\81[
\83V
\83\87\83\93 \83\81\83j
\83\85\81[
\82Ì
\8f\88\97\9d
185 // WM_PAINT -
\83\81\83C
\83\93 \83E
\83B
\83\93\83h
\83E
\82Ì
\95`
\89æ
186 // WM_DESTROY -
\92\86\8e~
\83\81\83b
\83Z
\81[
\83W
\82ð
\95\
\8e¦
\82µ
\82Ä
\96ß
\82é
189 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
201 if (!HookDll.Init(hWnd)){
202 DBW("Hook.Init error");
205 HookDll.Config(-1, KA_POPUP, KF_CONTROL);
207 memset(&cfg, 0, sizeof(cfg));
212 HookDll.Config2(&cfg);
219 wmId = LOWORD(wParam);
220 wmEvent = HIWORD(wParam);
221 //
\91I
\91ð
\82³
\82ê
\82½
\83\81\83j
\83\85\81[
\82Ì
\89ð
\90Í:
225 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
231 return DefWindowProc(hWnd, message, wParam, lParam);
236 hdc = BeginPaint(hWnd, &ps);
245 COPYDATASTRUCT *cds = (COPYDATASTRUCT*)lParam;
247 switch (cds->dwData){
250 HDCInitParam &p = *(HDCInitParam*)cds->lpData;
251 return HookDll.Init(p.hwnd);
258 HDCConfigParam &p = *(HDCConfigParam*)cds->lpData;
259 return HookDll.Config(p.clickonly, p.keyaction, p.keyflag);
262 return HookDll.Config2((TDCHConfig*)cds->lpData);
264 return HookDll.Capture();
265 case HDC_CaptureAsync:
266 return HookDll.CaptureAsync();
267 case HDC_CaptureAsyncWait:
268 return HookDll.CaptureAsyncWait();
270 return HookDll.Debug();
275 return DefWindowProc(hWnd, message, wParam, lParam);
280 int atox( const TCHAR *str, TCHAR **next )
286 if ( c >= '0' && c <= '9' ){
287 val = (val<<4) + (c - '0');
288 } else if ( c >= 'A' && c <= 'F' ){
289 val = (val<<4) + ( c - 'A' + 10 );
290 } else if ( c >= 'a' && c <= 'f' ){
291 val = (val<<4) + ( c - 'a' + 10 );
297 if ( next ) *next = (TCHAR*)str;
301 static HWND hWin = NULL;
302 static const TCHAR *clsnameW = _T("TDbgMsgForm");
303 static const TCHAR *winnameW = _T("Debug Messenger");
305 void dbw( const char *format, ... )
308 hWin = FindWindow( clsnameW, winnameW );
312 va_start( ap, format );
314 wvsprintfA( buf, format, ap );
316 cds.dwData = 1; // Indicate String
317 cds.cbData = (DWORD)strlen(buf)+1;
319 SendMessageA( hWin, WM_COPYDATA, NULL, (LPARAM)&cds );
323 static const char *MyWinTitle = "<Processing...>";
324 HANDLE WinExecEx( const char *cmd, int show, const char *dir, const char *title )
327 memset( &sui, 0, sizeof(STARTUPINFO) );
328 sui.cb = sizeof(STARTUPINFO);
329 sui.dwFlags = STARTF_USESHOWWINDOW;
330 sui.wShowWindow = (WORD)show;
331 sui.lpTitle = (LPTSTR)(title ? title : MyWinTitle);
332 PROCESS_INFORMATION pi;
333 if ( !CreateProcess( NULL, (LPTSTR)cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, dir, &sui, &pi ) )