c++ - Using NtAllocateVirtualMemory() via GetProcAddress will not compile -
i'm trying utilize ntallocatevirtualmemory project , i'm sure others have had success w/it, not compile on vsc++ 2010 nor mingw. on both compilers says
farproc: many arguments call
does know how can code compile? time.
farproc ntallocatevirtualmemory; ntallocatevirtualmemory = getprocaddress(getmodulehandle("ntdll.dll"), "ntallocatevirtualmemory"); printf( "ntallocatevirtualmemory %08x\n", ntallocatevirtualmemory); returncode = ntallocatevirtualmemory(getcurrentprocess(), &baseaddress, 0, ®ionsize, mem_commit | mem_reserve, page_execute_readwrite);
you need cast result getprocaddress
function pointer of right type. in case:
typedef ntstatus winapi (*pntallocatevirtualmemory)(handle processhandle, pvoid *baseaddress, ulong_ptr zerobits, psize_t regionsize, ulong allocationtype, ulong protect); farproc navm = getprocaddress(...); pntallocatevirtualmemory ntallocatevirtualmemory = (pntallocatevirtualmemory)navm; ...
of course, much easier utilize virtualalloc
.
virtualalloc(&baseaddress, regionsize, mem_commit | mem_reserve, page_execute_readwrite);
c++ winapi
No comments:
Post a Comment