Код: Выделить всё
EXTERN wNtAllocateVirtualMemory: DWORD
.CODE
NtAllocateVirtualMemory proc
mov r10, rcx
mov eax, wNtAllocateVirtualMemory
syscall
ret
NtAllocateVirtualMemory endp
END
Код: Выделить всё
#include
#include
DWORD wNtAllocateVirtualMemory;
typedef long NTSTATUS;
typedef NTSTATUS* PNTSTATUS;
extern "C" { NTSTATUS NtAllocateVirtualMemory(HANDLE ProcessHandle, PVOID BaseAddress, ULONG_PTR ZeroBits, PSIZE_T RegionSize, ULONG AllocationType, ULONG Protect); }
int main() {
PVOID allocBuffer = NULL;
SIZE_T buffSize = 0x1000;
HANDLE hNtdll = GetModuleHandleA("ntdll");
if (hNtdll == NULL) {
perror("Fail to get handle");
return 0;
}
PVOID pNtAllocateVirtualMemory = GetProcAddress((HMODULE) hNtdll, "NtAllocateVirtualMemory");
wNtAllocateVirtualMemory = *((char*)pNtAllocateVirtualMemory + 4);
NtAllocateVirtualMemory((HANDLE)-1, (PVOID*)&allocBuffer, (ULONG_PTR)0, &buffSize, (ULONG)(MEM_COMMIT | MEM_RESERVE), PAGE_EXECUTE_READWRITE);
}
Код: Выделить всё
Error LNK2019 unresolved external symbol wNtAllocateVirtualMemory referenced in function NtAllocateVirtualMemory syscall_direct
temp.obj 1
Подробнее здесь: https://stackoverflow.com/questions/786 ... ompiling-c