xref: /aosp_15_r20/external/lzma/CPP/Windows/NtCheck.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // Windows/NtCheck.h
2 
3 #ifndef ZIP7_INC_WINDOWS_NT_CHECK_H
4 #define ZIP7_INC_WINDOWS_NT_CHECK_H
5 
6 #ifdef _WIN32
7 
8 #include "../Common/MyWindows.h"
9 
10 #if !defined(_WIN64) && !defined(UNDER_CE)
11 
12 #if defined(_MSC_VER) && _MSC_VER >= 1900
13 #pragma warning(push)
14 // GetVersionExW was declared deprecated
15 #pragma warning(disable : 4996)
16 #endif
IsItWindowsNT()17 static inline bool IsItWindowsNT()
18 {
19   OSVERSIONINFO vi;
20   vi.dwOSVersionInfoSize = sizeof(vi);
21   return (::GetVersionEx(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_NT);
22 }
23 #if defined(_MSC_VER) && _MSC_VER >= 1900
24 #pragma warning(pop)
25 #endif
26 
27 #endif
28 
29 #ifndef _UNICODE
30     extern
31     bool g_IsNT;
32   #if defined(_WIN64) || defined(UNDER_CE)
33     bool g_IsNT = true;
34     #define SET_IS_NT
35   #else
36     bool g_IsNT = false;
37     #define SET_IS_NT g_IsNT = IsItWindowsNT();
38   #endif
39   #define NT_CHECK_ACTION
40   // #define NT_CHECK_ACTION { NT_CHECK_FAIL_ACTION }
41 #else
42   #if !defined(_WIN64) && !defined(UNDER_CE)
43     #define NT_CHECK_ACTION if (!IsItWindowsNT()) { NT_CHECK_FAIL_ACTION }
44   #else
45     #define NT_CHECK_ACTION
46   #endif
47   #define SET_IS_NT
48 #endif
49 
50 #define NT_CHECK  NT_CHECK_ACTION SET_IS_NT
51 
52 #else
53 
54 #define NT_CHECK
55 
56 #endif
57 
58 #endif
59