OSDN Git Service

first commit
[dokopop/dokopop.git] / DCHookTest / HookLoader.h
1 #ifndef __HookLoader_h
2 #define __HookLoader_h
3
4 #include "../DCHook/DCHook.h"
5 #include "HookDll.h"
6
7 class THookLoader : public THookDllI {
8 public:
9         THookLoader(const char *dllname);
10         ~THookLoader();
11         virtual bool Load(HWND hwnd);
12         virtual void Unload();
13         virtual bool IsLoaded()
14                 { return hDll!=NULL; }
15
16         virtual bool Init(HWND hwnd);
17         virtual void Uninit();
18         virtual int Config( int clickonly, int keyaction, int keyflag )
19                 { return DCHConfig(clickonly, keyaction, keyflag); }
20         virtual int Config2( struct TDCHConfig *cfg )
21                 { return DCHConfig2(cfg); }
22         virtual int Capture();
23         virtual int CaptureAsync();
24         virtual int CaptureAsyncWait();
25         virtual int Debug()
26 #ifdef _DEBUG
27                 { return DCDebug(); }
28 #else
29                 { return 0; }
30 #endif
31 protected:
32         HANDLE hThread;
33         DWORD dwThreadId;
34         bool ThreadEnd;
35         void OpenThread();
36         static DWORD WINAPI cbWaitCaptureThread(LPVOID This);
37         void WaitCaptureThread();
38
39 protected:
40         const char *DllName;
41         HINSTANCE hDll;
42         FNDCHInit DCHInit;
43         FNDCHUninit DCHUninit;
44         FNDCHConfig DCHConfig;
45         FNDCHConfig2 DCHConfig2;
46         FNDCHCapture DCHCapture;
47         FNDCHWaitForCaptureResult DCHWaitForCaptureResult;
48 #ifdef _DEBUG
49         FNDebug DCDebug;
50         #define COMPSIZE        16
51         char share[ COMPSIZE ];
52 #endif
53 };
54
55 class THookLoader64 : public THookDllI {
56 public:
57         THookLoader64(HWND hwnd_recv);
58         virtual ~THookLoader64();
59         virtual bool Load(HWND hwnd);
60         virtual void Unload();
61         virtual bool IsLoaded()
62                 { return hProc!=NULL; }
63
64         virtual bool Init(HWND hwnd);
65         virtual void Uninit() ;
66         virtual int Config( int clickonly, int keyaction, int keyflag );
67         virtual int Config2( struct TDCHConfig *cfg );
68         virtual int Capture();
69         virtual int CaptureAsync();
70         virtual int CaptureAsyncWait();
71         virtual int Debug();
72         void SetTarget(HWND hwnd)
73                 { hwndTarget = hwnd; }
74         bool WaitFor() const
75         {
76                 return WaitForInputIdle(hProc, 500)==0;
77         }
78         bool IsPending() const { return LoadPending; }
79         void Notify64() { LoadPending = false; }
80
81 protected:
82         int Send(int msg, void *data=NULL, int len=0);
83
84         HWND hwndRecv;  // receive window handle (=main window handle)
85         HWND hwndTarget;        // main window handle of pdhk64.exe
86         HANDLE hProc;
87         bool LoadPending;
88 };
89
90 #endif
91