blob: 38bd1010d3eaf50f8cad0f8bed523f7469b75023 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include "winwrap.h"
bool nn_windows_init(void)
{
// https://learn.microsoft.com/en-us/windows/win32/api/objbase/ne-objbase-coinit
//CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY | COINIT_DISABLE_OLE1DDE);
WSADATA wsa_data;
if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0) {
return false;
}
ULONG actual_resolution;
NTSTATUS(__stdcall *ZwSetTimerResolution)(IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution);
ZwSetTimerResolution = (NTSTATUS(__stdcall *)(IN ULONG, IN BOOLEAN, OUT PULONG))(void *)GetProcAddress(GetModuleHandleW(L"ntdll"), "ZwSetTimerResolution");
ZwSetTimerResolution(1, TRUE, &actual_resolution);
NtDelayExecution = (NTSTATUS(__stdcall *)(BOOL, PLARGE_INTEGER))(void *)GetProcAddress(GetModuleHandleW(L"ntdll"), "NtDelayExecution");
QueryPerformanceFrequency(&performance_frequency);
return true;
}
void nn_windows_close(void)
{
// Still crashes on Windows.
//WSACleanup();
//CoUninitialize();
}
LARGE_INTEGER performance_frequency;
|