From 5f16cfcbf808e7879f5916e9a8366faea87cf7ae Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sat, 7 Jun 2025 13:16:37 -0700 Subject: [PATCH 1/3] Delete extra layer of metadata APIs Delegate extra layer of coreclr directory caching --- src/coreclr/binder/utils.cpp | 2 + src/coreclr/debug/daccess/daccess.cpp | 1 - src/coreclr/debug/daccess/task.cpp | 14 -- src/coreclr/debug/di/cordb.cpp | 1 - src/coreclr/debug/di/module.cpp | 28 +-- src/coreclr/debug/di/process.cpp | 1 - src/coreclr/dlls/mscoree/mscoree.cpp | 220 +----------------- src/coreclr/ilasm/main.cpp | 1 - src/coreclr/ilasm/writer.cpp | 2 - src/coreclr/ildasm/dasm.cpp | 1 - src/coreclr/ildasm/dman.cpp | 2 - src/coreclr/inc/cor.h | 8 - src/coreclr/inc/corpriv.h | 40 ++-- src/coreclr/inc/metadataexports.h | 53 ----- src/coreclr/inc/shimload.h | 26 --- src/coreclr/inc/utilcode.h | 12 - src/coreclr/md/compiler/regmeta.cpp | 14 +- src/coreclr/nativeaot/Runtime/amd64/GcProbe.S | 1 - .../nativeaot/Runtime/amd64/GcProbe.asm | 1 - src/coreclr/vm/appdomain.cpp | 16 +- src/coreclr/vm/appdomain.hpp | 30 --- src/coreclr/vm/assembly.cpp | 2 - src/coreclr/vm/ceeload.cpp | 1 - src/coreclr/vm/ceemain.cpp | 83 ------- src/coreclr/vm/codeman.cpp | 1 - src/coreclr/vm/disassembler.cpp | 8 +- src/coreclr/vm/encee.cpp | 2 +- src/coreclr/vm/excep.cpp | 1 - src/coreclr/vm/gcheaputilities.cpp | 3 +- src/coreclr/vm/nativeimage.cpp | 10 +- src/coreclr/vm/peassembly.cpp | 18 +- src/coreclr/vm/peimage.cpp | 20 +- src/coreclr/vm/proftoeeinterfaceimpl.cpp | 2 - src/coreclr/vm/readytoruninfo.cpp | 10 +- src/coreclr/vm/reflectclasswriter.cpp | 8 +- src/coreclr/vm/rtlfunctions.cpp | 30 +-- 36 files changed, 64 insertions(+), 609 deletions(-) delete mode 100644 src/coreclr/inc/metadataexports.h delete mode 100644 src/coreclr/inc/shimload.h diff --git a/src/coreclr/binder/utils.cpp b/src/coreclr/binder/utils.cpp index f1b916ec9dc1ab..babc413f171bd6 100644 --- a/src/coreclr/binder/utils.cpp +++ b/src/coreclr/binder/utils.cpp @@ -18,6 +18,8 @@ #include "clr/fs/path.h" using namespace clr::fs; +BOOL RuntimeFileNotFound(HRESULT hr); + namespace BINDER_SPACE { namespace diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 23fb000ed2c349..14e7cc8371f594 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -17,7 +17,6 @@ #include "peimagelayout.inl" #include "datatargetadapter.h" #include "readonlydatatargetfacade.h" -#include "metadataexports.h" #include "excep.h" #include "debugger.h" #include "dwreport.h" diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index 1cb002c9ec0faf..def99a1e10da74 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -11,20 +11,6 @@ #include "stdafx.h" -// XXX Microsoft - Why aren't these extra MD APIs in a header? -STDAPI GetMDPublicInterfaceFromInternal( - void *pIUnkPublic, // [IN] Given scope. - REFIID riid, // [in] The interface desired. - void **ppIUnkInternal); // [out] Return interface on success. - -STDAPI GetMetaDataPublicInterfaceFromInternal( - void *pv, // [IN] Given interface. - REFIID riid, // [IN] desired interface. - void **ppv) // [OUT] returned interface -{ - return GetMDPublicInterfaceFromInternal(pv, riid, ppv); -} - //---------------------------------------------------------------------------- // // ClrDataTask. diff --git a/src/coreclr/debug/di/cordb.cpp b/src/coreclr/debug/di/cordb.cpp index d83d9f921023eb..d7d3957ec7db26 100644 --- a/src/coreclr/debug/di/cordb.cpp +++ b/src/coreclr/debug/di/cordb.cpp @@ -13,7 +13,6 @@ #include "classfactory.h" #include "corsym.h" #include "contract.h" -#include "metadataexports.h" #if defined(FEATURE_DBGIPC_TRANSPORT_DI) #include "dbgtransportsession.h" #include "dbgtransportmanager.h" diff --git a/src/coreclr/debug/di/module.cpp b/src/coreclr/debug/di/module.cpp index 4c0983f5e98b1c..61ddfd18fc537f 100644 --- a/src/coreclr/debug/di/module.cpp +++ b/src/coreclr/debug/di/module.cpp @@ -10,8 +10,6 @@ #include "stdafx.h" #include "winbase.h" -#include "metadataexports.h" - #include "winbase.h" #include "corpriv.h" #include "corsym.h" @@ -19,30 +17,6 @@ #include "pedecoder.h" #include "stgpool.h" -//--------------------------------------------------------------------------------------- -// Update an existing metadata importer with a buffer -// -// Arguments: -// pUnk - IUnknoown of importer to update. -// pData - local buffer containing new metadata -// cbData - size of buffer in bytes. -// dwReOpenFlags - metadata flags to pass for reopening. -// -// Returns: -// S_OK on success. Else failure. -// -// Notes: -// This will call code:MDReOpenMetaDataWithMemoryEx from the metadata engine. -STDAPI ReOpenMetaDataWithMemoryEx( - void *pUnk, - LPCVOID pData, - ULONG cbData, - DWORD dwReOpenFlags) -{ - HRESULT hr = MDReOpenMetaDataWithMemoryEx(pUnk,pData, cbData, dwReOpenFlags); - return hr; -} - //--------------------------------------------------------------------------------------- // Initialize a new CordbModule around a Module in the target. // @@ -1063,7 +1037,7 @@ void CordbModule::UpdatePublicMetaDataFromRemote(TargetBuffer bufferRemoteMetaDa // Now tell our current IMetaDataImport object to re-initialize by swapping in the new memory block. // This allows us to keep manipulating metadata objects on other threads without crashing. // This will also invalidate an existing associated Internal MetaData. - hr = ReOpenMetaDataWithMemoryEx(m_pIMImport, pLocalMetaDataPtr, dwMetaDataSize, ofTakeOwnership ); + hr = MDReOpenMetaDataWithMemory(m_pIMImport, pLocalMetaDataPtr, dwMetaDataSize, ofTakeOwnership ); IfFailThrow(hr); // Success. MetaData now owns the metadata memory diff --git a/src/coreclr/debug/di/process.cpp b/src/coreclr/debug/di/process.cpp index e76546d19007bd..da0c9b841c7ed6 100644 --- a/src/coreclr/debug/di/process.cpp +++ b/src/coreclr/debug/di/process.cpp @@ -26,7 +26,6 @@ // @dbgtodo shim: process has some private hooks into the shim. #include "shimpriv.h" -#include "metadataexports.h" #include "readonlydatatargetfacade.h" #include "metahost.h" diff --git a/src/coreclr/dlls/mscoree/mscoree.cpp b/src/coreclr/dlls/mscoree/mscoree.cpp index af6130bfdbb600..19be0938f52781 100644 --- a/src/coreclr/dlls/mscoree/mscoree.cpp +++ b/src/coreclr/dlls/mscoree/mscoree.cpp @@ -6,16 +6,7 @@ #include "stdafx.h" // Standard header. #include // Utility helpers. -#include // Error handlers -#define INIT_GUIDS #include -#include -#include -#include "shimload.h" -#include "metadataexports.h" -#include "ex.h" - -#include #if !defined(CORECLR_EMBEDDED) @@ -45,18 +36,16 @@ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) #endif // !defined(CORECLR_EMBEDDED) -extern void* GetClrModuleBase(); - // --------------------------------------------------------------------------- // %%Function: MetaDataGetDispenser // This function gets the Dispenser interface given the CLSID and REFIID. +// Exported from coreclr and used by external profilers. // --------------------------------------------------------------------------- -STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT +STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT REFCLSID rclsid, // The class to desired. REFIID riid, // Interface wanted on class factory. LPVOID FAR *ppv) // Return interface pointer here. { - CONTRACTL { NOTHROW; GC_NOTRIGGER; @@ -69,208 +58,3 @@ STDAPI DLLEXPORT MetaDataGetDispenser( // Return HRESULT return CreateMetaDataDispenser(riid, ppv); } - -// --------------------------------------------------------------------------- -// %%Function: GetMetaDataInternalInterface -// This function gets the IMDInternalImport given the metadata on memory. -// --------------------------------------------------------------------------- -STDAPI DLLEXPORT GetMetaDataInternalInterface( - LPVOID pData, // [IN] in memory metadata section - ULONG cbData, // [IN] size of the metadata section - DWORD flags, // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC - REFIID riid, // [IN] desired interface - void **ppv) // [OUT] returned interface -{ - CONTRACTL{ - NOTHROW; - GC_NOTRIGGER; - ENTRY_POINT; - PRECONDITION(CheckPointer(pData)); - PRECONDITION(CheckPointer(ppv)); - } CONTRACTL_END; - - return GetMDInternalInterface(pData, cbData, flags, riid, ppv); -} - -// --------------------------------------------------------------------------- -// %%Function: GetMetaDataInternalInterfaceFromPublic -// This function gets the internal scopeless interface given the public -// scopeless interface. -// --------------------------------------------------------------------------- -STDAPI DLLEXPORT GetMetaDataInternalInterfaceFromPublic( - IUnknown *pv, // [IN] Given interface. - REFIID riid, // [IN] desired interface - void **ppv) // [OUT] returned interface -{ - CONTRACTL{ - NOTHROW; - GC_NOTRIGGER; - ENTRY_POINT; - PRECONDITION(CheckPointer(pv)); - PRECONDITION(CheckPointer(ppv)); - } CONTRACTL_END; - - return GetMDInternalInterfaceFromPublic(pv, riid, ppv); -} - -// --------------------------------------------------------------------------- -// %%Function: GetMetaDataPublicInterfaceFromInternal -// This function gets the public scopeless interface given the internal -// scopeless interface. -// --------------------------------------------------------------------------- -STDAPI DLLEXPORT GetMetaDataPublicInterfaceFromInternal( - void *pv, // [IN] Given interface. - REFIID riid, // [IN] desired interface. - void **ppv) // [OUT] returned interface -{ - CONTRACTL{ - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(pv)); - PRECONDITION(CheckPointer(ppv)); - ENTRY_POINT; - } CONTRACTL_END; - - return GetMDPublicInterfaceFromInternal(pv, riid, ppv); -} - - -// --------------------------------------------------------------------------- -// %%Function: ReopenMetaDataWithMemory -// This function gets the public scopeless interface given the internal -// scopeless interface. -// --------------------------------------------------------------------------- -STDAPI ReOpenMetaDataWithMemory( - void *pUnk, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData) // [in] Size of the data pointed to by pData. -{ - CONTRACTL{ - NOTHROW; - GC_NOTRIGGER; - ENTRY_POINT; - PRECONDITION(CheckPointer(pUnk)); - PRECONDITION(CheckPointer(pData)); - } CONTRACTL_END; - - return MDReOpenMetaDataWithMemory(pUnk, pData, cbData); -} - -// --------------------------------------------------------------------------- -// %%Function: ReopenMetaDataWithMemoryEx -// This function gets the public scopeless interface given the internal -// scopeless interface. -// --------------------------------------------------------------------------- -STDAPI ReOpenMetaDataWithMemoryEx( - void *pUnk, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData, // [in] Size of the data pointed to by pData. - DWORD dwReOpenFlags) // [in] ReOpen flags -{ - CONTRACTL{ - NOTHROW; - GC_NOTRIGGER; - ENTRY_POINT; - PRECONDITION(CheckPointer(pUnk)); - PRECONDITION(CheckPointer(pData)); - } CONTRACTL_END; - - return MDReOpenMetaDataWithMemoryEx(pUnk, pData, cbData, dwReOpenFlags); -} - -static DWORD g_dwSystemDirectory = 0; -static WCHAR * g_pSystemDirectory = NULL; - -HRESULT GetInternalSystemDirectory(_Out_writes_to_opt_(*pdwLength,*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength) -{ - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(buffer, NULL_OK)); - PRECONDITION(CheckPointer(pdwLength)); - } CONTRACTL_END; - - if (g_dwSystemDirectory == 0) - SetInternalSystemDirectory(); - - // - // g_dwSystemDirectory includes the NULL in its count! - // - if(*pdwLength < g_dwSystemDirectory) - { - *pdwLength = g_dwSystemDirectory; - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - - if (buffer != NULL) - { - // - // wcsncpy_s will automatically append a null and g_dwSystemDirectory - // includes the null in its count, so we have to subtract 1. - // - wcsncpy_s(buffer, *pdwLength, g_pSystemDirectory, g_dwSystemDirectory-1); - } - *pdwLength = g_dwSystemDirectory; - return S_OK; -} - - -LPCWSTR GetInternalSystemDirectory(_Out_ DWORD* pdwLength) -{ - LIMITED_METHOD_CONTRACT; - - if (g_dwSystemDirectory == 0) - { - SetInternalSystemDirectory(); - } - - if (pdwLength != NULL) - { - * pdwLength = g_dwSystemDirectory; - } - - return g_pSystemDirectory; -} - - -HRESULT SetInternalSystemDirectory() - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - } CONTRACTL_END; - - HRESULT hr = S_OK; - if(g_dwSystemDirectory == 0) { - - DWORD len = 0; - NewArrayHolder pSystemDirectory; - EX_TRY{ - - // use local buffer for thread safety - PathString wzSystemDirectory; - hr = GetClrModuleDirectory(wzSystemDirectory); - - if (FAILED(hr)) { - wzSystemDirectory.Set(W('\0')); - } - - pSystemDirectory = wzSystemDirectory.GetCopyOfUnicodeString(); - if (pSystemDirectory == NULL) - { - hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY); - } - len = wzSystemDirectory.GetCount() + 1; - - } - EX_CATCH_HRESULT(hr); - - // publish results idempotently with correct memory ordering - g_pSystemDirectory = pSystemDirectory.Extract(); - - (void)InterlockedExchange((LONG *)&g_dwSystemDirectory, len); - } - - return hr; -} - diff --git a/src/coreclr/ilasm/main.cpp b/src/coreclr/ilasm/main.cpp index da5fecb405b977..58e0ee7573aa69 100644 --- a/src/coreclr/ilasm/main.cpp +++ b/src/coreclr/ilasm/main.cpp @@ -9,7 +9,6 @@ #include "asmparse.h" #include "clrversion.h" -#include "shimload.h" #include "strsafe.h" #define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS((expr)) diff --git a/src/coreclr/ilasm/writer.cpp b/src/coreclr/ilasm/writer.cpp index 10e65d9a9119dd..e718839a8664e9 100644 --- a/src/coreclr/ilasm/writer.cpp +++ b/src/coreclr/ilasm/writer.cpp @@ -11,8 +11,6 @@ #include "ceefilegenwriter.h" #include "sha256.h" -#include "metadataexports.h" - #ifndef _MSC_VER //cloned definition from ntimage.h that is removed for non MSVC builds typedef VOID diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index f0e2755f29ab66..f6a9be411edea4 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -12,7 +12,6 @@ #include #include "formattype.h" #include "readytorun.h" -#include "metadataexports.h" #define DECLARE_DATA #include "dasmenum.hpp" diff --git a/src/coreclr/ildasm/dman.cpp b/src/coreclr/ildasm/dman.cpp index 196ba6c4e7bca0..d6409243d161ec 100644 --- a/src/coreclr/ildasm/dman.cpp +++ b/src/coreclr/ildasm/dman.cpp @@ -16,8 +16,6 @@ #include "dynamicarray.h" #include "resource.h" -#include "metadataexports.h" - #ifndef MAX_LOCALE_NAME #define MAX_LOCALE_NAME (32) #endif diff --git a/src/coreclr/inc/cor.h b/src/coreclr/inc/cor.h index ab598f2ac348e0..d4fe6b0275a0d2 100644 --- a/src/coreclr/inc/cor.h +++ b/src/coreclr/inc/cor.h @@ -121,24 +121,16 @@ typedef UNALIGNED void const *UVCP_CONSTANT; //***************************************************************************** -// -#ifndef _WINDOWS_UPDATES_ #include -#endif // updates //***************************************************************************** //***************************************************************************** -// CLSID_Cor: {bee00000-ee77-11d0-a015-00c04fbbb884} -EXTERN_GUID(CLSID_Cor, 0xbee00010, 0xee77, 0x11d0, 0xa0, 0x15, 0x00, 0xc0, 0x4f, 0xbb, 0xb8, 0x84); - // CLSID_CorMetaDataDispenser: {E5CB7A31-7512-11d2-89CE-0080C792E5D8} // This is the "Master Dispenser", always guaranteed to be the most recent // dispenser on the machine. EXTERN_GUID(CLSID_CorMetaDataDispenser, 0xe5cb7a31, 0x7512, 0x11d2, 0x89, 0xce, 0x0, 0x80, 0xc7, 0x92, 0xe5, 0xd8); -interface IMetaDataDispenser; - //------------------------------------- //--- IMetaDataError //------------------------------------- diff --git a/src/coreclr/inc/corpriv.h b/src/coreclr/inc/corpriv.h index a1fe03bfe3863f..8086a3f9cb580b 100644 --- a/src/coreclr/inc/corpriv.h +++ b/src/coreclr/inc/corpriv.h @@ -12,21 +12,17 @@ #include "cor.h" #include "corimage.h" #include "metadata.h" -#include class UTSemReadWrite; -// Helper function to get a pointer to the Dispenser interface. -STDAPI MetaDataGetDispenser( // Return HRESULT - REFCLSID rclsid, // The class to desired. - REFIID riid, // Interface wanted on class factory. - LPVOID FAR *ppv); // Return interface pointer here. - -BOOL RuntimeFileNotFound(HRESULT hr); +// Creation function to get IMetaDataDispenser(Ex) interface. +STDAPI CreateMetaDataDispenser( + REFIID riid, + void ** pMetaDataDispenserOut); // Helper function to get an Internal interface with an in-memory metadata section -STDAPI GetMetaDataInternalInterface( +STDAPI GetMDInternalInterface( LPVOID pData, // [IN] in memory metadata section ULONG cbData, // [IN] size of the metadata section DWORD flags, // [IN] CorOpenFlags @@ -34,13 +30,13 @@ STDAPI GetMetaDataInternalInterface( void **ppv); // [OUT] returned interface // Helper function to get an internal scopeless interface given a scope. -STDAPI GetMetaDataInternalInterfaceFromPublic( +STDAPI GetMDInternalInterfaceFromPublic( IUnknown *pv, // [IN] Given interface REFIID riid, // [IN] desired interface void **ppv); // [OUT] returned interface // Helper function to get an internal scopeless interface given a scope. -STDAPI GetMetaDataPublicInterfaceFromInternal( +STDAPI GetMDPublicInterfaceFromInternal( void *pv, // [IN] Given interface REFIID riid, // [IN] desired interface void **ppv); // [OUT] returned interface @@ -52,16 +48,12 @@ STDAPI ConvertMDInternalImport( // S_OK or error. IMDInternalImport *pIMD, // [IN] The metadata to be updated. IMDInternalImport **ppIMD); // [OUT] Put RW interface here. -STDAPI GetAssemblyMDInternalImport( // Return code. - LPCWSTR szFileName, // [IN] The scope to open. - REFIID riid, // [IN] The interface desired. - IUnknown **ppIUnk); // [OUT] Return interface on success. - -STDAPI GetAssemblyMDInternalImportByStream( // Return code. - IStream *pIStream, // [IN] The IStream for the file - UINT64 AssemblyId, // [IN] Unique Id for the assembly - REFIID riid, // [IN] The interface desired. - IUnknown **ppIUnk); // [OUT] Return interface on success. +// Update an existing metadata importer with a buffer +STDAPI MDReOpenMetaDataWithMemory( + void *pImport, // [IN] Given scope. public interfaces + LPCVOID pData, // [in] Location of scope data. + ULONG cbData, // [in] Size of the data pointed to by pData. + DWORD dwReOpenFlags); // [in] ReOpen flags enum MDInternalImportFlags @@ -74,10 +66,6 @@ enum MDInternalImportFlags }; // enum MDInternalImportFlags - -class CQuickBytes; - - // predefined constant for parent token for global functions #define COR_GLOBAL_PARENT_TOKEN TokenFromRid(1, mdtTypeDef) @@ -368,7 +356,7 @@ DECLARE_INTERFACE_(ICeeGenInternal, IUnknown) // Private interface exposed by // AssemblyMDInternalImport - gives us access to the internally stored IMDInternalImport*. // -// RegMeta - supports the internal GetMetaDataInternalInterfaceFromPublic() "api". +// RegMeta - supports the internal GetMDInternalInterfaceFromPublic() "api". // // {92B2FEF9-F7F5-420d-AD42-AECEEE10A1EF} EXTERN_GUID(IID_IGetIMDInternalImport, 0x92b2fef9, 0xf7f5, 0x420d, 0xad, 0x42, 0xae, 0xce, 0xee, 0x10, 0xa1, 0xef); diff --git a/src/coreclr/inc/metadataexports.h b/src/coreclr/inc/metadataexports.h deleted file mode 100644 index 21050611b00750..00000000000000 --- a/src/coreclr/inc/metadataexports.h +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -//***************************************************************************** -// MDCommon.h -// - -// -// Header for functions exported by metadata. These are consumed 2 ways: -// 1. Mscoree provides public exports that plumb to some of these functions to invoke these dynamically. -// 2. Standalone metadata (statically linked) -// -//***************************************************************************** - - -#ifndef _METADATA_EXPORTS_ -#define _METADATA_EXPORTS_ - - - -// Specific creation function to get IMetaDataDispenser(Ex) interface. -HRESULT CreateMetaDataDispenser(REFIID riid, void ** pMetaDataDispenserOut); - -STDAPI GetMDInternalInterface( - LPVOID pData, - ULONG cbData, - DWORD flags, // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC - REFIID riid, // [in] The interface desired. - void **ppIUnk); // [out] Return interface on success. - -STDAPI GetMDInternalInterfaceFromPublic( - IUnknown *pIUnkPublic, // [IN] Given scope. - REFIID riid, // [in] The interface desired. - void **ppIUnkInternal); // [out] Return interface on success. - -STDAPI GetMDPublicInterfaceFromInternal( - void *pIUnkPublic, // [IN] Given scope. - REFIID riid, // [in] The interface desired. - void **ppIUnkInternal); // [out] Return interface on success. - -STDAPI MDReOpenMetaDataWithMemory( - void *pImport, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData); // [in] Size of the data pointed to by pData. - -STDAPI MDReOpenMetaDataWithMemoryEx( - void *pImport, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData, // [in] Size of the data pointed to by pData. - DWORD dwReOpenFlags); // [in] ReOpen flags - - - -#endif // _METADATA_EXPORTS_ diff --git a/src/coreclr/inc/shimload.h b/src/coreclr/inc/shimload.h deleted file mode 100644 index 9e1e88eebf6216..00000000000000 --- a/src/coreclr/inc/shimload.h +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================ -** -** Header: ShimLoad.hpp -** -** Purpose: Delay load hook used to images to bind to -** dll's shim shipped with the EE -** -** -===========================================================*/ -#ifndef _SHIMLOAD_H -#define _SHIMLOAD_H - - -//***************************************************************************** -// Sets/Gets the directory based on the location of the module. This routine -// is called at COR setup time. Set is called during EEStartup and by the -// MetaData dispenser. -//***************************************************************************** -HRESULT SetInternalSystemDirectory(); -HRESULT GetInternalSystemDirectory(_Out_writes_opt_(*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength); - -#endif - diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index d36b1627e611c9..a65140ea80331a 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -49,12 +49,8 @@ using std::nothrow; #define CoreLibName_W W("System.Private.CoreLib") #define CoreLibName_IL_W W("System.Private.CoreLib.dll") -#define CoreLibName_NI_W W("System.Private.CoreLib.ni.dll") -#define CoreLibName_TLB_W W("System.Private.CoreLib.tlb") #define CoreLibName_A "System.Private.CoreLib" #define CoreLibName_IL_A "System.Private.CoreLib.dll" -#define CoreLibName_NI_A "System.Private.CoreLib.ni.dll" -#define CoreLibName_TLB_A "System.Private.CoreLib.tlb" #define CoreLibNameLen 22 #define CoreLibSatelliteName_A "System.Private.CoreLib.resources" #define CoreLibSatelliteNameLen 32 @@ -3199,14 +3195,6 @@ inline HRESULT FakeCoCreateInstance(REFCLSID rclsid, return FakeCoCreateInstanceEx(rclsid, NULL, riid, ppv, NULL); }; -//***************************************************************************** -// Gets the directory based on the location of the module. This routine -// is called at COR setup time. Set is called during EEStartup and by the -// MetaData dispenser. -//***************************************************************************** -HRESULT GetInternalSystemDirectory(_Out_writes_to_opt_(*pdwLength,*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength); -LPCWSTR GetInternalSystemDirectory(_Out_opt_ DWORD * pdwLength = NULL); - //***************************************************************************** // This function validates the given Method/Field/Standalone signature. (util.cpp) //***************************************************************************** diff --git a/src/coreclr/md/compiler/regmeta.cpp b/src/coreclr/md/compiler/regmeta.cpp index fdc4b75d8791b8..b635d43b212435 100644 --- a/src/coreclr/md/compiler/regmeta.cpp +++ b/src/coreclr/md/compiler/regmeta.cpp @@ -1405,9 +1405,9 @@ HRESULT RegMeta::ReOpenWithMemory( //***************************************************************************** // This function returns the requested public interface based on the given // internal import interface. -// A common path to call this is updating the matedata for dynamic modules. +// A common path to call this is updating the metadata for dynamic modules. //***************************************************************************** -STDAPI MDReOpenMetaDataWithMemoryEx( +STDAPI MDReOpenMetaDataWithMemory( void *pImport, // [IN] Given scope. public interfaces LPCVOID pData, // [in] Location of scope data. ULONG cbData, // [in] Size of the data pointed to by pData. @@ -1430,15 +1430,7 @@ STDAPI MDReOpenMetaDataWithMemoryEx( pMDImport->Release(); return hr; -} // MDReOpenMetaDataWithMemoryEx - -STDAPI MDReOpenMetaDataWithMemory( - void *pImport, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData) // [in] Size of the data pointed to by pData. -{ - return MDReOpenMetaDataWithMemoryEx(pImport, pData, cbData, 0); -} +} // MDReOpenMetaDataWithMemory // diff --git a/src/coreclr/nativeaot/Runtime/amd64/GcProbe.S b/src/coreclr/nativeaot/Runtime/amd64/GcProbe.S index dbf23d54bc928a..0d6f48c60b97d0 100644 --- a/src/coreclr/nativeaot/Runtime/amd64/GcProbe.S +++ b/src/coreclr/nativeaot/Runtime/amd64/GcProbe.S @@ -148,7 +148,6 @@ LEAF_END RhpGcPoll, _TEXT NESTED_ENTRY RhpGcPollRare, _TEXT, NoHandler PUSH_COOP_PINVOKE_FRAME rdi - END_PROLOGUE call C_FUNC(RhpGcPoll2) POP_COOP_PINVOKE_FRAME ret diff --git a/src/coreclr/nativeaot/Runtime/amd64/GcProbe.asm b/src/coreclr/nativeaot/Runtime/amd64/GcProbe.asm index 86f5816ade7985..67e139beb92ea7 100644 --- a/src/coreclr/nativeaot/Runtime/amd64/GcProbe.asm +++ b/src/coreclr/nativeaot/Runtime/amd64/GcProbe.asm @@ -140,7 +140,6 @@ LEAF_END RhpGcPoll, _TEXT NESTED_ENTRY RhpGcPollRare, _TEXT PUSH_COOP_PINVOKE_FRAME rcx - END_PROLOGUE call RhpGcPoll2 POP_COOP_PINVOKE_FRAME ret diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index 8c17e76a787cf5..9491200b91e80d 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -20,7 +20,6 @@ #include "mlinfo.h" #include "posterror.h" #include "assemblynative.hpp" -#include "shimload.h" #include "stringliteralmap.h" #include "frozenobjectheap.h" #include "codeman.h" @@ -877,25 +876,12 @@ void SystemDomain::Init() m_pSystemPEAssembly = NULL; m_pSystemAssembly = NULL; - DWORD size = 0; - // Get the install directory so we can find CoreLib - hr = GetInternalSystemDirectory(NULL, &size); - if (hr != HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)) - ThrowHR(hr); - - // GetInternalSystemDirectory returns a size, including the null! - WCHAR* buffer = m_SystemDirectory.OpenUnicodeBuffer(size - 1); - IfFailThrow(GetInternalSystemDirectory(buffer, &size)); - m_SystemDirectory.CloseBuffer(); + IfFailThrow(GetClrModuleDirectory(m_SystemDirectory)); m_SystemDirectory.Normalize(); // At this point m_SystemDirectory should already be canonicalized m_BaseLibrary.Append(m_SystemDirectory); - if (!m_BaseLibrary.EndsWith(SString{ DIRECTORY_SEPARATOR_CHAR_W })) - { - m_BaseLibrary.Append(DIRECTORY_SEPARATOR_CHAR_W); - } m_BaseLibrary.Append(g_pwBaseLibrary); m_BaseLibrary.Normalize(); diff --git a/src/coreclr/vm/appdomain.hpp b/src/coreclr/vm/appdomain.hpp index c6624b5fef470b..e765b036dc7350 100644 --- a/src/coreclr/vm/appdomain.hpp +++ b/src/coreclr/vm/appdomain.hpp @@ -1846,36 +1846,6 @@ class SystemDomain final return m_BaseLibrary; } -#ifndef DACCESS_COMPILE - BOOL IsBaseLibrary(SString &path) - { - WRAPPER_NO_CONTRACT; - - // See if it is the installation path to CoreLib - if (path.EqualsCaseInsensitive(m_BaseLibrary)) - return TRUE; - - // Or, it might be the location of CoreLib - if (System()->SystemAssembly() != NULL - && path.EqualsCaseInsensitive(System()->SystemAssembly()->GetPEAssembly()->GetPath())) - return TRUE; - - return FALSE; - } - - BOOL IsBaseLibrarySatellite(SString &path) - { - WRAPPER_NO_CONTRACT; - - // See if it is the installation path to corelib.resources - SString s(SString::Ascii,g_psBaseLibrarySatelliteAssemblyName); - if (path.EqualsCaseInsensitive(s)) - return TRUE; - - return FALSE; - } -#endif // DACCESS_COMPILE - // Return the system directory LPCWSTR SystemDirectory() { diff --git a/src/coreclr/vm/assembly.cpp b/src/coreclr/vm/assembly.cpp index 7c55602288e081..95fd73a73ad64d 100644 --- a/src/coreclr/vm/assembly.cpp +++ b/src/coreclr/vm/assembly.cpp @@ -37,8 +37,6 @@ #include "peimagelayout.inl" -#include "metadataexports.h" - // Define these macro's to do strict validation for jit lock and class init entry leaks. // This defines determine if the asserts that verify for these leaks are defined or not. // These asserts can sometimes go off even if no entries have been leaked so this defines diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 71386bf855cf43..029da5ad02e72a 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -37,7 +37,6 @@ #include #include "fieldmarshaler.h" #include "sigbuilder.h" -#include "metadataexports.h" #include "inlinetracking.h" #include "threads.h" #include "nativeimage.h" diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index 9f6cc475e4f1e8..bd00b1c7a5406d 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -150,7 +150,6 @@ #include "comcallablewrapper.h" #include "../dlls/mscorrc/resource.h" #include "util.hpp" -#include "shimload.h" #include "posterror.h" #include "virtualcallstub.h" #include "strongnameinternal.h" @@ -1405,71 +1404,6 @@ void STDMETHODCALLTYPE EEShutDownHelper(BOOL fIsDllUnloading) } } - -#ifdef FEATURE_COMINTEROP - -BOOL IsThreadInSTA() -{ - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - // If ole32.dll is not loaded - if (GetModuleHandle(W("ole32.dll")) == NULL) - { - return FALSE; - } - - BOOL fInSTA = TRUE; - // To be conservative, check if finalizer thread is around - EX_TRY - { - Thread *pFinalizerThread = FinalizerThread::GetFinalizerThread(); - if (!pFinalizerThread || pFinalizerThread->Join(0, FALSE) != WAIT_TIMEOUT) - { - fInSTA = FALSE; - } - } - EX_CATCH - { - } - EX_END_CATCH(SwallowAllExceptions); - - if (!fInSTA) - { - return FALSE; - } - - THDTYPE type; - HRESULT hr = S_OK; - - hr = GetCurrentThreadTypeNT5(&type); - if (hr == S_OK) - { - fInSTA = (type == THDTYPE_PROCESSMESSAGES) ? TRUE : FALSE; - - // If we get back THDTYPE_PROCESSMESSAGES, we are guaranteed to - // be an STA thread. If not, we are an MTA thread, however - // we can't know if the thread has been explicitly set to MTA - // (via a call to CoInitializeEx) or if it has been implicitly - // made MTA (if it hasn't been CoInitializeEx'd but CoInitialize - // has already been called on some other thread in the process. - } - else - { - // CoInitialize hasn't been called in the process yet so assume the current thread - // is MTA. - fInSTA = FALSE; - } - - return fInSTA; -} -#endif - // #EEShutDown // // Function: EEShutDown(BOOL fIsDllUnloading) @@ -1562,23 +1496,6 @@ BOOL IsRuntimeActive() return (g_fEEStarted); } -//***************************************************************************** -BOOL ExecuteDLL_ReturnOrThrow(HRESULT hr, BOOL fFromThunk) -{ - CONTRACTL { - if (fFromThunk) THROWS; else NOTHROW; - WRAPPER(GC_TRIGGERS); - MODE_ANY; - } CONTRACTL_END; - - // If we have a failure result, and we're called from a thunk, - // then we need to throw an exception to communicate the error. - if (FAILED(hr) && fFromThunk) - { - COMPlusThrowHR(hr); - } - return SUCCEEDED(hr); -} // // Initialize the Garbage Collector diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index 4dd62e194a7010..722a12ad50d1fb 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -25,7 +25,6 @@ #include "rtlfunctions.h" -#include "shimload.h" #include "debuginfostore.h" #include "strsafe.h" diff --git a/src/coreclr/vm/disassembler.cpp b/src/coreclr/vm/disassembler.cpp index e5f01eb4e8005e..f938d9eeba9db6 100644 --- a/src/coreclr/vm/disassembler.cpp +++ b/src/coreclr/vm/disassembler.cpp @@ -78,12 +78,10 @@ namespace { LIMITED_METHOD_CONTRACT; - LPCWSTR sysDirectory = GetInternalSystemDirectory(); - LPCWSTR libFileName = MAKEDLLNAME(W("coredistools")); - // Look for the coredistools module next to the clr binary - libPath.Append(sysDirectory); - libPath.Append(libFileName); + IfFailThrow(GetClrModuleDirectory(libPath)); + + libPath.Append(MAKEDLLNAME(W("coredistools"))); LPCWSTR libraryName = libPath.GetUnicode(); return CLRLoadLibrary(libraryName); diff --git a/src/coreclr/vm/encee.cpp b/src/coreclr/vm/encee.cpp index 3a6e40a8bece81..bc3871601ae843 100644 --- a/src/coreclr/vm/encee.cpp +++ b/src/coreclr/vm/encee.cpp @@ -194,7 +194,7 @@ HRESULT EditAndContinueModule::ApplyEditAndContinue( IfFailRet(pMDImport->QueryInterface(IID_IMDInternalImportENC, (void **)&pIMDInternalImportENC)); // get an emitter interface - IfFailRet(GetMetaDataPublicInterfaceFromInternal(pMDImport, IID_IMetaDataEmit, (void **)&pEmitter)); + IfFailRet(GetMDPublicInterfaceFromInternal(pMDImport, IID_IMetaDataEmit, (void **)&pEmitter)); // Copy the delta IL into our RVA-able IL memory BYTE* pLocalILMemory = (BYTE*)(void*)GetLoaderAllocator()->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(cbDeltaIL)); diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 6cddfde642076e..84e96955cd3c8c 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -20,7 +20,6 @@ #include "eedbginterfaceimpl.h" //so we can clearexception in RealCOMPlusThrow #include "dllimportcallback.h" #include "stackwalk.h" //for CrawlFrame, in SetIPFromSrcToDst -#include "shimload.h" #include "eeconfig.h" #include "virtualcallstub.h" #include "typestring.h" diff --git a/src/coreclr/vm/gcheaputilities.cpp b/src/coreclr/vm/gcheaputilities.cpp index d3c99039b78a8f..7525be410b99a3 100644 --- a/src/coreclr/vm/gcheaputilities.cpp +++ b/src/coreclr/vm/gcheaputilities.cpp @@ -203,7 +203,8 @@ HMODULE LoadStandaloneGc(LPCWSTR libFileName, LPCWSTR libFilePath) if (result == nullptr) { // Look for the standalone GC module next to the clr binary - PathString libPath = GetInternalSystemDirectory(); + PathString libPath; + IfFailThrow(GetClrModuleDirectory(libPath)); libPath.Append(libFileName); LOG((LF_GC, LL_INFO100, "Loading standalone GC by coreclr %s\n", libPath.GetUTF8())); diff --git a/src/coreclr/vm/nativeimage.cpp b/src/coreclr/vm/nativeimage.cpp index 66e57b5e2a0004..9cf715638bcda3 100644 --- a/src/coreclr/vm/nativeimage.cpp +++ b/src/coreclr/vm/nativeimage.cpp @@ -301,11 +301,11 @@ IMDInternalImport *NativeImage::LoadManifestMetadata() } IMDInternalImport *pNewImport = NULL; - IfFailThrow(GetMetaDataInternalInterface((BYTE *)m_pImageLayout->GetBase() + VAL32(pMeta->VirtualAddress), - VAL32(pMeta->Size), - ofRead, - IID_IMDInternalImport, - (void **) &pNewImport)); + IfFailThrow(GetMDInternalInterface((BYTE *)m_pImageLayout->GetBase() + VAL32(pMeta->VirtualAddress), + VAL32(pMeta->Size), + ofRead, + IID_IMDInternalImport, + (void **) &pNewImport)); return pNewImport; } diff --git a/src/coreclr/vm/peassembly.cpp b/src/coreclr/vm/peassembly.cpp index 2d6db638c7734d..adc08d6fc020b6 100644 --- a/src/coreclr/vm/peassembly.cpp +++ b/src/coreclr/vm/peassembly.cpp @@ -289,9 +289,9 @@ void PEAssembly::OpenImporter() ConvertMDInternalToReadWrite(); IMetaDataImport2 *pIMDImport = NULL; - IfFailThrow(GetMetaDataPublicInterfaceFromInternal((void*)GetMDImport(), - IID_IMetaDataImport2, - (void **)&pIMDImport)); + IfFailThrow(GetMDPublicInterfaceFromInternal((void*)GetMDImport(), + IID_IMetaDataImport2, + (void **)&pIMDImport)); // Atomically swap it into the field (release it if we lose the race) if (InterlockedCompareExchangeT(&m_pImporter, pIMDImport, NULL) != NULL) @@ -319,7 +319,7 @@ void PEAssembly::ConvertMDInternalToReadWrite() IMetaDataImport *pIMDImport = m_pImporter; if (pIMDImport != NULL) { - HRESULT hr = GetMetaDataInternalInterfaceFromPublic(pIMDImport, IID_IMDInternalImport, (void **)&pNew); + HRESULT hr = GetMDInternalInterfaceFromPublic(pIMDImport, IID_IMDInternalImport, (void **)&pNew); if (FAILED(hr)) { EX_THROW(EEMessageException, (hr)); @@ -410,9 +410,9 @@ void PEAssembly::OpenEmitter() ConvertMDInternalToReadWrite(); IMetaDataEmit *pIMDEmit = NULL; - IfFailThrow(GetMetaDataPublicInterfaceFromInternal((void*)GetMDImport(), - IID_IMetaDataEmit, - (void **)&pIMDEmit)); + IfFailThrow(GetMDPublicInterfaceFromInternal((void*)GetMDImport(), + IID_IMetaDataEmit, + (void **)&pIMDEmit)); // Atomically swap it into the field (release it if we lose the race) if (InterlockedCompareExchangeT(&m_pEmitter, pIMDEmit, NULL) != NULL) @@ -682,8 +682,8 @@ PEAssembly::PEAssembly( OpenMDImport(); //constructor, cannot race with anything else { - IfFailThrow(GetMetaDataInternalInterfaceFromPublic(pEmit, IID_IMDInternalImport, - (void **)&m_pMDImport)); + IfFailThrow(GetMDInternalInterfaceFromPublic(pEmit, IID_IMDInternalImport, + (void **)&m_pMDImport)); m_pEmitter = pEmit; pEmit->AddRef(); m_MDImportIsRW_Debugger_Use_Only = TRUE; diff --git a/src/coreclr/vm/peimage.cpp b/src/coreclr/vm/peimage.cpp index de16e04c1fd2a3..090c2ed5b864ed 100644 --- a/src/coreclr/vm/peimage.cpp +++ b/src/coreclr/vm/peimage.cpp @@ -311,11 +311,11 @@ void PEImage::OpenMDImport() if(pMeta==NULL) return; - IfFailThrow(GetMetaDataInternalInterface((void *) pMeta, - cMeta, - ofRead, - IID_IMDInternalImport, - (void **) &m_pNewImport)); + IfFailThrow(GetMDInternalInterface((void *) pMeta, + cMeta, + ofRead, + IID_IMDInternalImport, + (void **) &m_pNewImport)); if(InterlockedCompareExchangeT(&m_pMDImport, m_pNewImport, NULL)) { @@ -370,11 +370,11 @@ void PEImage::GetMVID(GUID *pMvid) SafeComHolder pMDImport; - IfFailThrow(GetMetaDataInternalInterface((void *) pMeta, - cMeta, - ofRead, - IID_IMDInternalImport, - (void **) &pMDImport)); + IfFailThrow(GetMDInternalInterface((void *) pMeta, + cMeta, + ofRead, + IID_IMDInternalImport, + (void **) &pMDImport)); pMDImport->GetScopeProps(NULL, &MvidDEBUG); diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index ea42d1ab468e7a..0cb168a28c82fb 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -136,8 +136,6 @@ #include "profdetach.h" -#include "metadataexports.h" - #ifdef FEATURE_PERFTRACING #include "eventpipeadapter.h" #endif // FEATURE_PERFTRACING diff --git a/src/coreclr/vm/readytoruninfo.cpp b/src/coreclr/vm/readytoruninfo.cpp index 53b7db308aa794..2fa9632fea82b8 100644 --- a/src/coreclr/vm/readytoruninfo.cpp +++ b/src/coreclr/vm/readytoruninfo.cpp @@ -794,11 +794,11 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocat if (pNativeMetadataSection != NULL) { pNativeMDImport = NULL; - IfFailThrow(GetMetaDataInternalInterface((void *) m_pComposite->GetLayout()->GetDirectoryData(pNativeMetadataSection), - pNativeMetadataSection->Size, - ofRead, - IID_IMDInternalImport, - (void **) &pNativeMDImport)); + IfFailThrow(GetMDInternalInterface((void *) m_pComposite->GetLayout()->GetDirectoryData(pNativeMetadataSection), + pNativeMetadataSection->Size, + ofRead, + IID_IMDInternalImport, + (void **) &pNativeMDImport)); HENUMInternal assemblyEnum; HRESULT hr = pNativeMDImport->EnumAllInit(mdtAssemblyRef, &assemblyEnum); diff --git a/src/coreclr/vm/reflectclasswriter.cpp b/src/coreclr/vm/reflectclasswriter.cpp index c37dc944261a8a..772eaab44fc4c7 100644 --- a/src/coreclr/vm/reflectclasswriter.cpp +++ b/src/coreclr/vm/reflectclasswriter.cpp @@ -7,12 +7,6 @@ #include "common.h" #include "reflectclasswriter.h" -// Forward declaration. -STDAPI GetMetaDataInternalInterfaceFromPublic( - IUnknown *pv, // [IN] Given interface. - REFIID riid, // [IN] desired interface - void **ppv); // [OUT] returned interface - //****************************************************** //* //* constructor for RefClassWriter @@ -60,7 +54,7 @@ HRESULT RefClassWriter::Init(ICeeGenInternal *pCeeGen, IUnknown *pUnk, LPCWSTR s if (FAILED(hr)) RETURN(hr); - hr = GetMetaDataInternalInterfaceFromPublic(pUnk, IID_IMDInternalImport, (void**)&m_internalimport); + hr = GetMDInternalInterfaceFromPublic(pUnk, IID_IMDInternalImport, (void**)&m_internalimport); if (FAILED(hr)) RETURN(hr); diff --git a/src/coreclr/vm/rtlfunctions.cpp b/src/coreclr/vm/rtlfunctions.cpp index 65642ee3c891c7..bd0dab6094ff29 100644 --- a/src/coreclr/vm/rtlfunctions.cpp +++ b/src/coreclr/vm/rtlfunctions.cpp @@ -76,41 +76,21 @@ VOID InstallEEFunctionTable ( CONTRACTL_END; static LPWSTR wszModuleName = NULL; - static WCHAR rgwModuleName[MAX_LONGPATH] = { 0 }; if (wszModuleName == NULL) { StackSString ssTempName; - DWORD dwTempNameSize; - // Leaves trailing backslash on path, producing something like "c:\windows\microsoft.net\framework\v4.0.x86dbg\" - LPCWSTR pszSysDir = GetInternalSystemDirectory(&dwTempNameSize); + IfFailThrow(GetClrModuleDirectory(ssTempName)); - //finish creating complete path and copy to buffer if we can - if (pszSysDir == NULL) - { // The CLR should become unavailable in this case. - EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE); - } - - ssTempName.Set(pszSysDir); ssTempName.Append(MAIN_DAC_MODULE_DLL_NAME_W); - if (ssTempName.GetCount() < MAX_LONGPATH) - { - wcscpy_s(rgwModuleName, MAX_LONGPATH, ssTempName.GetUnicode()); + NewArrayHolder wzTempName(ssTempName.GetCopyOfUnicodeString()); - // publish result - InterlockedExchangeT(&wszModuleName, rgwModuleName); - } - else + // publish result + if (InterlockedCompareExchangeT(&wszModuleName, (LPWSTR)wzTempName, nullptr) == nullptr) { - NewArrayHolder wzTempName(ssTempName.GetCopyOfUnicodeString()); - - // publish result - if (InterlockedCompareExchangeT(&wszModuleName, (LPWSTR)wzTempName, nullptr) == nullptr) - { - wzTempName.SuppressRelease(); - } + wzTempName.SuppressRelease(); } } From 2c4aef85dccca15e6c0f69a16f741f1cbd7c2397 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 8 Jun 2025 05:37:49 -0700 Subject: [PATCH 2/3] FB --- src/coreclr/runtime/amd64/AllocFast.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/runtime/amd64/AllocFast.S b/src/coreclr/runtime/amd64/AllocFast.S index ea8b60c227b1e9..d5b366b876dad6 100644 --- a/src/coreclr/runtime/amd64/AllocFast.S +++ b/src/coreclr/runtime/amd64/AllocFast.S @@ -78,7 +78,6 @@ LEAF_END RhpNewFinalizable, _TEXT NESTED_ENTRY RhpNewObject, _TEXT, NoHandler PUSH_COOP_PINVOKE_FRAME rcx - END_PROLOGUE // RCX: transition frame @@ -258,7 +257,6 @@ NESTED_ENTRY RhpNewVariableSizeObject, _TEXT, NoHandler // rsi == element count PUSH_COOP_PINVOKE_FRAME rcx - END_PROLOGUE // rcx: transition frame From f7164e987b44a3e6328d3d61497e880dbfe674d5 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 8 Jun 2025 18:12:22 -0700 Subject: [PATCH 3/3] Update src/coreclr/binder/utils.cpp Co-authored-by: Aaron Robinson --- src/coreclr/binder/utils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/binder/utils.cpp b/src/coreclr/binder/utils.cpp index babc413f171bd6..f071aea3c48792 100644 --- a/src/coreclr/binder/utils.cpp +++ b/src/coreclr/binder/utils.cpp @@ -18,6 +18,7 @@ #include "clr/fs/path.h" using namespace clr::fs; +// Forward declaration - see src/vm/util.cpp BOOL RuntimeFileNotFound(HRESULT hr); namespace BINDER_SPACE