Question

I get functions from ntdll.dll dynamically, using GetProcAddress winapi function like this:

HMODULE ntdllh = LoadLibrary(L"ntdll.dll");
unsigned char* ptrToNtLoadDriver 
                        = (unsigned char*)GetProcAddress(ntdllh, "NtLoadDriver");

How can I call NtLoadDriver function via ptrToNtLoadDriver ? I thought of something like this: ((NTSTATUS NtLoadDriver(PUNICODE_STRING driverServiceName))ptrToNtLoadDriver)(fooString)

Was it helpful?

Solution

  1. do typedef "X" for function type you want to call (example: "typedef returntype (*X)(argtype);")
  2. change "unsigned char* ptrToNtLoadDriver" to "X ptrToNtLoadDriver"
  3. call function as "ptrToNtLoadDriver(argsHere)"

OTHER TIPS

((NTSTATUS (WINAPI*)(PUNICODE_STRING))ptrToNtLoadDriver)(fooStrin);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top