Rizin
unix-like reverse engineering framework and cli tools
winapi.c File Reference
#include <assert.h>
#include "uv.h"
#include "internal.h"

Go to the source code of this file.

Functions

void uv_winapi_init (void)
 

Variables

sRtlGetVersion pRtlGetVersion
 
sRtlNtStatusToDosError pRtlNtStatusToDosError
 
sNtDeviceIoControlFile pNtDeviceIoControlFile
 
sNtQueryInformationFile pNtQueryInformationFile
 
sNtSetInformationFile pNtSetInformationFile
 
sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile
 
sNtQueryDirectoryFile pNtQueryDirectoryFile
 
sNtQuerySystemInformation pNtQuerySystemInformation
 
sNtQueryInformationProcess pNtQueryInformationProcess
 
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx
 
sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification
 
sSetWinEventHook pSetWinEventHook
 

Function Documentation

◆ uv_winapi_init()

void uv_winapi_init ( void  )

Definition at line 49 of file winapi.c.

49  {
50  HMODULE ntdll_module;
51  HMODULE powrprof_module;
52  HMODULE user32_module;
53  HMODULE kernel32_module;
54 
55  ntdll_module = GetModuleHandleA("ntdll.dll");
56  if (ntdll_module == NULL) {
57  uv_fatal_error(GetLastError(), "GetModuleHandleA");
58  }
59 
60  pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module,
61  "RtlGetVersion");
62 
64  ntdll_module,
65  "RtlNtStatusToDosError");
67  uv_fatal_error(GetLastError(), "GetProcAddress");
68  }
69 
71  ntdll_module,
72  "NtDeviceIoControlFile");
74  uv_fatal_error(GetLastError(), "GetProcAddress");
75  }
76 
78  ntdll_module,
79  "NtQueryInformationFile");
81  uv_fatal_error(GetLastError(), "GetProcAddress");
82  }
83 
85  ntdll_module,
86  "NtSetInformationFile");
87  if (pNtSetInformationFile == NULL) {
88  uv_fatal_error(GetLastError(), "GetProcAddress");
89  }
90 
92  GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile");
94  uv_fatal_error(GetLastError(), "GetProcAddress");
95  }
96 
98  GetProcAddress(ntdll_module, "NtQueryDirectoryFile");
100  uv_fatal_error(GetLastError(), "GetProcAddress");
101  }
102 
104  ntdll_module,
105  "NtQuerySystemInformation");
107  uv_fatal_error(GetLastError(), "GetProcAddress");
108  }
109 
111  ntdll_module,
112  "NtQueryInformationProcess");
114  uv_fatal_error(GetLastError(), "GetProcAddress");
115  }
116 
117  kernel32_module = GetModuleHandleA("kernel32.dll");
118  if (kernel32_module == NULL) {
119  uv_fatal_error(GetLastError(), "GetModuleHandleA");
120  }
121 
123  kernel32_module,
124  "GetQueuedCompletionStatusEx");
125 
126  powrprof_module = LoadLibraryA("powrprof.dll");
127  if (powrprof_module != NULL) {
129  GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification");
130  }
131 
132  user32_module = LoadLibraryA("user32.dll");
133  if (user32_module != NULL) {
135  GetProcAddress(user32_module, "SetWinEventHook");
136  }
137 }
#define NULL
Definition: cris-opc.c:27
void uv_fatal_error(const int errorno, const char *syscall)
Definition: error.c:35
sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile
Definition: winapi.c:34
sNtQueryDirectoryFile pNtQueryDirectoryFile
Definition: winapi.c:35
sNtQueryInformationProcess pNtQueryInformationProcess
Definition: winapi.c:37
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx
Definition: winapi.c:40
sNtDeviceIoControlFile pNtDeviceIoControlFile
Definition: winapi.c:31
sRtlGetVersion pRtlGetVersion
Definition: winapi.c:29
sNtSetInformationFile pNtSetInformationFile
Definition: winapi.c:33
sNtQueryInformationFile pNtQueryInformationFile
Definition: winapi.c:32
sSetWinEventHook pSetWinEventHook
Definition: winapi.c:46
sRtlNtStatusToDosError pRtlNtStatusToDosError
Definition: winapi.c:30
sNtQuerySystemInformation pNtQuerySystemInformation
Definition: winapi.c:36
sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification
Definition: winapi.c:43
HWINEVENTHOOK(WINAPI * sSetWinEventHook)(UINT eventMin, UINT eventMax, HMODULE hmodWinEventProc, WINEVENTPROC lpfnWinEventProc, DWORD idProcess, DWORD idThread, UINT dwflags)
Definition: winapi.h:4721
BOOL(WINAPI * sGetQueuedCompletionStatusEx)(HANDLE CompletionPort, LPOVERLAPPED_ENTRY lpCompletionPortEntries, ULONG ulCount, PULONG ulNumEntriesRemoved, DWORD dwMilliseconds, BOOL fAlertable)
Definition: winapi.h:4670
NTSTATUS(NTAPI * sNtSetInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass)
Definition: winapi.h:4559
NTSTATUS(NTAPI * sRtlGetVersion)(PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: winapi.h:4534
NTSTATUS(NTAPI * sNtQueryInformationProcess)(HANDLE ProcessHandle, UINT ProcessInformationClass, PVOID ProcessInformation, ULONG Length, PULONG ReturnLength)
Definition: winapi.h:4593
ULONG(NTAPI * sRtlNtStatusToDosError)(NTSTATUS Status)
Definition: winapi.h:4537
NTSTATUS(NTAPI * sNtQueryInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass)
Definition: winapi.h:4552
DWORD(WINAPI * sPowerRegisterSuspendResumeNotification)(DWORD Flags, HANDLE Recipient, _PHPOWERNOTIFY RegistrationHandle)
Definition: winapi.h:4706
NTSTATUS(NTAPI * sNtQueryVolumeInformationFile)(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
Definition: winapi.h:4566
NTSTATUS(NTAPI * sNtQueryDirectoryFile)(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass, BOOLEAN ReturnSingleEntry, PUNICODE_STRING FileName, BOOLEAN RestartScan)
Definition: winapi.h:4579
NTSTATUS(NTAPI * sNtDeviceIoControlFile)(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG IoControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
Definition: winapi.h:4540
NTSTATUS(NTAPI * sNtQuerySystemInformation)(UINT SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength)
Definition: winapi.h:4573

References NULL, pGetQueuedCompletionStatusEx, pNtDeviceIoControlFile, pNtQueryDirectoryFile, pNtQueryInformationFile, pNtQueryInformationProcess, pNtQuerySystemInformation, pNtQueryVolumeInformationFile, pNtSetInformationFile, pPowerRegisterSuspendResumeNotification, pRtlGetVersion, pRtlNtStatusToDosError, pSetWinEventHook, and uv_fatal_error().

Referenced by uv_init().

Variable Documentation

◆ pGetQueuedCompletionStatusEx

sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx

Definition at line 40 of file winapi.c.

Referenced by uv__poll(), uv_run(), and uv_winapi_init().

◆ pNtDeviceIoControlFile

sNtDeviceIoControlFile pNtDeviceIoControlFile

◆ pNtQueryDirectoryFile

sNtQueryDirectoryFile pNtQueryDirectoryFile

Definition at line 35 of file winapi.c.

Referenced by fs__scandir(), and uv_winapi_init().

◆ pNtQueryInformationFile

◆ pNtQueryInformationProcess

sNtQueryInformationProcess pNtQueryInformationProcess

Definition at line 37 of file winapi.c.

Referenced by uv__tty_console_resize_message_loop_thread(), and uv_winapi_init().

◆ pNtQuerySystemInformation

sNtQuerySystemInformation pNtQuerySystemInformation

Definition at line 36 of file winapi.c.

Referenced by uv_cpu_info(), and uv_winapi_init().

◆ pNtQueryVolumeInformationFile

sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile

Definition at line 34 of file winapi.c.

Referenced by fs__stat_handle(), and uv_winapi_init().

◆ pNtSetInformationFile

sNtSetInformationFile pNtSetInformationFile

Definition at line 33 of file winapi.c.

Referenced by fs__fchmod(), fs__ftruncate(), fs__unlink(), and uv_winapi_init().

◆ pPowerRegisterSuspendResumeNotification

sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification

Definition at line 43 of file winapi.c.

Referenced by uv__register_system_resume_callback(), and uv_winapi_init().

◆ pRtlGetVersion

sRtlGetVersion pRtlGetVersion

Definition at line 29 of file winapi.c.

Referenced by uv__is_fast_loopback_fail_supported(), uv_os_uname(), and uv_winapi_init().

◆ pRtlNtStatusToDosError

◆ pSetWinEventHook

sSetWinEventHook pSetWinEventHook

Definition at line 46 of file winapi.c.

Referenced by uv__tty_console_resize_message_loop_thread(), and uv_winapi_init().