diff --git a/src/coreclr/dlls/mscoree/CMakeLists.txt b/src/coreclr/dlls/mscoree/CMakeLists.txt index 785655763d5d91..ddd67bdc0b574a 100644 --- a/src/coreclr/dlls/mscoree/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/CMakeLists.txt @@ -11,10 +11,8 @@ set(CLR_SOURCES if(CLR_CMAKE_TARGET_WIN32) list(APPEND CLR_SOURCES - ${CLR_SRC_NATIVE_DIR}/libs/Common/delayloadhook_windows.cpp - Native.rc + Native.rc ) - set (DEF_SOURCES mscorwks_ntdef.src ) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 40de140098a0e8..ce7ca2870fb840 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -21,12 +21,6 @@ if (CLR_CMAKE_HOST_WIN32) # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page). add_linker_flag("/INCREMENTAL:NO") - # Delay load libraries required for WinRT as that is not supported on all platforms - add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") - - # Delay load version.dll so that we can specify how to search when loading it as it is not part of Windows' known DLLs - add_linker_flag("/DELAYLOAD:version.dll") - # No library groups for Win32 set(START_LIBRARY_GROUP) set(END_LIBRARY_GROUP) @@ -131,7 +125,6 @@ if(CLR_CMAKE_TARGET_WIN32) shlwapi.lib bcrypt.lib RuntimeObject.lib - delayimp.lib ) else() list(APPEND CORECLR_LIBRARIES diff --git a/src/coreclr/inc/ostype.h b/src/coreclr/inc/ostype.h index 53f606af6b0804..45678284f47229 100644 --- a/src/coreclr/inc/ostype.h +++ b/src/coreclr/inc/ostype.h @@ -12,49 +12,6 @@ #define LIMITED_METHOD_CONTRACT #endif -//***************************************************************************** -// Enum to track which version of the OS we are running -// Note that Win7 is the minimum supported platform. Any code using -// utilcode (which includes the CLR's execution engine) will fail to start -// on a pre-Win7 platform. This is enforced by InitRunningOnVersionStatus. -//***************************************************************************** -typedef enum { - RUNNING_ON_STATUS_UNINITED = 0, - RUNNING_ON_WIN7 = 1, - RUNNING_ON_WIN8 = 2 -} RunningOnStatusEnum; - -extern RunningOnStatusEnum gRunningOnStatus; - -void InitRunningOnVersionStatus(); - -//***************************************************************************** -// Returns true if you are running on Windows 8 or newer. -//***************************************************************************** -inline BOOL RunningOnWin8() -{ - WRAPPER_NO_CONTRACT; -#if (!defined(HOST_X86) && !defined(HOST_AMD64)) - return TRUE; -#else - if (gRunningOnStatus == RUNNING_ON_STATUS_UNINITED) - { - InitRunningOnVersionStatus(); - } - - return (gRunningOnStatus >= RUNNING_ON_WIN8) ? TRUE : FALSE; -#endif -} - -#ifdef FEATURE_COMINTEROP - -inline BOOL WinRTSupported() -{ - return RunningOnWin8(); -} - -#endif // FEATURE_COMINTEROP - #ifdef HOST_64BIT inline BOOL RunningInWow64() { diff --git a/src/coreclr/utilcode/util_nodependencies.cpp b/src/coreclr/utilcode/util_nodependencies.cpp index 6f67c3160b2c23..1b2f1cd9dd82c1 100644 --- a/src/coreclr/utilcode/util_nodependencies.cpp +++ b/src/coreclr/utilcode/util_nodependencies.cpp @@ -14,43 +14,8 @@ #include "utilcode.h" #include "ex.h" -#ifdef HOST_WINDOWS -#include -#endif - #if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES) || defined(_DEBUG) -RunningOnStatusEnum gRunningOnStatus = RUNNING_ON_STATUS_UNINITED; - -#define NON_SUPPORTED_PLATFORM_TERMINATE_ERROR_CODE 0xBAD1BAD1 - -//***************************************************************************** -// One time initialization of the OS version -//***************************************************************************** -void InitRunningOnVersionStatus () -{ -#ifdef HOST_WINDOWS - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - - if(IsWindows8OrGreater()) - { - gRunningOnStatus = RUNNING_ON_WIN8; - } - else if(IsWindows7OrGreater()) - { - gRunningOnStatus = RUNNING_ON_WIN7; - } - else - { - // The current platform isn't supported. Display a message to this effect and exit. - minipal_log_print_error("Platform not supported: Windows 7 is the minimum supported version\n"); - TerminateProcess(GetCurrentProcess(), NON_SUPPORTED_PLATFORM_TERMINATE_ERROR_CODE); - } -#endif // HOST_WINDOWS -} // InitRunningOnVersionStatus - #ifndef HOST_64BIT //------------------------------------------------------------------------------ // Returns TRUE if we are running on a 64-bit OS in WoW, FALSE otherwise. diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 48881d47a64d67..271fbf631ad979 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -2363,7 +2363,6 @@ void Thread::BaseWinRTUninitialize() STATIC_CONTRACT_GC_TRIGGERS; STATIC_CONTRACT_MODE_PREEMPTIVE; - _ASSERTE(WinRTSupported()); _ASSERTE(GetThread() == this); _ASSERTE(IsWinRTInitialized()); @@ -2401,7 +2400,6 @@ void Thread::CoUninitialize() #ifdef FEATURE_COMINTEROP if (IsWinRTInitialized()) { - _ASSERTE(WinRTSupported()); BaseWinRTUninitialize(); ResetWinRTInitialized(); } @@ -2612,7 +2610,6 @@ void Thread::CleanupCOMState() #ifdef FEATURE_COMINTEROP if (IsWinRTInitialized()) { - _ASSERTE(WinRTSupported()); BaseWinRTUninitialize(); ResetWinRTInitialized(); } @@ -3783,7 +3780,6 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state) #ifdef FEATURE_COMINTEROP if (IsWinRTInitialized()) { - _ASSERTE(WinRTSupported()); BaseWinRTUninitialize(); ResetWinRTInitialized(); } @@ -3875,10 +3871,10 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state) _ASSERTE(!"Unexpected HRESULT returned from CoInitializeEx!"); } - // If WinRT is supported on this OS, also initialize it at the same time. Since WinRT sits on top of COM - // we need to make sure that it is initialized in the same threading mode as we just started COM itself + // Since WinRT sits on top of COM we need to make sure that it is initialized + // in the same threading mode as we just started COM itself // with (or that we detected COM had already been started with). - if (WinRTSupported() && !IsWinRTInitialized()) + if (!IsWinRTInitialized()) { GCX_PREEMP(); diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 94937ca5139628..928180b8ecdcb2 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -61,7 +61,6 @@ if(CLR_CMAKE_TARGET_WIN32) add_compile_definitions(UNICODE) list(APPEND SOURCES ../apphost.windows.cpp - ${CLR_SRC_NATIVE_DIR}/libs/Common/delayloadhook_windows.cpp ) list(APPEND HEADERS @@ -119,12 +118,6 @@ if(CLR_CMAKE_TARGET_WIN32) # Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page). add_linker_flag("/INCREMENTAL:NO") - - # Delay load libraries required for WinRT as that is not supported on all platforms - add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") - - # Delay load version.dll so that we can specify how to search when loading it as it is not part of Windows' known DLLs - add_linker_flag("/DELAYLOAD:version.dll") endif() if(CLR_CMAKE_TARGET_WIN32) @@ -145,7 +138,6 @@ if(CLR_CMAKE_TARGET_WIN32) shell32.lib bcrypt.lib RuntimeObject.lib - delayimp.lib ) # additional requirements for System.IO.Compression.Native @@ -309,4 +301,4 @@ add_sanitizer_runtime_support(singlefilehost) if (CLR_CMAKE_HOST_APPLE) adhoc_sign_with_entitlements(singlefilehost "${CLR_ENG_NATIVE_DIR}/entitlements.plist") -endif() \ No newline at end of file +endif() diff --git a/src/native/libs/Common/delayloadhook_windows.cpp b/src/native/libs/Common/delayloadhook_windows.cpp deleted file mode 100644 index 4e286cc69a5861..00000000000000 --- a/src/native/libs/Common/delayloadhook_windows.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// -// File: delayloadhook.cpp -// - -#include -#include - -FARPROC WINAPI secureDelayHook(unsigned dliNotify, PDelayLoadInfo pdli) -{ - if (dliNotify == dliNotePreLoadLibrary) - { - // Use a safe search path to avoid delay load dll hijacking - return (FARPROC)::LoadLibraryExA(pdli->szDll, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); - } - - return nullptr; -} - -// See https://learn.microsoft.com/cpp/build/reference/notification-hooks -// This global hook is called prior to all the delay load LoadLibrary/GetProcAddress/etc. calls -// Hooking this callback allows us to ensure that delay load LoadLibrary calls -// specify the LOAD_LIBRARY_SEARCH_SYSTEM32 search path -const PfnDliHook __pfnDliNotifyHook2 = secureDelayHook;