-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdllmain.cpp
More file actions
75 lines (63 loc) · 1.87 KB
/
dllmain.cpp
File metadata and controls
75 lines (63 loc) · 1.87 KB
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
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include "Easyhook.h"
HOOK_TRACE_INFO hHook = { nullptr };
BOOL WINAPI HookedGetCursorInfo(PCURSORINFO pci);
//n**** All your cursorinfo belong to us!
BOOL WINAPI HookedGetCursorInfo(PCURSORINFO pci) {
BOOL result = GetCursorInfo(pci);
if (result == true)
{
POINT nypt;
GetCursorPos(&nypt);
pci->ptScreenPos.x = nypt.x;
pci->ptScreenPos.y = nypt.y;
return true;
}
else return false;
}
void Setuphook() {
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
if (!hUser32) MessageBoxA(NULL, "No User32? hooked too early maybe", "Error", MB_OK);
void* target = GetProcAddress(hUser32, "GetCursorInfo");
if (!target) MessageBoxA(NULL, "GetcursorInfo not found", "Error", MB_OK);
// Install the hook
NTSTATUS result = LhInstallHook(
target,
HookedGetCursorInfo,
NULL,
&hHook
);
if (FAILED(result)) {
MessageBoxA(NULL, "Failed to install EasyHook", "Error", MB_OK);
return;
}
//Activating hook for current thread only
//If the threadId in the ACL is set to 0,
//then internally EasyHook uses GetCurrentThreadId()
ULONG ACLEntries[1] = { 0 };
result = LhSetInclusiveACL(ACLEntries, 1, &hHook);
if (FAILED(result)) {
MessageBoxA(NULL, "Failed to set ACL", "Error", MB_OK);
return;
}
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Setuphook();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
// LhUninstallHook(&hHook);
// LhWaitForPendingRemovals();
break;
}
return TRUE;
}