123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #include "precompile.h"
- #include <assert.h>
- #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");
- }
|