#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;