#include "precompile.h" #include #include "internal.h" /* Ntdll function pointers */ sRtlGetVersion pRtlGetVersion; sRtlNtStatusToDosError pRtlNtStatusToDosError; sNtDeviceIoControlFile pNtDeviceIoControlFile; sNtQueryInformationFile pNtQueryInformationFile; sNtSetInformationFile pNtSetInformationFile; sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile; sNtQueryDirectoryFile pNtQueryDirectoryFile; sNtQuerySystemInformation pNtQuerySystemInformation; sNtQueryInformationProcess pNtQueryInformationProcess; /* Advapi32 function pointers */ sRtlGenRandom pRtlGenRandom; /* Kernel32 function pointers */ sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; /* Powrprof.dll function pointer */ sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; /* User32.dll function pointer */ sSetWinEventHook pSetWinEventHook; void toolkit_winapi_init(void) { HMODULE ntdll_module; HMODULE powrprof_module; HMODULE user32_module; HMODULE kernel32_module; HMODULE advapi32_module; ntdll_module = GetModuleHandleA("ntdll.dll"); if (ntdll_module == NULL) { toolkit_fatal_error(GetLastError(), "GetModuleHandleA"); } pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module, "RtlGetVersion"); pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress( ntdll_module, "RtlNtStatusToDosError"); if (pRtlNtStatusToDosError == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtDeviceIoControlFile = (sNtDeviceIoControlFile) GetProcAddress( ntdll_module, "NtDeviceIoControlFile"); if (pNtDeviceIoControlFile == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress( ntdll_module, "NtQueryInformationFile"); if (pNtQueryInformationFile == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress( ntdll_module, "NtSetInformationFile"); if (pNtSetInformationFile == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryVolumeInformationFile = (sNtQueryVolumeInformationFile) GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile"); if (pNtQueryVolumeInformationFile == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryDirectoryFile = (sNtQueryDirectoryFile) GetProcAddress(ntdll_module, "NtQueryDirectoryFile"); if (pNtQueryVolumeInformationFile == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress( ntdll_module, "NtQuerySystemInformation"); if (pNtQuerySystemInformation == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } pNtQueryInformationProcess = (sNtQueryInformationProcess) GetProcAddress( ntdll_module, "NtQueryInformationProcess"); if (pNtQueryInformationProcess == NULL) { toolkit_fatal_error(GetLastError(), "GetProcAddress"); } kernel32_module = GetModuleHandleA("kernel32.dll"); if (kernel32_module == NULL) { toolkit_fatal_error(GetLastError(), "GetModuleHandleA"); } pGetQueuedCompletionStatusEx = (sGetQueuedCompletionStatusEx) GetProcAddress( kernel32_module, "GetQueuedCompletionStatusEx"); powrprof_module = LoadLibraryA("powrprof.dll"); if (powrprof_module != NULL) { pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification) GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); } user32_module = LoadLibraryA("user32.dll"); if (user32_module != NULL) { pSetWinEventHook = (sSetWinEventHook) GetProcAddress(user32_module, "SetWinEventHook"); } advapi32_module = GetModuleHandleA("advapi32.dll"); if (advapi32_module == NULL) { toolkit_fatal_error(GetLastError(), "GetModuleHandleA"); } pRtlGenRandom = (sRtlGenRandom) GetProcAddress(advapi32_module, "SystemFunction036"); }