Skip to content

Commit b575f52

Browse files
authored
[FEATURE] Added a demo case: popup messages from the list
1 parent cebb8c4 commit b575f52

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

demos/popup_arr.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <Windows.h>
2+
#include "peb_lookup.h"
3+
4+
int main()
5+
{
6+
LPVOID base = get_module_by_name((const LPWSTR)L"kernel32.dll");
7+
if (!base) {
8+
return 1;
9+
}
10+
11+
LPVOID load_lib = get_func_by_name((HMODULE)base, (LPSTR)"LoadLibraryA");
12+
if (!load_lib) {
13+
return 2;
14+
}
15+
LPVOID get_proc = get_func_by_name((HMODULE)base, (LPSTR)"GetProcAddress");
16+
if (!get_proc) {
17+
return 3;
18+
}
19+
HMODULE(WINAPI * _LoadLibraryA)(LPCSTR lpLibFileName) = (HMODULE(WINAPI*)(LPCSTR))load_lib;
20+
FARPROC(WINAPI * _GetProcAddress)(HMODULE hModule, LPCSTR lpProcName)
21+
= (FARPROC(WINAPI*)(HMODULE, LPCSTR)) get_proc;
22+
23+
LPVOID u32_dll = _LoadLibraryA("user32.dll");
24+
25+
int (WINAPI * _MessageBoxW)(
26+
_In_opt_ HWND hWnd,
27+
_In_opt_ LPCWSTR lpText,
28+
_In_opt_ LPCWSTR lpCaption,
29+
_In_ UINT uType) = (int (WINAPI*)(
30+
_In_opt_ HWND,
31+
_In_opt_ LPCWSTR,
32+
_In_opt_ LPCWSTR,
33+
_In_ UINT)) _GetProcAddress((HMODULE)u32_dll, "MessageBoxW");
34+
35+
if (_MessageBoxW == NULL) return 4;
36+
37+
wchar_t* temp[] = { L"123", L"xxx", L"bbb" };
38+
for (size_t i = 0; i < _countof(temp); i++) {
39+
_MessageBoxW(0, temp[i], L"Demo", MB_OK);
40+
}
41+
return 0;
42+
}

0 commit comments

Comments
 (0)