1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5
6#include "staticcontract.h"
7
8#ifndef WRAPPER_NO_CONTRACT
9#define WRAPPER_NO_CONTRACT ANNOTATION_WRAPPER
10#endif
11
12#ifndef LIMITED_METHOD_CONTRACT
13#define LIMITED_METHOD_CONTRACT ANNOTATION_FN_LEAF
14#endif
15
16//*****************************************************************************
17// Enum to track which version of the OS we are running
18// Note that NT5 (Win2k) is the minimum supported platform. Any code using
19// utilcode (which includes the CLR's execution engine) will fail to start
20// on a pre-Win2k platform. This is enforced by InitRunningOnVersionStatus.
21//
22// Note: The value is used for data mining from links clicked by user in shim dialog - see code:FWLinkTemplateFromTextID
23// Please do not modify existing values, adding new ones is fine.
24//*****************************************************************************
25typedef enum {
26 RUNNING_ON_STATUS_UNINITED = 0,
27 RUNNING_ON_WIN7 = 1,
28 RUNNING_ON_WIN8 = 2
29} RunningOnStatusEnum;
30
31extern RunningOnStatusEnum gRunningOnStatus;
32
33void InitRunningOnVersionStatus();
34
35#if defined(FEATURE_COMINTEROP) && !defined(FEATURE_CORESYSTEM)
36typedef enum
37{
38 WINRT_STATUS_UNINITED = 0,
39 WINRT_STATUS_UNSUPPORTED,
40 WINRT_STATUS_SUPPORTED
41}
42WinRTStatusEnum;
43
44extern WinRTStatusEnum gWinRTStatus;
45
46void InitWinRTStatus();
47#endif // FEATURE_COMINTEROP && !FEATURE_CORESYSTEM
48
49//*****************************************************************************
50// Returns true if you are running on Windows 8 or newer.
51//*****************************************************************************
52inline BOOL RunningOnWin8()
53{
54 WRAPPER_NO_CONTRACT;
55#if (!defined(_X86_) && !defined(_AMD64_)) || defined(CROSSGEN_COMPILE)
56 return TRUE;
57#else
58 if (gRunningOnStatus == RUNNING_ON_STATUS_UNINITED)
59 {
60 InitRunningOnVersionStatus();
61 }
62
63 return (gRunningOnStatus >= RUNNING_ON_WIN8) ? TRUE : FALSE;
64#endif
65}
66
67#ifdef FEATURE_COMINTEROP
68
69#ifdef FEATURE_CORESYSTEM
70
71inline BOOL WinRTSupported()
72{
73 return RunningOnWin8();
74}
75#else
76inline BOOL WinRTSupported()
77{
78 STATIC_CONTRACT_NOTHROW;
79 STATIC_CONTRACT_GC_NOTRIGGER;
80 STATIC_CONTRACT_CANNOT_TAKE_LOCK;
81 STATIC_CONTRACT_SO_TOLERANT;
82
83#ifdef CROSSGEN_COMPILE
84 return TRUE;
85#endif
86
87 if (gWinRTStatus == WINRT_STATUS_UNINITED)
88 {
89 InitWinRTStatus();
90 }
91
92 return gWinRTStatus == WINRT_STATUS_SUPPORTED;
93}
94#endif // FEATURE_CORESYSTEM
95
96#endif // FEATURE_COMINTEROP
97
98#ifdef _WIN64
99inline BOOL RunningInWow64()
100{
101 return FALSE;
102}
103#else
104BOOL RunningInWow64();
105#endif
106