Merge pull request #758 from zhibog/master

Fixed getting windows version. The former function is no longer worki…
This commit is contained in:
gingerBill
2020-10-26 11:36:09 +00:00
committed by GitHub
3 changed files with 37 additions and 29 deletions
+16 -17
View File
@@ -160,40 +160,39 @@ _alloc_command_line_arguments :: proc() -> []string {
return arg_list; return arg_list;
} }
get_windows_version_ansi :: proc() -> win32.OSVERSIONINFOEXW { get_windows_version_w :: proc() -> win32.OSVERSIONINFOEXW {
osvi : win32.OSVERSIONINFOEXW; osvi : win32.OSVERSIONINFOEXW;
osvi.os_version_info_size = size_of(win32.OSVERSIONINFOEXW); osvi.dwOSVersionInfoSize = size_of(win32.OSVERSIONINFOEXW);
win32.GetVersionExW(&osvi); win32.RtlGetVersion(&osvi);
return osvi; return osvi;
} }
is_windows_xp :: proc() -> bool { is_windows_xp :: proc() -> bool {
osvi := get_windows_version_ansi(); osvi := get_windows_version_w();
return (osvi.major_version == 5 && osvi.minor_version == 1); return (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1);
} }
is_windows_vista :: proc() -> bool { is_windows_vista :: proc() -> bool {
osvi := get_windows_version_ansi(); osvi := get_windows_version_w();
return (osvi.major_version == 6 && osvi.minor_version == 0); return (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0);
} }
is_windows_7 :: proc() -> bool { is_windows_7 :: proc() -> bool {
osvi := get_windows_version_ansi(); osvi := get_windows_version_w();
return (osvi.major_version == 6 && osvi.minor_version == 1); return (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1);
} }
is_windows_8 :: proc() -> bool { is_windows_8 :: proc() -> bool {
osvi := get_windows_version_ansi(); osvi := get_windows_version_w();
return (osvi.major_version == 6 && osvi.minor_version == 2); return (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2);
} }
is_windows_8_1 :: proc() -> bool { is_windows_8_1 :: proc() -> bool {
osvi := get_windows_version_ansi(); osvi := get_windows_version_w();
return (osvi.major_version == 6 && osvi.minor_version == 3); return (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3);
} }
is_windows_10 :: proc() -> bool { is_windows_10 :: proc() -> bool {
osvi := get_windows_version_ansi(); osvi := get_windows_version_w();
return (osvi.major_version == 10 && osvi.minor_version == 0); return (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0);
} }
+8
View File
@@ -0,0 +1,8 @@
package sys_windows
foreign import ntdll_lib "system:ntdll.lib"
@(default_calling_convention="std")
foreign ntdll_lib {
RtlGetVersion :: proc(lpVersionInformation: ^OSVERSIONINFOEXW) -> NTSTATUS ---;
}
+13 -12
View File
@@ -36,6 +36,7 @@ ULONG_PTR :: uint;
DWORD_PTR :: ULONG_PTR; DWORD_PTR :: ULONG_PTR;
ULONG :: c_ulong; ULONG :: c_ulong;
UCHAR :: BYTE; UCHAR :: BYTE;
NTSTATUS :: c.long;
PDWORD_PTR :: ^DWORD_PTR; PDWORD_PTR :: ^DWORD_PTR;
ATOM :: distinct WORD; ATOM :: distinct WORD;
@@ -721,15 +722,15 @@ SYSTEM_INFO :: struct {
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfoexw // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfoexw
OSVERSIONINFOEXW :: struct { OSVERSIONINFOEXW :: struct {
os_version_info_size: ULONG, dwOSVersionInfoSize: ULONG,
major_version: ULONG, dwMajorVersion: ULONG,
minor_version: ULONG, dwMinorVersion: ULONG,
build_number: ULONG, dwBuildNumber: ULONG,
platform_id : ULONG, dwPlatformId: ULONG,
service_pack_string: [128]WCHAR, szCSDVersion: [128]WCHAR,
service_pack_major: USHORT, wServicePackMajor: USHORT,
service_pack_minor: USHORT, wServicePackMinor: USHORT,
suite_mask: USHORT, wSuiteMask: USHORT,
product_type: UCHAR, wProductType: UCHAR,
reserved: UCHAR, wReserved: UCHAR,
} };