@@ -27,25 +27,27 @@ bool load_payload(LPCTSTR pe_path)
27
27
*/
28
28
size_t bufsize = 0 ;
29
29
BYTE* buf = peconv::load_file (pe_path, bufsize);
30
- if (buf) {
31
- // if the file is NOT dropped on the disk, you can load it directly from a memory buffer:
32
- g_Payload = peconv::load_pe_executable (buf, bufsize, g_PayloadSize);
30
+ if (!buf) {
31
+ return false ;
32
+ }
33
+ // if the file is NOT dropped on the disk, you can load it directly from a memory buffer:
34
+ g_Payload = peconv::load_pe_executable (buf, bufsize, g_PayloadSize);
33
35
34
- // if the loaded PE needs to access resources, you may need to connect it to the PEB:
35
- peconv::set_main_module_in_peb ((HMODULE)g_Payload);
36
+ // at this point we can free the buffer with the raw payload:
37
+ peconv::free_file (buf); buf = nullptr ;
38
+
39
+ #endif
40
+ if (!g_Payload) {
41
+ return false ;
42
+ }
36
43
37
- // load delayed imports (if present):
38
- const ULONGLONG loadBase = (ULONGLONG)g_Payload;
39
- peconv::load_delayed_imports (g_Payload, loadBase);
44
+ // if the loaded PE needs to access resources, you may need to connect it to the PEB:
45
+ peconv::set_main_module_in_peb ((HMODULE)g_Payload);
40
46
41
- // at this point we can free the buffer with the raw payload:
42
- peconv::free_file (buf); buf = nullptr ;
47
+ // load delayed imports (if present):
48
+ const ULONGLONG loadBase = (ULONGLONG)g_Payload;
49
+ peconv::load_delayed_imports (g_Payload, loadBase);
43
50
44
- if (!g_Payload) {
45
- return false ;
46
- }
47
- }
48
- #endif
49
51
return true ;
50
52
}
51
53
0 commit comments