win: fix -Wcast-function-type warnings in winapi.c (#4834)
This commit is contained in:
parent
9424da3e46
commit
6f3199dd3f
@ -55,90 +55,106 @@ void uv__winapi_init(void) {
|
|||||||
HMODULE ws2_32_module;
|
HMODULE ws2_32_module;
|
||||||
HMODULE api_win_core_file_module;
|
HMODULE api_win_core_file_module;
|
||||||
|
|
||||||
|
union {
|
||||||
|
FARPROC proc;
|
||||||
|
sRtlGetVersion pRtlGetVersion;
|
||||||
|
sRtlNtStatusToDosError pRtlNtStatusToDosError;
|
||||||
|
sNtDeviceIoControlFile pNtDeviceIoControlFile;
|
||||||
|
sNtQueryInformationFile pNtQueryInformationFile;
|
||||||
|
sNtSetInformationFile pNtSetInformationFile;
|
||||||
|
sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile;
|
||||||
|
sNtQueryDirectoryFile pNtQueryDirectoryFile;
|
||||||
|
sNtQuerySystemInformation pNtQuerySystemInformation;
|
||||||
|
sNtQueryInformationProcess pNtQueryInformationProcess;
|
||||||
|
sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification;
|
||||||
|
sSetWinEventHook pSetWinEventHook;
|
||||||
|
uv_sGetHostNameW pGetHostNameW;
|
||||||
|
sGetFileInformationByName pGetFileInformationByName;
|
||||||
|
} u;
|
||||||
|
|
||||||
ntdll_module = GetModuleHandleW(L"ntdll.dll");
|
ntdll_module = GetModuleHandleW(L"ntdll.dll");
|
||||||
if (ntdll_module == NULL) {
|
if (ntdll_module == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetModuleHandleW");
|
uv_fatal_error(GetLastError(), "GetModuleHandleW");
|
||||||
}
|
}
|
||||||
|
|
||||||
pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module,
|
u.proc = GetProcAddress(ntdll_module, "RtlGetVersion");
|
||||||
"RtlGetVersion");
|
pRtlGetVersion = u.pRtlGetVersion;
|
||||||
|
|
||||||
pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress(
|
u.proc = GetProcAddress(ntdll_module, "RtlNtStatusToDosError");
|
||||||
ntdll_module,
|
pRtlNtStatusToDosError = u.pRtlNtStatusToDosError;
|
||||||
"RtlNtStatusToDosError");
|
|
||||||
if (pRtlNtStatusToDosError == NULL) {
|
if (pRtlNtStatusToDosError == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtDeviceIoControlFile = (sNtDeviceIoControlFile) GetProcAddress(
|
u.proc = GetProcAddress(ntdll_module, "NtDeviceIoControlFile");
|
||||||
ntdll_module,
|
pNtDeviceIoControlFile = u.pNtDeviceIoControlFile;
|
||||||
"NtDeviceIoControlFile");
|
|
||||||
if (pNtDeviceIoControlFile == NULL) {
|
if (pNtDeviceIoControlFile == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress(
|
u.proc = GetProcAddress(ntdll_module, "NtQueryInformationFile");
|
||||||
ntdll_module,
|
pNtQueryInformationFile = u.pNtQueryInformationFile;
|
||||||
"NtQueryInformationFile");
|
|
||||||
if (pNtQueryInformationFile == NULL) {
|
if (pNtQueryInformationFile == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress(
|
u.proc = GetProcAddress(ntdll_module, "NtSetInformationFile");
|
||||||
ntdll_module,
|
pNtSetInformationFile = u.pNtSetInformationFile;
|
||||||
"NtSetInformationFile");
|
|
||||||
if (pNtSetInformationFile == NULL) {
|
if (pNtSetInformationFile == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtQueryVolumeInformationFile = (sNtQueryVolumeInformationFile)
|
u.proc = GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile");
|
||||||
GetProcAddress(ntdll_module, "NtQueryVolumeInformationFile");
|
pNtQueryVolumeInformationFile = u.pNtQueryVolumeInformationFile;
|
||||||
if (pNtQueryVolumeInformationFile == NULL) {
|
if (pNtQueryVolumeInformationFile == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtQueryDirectoryFile = (sNtQueryDirectoryFile)
|
u.proc = GetProcAddress(ntdll_module, "NtQueryDirectoryFile");
|
||||||
GetProcAddress(ntdll_module, "NtQueryDirectoryFile");
|
pNtQueryDirectoryFile = u.pNtQueryDirectoryFile;
|
||||||
if (pNtQueryDirectoryFile == NULL) {
|
if (pNtQueryDirectoryFile == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress(
|
u.proc = GetProcAddress(ntdll_module, "NtQuerySystemInformation");
|
||||||
ntdll_module,
|
pNtQuerySystemInformation = u.pNtQuerySystemInformation;
|
||||||
"NtQuerySystemInformation");
|
|
||||||
if (pNtQuerySystemInformation == NULL) {
|
if (pNtQuerySystemInformation == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
pNtQueryInformationProcess = (sNtQueryInformationProcess) GetProcAddress(
|
u.proc = GetProcAddress(ntdll_module, "NtQueryInformationProcess");
|
||||||
ntdll_module,
|
pNtQueryInformationProcess = u.pNtQueryInformationProcess;
|
||||||
"NtQueryInformationProcess");
|
|
||||||
if (pNtQueryInformationProcess == NULL) {
|
if (pNtQueryInformationProcess == NULL) {
|
||||||
uv_fatal_error(GetLastError(), "GetProcAddress");
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
||||||
}
|
}
|
||||||
|
|
||||||
powrprof_module = LoadLibraryExA("powrprof.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
powrprof_module = LoadLibraryExA("powrprof.dll",
|
||||||
|
NULL,
|
||||||
|
LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||||
if (powrprof_module != NULL) {
|
if (powrprof_module != NULL) {
|
||||||
pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification)
|
u.proc = GetProcAddress(powrprof_module,
|
||||||
GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification");
|
"PowerRegisterSuspendResumeNotification");
|
||||||
|
pPowerRegisterSuspendResumeNotification =
|
||||||
|
u.pPowerRegisterSuspendResumeNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
user32_module = GetModuleHandleW(L"user32.dll");
|
user32_module = GetModuleHandleW(L"user32.dll");
|
||||||
if (user32_module != NULL) {
|
if (user32_module != NULL) {
|
||||||
pSetWinEventHook = (sSetWinEventHook)
|
u.proc = GetProcAddress(user32_module, "SetWinEventHook");
|
||||||
GetProcAddress(user32_module, "SetWinEventHook");
|
pSetWinEventHook = u.pSetWinEventHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws2_32_module = GetModuleHandleW(L"ws2_32.dll");
|
ws2_32_module = GetModuleHandleW(L"ws2_32.dll");
|
||||||
if (ws2_32_module != NULL) {
|
if (ws2_32_module != NULL) {
|
||||||
pGetHostNameW = (uv_sGetHostNameW) GetProcAddress(
|
u.proc = GetProcAddress(ws2_32_module, "GetHostNameW");
|
||||||
ws2_32_module,
|
pGetHostNameW = u.pGetHostNameW;
|
||||||
"GetHostNameW");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api_win_core_file_module = GetModuleHandleW(L"api-ms-win-core-file-l2-1-4.dll");
|
api_win_core_file_module =
|
||||||
|
GetModuleHandleW(L"api-ms-win-core-file-l2-1-4.dll");
|
||||||
if (api_win_core_file_module != NULL) {
|
if (api_win_core_file_module != NULL) {
|
||||||
pGetFileInformationByName = (sGetFileInformationByName)GetProcAddress(
|
u.proc = GetProcAddress(api_win_core_file_module,
|
||||||
api_win_core_file_module, "GetFileInformationByName");
|
"GetFileInformationByName");
|
||||||
|
pGetFileInformationByName = u.pGetFileInformationByName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user