File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments