1. Remove disable of C4996
authorRahul Kumar <rahku@microsoft.com>
Wed, 29 Mar 2017 22:31:29 +0000 (15:31 -0700)
committerRahul Kumar <rahku@microsoft.com>
Fri, 31 Mar 2017 21:32:33 +0000 (14:32 -0700)
2. delete some dead code
3. Remove implementation of GetOSVersion and hardcode OS version to be 0.0.0
4. Add implementation of IsWindows8OrAbove & IsWinrtSupported (donno why this was deleted earlier)
5. remove GetVersionEx from PAL

29 files changed:
src/classlibnative/bcltype/system.cpp
src/classlibnative/bcltype/system.h
src/inc/eventtracebase.h
src/inc/legacyactivationshim.h [deleted file]
src/inc/legacyactivationshimdelayload.h [deleted file]
src/inc/winwrap.h
src/jit/codegenlegacy.cpp
src/mscorlib/src/Microsoft/Win32/Win32Native.cs
src/mscorlib/src/System/Diagnostics/Eventing/EventSource.cs
src/mscorlib/src/System/Environment.cs
src/pal/inc/pal.h
src/pal/inc/palprivate.h
src/pal/src/CMakeLists.txt
src/pal/src/misc/version.cpp [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExA/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/test.cpp [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/testinfo.dat [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExW/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/CMakeLists.txt [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/test.cpp [deleted file]
src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/testinfo.dat [deleted file]
src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
src/utilcode/CMakeLists.txt
src/vm/ceemain.cpp
src/vm/domainfile.cpp
src/vm/ecalllist.h
src/vm/eventtrace.cpp
src/vm/jitinterface.cpp

index 2767d1e..c36d2e1 100644 (file)
@@ -609,8 +609,6 @@ FCIMPL2(VOID, SystemNative::FailFastWithException, StringObject* refMessageUNSAF
 }
 FCIMPLEND
 
-
-
 FCIMPL0(FC_BOOL_RET, SystemNative::IsServerGC)
 {
     FCALL_CONTRACT;
@@ -636,95 +634,6 @@ BOOL QCALLTYPE SystemNative::WinRTSupported()
 
 #endif // FEATURE_COMINTEROP
 
-// Helper method to retrieve OS Version based on the environment.
-BOOL GetOSVersionForEnvironment(LPOSVERSIONINFO lpVersionInformation)
-{
-#ifdef FEATURE_WINDOWSPHONE
-    // Return phone version information if it is available
-    if (!g_fGetPhoneVersionInitialized)
-    {
-        HMODULE hPhoneInfo = WszLoadLibrary(W("phoneinfo.dll"));
-        if(hPhoneInfo != NULL)
-            g_pfnGetPhoneVersion = (pfnGetPhoneVersion)GetProcAddress(hPhoneInfo, "GetPhoneVersion");
-
-        g_fGetPhoneVersionInitialized = true;
-    }
-
-    if (g_pfnGetPhoneVersion!= NULL)
-        return g_pfnGetPhoneVersion(lpVersionInformation);
-#endif // FEATURE_WINDOWSPHONE
-
-    return ::GetOSVersion(lpVersionInformation);
-}
-
-
-/*
- * SystemNative::GetOSVersion - Fcall corresponding to System.Environment.GetVersion
- * It calls clr!GetOSVersion to get the real OS version even when running in 
- * app compat. Calling kernel32!GetVersionEx() directly will be shimmed and will return the
- * fake OS version. In order to avoid this the call to getVersionEx is made via mscoree.dll.
- * Mscoree.dll resides in system32 dir and is never lied about OS version.
- */
-
-FCIMPL1(FC_BOOL_RET, SystemNative::GetOSVersion, OSVERSIONINFOObject *osVer)
-{
-    FCALL_CONTRACT;
-
-    OSVERSIONINFO ver;    
-    ver.dwOSVersionInfoSize = osVer->dwOSVersionInfoSize;
-
-    BOOL ret = GetOSVersionForEnvironment(&ver);
-
-    if(ret)
-    {
-        osVer->dwMajorVersion  = ver.dwMajorVersion;
-        osVer->dwMinorVersion = ver.dwMinorVersion;
-        osVer->dwBuildNumber  = ver.dwBuildNumber;
-        osVer->dwPlatformId = ver.dwPlatformId;
-
-        HELPER_METHOD_FRAME_BEGIN_RET_1(osVer);
-        SetObjectReference((OBJECTREF*)&(osVer->szCSDVersion), StringObject::NewString(ver.szCSDVersion), GetAppDomain());
-        HELPER_METHOD_FRAME_END();
-    }
-
-    FC_RETURN_BOOL(ret);
-}
-FCIMPLEND
-
-/*
- * SystemNative::GetOSVersionEx - Fcall implementation for System.Environment.GetVersionEx
- * Similar as above except this takes OSVERSIONINFOEX structure as input
- */
-
-FCIMPL1(FC_BOOL_RET, SystemNative::GetOSVersionEx, OSVERSIONINFOEXObject *osVer)
-{
-    FCALL_CONTRACT;
-
-    OSVERSIONINFOEX ver;
-    ver.dwOSVersionInfoSize = osVer->dwOSVersionInfoSize;
-
-    BOOL ret = GetOSVersionForEnvironment((OSVERSIONINFO *)&ver);
-
-    if(ret)
-    {
-        osVer->dwMajorVersion  = ver.dwMajorVersion;
-        osVer->dwMinorVersion = ver.dwMinorVersion;
-        osVer->dwBuildNumber  = ver.dwBuildNumber;
-        osVer->dwPlatformId = ver.dwPlatformId;
-        osVer->wServicePackMajor = ver.wServicePackMajor;
-        osVer->wServicePackMinor = ver.wServicePackMinor;
-        osVer->wSuiteMask = ver.wSuiteMask;
-        osVer->wProductType = ver.wProductType;
-        osVer->wReserved = ver.wReserved;
-
-        HELPER_METHOD_FRAME_BEGIN_RET_1(osVer);
-        SetObjectReference((OBJECTREF*)&(osVer->szCSDVersion), StringObject::NewString(ver.szCSDVersion), GetAppDomain());
-        HELPER_METHOD_FRAME_END();
-    }
-
-    FC_RETURN_BOOL(ret);
-}
-FCIMPLEND
 
 
 
index 1da1058..986c55b 100644 (file)
@@ -74,9 +74,6 @@ public:
     static FCDECL0(INT64, __GetSystemTimeAsFileTime);
     static FCDECL0(UINT32, GetCurrentProcessorNumber);
     static FCDECL0(UINT32, GetTickCount);
-    static FCDECL1(FC_BOOL_RET, GetOSVersion, OSVERSIONINFOObject *osVer);
-    static FCDECL1(FC_BOOL_RET, GetOSVersionEx, OSVERSIONINFOEXObject *osVer);
-
 
     static
     void QCALLTYPE Exit(INT32 exitcode);
index f773a7c..bd5ad1a 100644 (file)
@@ -154,11 +154,6 @@ public:
 
 class Object;
 #if !defined(FEATURE_PAL)
-/******************************/
-/* CLR ETW supported versions */
-/******************************/
-#define ETW_SUPPORTED_MAJORVER 5    // ETW is supported on win2k and above
-#define ETW_ENABLED_MAJORVER 6      // OS versions >= to this we enable ETW registration by default, since on XP and Windows 2003, registration is too slow.
 
 /***************************************/
 /* Tracing levels supported by CLR ETW */
@@ -201,11 +196,6 @@ struct ProfilingScanContext;
 #include <wmistr.h>
 #include <evntrace.h>
 #include <evntprov.h>
-#if !defined(DONOT_DEFINE_ETW_CALLBACK) && !defined(DACCESS_COMPILE)
-#define GetVersionEx(Version) (GetOSVersion((LPOSVERSIONINFOW)Version))
-#else
-#define GetVersionEx(Version) (WszGetVersionEx((LPOSVERSIONINFOW)Version))
-#endif // !DONOT_DEFINE_ETW_CALLBACK && !DACCESS_COMPILE
 #endif //!FEATURE_REDHAWK
 #endif //!defined(FEATURE_PAL)
 
diff --git a/src/inc/legacyactivationshim.h b/src/inc/legacyactivationshim.h
deleted file mode 100644 (file)
index 4d8eaa5..0000000
+++ /dev/null
@@ -1,1382 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-// LegacyActivationShim.h
-//
-// This file allows simple migration from .NET Runtime v2 Host Activation APIs
-// to the .NET Runtime v4 Host Activation APIs through simple shim functions.
-
-#ifndef __LEGACYACTIVATIONSHIM_H__
-#define __LEGACYACTIVATIONSHIM_H__
-
-#pragma warning(push)
-#pragma warning(disable:4127) // warning C4127: conditional expression is constant
-                              // caused by IfHrFailRet's while(0) code.
-#pragma warning(disable:4917) // a GUID can only be associated with a class, interface or namespace 
-#pragma warning(disable:4191) // 'reinterpret_cast' : unsafe conversion from 'FARPROC' to 'XXX' 
-
-#ifdef _MANAGED
-// We are compiling Managed C++, switch to native code then (and store current managed/native status on the stack)
-#pragma managed(push, off)
-#endif //_MANAGED
-
-#include "mscoree.h"
-#include "metahost.h"
-
-#include "wchar.h"
-
-#include "corerror.h"
-
-// To minimize how much we perturb sources that we are included in, we make sure that
-// all macros we define/redefine are restored at the end of the header.
-#pragma push_macro("IfHrFailRet")
-#pragma push_macro("IfHrFailRetFALSE")
-#pragma push_macro("IfHrFailRetVOID")
-
-// ---IfHrFailRet------------------------------------------------------------------------------------
-#undef IfHrFailRet
-#undef IfHrFailRetFALSE
-#undef IfHrFailRetVOID
-#define IfHrFailRet(EXPR) do { hr = (EXPR); if(FAILED(hr)) { return (hr); } } while (0)
-#define IfHrFailRetFALSE(EXPR) do { HRESULT _hr_ = (EXPR); if(FAILED(_hr_)) { return false; } } while (0)
-#define IfHrFailRetVOID(EXPR) do { HRESULT _hr_ = (EXPR); if(FAILED(_hr_)) { return; } } while (0)
-
-#include "legacyactivationshimutil.h"
-
-// Use of deprecated APIs within LegacyActivationShim namespace will result in C4996 that we will
-// disable for our own use.
-#pragma warning(push)
-#pragma warning(disable:4996)
-// ---LEGACYACTIVATONSHIM NAMESPACE----------------------------------------------------------------
-namespace LegacyActivationShim
-{
-    // ---HELPERS----------------------------------------------------------------------------------
-#define GET_CLRMETAHOST(x) \
-    ICLRMetaHost *x = NULL; \
-    IfHrFailRet(Util::GetCLRMetaHost(&x))
-
-#define GET_CLRMETAHOSTPOLICY(x) \
-    ICLRMetaHostPolicy*x = NULL; \
-    IfHrFailRet(Util::GetCLRMetaHostPolicy(&x))
-
-#define GET_CLRINFO(x) \
-    ICLRRuntimeInfo *x = NULL; \
-    IfHrFailRet(Util::GetCLRRuntimeInfo(&x))
-
-#define LEGACY_API_PASS_THROUGH_STATIC(_name, _ret_type, _ret_value, _sig, _args)       \
-    {                                                                                   \
-        hr = S_OK;                                                                      \
-        _ret_value = ::_name _args;                                                     \
-    }
-
-#define LEGACY_API_PASS_THROUGH_STATIC_VOIDRET(_name, _sig, _args)                      \
-    {                                                                                   \
-        ::_name _args;                                                                  \
-    }
-
-#define LEGACY_API_PASS_THROUGH_DELAYLOAD(_name, _ret_type, _ret_value, _sig, _args)    \
-    {                                                                                   \
-        typedef _ret_type __stdcall t_FN _sig;                                          \
-        Util::MscoreeFunctor<t_FN> FN;                                                  \
-        if (SUCCEEDED(hr = FN.Init(#_name))) {                                          \
-            _ret_value = FN()_args;                                                     \
-        }                                                                               \
-    }
-
-#define LEGACY_API_PASS_THROUGH_DELAYLOAD_VOIDRET(_name, _sig, _args)                   \
-    {                                                                                   \
-        typedef void __stdcall t_FN _sig;                                               \
-        Util::MscoreeFunctor<t_FN> FN;                                                  \
-        if (SUCCEEDED(FN.Init(#_name))) {                                          \
-            FN()_args;                                                                  \
-        }                                                                               \
-    }
-
-#ifndef LEGACY_ACTIVATION_SHIM_DELAY_LOAD
-#define CALL_LEGACY_API(_name, _sig, _args)                                             \
-    LEGACY_API_PASS_THROUGH_STATIC(_name, HRESULT, hr, _sig, _args)
-#define CALL_LEGACY_API_VOIDRET(_name, _sig, _args)                                     \
-    LEGACY_API_PASS_THROUGH_STATIC_VOIDRET(_name, _sig, _args)
-#else
-#define CALL_LEGACY_API(_name, _sig, _args)                                             \
-    LEGACY_API_PASS_THROUGH_DELAYLOAD(_name, HRESULT, hr, _sig, _args)
-#define CALL_LEGACY_API_VOIDRET(_name, _sig, _args)                                     \
-    LEGACY_API_PASS_THROUGH_DELAYLOAD_VOIDRET(_name, _sig, _args)
-#endif
-
-    // ---LEGACY SHIM FUNCTIONS--------------------------------------------------------------------
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetCORSystemDirectory(
-        __out_ecount(cchBuffer) LPWSTR pBuffer, 
-        __in  DWORD  cchBuffer, 
-        __out DWORD *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            DWORD dwLengthDummy = cchBuffer;
-            if (pdwLength == NULL)
-                pdwLength = &dwLengthDummy;
-            else
-                *pdwLength = cchBuffer;
-
-            GET_CLRINFO(pInfo);
-            IfHrFailRet(pInfo->GetRuntimeDirectory(pBuffer, pdwLength));
-        }
-        else
-        {
-            CALL_LEGACY_API(GetCORSystemDirectory,
-                            (LPWSTR pBuffer, 
-                             DWORD  cchBuffer, 
-                             DWORD *pdwLength),
-                            (pBuffer,
-                             cchBuffer,
-                             pdwLength));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetCORVersion(
-        __out_ecount(cchBuffer) LPWSTR pbBuffer, 
-        __in  DWORD  cchBuffer, 
-        __out DWORD *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            DWORD dwLengthDummy = cchBuffer;
-            if (pdwLength == NULL)
-                pdwLength = &dwLengthDummy;
-            else
-                *pdwLength = cchBuffer;
-
-            GET_CLRINFO(pInfo);
-            IfHrFailRet(pInfo->GetVersionString(pbBuffer, pdwLength));
-        }
-        else
-        {
-            CALL_LEGACY_API(GetCORVersion,
-                            (LPWSTR pbBuffer,
-                             DWORD  cchBuffer,
-                             DWORD *pdwLength),
-                            (pbBuffer,
-                             cchBuffer,
-                             pdwLength));
-                            
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetFileVersion(
-        __in  LPCWSTR szFileName, 
-        __out_ecount(cchBuffer) LPWSTR  szBuffer, 
-        __in  DWORD   cchBuffer, 
-        __out DWORD  *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            DWORD dwLengthDummy = cchBuffer;
-            if (pdwLength == NULL)
-                pdwLength = &dwLengthDummy;
-            else
-                *pdwLength = cchBuffer;
-
-            GET_CLRMETAHOST(pMH);
-            IfHrFailRet(pMH->GetVersionFromFile(szFileName, szBuffer, pdwLength));
-        }
-        else
-        {
-            CALL_LEGACY_API(GetFileVersion,
-                            (LPCWSTR szFileName, 
-                             LPWSTR  szBuffer, 
-                             DWORD   cchBuffer, 
-                             DWORD  *pdwLength),
-                            (szFileName,
-                             szBuffer,
-                             cchBuffer,
-                             pdwLength));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetCORRequiredVersion(
-        __out_ecount(cchBuffer) LPWSTR pBuffer, 
-        __in  DWORD  cchBuffer, 
-        __out DWORD *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            DWORD dwLengthDummy = cchBuffer;
-            if (pdwLength == NULL)
-                pdwLength = &dwLengthDummy;
-            else
-                *pdwLength = cchBuffer;
-
-            IfHrFailRet(Util::GetConfigImageVersion(pBuffer, pdwLength));
-        }
-        else
-        {
-            CALL_LEGACY_API(GetCORRequiredVersion,
-                            (LPWSTR pBuffer, 
-                             DWORD  cchBuffer, 
-                             DWORD *pdwLength),
-                            (pBuffer,
-                             cchBuffer,
-                             pdwLength));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    // This API is the one exception that we don't have fully equivalent functionality for
-    // in the new APIs. Specifically, we do not have the runtimeInfoFlags equivalent that
-    // allows platform differentiation. As such, we just send the call to the legacy API,
-    // which does not bind (thankfully) and so we do not cap this specific API to Whidbey.
-    inline
-    HRESULT GetRequestedRuntimeInfo(
-        __in_opt  LPCWSTR pExe,
-        __in_opt  LPCWSTR pwszVersion,
-        __in_opt  LPCWSTR pConfigurationFile,
-        __in  DWORD startupFlags,
-        __in  DWORD runtimeInfoFlags,
-        __out_ecount(dwDirectory) LPWSTR pDirectory,
-        __in  DWORD dwDirectory,
-        __out DWORD  *pdwDirectoryLength, 
-        __out_ecount(cchBuffer) LPWSTR pVersion,
-        __in  DWORD cchBuffer,
-        __out DWORD  *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        CALL_LEGACY_API(GetRequestedRuntimeInfo,
-                        (LPCWSTR  pExe, 
-                         LPCWSTR  pwszVersion, 
-                         LPCWSTR  pConfigurationFile, 
-                         DWORD    startupFlags, 
-                         DWORD    runtimeInfoFlags, 
-                         LPWSTR   pDirectory, 
-                         DWORD    dwDirectory, 
-                         DWORD   *pdwDirectoryLength, 
-                         LPWSTR   pVersion, 
-                         DWORD    cchBuffer, 
-                         DWORD   *pdwLength),
-                        (pExe,
-                         pwszVersion,
-                         pConfigurationFile,
-                         startupFlags,
-                         runtimeInfoFlags,
-                         pDirectory,
-                         dwDirectory,
-                         pdwDirectoryLength, 
-                         pVersion,
-                         cchBuffer,
-                         pdwLength));
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetRequestedRuntimeVersion(
-        __in  LPWSTR pExe,
-        __out_ecount(cchBuffer) LPWSTR pVersion,
-        __in  DWORD cchBuffer,
-        __out DWORD *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            DWORD dwLengthDummy = cchBuffer;
-            if (pdwLength == NULL)
-                pdwLength = &dwLengthDummy;
-            else
-                *pdwLength = cchBuffer;
-
-            GET_CLRMETAHOSTPOLICY(pMHP);
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRet(pMHP->GetRequestedRuntime(
-                METAHOST_POLICY_USE_PROCESS_IMAGE_PATH,
-                pExe,
-                NULL, // config stream
-                pVersion,
-                pdwLength, 
-                NULL, // image version str
-                NULL, // image version len
-                NULL,
-                IID_ICLRRuntimeInfo,
-                reinterpret_cast<LPVOID*>(&pInfo)));// ppRuntime
-            Util::ReleaseHolder<ICLRRuntimeInfo*> hInfo(pInfo);
-        }
-        else
-        {
-            CALL_LEGACY_API(GetRequestedRuntimeVersion,
-                            (LPWSTR pExe,
-                             LPWSTR pVersion,
-                             DWORD cchBuffer,
-                             DWORD *pdwLength),
-                            (pExe,
-                             pVersion,
-                             cchBuffer,
-                             pdwLength));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CorBindToRuntimeHost(
-        LPCWSTR pwszVersion,
-        LPCWSTR pwszBuildFlavor,
-        LPCWSTR pwszHostConfigFile,
-        VOID* pReserved,
-        DWORD startupFlags,
-        REFCLSID rclsid,
-        REFIID riid,
-        LPVOID FAR *ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            IStream *pConfigStream = NULL;
-            Util::ReleaseHolder<IStream*> hConfigStream;
-            if (pwszHostConfigFile != NULL)
-            {
-                IfHrFailRet(Util::CreateIStreamFromFile(pwszHostConfigFile, &pConfigStream));
-                hConfigStream.Assign(pConfigStream);
-            }
-
-            WCHAR wszVersionLocal[512];
-            DWORD cchVersionLocal = 512;
-            if (pwszVersion != NULL)
-                wcsncpy_s(&wszVersionLocal[0], cchVersionLocal, pwszVersion, _TRUNCATE);
-
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRet(Util::GetCLRRuntimeInfo(
-                &pInfo,
-                NULL,
-                pConfigStream,
-                pwszVersion == NULL ? NULL : &wszVersionLocal[0],
-                pwszVersion == NULL ? NULL : &cchVersionLocal));
-
-            // We're intentionally ignoring the HRESULT return value, since CorBindToRuntimeEx
-            // always ignored these flags when a runtime had already been bound, and we need
-            // to emulate that behavior for when multiple calls to CorBindToRuntimeEx are made
-            // but with different startup flags (ICLRRuntimeInfo::SetDefaultStartupFlags will
-            // return E_INVALIDARG in the case that the runtime has already been started with
-            // different flags).
-            Util::AddStartupFlags(pInfo, pwszBuildFlavor, startupFlags, pwszHostConfigFile);
-
-            IfHrFailRet(pInfo->GetInterface(rclsid, riid, ppv));
-        }
-        else
-        {
-            CALL_LEGACY_API(CorBindToRuntimeHost,
-                            (LPCWSTR pwszVersion,
-                             LPCWSTR pwszBuildFlavor,
-                             LPCWSTR pwszHostConfigFile,
-                             VOID* pReserved,
-                             DWORD startupFlags,
-                             REFCLSID rclsid,
-                             REFIID riid,
-                             LPVOID FAR *ppv),
-                            (pwszVersion,
-                             pwszBuildFlavor,
-                             pwszHostConfigFile,
-                             pReserved,
-                             startupFlags,
-                             rclsid,
-                             riid,
-                             ppv));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CorBindToRuntimeEx(
-        LPCWSTR pwszVersion,
-        LPCWSTR pwszBuildFlavor,
-        DWORD startupFlags,
-        REFCLSID rclsid,
-        REFIID riid,
-        LPVOID* ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            WCHAR wszVersionLocal[512];
-            DWORD cchVersionLocal = 512;
-            if (pwszVersion != NULL)
-                wcsncpy_s(&wszVersionLocal[0], cchVersionLocal, pwszVersion, _TRUNCATE);
-
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRet(Util::GetCLRRuntimeInfo(
-                &pInfo,
-                NULL, // exe path
-                NULL, // config stream
-                pwszVersion == NULL ? NULL : &wszVersionLocal[0],
-                pwszVersion == NULL ? NULL : &cchVersionLocal));
-
-            // We're intentionally ignoring the HRESULT return value, since CorBindToRuntimeEx
-            // always ignored these flags when a runtime had already been bound, and we need
-            // to emulate that behavior for when multiple calls to CorBindToRuntimeEx are made
-            // but with different startup flags (ICLRRuntimeInfo::SetDefaultStartupFlags will
-            // return E_INVALIDARG in the case that the runtime has already been started with
-            // different flags).
-            Util::AddStartupFlags(pInfo, pwszBuildFlavor, startupFlags, NULL);
-
-            IfHrFailRet(pInfo->GetInterface(rclsid, riid, ppv));
-        }
-        else
-        {
-            CALL_LEGACY_API(CorBindToRuntimeEx,
-                            (LPCWSTR pwszVersion,
-                             LPCWSTR pwszBuildFlavor,
-                             DWORD startupFlags,
-                             REFCLSID rclsid,
-                             REFIID riid,
-                             LPVOID* ppv),
-                            (pwszVersion,
-                             pwszBuildFlavor,
-                             startupFlags,
-                             rclsid,
-                             riid,
-                             ppv));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CorBindToRuntimeByCfg(
-        IStream* pCfgStream,
-        DWORD reserved,
-        DWORD startupFlags,
-        REFCLSID rclsid,
-        REFIID riid,
-        LPVOID* ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            // The legacy CorBindToRuntimeByCfg picks up startup flags from both the config stream and
-            // application config file if it is present. For simplicity, we ignore the app config here.
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRet(Util::GetCLRRuntimeInfo(
-                &pInfo,
-                NULL, // exe path
-                pCfgStream));
-
-            // We're intentionally ignoring the HRESULT return value, since CorBindToRuntimeEx
-            // always ignored these flags when a runtime had already been bound, and we need
-            // to emulate that behavior for when multiple calls to CorBindToRuntimeEx are made
-            // but with different startup flags (ICLRRuntimeInfo::SetDefaultStartupFlags will
-            // return E_INVALIDARG in the case that the runtime has already been started with
-            // different flags).
-            Util::AddStartupFlags(pInfo, NULL, startupFlags, NULL);
-
-            IfHrFailRet(pInfo->GetInterface(rclsid, riid, ppv));
-        }
-        else
-        {
-            CALL_LEGACY_API(CorBindToRuntimeByCfg,
-                            (IStream* pCfgStream,
-                             DWORD reserved,
-                             DWORD startupFlags,
-                             REFCLSID rclsid,
-                             REFIID riid,
-                             LPVOID* ppv),
-                            (pCfgStream,
-                             reserved,
-                             startupFlags,
-                             rclsid,
-                             riid,
-                             ppv));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CorBindToRuntime(
-        LPCWSTR pwszVersion,
-        LPCWSTR pwszBuildFlavor,
-        REFCLSID rclsid,
-        REFIID riid,
-        LPVOID* ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            WCHAR wszVersionLocal[512];
-            DWORD cchVersionLocal = 512;
-            if (pwszVersion != NULL)
-                wcsncpy_s(&wszVersionLocal[0], cchVersionLocal, pwszVersion, _TRUNCATE);
-
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRet(Util::GetCLRRuntimeInfo(
-                &pInfo,
-                NULL, // exe path
-                NULL, // config stream
-                pwszVersion == NULL ? NULL : &wszVersionLocal[0],
-                pwszVersion == NULL ? NULL : &cchVersionLocal));
-
-            // CorBindToRuntime has its special default flags
-            //
-            // We're intentionally ignoring the HRESULT return value, since CorBindToRuntimeEx
-            // always ignored these flags when a runtime had already been bound, and we need
-            // to emulate that behavior for when multiple calls to CorBindToRuntimeEx are made
-            // but with different startup flags (ICLRRuntimeInfo::SetDefaultStartupFlags will
-            // return E_INVALIDARG in the case that the runtime has already been started with
-            // different flags).
-            Util::AddStartupFlags(pInfo, NULL, STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST, NULL);
-
-            IfHrFailRet(pInfo->GetInterface(rclsid, riid, ppv));
-        }
-        else
-        {
-            CALL_LEGACY_API(CorBindToRuntime,
-                            (LPCWSTR pwszVersion,
-                             LPCWSTR pwszBuildFlavor,
-                             REFCLSID rclsid,
-                             REFIID riid,
-                             LPVOID* ppv),
-                            (pwszVersion,
-                             pwszBuildFlavor,
-                             rclsid,
-                             riid,
-                             ppv));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CorBindToCurrentRuntime(
-        LPCWSTR pwszFileName,
-        REFCLSID rclsid,
-        REFIID riid,
-        LPVOID FAR *ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRet(Util::GetCLRRuntimeInfo(
-                &pInfo,
-                pwszFileName));
-
-            IfHrFailRet(pInfo->GetInterface(rclsid, riid, ppv));
-        }
-        else
-        {
-            CALL_LEGACY_API(CorBindToCurrentRuntime,
-                            (LPCWSTR pwszFileName,
-                             REFCLSID rclsid,
-                             REFIID riid,
-                             LPVOID FAR *ppv),
-                            (pwszFileName,
-                             rclsid,
-                             riid,
-                             ppv));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT ClrCreateManagedInstance(
-        LPCWSTR pTypeName,
-        REFIID riid,
-        void **ppObject)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            GET_CLRINFO(pInfo);
-            HRESULT (STDMETHODCALLTYPE *pfnClrCreateManagedInstance)(LPCWSTR typeName, REFIID riid, void ** ppv) = NULL;
-            IfHrFailRet(pInfo->GetProcAddress("ClrCreateManagedInstance", (LPVOID *)&pfnClrCreateManagedInstance));
-            IfHrFailRet(pfnClrCreateManagedInstance(pTypeName, riid, ppObject));
-        }
-        else
-        {
-            CALL_LEGACY_API(ClrCreateManagedInstance,
-                            (LPCWSTR pTypeName,
-                             REFIID riid,
-                             void **ppObject),
-                            (pTypeName,
-                             riid,
-                             ppObject));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT LoadLibraryShim(
-        LPCWSTR szDllName,
-        LPCWSTR szVersion,
-        LPVOID pvReserved,
-        HMODULE *phModDll)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            Util::ReleaseHolder<ICLRRuntimeInfo*> hInfo;
-            ICLRRuntimeInfo *pInfo = NULL;
-
-            // Semantics of LoadLibraryShim is that a non-null version must match exactly.
-            if (szVersion != NULL)
-            {
-                GET_CLRMETAHOST(pMH);
-                IfHrFailRet(pMH->GetRuntime(szVersion, IID_ICLRRuntimeInfo, reinterpret_cast<LPVOID*>(&pInfo)));
-                hInfo.Assign(pInfo);
-            }
-            else
-            {
-                IfHrFailRet(Util::GetCLRRuntimeInfo(&pInfo));
-            }
-            IfHrFailRet(pInfo->LoadLibrary(szDllName, phModDll));
-        }
-        else
-        {
-            CALL_LEGACY_API(LoadLibraryShim,
-                            (LPCWSTR szDllName,
-                             LPCWSTR szVersion,
-                             LPVOID pvReserved,
-                             HMODULE *phModDll),
-                            (szDllName,
-                             szVersion,
-                             pvReserved,
-                             phModDll));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CallFunctionShim(
-        LPCWSTR szDllName,
-        LPCSTR szFunctionName,
-        LPVOID lpvArgument1,
-        LPVOID lpvArgument2,
-        LPCWSTR szVersion,
-        LPVOID pvReserved)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            HMODULE hMod = NULL;
-            HRESULT (__stdcall * pfn)(LPVOID,LPVOID) = NULL;
-
-            // Load library
-            IfHrFailRet(LegacyActivationShim::LoadLibraryShim(szDllName, szVersion, pvReserved, &hMod));
-
-            // NOTE: Legacy CallFunctionShim does not release HMODULE, leak to maintain compat
-            // Util::HMODULEHolder hModHolder(hMod);
-            
-            // Find function.
-            pfn = (HRESULT (__stdcall *)(LPVOID,LPVOID))GetProcAddress(hMod, szFunctionName);
-            if (pfn == NULL)
-                return HRESULT_FROM_WIN32(GetLastError());
-            
-            // Call it.
-            return pfn(lpvArgument1, lpvArgument2);
-        }
-        else
-        {
-            CALL_LEGACY_API(CallFunctionShim,
-                            (LPCWSTR szDllName,
-                             LPCSTR szFunctionName,
-                             LPVOID lpvArgument1,
-                             LPVOID lpvArgument2,
-                             LPCWSTR szVersion,
-                             LPVOID pvReserved),
-                            (szDllName,
-                             szFunctionName,
-                             lpvArgument1,
-                             lpvArgument2,
-                             szVersion,
-                             pvReserved));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetRealProcAddress(
-        LPCSTR pwszProcName, 
-        VOID **ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            GET_CLRINFO(pInfo);
-            IfHrFailRet(pInfo->GetProcAddress(pwszProcName, ppv));
-        }
-        else
-        {
-            CALL_LEGACY_API(GetRealProcAddress,
-                            (LPCSTR pwszProcName, 
-                             VOID **ppv),
-                            (pwszProcName,
-                             ppv));
-        }
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    void CorExitProcess(
-        int exitCode)
-    {
-#ifndef LEGACY_ACTIVATION_SHIM_DELAY_LOAD
-        ::CorExitProcess(exitCode);
-#else
-        typedef void __stdcall t_CorExitProcess(
-            int exitCode);
-
-        Util::MscoreeFunctor<t_CorExitProcess> FN;
-        if (FAILED(FN.Init("CorExitProcess")))
-            return;
-
-        FN()(exitCode);
-#endif
-    }
-
-// Define this method only if it is not yet defined as macro (see ndp\clr\src\inc\UtilCode.h).
-#ifndef LoadStringRC
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT LoadStringRC(
-        UINT   nResourceID, 
-        __out_ecount(nMax) LPWSTR szBuffer,
-        int    nMax, 
-        int    fQuiet)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            GET_CLRINFO(pInfo);
-            DWORD cchMax = static_cast<DWORD>(nMax);
-            IfHrFailRet(pInfo->LoadErrorString(nResourceID, szBuffer, &cchMax, -1));
-        }
-        else
-        {
-            CALL_LEGACY_API(LoadStringRC,
-                            (UINT   nResourceID, 
-                             LPWSTR szBuffer,
-                             int    nMax, 
-                             int    fQuiet),
-                            (nResourceID,
-                             szBuffer,
-                             nMax,
-                             fQuiet));
-        }
-
-        return hr;
-    }
-#endif //LoadStringRC
-
-// Define this method only if it is not yet defined as macro (see ndp\clr\src\inc\UtilCode.h).
-#if !defined(LoadStringRCEx) && !defined(FEATURE_CORESYSTEM)
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT LoadStringRCEx(
-        LCID lcid,
-        UINT   nResourceID, 
-        __out_ecount(nMax) LPWSTR szBuffer,
-        int    nMax, 
-        int    fQuiet, 
-        int *pcwchUsed)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs())
-        {
-            GET_CLRINFO(pInfo);
-            DWORD cchUsed = static_cast<DWORD>(nMax);
-            IfHrFailRet(pInfo->LoadErrorString(nResourceID, szBuffer, &cchUsed, lcid));
-            *pcwchUsed = cchUsed;
-        }
-        else
-        {
-            CALL_LEGACY_API(LoadStringRCEx,
-                            (LCID lcid,
-                             UINT   nResourceID, 
-                             LPWSTR szBuffer,
-                             int    nMax, 
-                             int    fQuiet, 
-                             int *pcwchUsed),
-                            (lcid,
-                             nResourceID,
-                             szBuffer,
-                             nMax,
-                             fQuiet,
-                             pcwchUsed));
-        }
-
-        return hr;
-    }
-#endif //LoadStringRCEx
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT LockClrVersion(
-        FLockClrVersionCallback hostCallback,
-        FLockClrVersionCallback *pBeginHostSetup,
-        FLockClrVersionCallback *pEndHostSetup)
-    {
-        HRESULT hr = S_OK;
-
-        CALL_LEGACY_API(LockClrVersion,
-                        (FLockClrVersionCallback hostCallback,
-                         FLockClrVersionCallback *pBeginHostSetup,
-                         FLockClrVersionCallback *pEndHostSetup),
-                        (hostCallback,
-                         pBeginHostSetup,
-                         pEndHostSetup));
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT CreateDebuggingInterfaceFromVersion(
-        int        nDebuggerVersion, 
-        LPCWSTR szDebuggeeVersion,
-        IUnknown ** ppCordb)
-    {
-        HRESULT hr = S_OK;
-
-        CALL_LEGACY_API(CreateDebuggingInterfaceFromVersion,
-                        (int        nDebuggerVersion, 
-                         LPCWSTR szDebuggeeVersion,
-                         IUnknown ** ppCordb),
-                        (nDebuggerVersion,
-                         szDebuggeeVersion,
-                         ppCordb));
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-    inline
-    HRESULT GetVersionFromProcess(
-        __in  HANDLE hProcess,
-        __out_ecount(cchBuffer) LPWSTR pVersion,
-        __in  DWORD cchBuffer,
-        __out DWORD *pdwLength)
-    {
-        HRESULT hr = S_OK;
-
-        CALL_LEGACY_API(GetVersionFromProcess,
-                        (HANDLE hProcess,
-                         LPWSTR pVersion,
-                         DWORD cchBuffer,
-                         DWORD *pdwLength),
-                        (hProcess,
-                         pVersion,
-                         cchBuffer,
-                         pdwLength));
-
-        return hr;
-    }
-
-    // --------------------------------------------------------------------------------------------
-// CoInitializeEE is declared in cor.h, define it only if explicitly requested
-#ifdef LEGACY_ACTIVATION_SHIM_DEFINE_CoInitializeEE
-    inline 
-    HRESULT CoInitializeEE(DWORD flags)
-    {
-        HRESULT hr = S_OK;
-        
-        if (Util::HasNewActivationAPIs())
-        {
-            GET_CLRINFO(pInfo);
-            HRESULT (* pfnCoInitializeEE)(DWORD);
-            IfHrFailRet(pInfo->GetProcAddress("CoInitializeEE", (LPVOID *)&pfnCoInitializeEE));
-            return (*pfnCoInitializeEE)(flags);
-        }
-        else
-        {
-            CALL_LEGACY_API(CoInitializeEE,
-                            (DWORD flags),
-                            (flags));
-        }
-        
-        return hr;
-    }
-
-    inline 
-    VOID CoUninitializeEE(BOOL flags)
-    {
-        if (Util::HasNewActivationAPIs())
-        {
-            ICLRRuntimeInfo *pInfo = NULL;
-            if (FAILED(Util::GetCLRRuntimeInfo(&pInfo)))
-                return;
-
-            VOID (* pfnCoUninitializeEE)(BOOL);
-            if (FAILED(pInfo->GetProcAddress("CoUninitializeEE", (LPVOID *)&pfnCoUninitializeEE)))
-                return;
-
-            (*pfnCoUninitializeEE)(flags);
-        }
-        else
-        {
-            CALL_LEGACY_API_VOIDRET(CoUninitializeEE,
-                                    (BOOL flags),
-                                    (flags));
-        }
-    }
-
-    inline 
-    HRESULT CoInitializeCor(DWORD flags)
-    {
-        HRESULT hr = S_OK;
-        
-        if (Util::HasNewActivationAPIs())
-        {
-            GET_CLRINFO(pInfo);
-            HRESULT (* pfnCoInitializeCor)(DWORD);
-            IfHrFailRet(pInfo->GetProcAddress("CoInitializeCor", (LPVOID *)&pfnCoInitializeCor));
-            return (*pfnCoInitializeCor)(flags);
-        }
-        else
-        {
-            CALL_LEGACY_API(CoInitializeCor,
-                            (DWORD flags),
-                            (flags));
-        }
-        
-        return hr;
-    }
-
-    inline 
-    VOID CoUninitializeCor()
-    {
-        if (Util::HasNewActivationAPIs())
-        {
-            ICLRRuntimeInfo *pInfo = NULL;
-            if (FAILED(Util::GetCLRRuntimeInfo(&pInfo)))
-                return;
-
-            VOID (* pfnCoUninitializeCor)();
-            if (FAILED(pInfo->GetProcAddress("CoUninitializeCor", (LPVOID *)&pfnCoUninitializeCor)))
-                return;
-
-            (*pfnCoUninitializeCor)();
-        }
-        else
-        {
-            CALL_LEGACY_API_VOIDRET(CoUninitializeCor,
-                                    (VOID),
-                                    ());
-        }
-    }
-
-#endif //LEGACY_ACTIVATION_SHIM_DEFINE_CoInitializeEE
-    
-    // --------------------------------------------------------------------------------------------
-// CoEEShutDownCOM is declared in cor.h, define it only if explicitly requested
-#ifdef LEGACY_ACTIVATION_SHIM_DEFINE_CoEEShutDownCOM
-    inline 
-    void CoEEShutDownCOM()
-    {
-        if (Util::HasNewActivationAPIs())
-        {
-            ICLRRuntimeInfo *pInfo = NULL;
-            IfHrFailRetVOID(Util::GetCLRRuntimeInfo(&pInfo));
-            void (* pfnCoEEShutDownCOM)();
-            IfHrFailRetVOID(pInfo->GetProcAddress("CoEEShutDownCOM", (LPVOID *)&pfnCoEEShutDownCOM));
-            (*pfnCoEEShutDownCOM)();
-        }
-        else
-        {
-            CALL_LEGACY_API_VOIDRET(CoEEShutDownCOM, 
-                            (), 
-                            ());
-        }
-        
-        return;
-    }
-#endif //LEGACY_ACTIVATION_SHIM_DEFINE_CoEEShutDownCOM
-    
-    // ---StrongName Function Helpers--------------------------------------------------------------
-#if !defined(LEGACY_ACTIVATION_SHIM_DELAY_LOAD) && defined(__STRONG_NAME_H)
-#define LEGACY_STRONGNAME_API_PASS_THROUGH(_name, _ret_type, _ret_value, _sig, _args)   \
-    LEGACY_API_PASS_THROUGH_STATIC(_name, _ret_type, _ret_value, _sig, _args)
-#define LEGACY_STRONGNAME_API_PASS_THROUGH_VOIDRET(_name, _sig, _args)   \
-    LEGACY_API_PASS_THROUGH_STATIC_VOIDRET(_name, _sig, _args)
-#else //defined(LEGACY_ACTIVATION_SHIM_DELAY_LOAD) || !defined(__STRONG_NAME_H)
-#define LEGACY_STRONGNAME_API_PASS_THROUGH(_name, _ret_type, _ret_value, _sig, _args)   \
-    LEGACY_API_PASS_THROUGH_DELAYLOAD(_name, _ret_type, _ret_value, _sig, _args)
-#define LEGACY_STRONGNAME_API_PASS_THROUGH_VOIDRET(_name, _sig, _args)   \
-    LEGACY_API_PASS_THROUGH_DELAYLOAD_VOIDRET(_name, _sig, _args)
-#endif //defined(LEGACY_ACTIVATION_SHIM_DELAY_LOAD) || !defined(__STRONG_NAME_H)
-
-// Defines a method that just delegates a call to the right runtime, this one is for SN APIs that 
-// return HRESULT.
-#define PASS_THROUGH_IMPL_HRESULT(_name, _signature, _args)     \
-    inline                                                      \
-    HRESULT _name##_signature                                   \
-    {                                                           \
-        HRESULT hr = S_OK;                                      \
-        if (Util::HasNewActivationAPIs())                       \
-        {                                                       \
-            ICLRStrongName *pSN = NULL;                         \
-            IfHrFailRet(Util::GetCLRStrongName(&pSN));          \
-            IfHrFailRet(pSN->_name _args);                      \
-        }                                                       \
-        else                                                    \
-        {                                                       \
-            LEGACY_STRONGNAME_API_PASS_THROUGH(                 \
-                _name, HRESULT, hr, _signature, _args);         \
-            IfHrFailRet(hr);                                    \
-        }                                                       \
-        return hr;                                              \
-    }
-
-// Defines a method that just delegates a call to the right runtime, this one is for SN APIs that 
-// return BOOL.
-#define PASS_THROUGH_IMPL_BOOLEAN(_name, _signature, _args)     \
-    inline                                                      \
-    BOOL _name##_signature                                      \
-    {                                                           \
-        HRESULT hr = S_OK;                                      \
-        if (Util::HasNewActivationAPIs())                       \
-        {                                                       \
-            ICLRStrongName *pSN = NULL;                         \
-            IfHrFailRetFALSE(Util::GetCLRStrongName(&pSN));     \
-            IfHrFailRetFALSE(pSN->_name _args);                 \
-            return TRUE;                                        \
-        }                                                       \
-        else                                                    \
-        {                                                       \
-            BOOL fResult = TRUE;                                \
-            LEGACY_STRONGNAME_API_PASS_THROUGH(                 \
-                _name, BOOL, fResult, _signature, _args);       \
-            IfHrFailRetFALSE(hr);                               \
-            return fResult;                                     \
-        }                                                       \
-    }
-
-// Defines a method that just delegates a call to the right runtime, this one is for SN APIs that 
-// return VOID.
-#define PASS_THROUGH_IMPL_VOID(_name, _signature, _args)        \
-    inline                                                      \
-    VOID _name##_signature                                      \
-    {                                                           \
-        HRESULT hr = S_OK;                                      \
-        if (Util::HasNewActivationAPIs())                       \
-        {                                                       \
-            ICLRStrongName *pSN = NULL;                         \
-            IfHrFailRetVOID(Util::GetCLRStrongName(&pSN));      \
-            IfHrFailRetVOID(pSN->_name _args);                  \
-            return;                                             \
-        }                                                       \
-        else                                                    \
-        {                                                       \
-            LEGACY_STRONGNAME_API_PASS_THROUGH_VOIDRET(         \
-                _name, _signature, _args);                      \
-            IfHrFailRetVOID(hr);                                \
-            return;                                             \
-        }                                                       \
-    }
-
-    // ---StrongName functions---------------------------------------------------------------------
-
-PASS_THROUGH_IMPL_HRESULT(GetHashFromAssemblyFile,
-                         (LPCSTR pszFilePath, unsigned int *piHashAlg, BYTE *pbHash, DWORD cchHash, DWORD *pchHash),
-                         (pszFilePath, piHashAlg, pbHash, cchHash, pchHash));
-
-PASS_THROUGH_IMPL_HRESULT(GetHashFromAssemblyFileW,
-                         (LPCWSTR pwzFilePath, unsigned int *piHashAlg, BYTE *pbHash, DWORD cchHash, DWORD *pchHash),
-                         (pwzFilePath, piHashAlg, pbHash, cchHash, pchHash));
-
-PASS_THROUGH_IMPL_HRESULT(GetHashFromBlob,
-                         (BYTE *pbBlob, DWORD cchBlob, unsigned int *piHashAlg, BYTE *pbHash, DWORD cchHash, DWORD *pchHash),
-                         (pbBlob, cchBlob, piHashAlg, pbHash, cchHash, pchHash));
-
-PASS_THROUGH_IMPL_HRESULT(GetHashFromFile,
-                         (LPCSTR pszFilePath, unsigned int *piHashAlg, BYTE *pbHash, DWORD cchHash, DWORD *pchHash),
-                         (pszFilePath, piHashAlg, pbHash, cchHash, pchHash));
-
-PASS_THROUGH_IMPL_HRESULT(GetHashFromFileW,
-                         (LPCWSTR pwzFilePath, unsigned int *piHashAlg, BYTE *pbHash, DWORD cchHash, DWORD *pchHash),
-                         (pwzFilePath, piHashAlg, pbHash, cchHash, pchHash));
-
-PASS_THROUGH_IMPL_HRESULT(GetHashFromHandle,
-                         (HANDLE hFile, unsigned int *piHashAlg, BYTE *pbHash, DWORD cchHash, DWORD *pchHash),
-                         (hFile, piHashAlg, pbHash, cchHash, pchHash));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameCompareAssemblies,
-                         (LPCWSTR pwzAssembly1, LPCWSTR pwzAssembly2, DWORD *pdwResult),
-                         (pwzAssembly1, pwzAssembly2, pdwResult));
-
-PASS_THROUGH_IMPL_VOID(StrongNameFreeBuffer,
-                      (BYTE *pbMemory),
-                      (pbMemory));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameGetBlob,
-                         (LPCWSTR pwzFilePath, BYTE *pbBlob, DWORD *pcbBlob),
-                         (pwzFilePath, pbBlob, pcbBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameGetBlobFromImage,
-                         (BYTE *pbBase, DWORD dwLength, BYTE *pbBlob, DWORD *pcbBlob),
-                         (pbBase, dwLength, pbBlob, pcbBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameGetPublicKey,
-                         (LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob, BYTE **ppbPublicKeyBlob, ULONG *pcbPublicKeyBlob),
-                         (pwzKeyContainer, pbKeyBlob, cbKeyBlob, ppbPublicKeyBlob, pcbPublicKeyBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameHashSize,
-                         (ULONG ulHashAlg, DWORD *pcbSize),
-                         (ulHashAlg, pcbSize));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameKeyDelete,
-                         (LPCWSTR pwzKeyContainer),
-                         (pwzKeyContainer));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameKeyGen,
-                         (LPCWSTR pwzKeyContainer, DWORD dwFlags, BYTE **ppbKeyBlob, ULONG *pcbKeyBlob),
-                         (pwzKeyContainer, dwFlags, ppbKeyBlob, pcbKeyBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameKeyGenEx,
-                         (LPCWSTR pwzKeyContainer, DWORD dwFlags, DWORD dwKeySize, BYTE **ppbKeyBlob, ULONG *pcbKeyBlob),
-                         (pwzKeyContainer, dwFlags, dwKeySize, ppbKeyBlob, pcbKeyBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameKeyInstall,
-                         (LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob),
-                         (pwzKeyContainer, pbKeyBlob, cbKeyBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameSignatureGeneration,
-                         (LPCWSTR pwzFilePath, LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob, BYTE **ppbSignatureBlob, ULONG *pcbSignatureBlob),
-                         (pwzFilePath, pwzKeyContainer, pbKeyBlob, cbKeyBlob, ppbSignatureBlob, pcbSignatureBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameSignatureGenerationEx,
-                         (LPCWSTR wszFilePath, LPCWSTR wszKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob, BYTE **ppbSignatureBlob, ULONG *pcbSignatureBlob, DWORD dwFlags),
-                         (wszFilePath, wszKeyContainer, pbKeyBlob, cbKeyBlob, ppbSignatureBlob, pcbSignatureBlob, dwFlags));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameSignatureSize,
-                         (BYTE *pbPublicKeyBlob, ULONG cbPublicKeyBlob, DWORD *pcbSize),
-                         (pbPublicKeyBlob, cbPublicKeyBlob, pcbSize));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameSignatureVerification,
-                         (LPCWSTR  pwzFilePath, DWORD dwInFlags, DWORD *pdwOutFlags),
-                         (pwzFilePath, dwInFlags, pdwOutFlags));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameSignatureVerificationEx,
-                         (LPCWSTR pwzFilePath, BOOLEAN fForceVerification, BOOLEAN *pfWasVerified),
-                         (pwzFilePath, fForceVerification, pfWasVerified));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameSignatureVerificationFromImage,
-                         (BYTE *pbBase, DWORD dwLength, DWORD dwInFlags, DWORD *pdwOutFlags),
-                         (pbBase, dwLength, dwInFlags, pdwOutFlags));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameTokenFromAssembly,
-                         (LPCWSTR pwzFilePath, BYTE **ppbStrongNameToken, ULONG *pcbStrongNameToken),
-                         (pwzFilePath, ppbStrongNameToken, pcbStrongNameToken));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameTokenFromAssemblyEx,
-                         (LPCWSTR pwzFilePath, BYTE **ppbStrongNameToken, ULONG *pcbStrongNameToken, BYTE **ppbPublicKeyBlob, ULONG *pcbPublicKeyBlob),
-                         (pwzFilePath, ppbStrongNameToken, pcbStrongNameToken, ppbPublicKeyBlob, pcbPublicKeyBlob));
-
-PASS_THROUGH_IMPL_BOOLEAN(StrongNameTokenFromPublicKey,
-                         (BYTE *pbPublicKeyBlob, ULONG cbPublicKeyBlob, BYTE **ppbStrongNameToken, ULONG *pcbStrongNameToken),
-                         (pbPublicKeyBlob, cbPublicKeyBlob, ppbStrongNameToken, pcbStrongNameToken));
-
-#undef PASS_THROUGH_IMPL_HRESULT
-#undef PASS_THROUGH_IMPL_BOOLEAN
-#undef PASS_THROUGH_IMPL_VOID
-
-// Defines a method that just delegates a call to the right runtime, this one is for SN APIs that 
-// return BOOLEAN.
-#define WRAP_HRESULT_IMPL_BOOLEAN(_WrapperName, _name, _signature, _args)               \
-    inline                                                                              \
-    HRESULT _WrapperName##_signature                                                    \
-    {                                                                                   \
-        HRESULT hr = S_OK;                                                              \
-        if (Util::HasNewActivationAPIs())                                               \
-        {                                                                               \
-            ICLRStrongName *pSN = NULL;                                                 \
-            IfHrFailRet(Util::GetCLRStrongName(&pSN));                                  \
-            return pSN->_name _args;                                                    \
-        }                                                                               \
-        else                                                                            \
-        {                                                                               \
-            typedef BOOL __stdcall t_FN _signature;                                     \
-            Util::MscoreeFunctor<t_FN> FN;                                              \
-            IfHrFailRet(FN.Init(#_name));                                               \
-            if ((FN() _args))                                                           \
-            {                                                                           \
-                return S_OK;                                                            \
-            }                                                                           \
-            else                                                                        \
-            {   /*@TODO: Static bind version, if necessary*/                            \
-                typedef DWORD __stdcall t_FNStrongNameErrorInfo(void);                  \
-                Util::MscoreeFunctor<t_FNStrongNameErrorInfo> FNStrongNameErrorInfo;    \
-                IfHrFailRet(FNStrongNameErrorInfo.Init("StrongNameErrorInfo"));         \
-                HRESULT hrResult = (HRESULT)FNStrongNameErrorInfo() ();                 \
-                if (SUCCEEDED(hrResult))                                                \
-                {                                                                       \
-                    hrResult = E_FAIL;                                                  \
-                }                                                                       \
-                return hrResult;                                                        \
-            }                                                                           \
-        }                                                                               \
-    }
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameHashSize_HRESULT, 
-                          StrongNameHashSize, 
-                          (ULONG ulHashAlg, DWORD *pcbSize), 
-                          (ulHashAlg, pcbSize));
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameTokenFromPublicKey_HRESULT, 
-                          StrongNameTokenFromPublicKey, 
-                          (BYTE *pbPublicKeyBlob, ULONG cbPublicKeyBlob, BYTE **ppbStrongNameToken, ULONG *pcbStrongNameToken), 
-                          (pbPublicKeyBlob, cbPublicKeyBlob, ppbStrongNameToken, pcbStrongNameToken));
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameSignatureSize_HRESULT, 
-                          StrongNameSignatureSize, 
-                          (BYTE *pbPublicKeyBlob, ULONG cbPublicKeyBlob, DWORD *pcbSize), 
-                          (pbPublicKeyBlob, cbPublicKeyBlob, pcbSize));
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameGetPublicKey_HRESULT, 
-                          StrongNameGetPublicKey, 
-                          (LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob, BYTE **ppbPublicKeyBlob, ULONG *pcbPublicKeyBlob), 
-                          (pwzKeyContainer, pbKeyBlob, cbKeyBlob, ppbPublicKeyBlob, pcbPublicKeyBlob));
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameKeyInstall_HRESULT, 
-                          StrongNameKeyInstall, 
-                          (LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob), 
-                          (pwzKeyContainer, pbKeyBlob, cbKeyBlob));
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameSignatureGeneration_HRESULT, 
-                          StrongNameSignatureGeneration, 
-                          (LPCWSTR pwzFilePath, LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob, BYTE **ppbSignatureBlob, ULONG *pcbSignatureBlob), 
-                          (pwzFilePath, pwzKeyContainer, pbKeyBlob, cbKeyBlob, ppbSignatureBlob, pcbSignatureBlob));
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameKeyGen_HRESULT, 
-                          StrongNameKeyGen, 
-                          (LPCWSTR pwzKeyContainer, DWORD dwFlags, BYTE **ppbKeyBlob, ULONG *pcbKeyBlob), 
-                          (pwzKeyContainer, dwFlags, ppbKeyBlob, pcbKeyBlob));
-
-#undef WRAP_HRESULT_IMPL_BOOLEAN
-
-// Defines a method that just delegates a call to the right runtime, this one is for ICLRStrongName2 
-// APIs that return BOOLEAN.
-#define WRAP_HRESULT_IMPL_BOOLEAN(_WrapperName, _name, _signature, _args)               \
-    inline                                                                              \
-    HRESULT _WrapperName##_signature                                                    \
-    {                                                                                   \
-        HRESULT hr = S_OK;                                                              \
-        if (Util::HasNewActivationAPIs())                                               \
-        {                                                                               \
-            ICLRStrongName2 *pSN = NULL;                                                \
-            IfHrFailRet(Util::GetCLRStrongName2(&pSN));                                 \
-            return pSN->_name _args;                                                    \
-        }                                                                               \
-        else                                                                            \
-        {                                                                               \
-            return E_FAIL;                                                              \
-        }                                                                               \
-    }
-
-
-WRAP_HRESULT_IMPL_BOOLEAN(StrongNameGetPublicKeyEx_HRESULT, 
-                          StrongNameGetPublicKeyEx, 
-                          (LPCWSTR pwzKeyContainer, BYTE *pbKeyBlob, ULONG cbKeyBlob, BYTE **ppbPublicKeyBlob, ULONG *pcbPublicKeyBlob, ULONG uHashAlgId, ULONG uReserved), 
-                          (pwzKeyContainer, pbKeyBlob, cbKeyBlob, ppbPublicKeyBlob, pcbPublicKeyBlob, uHashAlgId, uReserved));
-
-#undef WRAP_HRESULT_IMPL_BOOLEAN
-
-    inline
-    HRESULT ClrCoCreateInstance(
-      REFCLSID rclsid,
-      LPUNKNOWN pUnkOuter,
-      DWORD dwClsContext,
-      REFIID riid,
-      LPVOID * ppv)
-    {
-        HRESULT hr = S_OK;
-
-        if (Util::HasNewActivationAPIs() /*&& Util::IsCLSIDHostedByClr(rclsid)*/)
-        {
-            GET_CLRINFO(pInfo);
-            IfHrFailRet(pInfo->GetInterface(rclsid, riid, ppv));
-        }
-        else
-        {
-            IfHrFailRet(::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv));
-        }
-
-        return hr;
-    }
-}; // namespace LegacyActivationShim
-#pragma warning(pop) // Revert C4996 status
-
-#undef LEGACY_API_PASS_THROUGH_STATIC
-#undef LEGACY_API_PASS_THROUGH_STATIC_VOIDRET
-#undef LEGACY_API_PASS_THROUGH_DELAYLOAD
-#undef LEGACY_API_PASS_THROUGH_DELAYLOAD_VOIDRET
-#undef CALL_LEGACY_API
-#undef LEGACY_STRONGNAME_API_PASS_THROUGH
-#undef LEGACY_STRONGNAME_API_PASS_THROUGH_VOIDRET
-
-#undef LEGACY_ACTIVATION_SHIM_DEFAULT_PRODUCT_VER_HELPER_L
-#undef LEGACY_ACTIVATION_SHIM_DEFAULT_PRODUCT_VER_STR_L
-
-#pragma pop_macro("IfHrFailRetVOID")
-#pragma pop_macro("IfHrFailRetFALSE")
-#pragma pop_macro("IfHrFailRet")
-
-#ifdef _MANAGED
-// We are compiling Managed C++, restore previous managed/native status from the stack
-#pragma managed(pop)
-#endif //_MANAGED
-
-#pragma warning(pop)
-
-#endif // __LEGACYACTIVATIONSHIM_H__
diff --git a/src/inc/legacyactivationshimdelayload.h b/src/inc/legacyactivationshimdelayload.h
deleted file mode 100644 (file)
index 8e77ff2..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-//
-
-#ifndef __LEGACYACTIVATIONSHIMDELAYLOAD_H__
-#define __LEGACYACTIVATIONSHIMDELAYLOAD_H__
-
-#define LEGACY_ACTIVATION_SHIM_DELAY_LOAD
-#include <legacyactivationshim.h>
-#undef LEGACY_ACTIVATION_SHIM_DELAY_LOAD
-
-#endif //__LEGACYACTIVATIONSHIMDELAYLOAD_H__
index be09815..820d64b 100644 (file)
 #define WszLogonUser LogonUserW
 #define WszCreateProcessAsUser CreateProcessAsUserW
 #define WszGetCurrentHwProfile GetCurrentHwProfileW
-#define WszGetVersionEx GetVersionExW
 #define WszCreateJobObject CreateJobObjectW
 #define WszOpenJobObject OpenJobObjectW
 
@@ -925,8 +924,6 @@ __forceinline LONGLONG __InterlockedExchangeAdd64(LONGLONG volatile * Addend, LO
 #define CLR_VER_SUITENAME                   0x0000040
 #define CLR_VER_PRODUCT_TYPE                0x0000080
 
-BOOL GetOSVersion(LPOSVERSIONINFOW osVer);
-
 // Output printf-style formatted text to the debugger if it's present or stdout otherwise.
 inline void DbgWPrintf(const LPCWSTR wszFormat, ...)
 {
index ff6c14b..d653511 100644 (file)
@@ -21029,8 +21029,6 @@ regMaskTP CodeGen::genPInvokeMethodProlog(regMaskTP initRegs)
     }
     else
     {
-        noway_assert(pInfo->osMajor >= 5);
-
         DWORD basePtr = WIN_NT5_TLS_HIGHOFFSET;
         threadTlsIndex -= 64;
 
index 8408937..ee0eb25 100644 (file)
@@ -971,5 +971,15 @@ namespace Microsoft.Win32
 #else
         private const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
 #endif
+
+        internal const byte VER_GREATER_EQUAL = 0x3;
+        internal const uint VER_MAJORVERSION = 0x0000002;
+        internal const uint VER_MINORVERSION = 0x0000001;
+        internal const uint VER_SERVICEPACKMAJOR = 0x0000020;
+        internal const uint VER_SERVICEPACKMINOR = 0x0000010;
+        [DllImport("kernel32.dll")]
+        internal static extern bool VerifyVersionInfoW([In, Out] OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
+        [DllImport("kernel32.dll")]
+        internal static extern ulong VerSetConditionMask(ulong dwlConditionMask, uint dwTypeBitMask, byte dwConditionMask);        
     }
 }
index 3668d8c..1d5830c 100644 (file)
@@ -1470,8 +1470,7 @@ namespace System.Diagnostics.Tracing
 #if (!ES_BUILD_STANDALONE && !PROJECTN)
                 // API available on OS >= Win 8 and patched Win 7.
                 // Disable only for FrameworkEventSource to avoid recursion inside exception handling.
-                var osVer = Environment.OSVersion.Version.Major * 10 + Environment.OSVersion.Version.Minor;
-                if (this.Name != "System.Diagnostics.Eventing.FrameworkEventSource" || osVer >= 62)
+                if (this.Name != "System.Diagnostics.Eventing.FrameworkEventSource" || Environment.IsWindows8OrAbove)
 #endif
                 {
                     int setInformationResult;
index 453583b..062e5d9 100644 (file)
@@ -361,69 +361,38 @@ namespace System
             }
         }
 
-        /*==================================OSVersion===================================
-        **Action:
-        **Returns:
-        **Arguments:
-        **Exceptions:
-        ==============================================================================*/
-        internal static OperatingSystem OSVersion
-        {
-            get
-            {
-                Contract.Ensures(Contract.Result<OperatingSystem>() != null);
-
-                if (m_os == null)
-                { // We avoid the lock since we don't care if two threads will set this at the same time.
-                    Microsoft.Win32.Win32Native.OSVERSIONINFO osvi = new Microsoft.Win32.Win32Native.OSVERSIONINFO();
-                    if (!GetVersion(osvi))
-                    {
-                        throw new InvalidOperationException(SR.InvalidOperation_GetVersion);
-                    }
-
-                    Microsoft.Win32.Win32Native.OSVERSIONINFOEX osviEx = new Microsoft.Win32.Win32Native.OSVERSIONINFOEX();
-                    if (!GetVersionEx(osviEx))
-                        throw new InvalidOperationException(SR.InvalidOperation_GetVersion);
-
-#if PLATFORM_UNIX
-                    PlatformID id = PlatformID.Unix;
-#else
-                    PlatformID id = PlatformID.Win32NT;
-#endif // PLATFORM_UNIX
-
-                    Version v = new Version(osvi.MajorVersion, osvi.MinorVersion, osvi.BuildNumber, (osviEx.ServicePackMajor << 16) | osviEx.ServicePackMinor);
-                    m_os = new OperatingSystem(id, v, osvi.CSDVersion);
-                }
-                Debug.Assert(m_os != null, "m_os != null");
-                return m_os;
-            }
-        }
-
-
-        internal static bool IsWindows8OrAbove
-        {
-            get
-            {
-                return true;
-            }
-        }
-
+#if !FEATURE_PAL
+        private static Lazy<bool> s_IsWindows8OrAbove = new Lazy<bool>(() => 
+        {
+            ulong conditionMask = Win32Native.VerSetConditionMask(0, Win32Native.VER_MAJORVERSION, Win32Native.VER_GREATER_EQUAL);
+            conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_MINORVERSION, Win32Native.VER_GREATER_EQUAL);
+            conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_SERVICEPACKMAJOR, Win32Native.VER_GREATER_EQUAL);
+            conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_SERVICEPACKMINOR, Win32Native.VER_GREATER_EQUAL);
+
+            // Windows 8 version is 6.2
+            var version = new Win32Native.OSVERSIONINFOEX { MajorVersion = 6, MinorVersion = 2, ServicePackMajor = 0, ServicePackMinor = 0 };
+                
+            return Win32Native.VerifyVersionInfoW(version, 
+                       Win32Native.VER_MAJORVERSION | Win32Native.VER_MINORVERSION | Win32Native.VER_SERVICEPACKMAJOR | Win32Native.VER_SERVICEPACKMINOR,
+                       conditionMask);
+        });
+        internal static bool IsWindows8OrAbove => s_IsWindows8OrAbove.Value;
+#endif
+        
 #if FEATURE_COMINTEROP
-        internal static bool IsWinRTSupported
+        // Does the current version of Windows have Windows Runtime suppport?
+        private static Lazy<bool> s_IsWinRTSupported = new Lazy<bool>(() =>
         {
-            get
-            {
-                return true;
-            }
-        }
-#endif // FEATURE_COMINTEROP
-
+            return WinRTSupported();
+        });
 
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        internal static extern bool GetVersion(Microsoft.Win32.Win32Native.OSVERSIONINFO osVer);
+        internal static bool IsWinRTSupported => s_IsWinRTSupported.Value;
 
-        [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        internal static extern bool GetVersionEx(Microsoft.Win32.Win32Native.OSVERSIONINFOEX osVer);
+        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+        [SuppressUnmanagedCodeSecurity]
+        [return: MarshalAs(UnmanagedType.Bool)]
+        private static extern bool WinRTSupported();
+#endif // FEATURE_COMINTEROP
 
 
         /*==================================StackTrace==================================
index 1d74358..589eb54 100644 (file)
@@ -4742,18 +4742,6 @@ typedef POSVERSIONINFOEXA POSVERSIONINFOEX;
 typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX;
 #endif
 
-PALIMPORT
-BOOL
-PALAPI
-GetVersionExW(
-          IN OUT LPOSVERSIONINFOW lpVersionInformation);
-
-#ifdef UNICODE
-#define GetVersionEx GetVersionExW
-#else
-#define GetVersionEx GetVersionExA
-#endif
-
 #define IMAGE_FILE_MACHINE_I386              0x014c
 #define IMAGE_FILE_MACHINE_ARM64             0xAA64  // ARM64 Little-Endian
 
index 2677dd6..554a502 100644 (file)
@@ -293,12 +293,6 @@ FreeEnvironmentStringsA(
 PALIMPORT
 BOOL
 PALAPI
-GetVersionExA(
-          IN OUT LPOSVERSIONINFOA lpVersionInformation);
-
-PALIMPORT
-BOOL
-PALAPI
 RemoveDirectoryA(
                  IN LPCSTR lpPathName);
 
index f21c9db..5314cdf 100644 (file)
@@ -181,7 +181,6 @@ set(SOURCES
   misc/sysinfo.cpp
   misc/time.cpp
   misc/utils.cpp
-  misc/version.cpp
   objmgr/palobjbase.cpp
   objmgr/shmobject.cpp
   objmgr/shmobjectmanager.cpp
diff --git a/src/pal/src/misc/version.cpp b/src/pal/src/misc/version.cpp
deleted file mode 100644 (file)
index 7a9f90a..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*++
-
-
-
-Module Name:
-
-    version.c
-
-Abstract:
-
-    Implementation of functions for getting platform.OS versions.
-
-Revision History:
-
-
-
---*/
-
-#include "pal/palinternal.h"
-#include "pal/dbgmsg.h"
-
-SET_DEFAULT_DEBUG_CHANNEL(MISC);
-
-/*++
-Function:
-  GetVersionExA
-
-
-
-GetVersionEx
-
-The GetVersionEx function obtains extended information about the
-version of the operating system that is currently running.
-
-Parameters
-
-lpVersionInfo 
-       [in/out] Pointer to an OSVERSIONINFO data structure that the
-       function fills with operating system version information.
-
-       Before calling the GetVersionEx function, set the
-       dwOSVersionInfoSize member of the OSVERSIONINFO data structure
-       to sizeof(OSVERSIONINFO).
-
-Return Values
-
-If the function succeeds, the return value is a nonzero value.
-
-If the function fails, the return value is zero. To get extended error
-information, call GetLastError. The function fails if you specify an
-invalid value for the dwOSVersionInfoSize member of the OSVERSIONINFO
-structure.
-
---*/
-BOOL
-PALAPI
-GetVersionExA(
-             IN OUT LPOSVERSIONINFOA lpVersionInformation)
-{
-    BOOL bRet = TRUE;
-    PERF_ENTRY(GetVersionExA);
-    ENTRY("GetVersionExA (lpVersionInformation=%p)\n", lpVersionInformation);
-
-    if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOA))
-    {
-        lpVersionInformation->dwMajorVersion = 5;       /* same as WIN2000 */
-        lpVersionInformation->dwMinorVersion = 0;       /* same as WIN2000 */
-        lpVersionInformation->dwBuildNumber = 0;
-        lpVersionInformation->dwPlatformId = VER_PLATFORM_UNIX;
-        lpVersionInformation->szCSDVersion[0] = '\0'; /* no service pack */
-    } 
-    else 
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        bRet = FALSE;
-    }
-    LOGEXIT("GetVersionExA returning BOOL %d\n", bRet);
-    PERF_EXIT(GetVersionExA);
-    return bRet;
-}
-
-
-/*++
-Function:
-  GetVersionExW
-
-See GetVersionExA
---*/
-BOOL
-PALAPI
-GetVersionExW(
-             IN OUT LPOSVERSIONINFOW lpVersionInformation)
-{
-    BOOL bRet = TRUE;
-
-    PERF_ENTRY(GetVersionExW);
-    ENTRY("GetVersionExW (lpVersionInformation=%p)\n", lpVersionInformation);
-
-    if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOW))
-    {
-        lpVersionInformation->dwMajorVersion = 5;       /* same as WIN2000 */
-        lpVersionInformation->dwMinorVersion = 0;       /* same as WIN2000 */
-        lpVersionInformation->dwBuildNumber = 0;
-        lpVersionInformation->dwPlatformId = VER_PLATFORM_UNIX;
-        lpVersionInformation->szCSDVersion[0] = '\0'; /* no service pack */
-    } 
-    else 
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        bRet =  FALSE;
-    }
-    LOGEXIT("GetVersionExW returning BOOL %d\n", bRet);
-    PERF_EXIT(GetVersionExW);
-    return bRet;
-}
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExA/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetVersionExA/CMakeLists.txt
deleted file mode 100644 (file)
index f6aa0cb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/CMakeLists.txt
deleted file mode 100644 (file)
index 1e512f3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
-  test.cpp
-)
-
-add_executable(paltest_getversionexa_test1
-  ${SOURCES}
-)
-
-add_dependencies(paltest_getversionexa_test1 coreclrpal)
-
-target_link_libraries(paltest_getversionexa_test1
-  ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/test.cpp
deleted file mode 100644 (file)
index 5dd20c6..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-** Source : test.c
-**
-** Purpose: Test for GetVersionExA() function
-**
-**
-**=========================================================*/
-
-#include <palsuite.h>
-
-int __cdecl main(int argc, char *argv[]) {
-       
-    OSVERSIONINFO TheVersionInfo;
-    OSVERSIONINFO* pVersionInfo = &TheVersionInfo;
-
-    /*
-     * Initialize the PAL and return FAILURE if this fails
-     */
-
-    if(0 != (PAL_Initialize(argc, argv)))
-    {
-        return FAIL;
-    }
-
-    /* This needs to be done before using GetVersionEx */
-    pVersionInfo->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-  
-    /* If GetVersionEx fails, then the test fails */
-    if(GetVersionEx(pVersionInfo) == 0) 
-    {
-        Fail("ERROR: The GetVersionEx function returned 0, which indicates "
-             "failure.");    
-    }
-  
-    /* These values are fixed, ensure they're set properly */
-    if(pVersionInfo->dwMajorVersion != 5) 
-    {
-        Fail("ERROR: The fixed value of dwMajorVersion shoud be 5, "
-             "but is really %d.",pVersionInfo->dwMajorVersion);
-    }
-
-    /* The minor version values for Win2k and XP are different 
-    for Win2k minor version equals 0 and for XP minor version
-    equals 1.  Both values are excepted here. */
-    if((pVersionInfo->dwMinorVersion != 0) && 
-       (pVersionInfo->dwMinorVersion != 1)) 
-    {
-        Fail("ERROR: The fixed value of dwMinorVersion shoud be 0 or 1, "
-             "but is really %d.",pVersionInfo->dwMinorVersion);
-    }
-    if(pVersionInfo->dwBuildNumber_PAL_Undefined < 0) 
-    {
-        Fail("ERROR: The value of dwBuildNumber shoud be at least 0, but "
-             "is really %d.",pVersionInfo->dwBuildNumber_PAL_Undefined);
-    }
-
-#if !WIN32
-    /* Under BSD, the PlatformID should be UNIX and the Service Pack
-       version should be set to "".
-    */
-
-    if(pVersionInfo->dwPlatformId != VER_PLATFORM_UNIX ||
-       pVersionInfo->szCSDVersion_PAL_Undefined[0] != 0) 
-    {
-        Fail("ERROR: The dwPlatformId should be %d but is really %d.  And the "
-             "szCSDVerion should be NULL.",
-             VER_PLATFORM_UNIX,pVersionInfo->dwPlatformId);
-    }
-#endif
-    
-    PAL_Terminate();
-    return PASS;
-}
-
-
-
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetVersionExA/test1/testinfo.dat
deleted file mode 100644 (file)
index 1e9c570..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Miscellaneous
-Function = GetVersionExA
-Name = Positive Test for GetVersionExA
-TYPE = DEFAULT
-EXE1 = test
-Description
-= Test that all the values in the OSVERSION structure are set properly
-= for the current environment.
-
-
-
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetVersionExW/CMakeLists.txt
deleted file mode 100644 (file)
index f6aa0cb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/CMakeLists.txt
deleted file mode 100644 (file)
index 4ef820c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
-  test.cpp
-)
-
-add_executable(paltest_getversionexw_test1
-  ${SOURCES}
-)
-
-add_dependencies(paltest_getversionexw_test1 coreclrpal)
-
-target_link_libraries(paltest_getversionexw_test1
-  ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/test.cpp
deleted file mode 100644 (file)
index 69aae54..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*============================================================
-**
-** Source : test.c
-**
-** Purpose: Test for GetVersionExW() function
-**
-**
-**=========================================================*/
-
-#define UNICODE
-
-#include <palsuite.h>
-
-int __cdecl main(int argc, char *argv[]) 
-{
-       
-    OSVERSIONINFO TheVersionInfo;
-    OSVERSIONINFO* pVersionInfo = &TheVersionInfo;
-    /*
-     * Initialize the PAL and return FAILURE if this fails
-     */
-
-    if(0 != (PAL_Initialize(argc, argv)))
-    {
-        return FAIL;
-    }
-
-    /* This needs to be done before using GetVersionEx */
-    pVersionInfo->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-  
-    /* If GetVersionEx fails, then the test fails */
-    if(GetVersionEx(pVersionInfo) == 0) 
-    {
-        Fail("ERROR: The GetVersionEx function returned 0, which indicates " 
-             "failure.");
-    }
-  
-    /* These values are fixed, ensure they're set properly */
-    if(pVersionInfo->dwMajorVersion != 5) 
-    {
-        Fail("ERROR: The fixed value of dwMajorVersion shoud be 5, but is "
-             " really %d.",pVersionInfo->dwMajorVersion);
-    }
-
-    /* The minor version values for Win2k and XP are different 
-       for Win2k minor version equals 0 and for XP minor version
-       equals 1.  Both values are excepted here. */
-    if((pVersionInfo->dwMinorVersion != 0) && 
-       (pVersionInfo->dwMinorVersion != 1)) 
-    {
-        Fail("ERROR: The fixed value of dwMinorVersion shoud be 0 or 1, "
-             "but is really %d.",pVersionInfo->dwMinorVersion);
-    }
-
-    if(pVersionInfo->dwBuildNumber_PAL_Undefined < 0) 
-    {
-        Fail("ERROR: The value of dwBuildNumber shoud be at least 0, but is "
-             "really %d.",pVersionInfo->dwBuildNumber_PAL_Undefined);
-    }
-
-#if !WIN32
-
-
-    /* Under BSD, the PlatformID should be UNIX and the Service Pack
-       version should be set to "".
-    */
-
-    if(pVersionInfo->dwPlatformId != VER_PLATFORM_UNIX ||
-       pVersionInfo->szCSDVersion_PAL_Undefined[0] != 0) 
-    {
-        Fail("ERROR: The dwPlatformId should be %d but is really %d.  And the "
-             "szCSDVerion should be NULL.",VER_PLATFORM_UNIX,
-             pVersionInfo->dwPlatformId);
-    }
-#endif
-  
-    
-    PAL_Terminate();
-    return PASS;
-}
-
-
-
diff --git a/src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetVersionExW/test1/testinfo.dat
deleted file mode 100644 (file)
index 7773245..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = Miscellaneous
-Function = GetVersionExW
-Name = Positive Test for GetVersionExW
-TYPE = DEFAULT
-EXE1 = test
-Description
-= Test that all the values in the OSVERSION structure are set properly
-= for the current environment.
-
-
-
index f7a293a..3f9469d 100644 (file)
@@ -144,8 +144,6 @@ miscellaneous/GetDateFormatW/GetDateFormatW_neg1/paltest_getdateformatw_getdatef
 miscellaneous/GetDateFormatW/GetDateFormatW_neg2/paltest_getdateformatw_getdateformatw_neg2
 miscellaneous/GetDateFormatW/test1/paltest_getdateformatw_test1
 miscellaneous/GetUserNameW/test1/paltest_getusernamew_test1
-miscellaneous/GetVersionExA/test1/paltest_getversionexa_test1
-miscellaneous/GetVersionExW/test1/paltest_getversionexw_test1
 miscellaneous/InterLockedExchangeAdd/test1/paltest_interlockedexchangeadd_test1
 miscellaneous/IsBadCodePtr/test1/paltest_isbadcodeptr_test1
 miscellaneous/IsBadReadPtr/test1/paltest_isbadreadptr_test1
index 27b7a4a..dfe830d 100644 (file)
@@ -1,10 +1,6 @@
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
-if(WIN32)
-    add_compile_options(/wd4996)
-endif(WIN32)
-
 set(UTILCODE_COMMON_SOURCES
   clrhost_nodependencies.cpp
   ccomprc.cpp
index 602ccc9..6aa11df 100644 (file)
@@ -3396,24 +3396,4 @@ void ContractRegressionCheck()
 
 #endif // ENABLE_CONTRACTS_IMPL
 
-
 #endif // CROSSGEN_COMPILE
-
-
-//
-// GetOSVersion - Gets the real OS version bypassing the OS compatibility shim
-// Mscoree.dll resides in System32 dir and is always excluded from compat shim.
-// This function calls mscoree!shim function via mscoreei ICLRRuntimeHostInternal interface
-// to get the OS version. We do not do this PAL or coreclr..we direclty call the OS
-// in that case.
-//
-BOOL GetOSVersion(LPOSVERSIONINFO lposVer)
-{
-// Fix for warnings when building against WinBlue build 9444.0.130614-1739
-// warning C4996: 'GetVersionExW': was declared deprecated
-// externalapis\windows\winblue\sdk\inc\sysinfoapi.h(442)
-// Deprecated. Use VerifyVersionInfo* or IsWindows* macros from VersionHelpers.
-#pragma warning( disable : 4996 )
-    return WszGetVersionEx(lposVer);
-#pragma warning( default : 4996 )
-}
index 253ebbb..2193c5a 100644 (file)
@@ -2418,14 +2418,11 @@ void DomainAssembly::GetCurrentVersionInfo(CORCOMPILE_VERSION_INFO *pNativeVersi
                                           &fForceProfiling,
                                           &fForceInstrument);
 
-    OSVERSIONINFOW osInfo;
-    osInfo.dwOSVersionInfoSize = sizeof(osInfo);
-    if (!GetOSVersion(&osInfo))
-        _ASSERTE(!"GetOSVersion failed");
-
-    _ASSERTE(osInfo.dwMajorVersion < 999);
-    _ASSERTE(osInfo.dwMinorVersion < 999);
-    pNativeVersionInfo->wOSPlatformID = (WORD) osInfo.dwPlatformId;
+#ifndef FEATURE_PAL 
+    pNativeVersionInfo->wOSPlatformID = VER_PLATFORM_WIN32_NT;
+#else
+    pNativeVersionInfo->wOSPlatformID = VER_PLATFORM_UNIX;
+#endif    
 
     // The native images should be OS-version agnostic. Do not store the actual OS version for determinism.
     // pNativeVersionInfo->wOSMajorVersion = (WORD) osInfo.dwMajorVersion;
index ad73135..415926e 100644 (file)
@@ -170,8 +170,6 @@ FCFuncStart(gDateTimeFuncs)
 FCFuncEnd()
 
 FCFuncStart(gEnvironmentFuncs)
-    FCFuncElement("GetVersion", SystemNative::GetOSVersion)
-    FCFuncElement("GetVersionEx", SystemNative::GetOSVersionEx)
     FCFuncElement("get_TickCount", SystemNative::GetTickCount)
     QCFuncElement("_Exit", SystemNative::Exit)
     FCFuncElement("set_ExitCode", SystemNative::SetExitCode)
@@ -181,7 +179,7 @@ FCFuncStart(gEnvironmentFuncs)
     FCFuncElement("GetCommandLineArgsNative", SystemNative::GetCommandLineArgs)
     FCFuncElement("get_CurrentProcessorNumber", SystemNative::GetCurrentProcessorNumber)
 
-#if defined(FEATURE_COMINTEROP) && !defined(FEATURE_CORESYSTEM)
+#if defined(FEATURE_COMINTEROP)
     QCFuncElement("WinRTSupported", SystemNative::WinRTSupported)
 #endif // FEATURE_COMINTEROP
     FCFuncElementSig("FailFast", &gsig_SM_Str_RetVoid, SystemNative::FailFast)
index b708f17..1eb8938 100644 (file)
@@ -4310,27 +4310,6 @@ HRESULT ETW::CEtwTracer::Register()
 {
     WRAPPER_NO_CONTRACT;
 
-#ifndef FEATURE_CORESYSTEM
-    OSVERSIONINFO osVer;
-    osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-
-    if (GetOSVersion(&osVer) == FALSE) {
-        return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
-    }
-    else if (osVer.dwMajorVersion < ETW_SUPPORTED_MAJORVER) {
-        return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
-    }
-
-    // if running on OS < Longhorn, skip registration unless reg key is set
-    // since ETW reg is expensive (in both time and working set) on older OSes
-    if (osVer.dwMajorVersion < ETW_ENABLED_MAJORVER && !g_fEnableETW && !CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_PreVistaETWEnabled))
-        return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
-
-    // If running on OS >= Longhorn, skip registration if ETW is not enabled
-    if (osVer.dwMajorVersion >= ETW_ENABLED_MAJORVER && !g_fEnableETW && !CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_VistaAndAboveETWEnabled))
-        return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
-#endif
-
     EventRegisterMicrosoft_Windows_DotNETRuntime();
     EventRegisterMicrosoft_Windows_DotNETRuntimePrivate();
     EventRegisterMicrosoft_Windows_DotNETRuntimeRundown();
index 248deac..9708a6f 100644 (file)
@@ -9917,15 +9917,12 @@ void CEEInfo::getEEInfo(CORINFO_EE_INFO *pEEInfoOut)
     pEEInfoOut->maxUncheckedOffsetForNullObject = MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT;
     pEEInfoOut->targetAbi = CORINFO_CORECLR_ABI;
 
-    OSVERSIONINFO   sVerInfo;
-    sVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    GetOSVersion(&sVerInfo);
-
     pEEInfoOut->osType = CORINFO_WINNT;
 
-    pEEInfoOut->osMajor = sVerInfo.dwMajorVersion;
-    pEEInfoOut->osMinor = sVerInfo.dwMinorVersion;
-    pEEInfoOut->osBuild = sVerInfo.dwBuildNumber;
+    // hardcode OS version to 0.0.0. These fields can be removed from JITEE interface
+    pEEInfoOut->osMajor = 0;
+    pEEInfoOut->osMinor = 0;
+    pEEInfoOut->osBuild = 0;
 
     EE_TO_JIT_TRANSITION();
 }