New issue
Advanced search Search tips

Issue 1182 attachment: xxxClientLpkDrawTextEx.cpp (1.6 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
#include <Windows.h>
#include <cstdio>

VOID PrintHex(PBYTE Data, ULONG dwBytes) {
for (ULONG i = 0; i < dwBytes; i += 16) {
printf("%.8x: ", i);

for (ULONG j = 0; j < 16; j++) {
if (i + j < dwBytes) {
printf("%.2x ", Data[i + j]);
}
else {
printf("?? ");
}
}

for (ULONG j = 0; j < 16; j++) {
if (i + j < dwBytes && Data[i + j] >= 0x20 && Data[i + j] <= 0x7e) {
printf("%c", Data[i + j]);
}
else {
printf(".");
}
}

printf("\n");
}
}

PVOID *GetUser32DispatchTable() {
__asm{
mov eax, fs:30h
mov eax, [eax+0x2c]
}
}

BOOL HookUser32DispatchFunction(UINT Index, PVOID lpNewHandler) {
PVOID *DispatchTable = GetUser32DispatchTable();
DWORD OldProtect;

if (!VirtualProtect(DispatchTable, 0x1000, PAGE_READWRITE, &OldProtect)) {
printf("VirtualProtect#1 failed, %d\n", GetLastError());
return FALSE;
}

DispatchTable[Index] = lpNewHandler;

if (!VirtualProtect(DispatchTable, 0x1000, OldProtect, &OldProtect)) {
printf("VirtualProtect#2 failed, %d\n", GetLastError());
return FALSE;
}

return TRUE;
}

VOID ClientLpkDrawTextExHook(LPVOID Data) {
printf("----------\n");
PrintHex((PBYTE)Data, 0x98);
}

int main() {
if (!HookUser32DispatchFunction(69, ClientLpkDrawTextExHook)) {
return 1;
}

HWND hwnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, 0, 0);
DestroyWindow(hwnd);

return 0;
}