-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixscancodemap.h
82 lines (73 loc) · 2.01 KB
/
fixscancodemap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <list>
#include <windows.h>
#include "registry.h"
typedef HMODULE (WINAPI *FpGetModuleHandleW)(LPCWSTR);
typedef FARPROC (WINAPI *FpGetProcAddress)(HMODULE, LPCSTR);
typedef BOOL (WINAPI *FpUpdatePerUserSystemParameters4)(BOOL);
typedef BOOL (WINAPI *FpUpdatePerUserSystemParameters8)(DWORD, BOOL);
typedef HANDLE (WINAPI *FpOpenProcess)(DWORD, BOOL, DWORD);
typedef BOOL (WINAPI *FpOpenProcessToken)(HANDLE, DWORD, PHANDLE);
typedef BOOL (WINAPI *FpImpersonateLoggedOnUser)(HANDLE);
typedef BOOL (WINAPI *FpRevertToSelf)(VOID);
typedef BOOL (WINAPI *FpCloseHandle)(HANDLE);
typedef struct {
DWORD isVistaOrLater_;
DWORD pid_;
TCHAR advapi32_[64];
CHAR impersonateLoggedOnUser_[32];
CHAR revertToSelf_[32];
CHAR openProcessToken_[32];
FpGetModuleHandleW pGetModuleHandle;
FpGetProcAddress pGetProcAddress;
FpUpdatePerUserSystemParameters4 pUpdate4;
FpUpdatePerUserSystemParameters8 pUpdate8;
FpOpenProcess pOpenProcess;
FpCloseHandle pCloseHandle;
} InjectInfo;
class FixScancodeMap {
private:
typedef struct {
DWORD header1;
DWORD header2;
DWORD count;
DWORD entry[1];
} ScancodeMap;
typedef struct {
HANDLE m_hProcess;
LPVOID m_remoteMem;
LPVOID m_remoteInfo;
HANDLE m_hThread;
} WlInfo;
private:
static const DWORD s_fixEntryNum;
static const DWORD s_fixEntry[];
private:
HWND m_hwnd;
UINT m_messageOnFail;
int m_errorOnConstruct;
DWORD m_winlogonPid;
std::list<WlInfo> m_wlTrash;
InjectInfo m_info;
Registry m_regHKCU;
Registry m_regHKLM;
Registry *m_pReg;
HANDLE m_hFixEvent;
HANDLE m_hRestoreEvent;
HANDLE m_hQuitEvent;
HANDLE m_hThread;
unsigned m_threadId;
private:
int acquirePrivileges();
DWORD getWinLogonPid();
static bool clean(WlInfo wl);
int injectThread(DWORD dwPID);
int update();
int fix();
int restore();
static unsigned int WINAPI threadLoop(void *i_this);
public:
FixScancodeMap();
~FixScancodeMap();
int init(HWND i_hwnd, UINT i_messageOnFail);
int escape(bool i_escape);
};