-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser32.cpp
More file actions
51 lines (45 loc) · 1.92 KB
/
user32.cpp
File metadata and controls
51 lines (45 loc) · 1.92 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
#include <efi.h>
#include <efilib.h>
#include "print.h"
typedef void* HWND;
typedef unsigned long DWORD;
typedef unsigned int UINT;
typedef long LONG;
typedef long LONG_PTR;
typedef const char* LPCSTR;
// Window stubs
HWND GetDesktopWindow() { printf("GetDesktopWindow called\n"); return (HWND)1; }
HWND GetActiveWindow() { printf("GetActiveWindow called\n"); return (HWND)1; }
HWND GetTopWindow(HWND) { printf("GetTopWindow called\n"); return (HWND)1; }
HWND GetWindow(HWND, UINT) { printf("GetWindow called\n"); return (HWND)1; }
LONG GetWindowLongA(HWND, int) { printf("GetWindowLongA called\n"); return 0; }
LONG_PTR GetWindowLongPtrA(HWND, int) { printf("GetWindowLongPtrA called\n"); return 0; }
void GetWindowThreadProcessId(HWND, DWORD*) { printf("GetWindowThreadProcessId called\n"); }
// MessageBox
int MessageBoxA(HWND, LPCSTR text, LPCSTR caption, UINT) {
printf("MessageBoxA called\n");
printf("[MessageBox] %s: %s\n", caption, text);
return 1;
}
extern int stricmp(const char *s1, const char *s2);
void* ResolveUser32(const char* functionName) {
if (stricmp(functionName, "GetDesktopWindow") == 0) {
return GetDesktopWindow;
} else if (stricmp(functionName, "GetActiveWindow") == 0) {
return GetActiveWindow;
} else if (stricmp(functionName, "GetTopWindow") == 0) {
return GetTopWindow;
} else if (stricmp(functionName, "GetWindow") == 0) {
return GetWindow;
} else if (stricmp(functionName, "GetWindowLongA") == 0) {
return GetWindowLongA;
} else if (stricmp(functionName, "GetWindowLongPtrA") == 0) {
return GetWindowLongPtrA;
} else if (stricmp(functionName, "GetWindowThreadProcessId") == 0) {
return GetWindowThreadProcessId;
} else if (stricmp(functionName, "MessageBoxA") == 0) {
return MessageBoxA;
}
printf("Unknown function: %s\n", functionName);
return NULL;
}