On Saturday, 24 March 2012 at 19:11:38 UTC, maarten van damme wrote:
hi,
I'm trying to call NtUnmapViewOfSection from ntdll.dll. According to the
msdn docs it should look like

NTSTATUS NtUnmapViewOfSection(
  __in      HANDLE ProcessHandle,
  __in_opt  PVOID BaseAddress
);


I tried to call it by simply declaring

extern(Windows) uint NtUnmapViewOfSection(HANDLE hProcess,PVOID baseAddress);

But now I get

 Error 42: Symbol Undefined _NtUnmapViewOfSection@8


I've also tried using GetProcAddress

cast(uint function(HANDLE hProcess,PVOID
address))GetProcAddress(Runtime.loadLibrary("ntdll.dll"),
"NtUnmapViewOfSection")

but when I looked at GetLastError I get error 127 (specified procedure
could not be found) and the function doesn't work.


It's likely I'm missing something easy here, I just can't figure out what it is.

Someone knows what it is?

Actually, Runtime.loadLibrary should return the function pointer correctly.

Your call to GetLastError() is returning 127 because Runtime.loadLibrary itself calls GetProcAddress to see if it contains a GC-related function (which will fail if it's not a D DLL).



Maarten


Reply via email to