2011-08-12 00:32:30 +00:00
|
|
|
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
#include "uv.h"
|
|
|
|
|
#include "../uv-common.h"
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sRtlNtStatusToDosError pRtlNtStatusToDosError;
|
|
|
|
|
sNtQueryInformationFile pNtQueryInformationFile;
|
2011-09-03 18:06:08 +00:00
|
|
|
sNtSetInformationFile pNtSetInformationFile;
|
2011-08-12 06:20:40 +00:00
|
|
|
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
|
2011-08-15 23:49:57 +00:00
|
|
|
sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes;
|
2011-09-03 23:31:35 +00:00
|
|
|
sCreateSymbolicLinkA pCreateSymbolicLinkA;
|
2011-08-12 00:32:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void uv_winapi_init() {
|
2011-08-12 06:20:40 +00:00
|
|
|
HMODULE ntdll_module;
|
|
|
|
|
HMODULE kernel32_module;
|
2011-08-12 00:32:30 +00:00
|
|
|
|
2011-08-12 06:20:40 +00:00
|
|
|
ntdll_module = GetModuleHandleA("ntdll.dll");
|
|
|
|
|
if (ntdll_module == NULL) {
|
2011-08-12 00:32:30 +00:00
|
|
|
uv_fatal_error(GetLastError(), "GetModuleHandleA");
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 06:20:40 +00:00
|
|
|
pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress(
|
|
|
|
|
ntdll_module,
|
2011-08-12 00:32:30 +00:00
|
|
|
"RtlNtStatusToDosError");
|
|
|
|
|
if (pRtlNtStatusToDosError == NULL) {
|
|
|
|
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 06:20:40 +00:00
|
|
|
pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress(
|
|
|
|
|
ntdll_module,
|
2011-08-12 00:32:30 +00:00
|
|
|
"NtQueryInformationFile");
|
|
|
|
|
if (pNtQueryInformationFile == NULL) {
|
|
|
|
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
|
|
|
|
}
|
2011-08-12 06:20:40 +00:00
|
|
|
|
2011-09-03 18:06:08 +00:00
|
|
|
pNtSetInformationFile = (sNtSetInformationFile) GetProcAddress(
|
|
|
|
|
ntdll_module,
|
|
|
|
|
"NtSetInformationFile");
|
|
|
|
|
if (pNtSetInformationFile == NULL) {
|
|
|
|
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-12 06:20:40 +00:00
|
|
|
kernel32_module = GetModuleHandleA("kernel32.dll");
|
|
|
|
|
if (kernel32_module == NULL) {
|
|
|
|
|
uv_fatal_error(GetLastError(), "GetModuleHandleA");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pGetQueuedCompletionStatusEx = (sGetQueuedCompletionStatusEx) GetProcAddress(
|
|
|
|
|
kernel32_module,
|
|
|
|
|
"GetQueuedCompletionStatusEx");
|
2011-08-15 23:49:57 +00:00
|
|
|
|
2011-08-18 21:24:00 +00:00
|
|
|
pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes)
|
2011-08-15 23:49:57 +00:00
|
|
|
GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes");
|
2011-09-03 23:31:35 +00:00
|
|
|
|
|
|
|
|
pCreateSymbolicLinkA = (sCreateSymbolicLinkA)
|
|
|
|
|
GetProcAddress(kernel32_module, "CreateSymbolicLinkA");
|
2011-08-12 06:20:40 +00:00
|
|
|
}
|