This repository has been archived by the owner on Mar 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathhacks.c
112 lines (94 loc) · 2.15 KB
/
hacks.c
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "main.h"
#include "loader.h"
#include "sdl_keys.h"
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint)
{
lpPoint->x = (int)ddraw->cursor.x;
lpPoint->y = (int)ddraw->cursor.y;
return TRUE;
}
SHORT WINAPI fake_GetAsyncKeyState(int vKey)
{
if (vKey == VK_LBUTTON)
{
return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1) ? 0xF000 : 0;
}
if (vKey == VK_RBUTTON)
{
return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2) ? 0xF000 : 0;
}
if (vKey == VK_SHIFT)
{
return SDL_GetModState() & KMOD_SHIFT ? 0xF000 : 0;
}
if (vKey == VK_CONTROL)
{
return SDL_GetModState() & KMOD_CTRL ? 0xF000 : 0;
}
if (vKey == VK_MENU)
{
return SDL_GetModState() & KMOD_ALT ? 0xF000 : 0;
}
if (vKey == VK_CAPITAL)
{
return SDL_GetModState() & KMOD_CAPS ? 0xF000 : 0;
}
if (vKey == VK_NUMLOCK)
{
return SDL_GetModState() & KMOD_NUM ? 0xF000 : 0;
}
Uint8 *keys = SDL_GetKeyState(NULL);
SDLKey idx = VKey_to_SDLKey[vKey];
if (!idx)
{
printf("Warning: VKey %d (0x%02X) was not translated\n", vKey, vKey);
}
return keys[idx] ? 0xF000 : 0;
}
SHORT WINAPI fake_GetKeyState(int vKey)
{
return fake_GetAsyncKeyState(vKey);
}
BOOL WINAPI fake_ClipCursor(const RECT *lpRect)
{
return TRUE;
}
int WINAPI fake_ShowCursor(BOOL bShow)
{
return TRUE;
}
HCURSOR WINAPI fake_SetCursor(HCURSOR hCursor)
{
return NULL;
}
BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow)
{
ShowWindow(hWnd, SW_HIDE);
return 0;
}
struct iat_table hacks_iat[] =
{
{
"user32.dll",
{
{ 0, "GetCursorPos", fake_GetCursorPos },
{ 0, "ClipCursor", fake_ClipCursor },
{ 0, "ShowCursor", fake_ShowCursor },
{ 0, "SetCursor", fake_SetCursor } ,
{ 0, "GetAsyncKeyState", fake_GetAsyncKeyState } ,
{ 0, "ShowWindow", fake_ShowWindow} ,
{ 0, "GetKeyState", fake_GetKeyState } ,
{ 0, "", NULL }
}
},
{
"",
{
{ 0, "", NULL }
}
}
};
void hacks()
{
loader(&hacks_iat[0]);
}