Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: retrieve NtQuerySystemInformation at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex authored and piscisaureus committed Jun 2, 2012
1 parent 120d997 commit 87f3530
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/win/winapi.c
Expand Up @@ -29,6 +29,7 @@ sRtlNtStatusToDosError pRtlNtStatusToDosError;
sNtDeviceIoControlFile pNtDeviceIoControlFile;
sNtQueryInformationFile pNtQueryInformationFile;
sNtSetInformationFile pNtSetInformationFile;
sNtQuerySystemInformation pNtQuerySystemInformation;
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes;
sCreateSymbolicLinkW pCreateSymbolicLinkW;
Expand Down Expand Up @@ -79,6 +80,13 @@ void uv_winapi_init() {
uv_fatal_error(GetLastError(), "GetProcAddress");
}

pNtQuerySystemInformation = (sNtQuerySystemInformation) GetProcAddress(
ntdll_module,
"NtQuerySystemInformation");
if (pNtQuerySystemInformation == NULL) {
uv_fatal_error(GetLastError(), "GetProcAddress");
}

kernel32_module = GetModuleHandleA("kernel32.dll");
if (kernel32_module == NULL) {
uv_fatal_error(GetLastError(), "GetModuleHandleA");
Expand Down
20 changes: 20 additions & 0 deletions src/win/winapi.h
Expand Up @@ -4202,6 +4202,19 @@ typedef enum _FILE_INFORMATION_CLASS {
FileMaximumInformation
} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;

typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
LARGE_INTEGER IdleTime;
LARGE_INTEGER KernelTime;
LARGE_INTEGER UserTime;
LARGE_INTEGER DpcTime;
LARGE_INTEGER InterruptTime;
ULONG InterruptCount;
} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;

#ifndef SystemProcessorPerformanceInformation
# define SystemProcessorPerformanceInformation 8
#endif

#ifndef DEVICE_TYPE
# define DEVICE_TYPE DWORD
#endif
Expand Down Expand Up @@ -4318,6 +4331,12 @@ typedef NTSTATUS (NTAPI *sNtSetInformationFile)
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass);

typedef NTSTATUS (NTAPI *sNtQuerySystemInformation)
(UINT SystemInformationClass,
PVOID SystemInformation,
ULONG SystemInformationLength,
PULONG ReturnLength);


/*
* Kernel32 headers
Expand Down Expand Up @@ -4405,6 +4424,7 @@ extern sRtlNtStatusToDosError pRtlNtStatusToDosError;
extern sNtDeviceIoControlFile pNtDeviceIoControlFile;
extern sNtQueryInformationFile pNtQueryInformationFile;
extern sNtSetInformationFile pNtSetInformationFile;
extern sNtQuerySystemInformation pNtQuerySystemInformation;


/* Kernel32 function pointers */
Expand Down

0 comments on commit 87f3530

Please sign in to comment.