Skip to content

Commit 65b1772

Browse files
committed
[BUGFIX] Fixed building for 32-bit
1 parent c8356f5 commit 65b1772

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

run_pe/patch_ntdll.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#include "patch_ntdll.h"
22
#include <peconv.h>
33

4-
bool apply_ntdll_patch(HANDLE hProcess, LPVOID module_ptr)
4+
bool apply_ntdll_patch64(HANDLE hProcess, LPVOID module_ptr)
55
{
6+
#ifndef _WIN64
7+
return false;
8+
#else
69
HMODULE hNtdll = GetModuleHandleA("ntdll");
710
if (!hNtdll) return false; // should never happen
811

@@ -27,7 +30,7 @@ bool apply_ntdll_patch(HANDLE hProcess, LPVOID module_ptr)
2730
if (!ReadProcessMemory(hProcess, (LPVOID)stub_ptr, stub_buffer_orig, stub_size, &out_bytes) || out_bytes != stub_size) {
2831
return false;
2932
}
30-
const BYTE nop_pattern[sizeof(LPVOID)] = {0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00};
33+
const BYTE nop_pattern[] = {0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00};
3134
if (::memcmp(stub_buffer_orig, nop_pattern, sizeof(nop_pattern)) != 0) {
3235
return false;
3336
}
@@ -91,4 +94,5 @@ bool apply_ntdll_patch(HANDLE hProcess, LPVOID module_ptr)
9194
return false;
9295
}
9396
return true;
97+
#endif
9498
}

run_pe/patch_ntdll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
#include <windows.h>
44

5-
bool apply_ntdll_patch(HANDLE hProcess, LPVOID module_ptr);
5+
bool apply_ntdll_patch64(HANDLE hProcess, LPVOID module_ptr);

run_pe/run_pe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool _run_pe(BYTE *loaded_pe, size_t payloadImageSize, PROCESS_INFORMATION &pi,
231231
std::cerr << "Redirecting failed!\n";
232232
return false;
233233
}
234-
if (!is32bit && g_PatchRequired && !apply_ntdll_patch(pi.hProcess, remoteBase)) {
234+
if (!is32bit && g_PatchRequired && !apply_ntdll_patch64(pi.hProcess, remoteBase)) {
235235
std::cout << "ERROR: failed to apply the required patch on NTDLL\n";
236236
}
237237
std::cout << "Resuming the process: " << std::dec << pi.dwProcessId << std::endl;

0 commit comments

Comments
 (0)