diff options
Diffstat (limited to 'src/dlls/mscoree')
27 files changed, 4278 insertions, 0 deletions
diff --git a/src/dlls/mscoree/.gitmirror b/src/dlls/mscoree/.gitmirror new file mode 100644 index 0000000000..f507630f94 --- /dev/null +++ b/src/dlls/mscoree/.gitmirror @@ -0,0 +1 @@ +Only contents of this folder, excluding subfolders, will be mirrored by the Git-TFS Mirror.
\ No newline at end of file diff --git a/src/dlls/mscoree/CMakeLists.txt b/src/dlls/mscoree/CMakeLists.txt new file mode 100644 index 0000000000..6a157e4105 --- /dev/null +++ b/src/dlls/mscoree/CMakeLists.txt @@ -0,0 +1,30 @@ +include_directories("../../inc") + +if(FEATURE_GDBJIT) + add_definitions(-DFEATURE_GDBJIT) +endif(FEATURE_GDBJIT) + +set(CLR_SOURCES + mscoree.cpp + unixinterface.cpp +) + +if(WIN32) +list(APPEND CLR_SOURCES + comcallunmarshal.cpp + delayload.cpp + Native.rc +) + +set (DEF_SOURCES + mscorwks_ntdef.src +) +else() +set (DEF_SOURCES + mscorwks_unixexports.src +) +endif(WIN32) + +convert_to_absolute_path(DEF_SOURCES ${DEF_SOURCES}) +convert_to_absolute_path(CLR_SOURCES ${CLR_SOURCES}) +add_subdirectory(coreclr) diff --git a/src/dlls/mscoree/Native.rc b/src/dlls/mscoree/Native.rc new file mode 100644 index 0000000000..faa7ea16c2 --- /dev/null +++ b/src/dlls/mscoree/Native.rc @@ -0,0 +1,8 @@ +// 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. + +#define FX_VER_FILEDESCRIPTION_STR "Microsoft .NET Runtime\0" + +#include <fxver.h> +#include <fxver.rc> diff --git a/src/dlls/mscoree/comcallunmarshal.cpp b/src/dlls/mscoree/comcallunmarshal.cpp new file mode 100644 index 0000000000..d0f9b7ca75 --- /dev/null +++ b/src/dlls/mscoree/comcallunmarshal.cpp @@ -0,0 +1,305 @@ +// 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. +// +// File: ComCallUnmarshal.cpp +// + +// +// Classes used to unmarshal all COM call wrapper IPs. +// + + +#include "stdafx.h" // Standard header. + +#ifdef FEATURE_COMINTEROP + +#include "ComCallUnmarshal.h" +#include <utilcode.h> // Utility helpers. + +// For free-threaded marshaling, we must not be spoofed by out-of-process or cross-runtime marshal data. +// Only unmarshal data that comes from our own runtime. +extern BYTE g_UnmarshalSecret[sizeof(GUID)]; +extern bool g_fInitedUnmarshalSecret; + +STDMETHODIMP ComCallUnmarshal::QueryInterface(REFIID iid, void **ppv) +{ + CONTRACTL + { + NOTHROW; + GC_NOTRIGGER; + SO_TOLERANT; + PRECONDITION(CheckPointer(ppv, NULL_OK)); + } CONTRACTL_END; + + if (!ppv) + return E_POINTER; + + *ppv = NULL; + if (iid == IID_IUnknown) + { + *ppv = (IUnknown *)this; + AddRef(); + } else if (iid == IID_IMarshal) + { + *ppv = (IMarshal *)this; + AddRef(); + } + return (*ppv != NULL) ? S_OK : E_NOINTERFACE; +} + +STDMETHODIMP_(ULONG) ComCallUnmarshal::AddRef(void) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + return 2; +} + +STDMETHODIMP_(ULONG) ComCallUnmarshal::Release(void) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + return 1; +} + +STDMETHODIMP ComCallUnmarshal::GetUnmarshalClass (REFIID riid, void * pv, ULONG dwDestContext, + void * pvDestContext, ULONG mshlflags, + LPCLSID pclsid) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + // Marshal side only. + _ASSERTE(FALSE); + return E_NOTIMPL; +} + +STDMETHODIMP ComCallUnmarshal::GetMarshalSizeMax (REFIID riid, void * pv, ULONG dwDestContext, + void * pvDestContext, ULONG mshlflags, + ULONG * pSize) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + // Marshal side only. + _ASSERTE(FALSE); + return E_NOTIMPL; +} + +STDMETHODIMP ComCallUnmarshal::MarshalInterface (LPSTREAM pStm, REFIID riid, void * pv, + ULONG dwDestContext, LPVOID pvDestContext, + ULONG mshlflags) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + // Marshal side only. + _ASSERTE(FALSE); + return E_NOTIMPL; +} + +STDMETHODIMP ComCallUnmarshal::UnmarshalInterface (LPSTREAM pStm, REFIID riid, void ** ppvObj) +{ + CONTRACTL { + NOTHROW; + GC_NOTRIGGER; + SO_TOLERANT;; + STATIC_CONTRACT_MODE_PREEMPTIVE; + PRECONDITION(CheckPointer(pStm)); + PRECONDITION(CheckPointer(ppvObj)); + } CONTRACTL_END; + + ULONG bytesRead; + ULONG mshlflags; + HRESULT hr = E_FAIL; + + BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return COR_E_STACKOVERFLOW); + // The marshal code added a reference to the object, but we return a + // reference to the object as well, so don't change the ref count on the + // success path. Need to release on error paths though (if we manage to + // retrieve the IP, that is). If the interface was marshalled + // TABLESTRONG or TABLEWEAK, there is going to be a ReleaseMarshalData + // in the future, so we should AddRef the IP we're about to give out. + // Note also that OLE32 requires us to advance the stream pointer even + // in failure cases. + + // Read the raw IP out of the marshalling stream. + hr = pStm->Read (ppvObj, sizeof (void *), &bytesRead); + if (FAILED (hr) || (bytesRead != sizeof (void *))) + IfFailGo(RPC_E_INVALID_DATA); + + // And then the marshal flags. + hr = pStm->Read (&mshlflags, sizeof (ULONG), &bytesRead); + if (FAILED (hr) || (bytesRead != sizeof (ULONG))) + IfFailGo(RPC_E_INVALID_DATA); + + // And then verify our secret, to be sure that cross-runtime clients aren't + // trying to trick us into mis-interpreting their data as a ppvObj. Note that + // it is guaranteed that the secret data is initialized, or else we certainly + // haven't written it into this buffer! + if (!g_fInitedUnmarshalSecret) + IfFailGo(E_UNEXPECTED); + + BYTE secret[sizeof(GUID)]; + + hr = pStm->Read(secret, sizeof(secret), &bytesRead); + if (FAILED(hr) || (bytesRead != sizeof(secret))) + IfFailGo(RPC_E_INVALID_DATA); + + if (memcmp(g_UnmarshalSecret, secret, sizeof(secret)) != 0) + IfFailGo(E_UNEXPECTED); + + if (ppvObj && ((mshlflags == MSHLFLAGS_TABLESTRONG) || (mshlflags == MSHLFLAGS_TABLEWEAK))) + { + // For table access we can just QI for the correct interface (this + // will addref the IP, but that's OK since we need to keep an extra + // ref on the IP until ReleaseMarshalData is called). + hr = ((IUnknown *)*ppvObj)->QueryInterface(riid, ppvObj); + } + else + { + // For normal access we QI for the correct interface then release + // the old IP. + NonVMComHolder<IUnknown> pOldUnk = (IUnknown *)*ppvObj; + hr = pOldUnk->QueryInterface(riid, ppvObj); + } +ErrExit: + ; + END_SO_INTOLERANT_CODE; + return hr; +} + +STDMETHODIMP ComCallUnmarshal::ReleaseMarshalData (LPSTREAM pStm) +{ + CONTRACTL { + NOTHROW; + GC_NOTRIGGER; + STATIC_CONTRACT_MODE_PREEMPTIVE; + SO_TOLERANT; + PRECONDITION(CheckPointer(pStm)); + } CONTRACTL_END; + + IUnknown *pUnk; + ULONG bytesRead; + ULONG mshlflags; + HRESULT hr = S_OK; + + if (!pStm) + return E_POINTER; + + BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return COR_E_STACKOVERFLOW); + + // Read the raw IP out of the marshalling stream. Do this first since we + // need to update the stream pointer even in case of failures. + hr = pStm->Read (&pUnk, sizeof (pUnk), &bytesRead); + if (FAILED (hr) || (bytesRead != sizeof (pUnk))) + IfFailGo(RPC_E_INVALID_DATA); + + // Now read the marshal flags. + hr = pStm->Read (&mshlflags, sizeof (mshlflags), &bytesRead); + if (FAILED (hr) || (bytesRead != sizeof (mshlflags))) + IfFailGo(RPC_E_INVALID_DATA); + + if (!g_fInitedUnmarshalSecret) + { + IfFailGo(E_UNEXPECTED); + } + + BYTE secret[sizeof(GUID)]; + + hr = pStm->Read(secret, sizeof(secret), &bytesRead); + if (FAILED(hr) || (bytesRead != sizeof(secret))) + IfFailGo(RPC_E_INVALID_DATA); + + if (memcmp(g_UnmarshalSecret, secret, sizeof(secret)) != 0) + IfFailGo(E_UNEXPECTED); + + pUnk->Release (); + +ErrExit: + ; + END_SO_INTOLERANT_CODE; + return hr; +} + +STDMETHODIMP ComCallUnmarshal::DisconnectObject (ULONG dwReserved) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + + // Nothing we can (or need to) do here. The client is using a raw IP to + // access this server, so the server shouldn't go away until the client + // Release()'s it. + + return S_OK; +} + +CComCallUnmarshalFactory::CComCallUnmarshalFactory() +{ + WRAPPER_NO_CONTRACT; +} + +STDMETHODIMP CComCallUnmarshalFactory::QueryInterface(REFIID iid, void **ppv) +{ + CONTRACTL + { + NOTHROW; + GC_NOTRIGGER; + SO_TOLERANT; + PRECONDITION(CheckPointer(ppv)); + } CONTRACTL_END; + + if (!ppv) + return E_POINTER; + + *ppv = NULL; + if (iid == IID_IClassFactory || iid == IID_IUnknown) { + *ppv = (IClassFactory *)this; + AddRef(); + } + return (*ppv != NULL) ? S_OK : E_NOINTERFACE; +} + +STDMETHODIMP_(ULONG) CComCallUnmarshalFactory::AddRef(void) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + + return 2; +} + +STDMETHODIMP_(ULONG) CComCallUnmarshalFactory::Release(void) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + + return 1; +} + +STDMETHODIMP CComCallUnmarshalFactory::CreateInstance(LPUNKNOWN punkOuter, REFIID iid, LPVOID FAR *ppv) +{ + CONTRACTL + { + NOTHROW; + GC_NOTRIGGER; + SO_TOLERANT; + PRECONDITION(CheckPointer(ppv)); + } CONTRACTL_END; + + if (!ppv) + return E_POINTER; + + *ppv = NULL; + + if (punkOuter != NULL) + return CLASS_E_NOAGGREGATION; + + return m_Unmarshaller.QueryInterface(iid, ppv); +} + +STDMETHODIMP CComCallUnmarshalFactory::LockServer(BOOL fLock) +{ + LIMITED_METHOD_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; + + return S_OK; +} + +#endif // FEATURE_COMINTEROP diff --git a/src/dlls/mscoree/comcallunmarshal.h b/src/dlls/mscoree/comcallunmarshal.h new file mode 100644 index 0000000000..2e8af4511a --- /dev/null +++ b/src/dlls/mscoree/comcallunmarshal.h @@ -0,0 +1,70 @@ +// 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. +// +// File: ComCallUnmarshal.h +// + +// +// Classes used to unmarshal all COM call wrapper IPs. +// + + +#pragma once + +#ifndef FEATURE_COMINTEROP +#error FEATURE_COMINTEROP is required for this file +#endif // FEATURE_COMINTEROP + +// Class used to unmarshal all COM call wrapper IPs. In order for this to work in side-by-side +// scenarios, the CLSID of this class has to be changed with every side-by-side release. +// +// The class is identified by the following CLSID: +// CLR v1.0, v1.1, v2.0: 3F281000-E95A-11d2-886B-00C04F869F04 +// CLR v4.0: 45FB4600-E6E8-4928-B25E-50476FF79425 +// +class ComCallUnmarshal : public IMarshal +{ +public: + + // *** IUnknown methods *** + STDMETHODIMP QueryInterface(REFIID iid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(void); + + // *** IMarshal methods *** + STDMETHODIMP GetUnmarshalClass (REFIID riid, void * pv, ULONG dwDestContext, + void * pvDestContext, ULONG mshlflags, + LPCLSID pclsid); + + STDMETHODIMP GetMarshalSizeMax (REFIID riid, void * pv, ULONG dwDestContext, + void * pvDestContext, ULONG mshlflags, + ULONG * pSize); + + STDMETHODIMP MarshalInterface (LPSTREAM pStm, REFIID riid, void * pv, + ULONG dwDestContext, LPVOID pvDestContext, + ULONG mshlflags); + + STDMETHODIMP UnmarshalInterface (LPSTREAM pStm, REFIID riid, void ** ppvObj); + STDMETHODIMP ReleaseMarshalData (LPSTREAM pStm); + STDMETHODIMP DisconnectObject (ULONG dwReserved); +}; + +// Class factory for the COM call wrapper unmarshaller. +class CComCallUnmarshalFactory : public IClassFactory +{ + ComCallUnmarshal m_Unmarshaller; + + public: + + CComCallUnmarshalFactory(); + + // *** IUnknown methods *** + STDMETHODIMP QueryInterface(REFIID iid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(void); + + // *** IClassFactory methods *** + STDMETHODIMP CreateInstance(LPUNKNOWN punkOuter, REFIID iid, LPVOID FAR *ppv); + STDMETHODIMP LockServer(BOOL fLock); +}; diff --git a/src/dlls/mscoree/coreclr/.gitmirror b/src/dlls/mscoree/coreclr/.gitmirror new file mode 100644 index 0000000000..f507630f94 --- /dev/null +++ b/src/dlls/mscoree/coreclr/.gitmirror @@ -0,0 +1 @@ +Only contents of this folder, excluding subfolders, will be mirrored by the Git-TFS Mirror.
\ No newline at end of file diff --git a/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/dlls/mscoree/coreclr/CMakeLists.txt new file mode 100644 index 0000000000..aa7bb0d9b9 --- /dev/null +++ b/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -0,0 +1,179 @@ +if (WIN32) + preprocess_def_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def) + + list(APPEND CLR_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def) + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /ENTRY:CoreDllMain") + + # Delay load libraries required for WinRT as that is not supported on all platforms + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:api-ms-win-ro-typeresolution-l1-1-0.dll") + + # No library groups for Win32 + set(START_LIBRARY_GROUP) + set(END_LIBRARY_GROUP) + +else() + add_definitions(-DNO_CRT_INIT) + + set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/coreclr.exports) + generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + + if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) + # This option is necessary to ensure that the overloaded delete operator defined inside + # of the utilcode will be used instead of the standard library delete operator. + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Xlinker -Bsymbolic-functions") + + # The following linked options can be inserted into the linker libraries list to + # ensure proper resolving of circular references between a subset of the libraries. + set(START_LIBRARY_GROUP -Wl,--start-group) + set(END_LIBRARY_GROUP -Wl,--end-group) + + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -Wl,--whole-archive) + set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) + + set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) + endif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) + + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -force_load) + set(END_WHOLE_ARCHIVE ) + + set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) + endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + +endif (WIN32) + +add_definitions(-DFX_VER_INTERNALNAME_STR=CoreCLR.dll) + +add_library_clr(coreclr + SHARED + ${CLR_SOURCES} +) + +add_custom_target(coreclr_exports DEPENDS ${EXPORTS_FILE}) +add_dependencies(coreclr coreclr_exports) + +set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) +set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) + +if (CLR_CMAKE_PLATFORM_UNIX) + set(LIB_UNWINDER unwinder_wks) +endif (CLR_CMAKE_PLATFORM_UNIX) + +if(FEATURE_MERGE_JIT_AND_ENGINE) + set(CLRJIT_STATIC clrjit_static) +endif(FEATURE_MERGE_JIT_AND_ENGINE) + +# IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is +# order dependent and changing the order can result in undefined symbols in the shared +# library. +set(CORECLR_LIBRARIES + utilcode + ${START_LIBRARY_GROUP} # Start group of libraries that have circular references + cordbee_wks + debug-pal + ${LIB_UNWINDER} + cee_wks + gc_wks + ${END_LIBRARY_GROUP} # End group of libraries that have circular references + mdcompiler_wks + mdruntime_wks + mdruntimerw_wks + mdhotdata_full + bcltype + ceefgen + ${CLRJIT_STATIC} + comfloat_wks + corguids + gcinfo # Condition="'$(TargetCpu)'=='amd64' or '$(TargetCpu)' == 'arm' or '$(TargetCpu)' == 'arm64'" + ildbsymlib + strongname_wks + utilcode + v3binder +) + +if(WIN32) + list(APPEND CORECLR_LIBRARIES + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} + mdwinmd_wks + comnls_wks + kernel32.lib + advapi32.lib + ole32.lib + oleaut32.lib + uuid.lib + user32.lib + version.lib + shlwapi.lib + bcrypt.lib + RuntimeObject.lib + ) +else() + list(APPEND CORECLR_LIBRARIES + ${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available + coreclrpal + tracepointprovider + ${END_WHOLE_ARCHIVE} + mscorrc_debug + palrt + ) +endif(WIN32) + +if(CLR_CMAKE_PLATFORM_UNIX AND FEATURE_EVENT_TRACE) + list(APPEND CORECLR_LIBRARIES + eventprovider + ) +endif(CLR_CMAKE_PLATFORM_UNIX AND FEATURE_EVENT_TRACE) + +target_link_libraries(coreclr ${CORECLR_LIBRARIES}) + +if(WIN32) + # Add dac table & debug resource to coreclr + get_include_directories(INC_DIR) + get_compile_definitions(PREPROCESS_DEFINITIONS) + list(APPEND INC_DIR -I${CLR_DIR}/src/vm -I${CLR_DIR}/src/vm/${ARCH_SOURCES_DIR} -I${CLR_DIR}/src/debug/ee -I${CLR_DIR}/src/gc) + list(APPEND PREPROCESS_DEFINITIONS -DDACCESS_COMPILE -DDBG_TARGET_64BIT=1 -DDBG_TARGET_WIN64=1) + + if (CLR_CMAKE_PLATFORM_ARCH_AMD64) + list(APPEND PREPROCESS_DEFINITIONS -DDBG_TARGET_AMD64=1) + elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64) + list(APPEND PREPROCESS_DEFINITIONS -DDBG_TARGET_ARM64=1) + elseif (CLR_CMAKE_PLATFORM_ARCH_ARM) + list(APPEND PREPROCESS_DEFINITIONS -DDBG_TARGET_ARM=1) + elseif (CLR_CMAKE_PLATFORM_ARCH_I386) + list(APPEND PREPROCESS_DEFINITIONS -DDBG_TARGET_X86=1) + else() + clr_unknown_arch() + endif() + + add_custom_command( + TARGET coreclr + POST_BUILD + COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/src/debug/daccess/daccess.cpp + COMMAND ${BuildToolsDir}/dactablegen.exe /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/coreclr.pdb /dll:$<TARGET_FILE:coreclr> /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin + COMMAND ${BuildToolsDir}/InjectResource.exe /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$<TARGET_FILE:coreclr> + COMMAND ${BuildToolsDir}/GenClrDebugResource.exe /dac:$<TARGET_FILE:mscordaccore> /dbi:$<TARGET_FILE:mscordbi> /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin + COMMAND ${BuildToolsDir}/InjectResource.exe /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$<TARGET_FILE:coreclr> /name:CLRDEBUGINFO + COMMENT Add dactable & debug resources to coreclr + ) +else() + add_custom_command( + TARGET coreclr + POST_BUILD + VERBATIM + COMMAND sh ${CLR_DIR}/src/pal/tools/gen-dactable-rva.sh $<TARGET_FILE:coreclr> ${GENERATED_INCLUDE_DIR}/dactablerva.h + COMMENT Generating ${GENERATED_INCLUDE_DIR}/dactablerva.h + ) +endif(WIN32) + +# add the install targets +install_clr(coreclr) + +# Enable profile guided optimization +add_pgo(coreclr) diff --git a/src/dlls/mscoree/coreclr/coreclr.nativeproj b/src/dlls/mscoree/coreclr/coreclr.nativeproj new file mode 100644 index 0000000000..d9350bcf4c --- /dev/null +++ b/src/dlls/mscoree/coreclr/coreclr.nativeproj @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood"> + <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" /> + <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\src\dlls\mscoree\mscoree.settings.targets" /> + <PropertyGroup Label="Globals"> + <SccProjectName>SAK</SccProjectName> + <SccAuxPath>SAK</SccAuxPath> + <SccLocalPath>SAK</SccLocalPath> + <SccProvider>SAK</SccProvider> + </PropertyGroup> + <PropertyGroup> + <BuildCoreBinaries>true</BuildCoreBinaries> + <BuildSysBinaries>true</BuildSysBinaries> + <OutputName>coreclr</OutputName> + <LinkAdditionalOptions Condition="'$(BuildArchitecture)'=='arm' and $(BuildForCoreSystem) == 'true'">$(LinkAdditionalOptions) /filealign:4096</LinkAdditionalOptions> + <IsProjectKLibrary>true</IsProjectKLibrary> + <IsTestNetCoreRuntimeLibrary>true</IsTestNetCoreRuntimeLibrary> + <IsPhoneLibrary>true</IsPhoneLibrary> + <IsTestNetTool>true</IsTestNetTool> + <IsPhoneTool>true</IsPhoneTool> + </PropertyGroup> + <ItemGroup Condition="'$(BuildForWindows7)' == 'true'"> + <ProductFile Include="$(SdkLibPath)\forwarders\*"> + <ProductName>ProjectK</ProductName> + <ProductPath>Runtime</ProductPath> + </ProductFile> + </ItemGroup> + + <Choose> + <!-- ARM64TODO: Enable PGO --> + <!-- TODO_X64CoreSys: Dont link pgort.lib as x64 CoreSys CoreCLR as Perf team does not have the instrumented data for it yet. Reenable it once its available --> + <When Condition="'$(BuildForCoreSystem)' == 'true' and !('$(_BuildType)' == 'chk' or '$(_BuildType)' == 'dbg' or '$(BuildArchitecture)'=='amd64' or '$(BuildArchitecture)'=='arm64')"> + <ItemGroup> + <TargetLib Include="$(VCToolsLegacyPath)\vc12\lib\ret\$(RealBuildArchitecture)\vc\pgort.lib" /> + </ItemGroup> + + <PropertyGroup> + <PogoOptimize>false</PogoOptimize> + <PogoInstrument>true</PogoInstrument> + <PogoUpdate>true</PogoUpdate> + <OptimizationDataRelativeDir>CoreSys.$(_BuildArch)\CLR\Base</OptimizationDataRelativeDir> + </PropertyGroup> + + <ItemGroup> + <PogoInstrumentedDestinationPath Include ="$(OutputRootPath)\OneCore\Pogo\" /> + </ItemGroup> + + </When> + </Choose> + + <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" /> + <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\src\dlls\mscoree\mscoree.targets" /> +</Project> diff --git a/src/dlls/mscoree/delayload.cpp b/src/dlls/mscoree/delayload.cpp new file mode 100644 index 0000000000..d74f58b444 --- /dev/null +++ b/src/dlls/mscoree/delayload.cpp @@ -0,0 +1,455 @@ +// 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. +//***************************************************************************** +// DelayLoad.cpp +// +// This code defines the dealy load helper notification routines that will be +// invoked when a dll marked for delay load is processed. A DLL is marked as +// delay load by using the DELAYLOAD=foo.dll directive in your sources file. +// This tells the linker to generate helpers for the imports of this dll instead +// of loading it directly. If your application never touches those functions, +// the the dll is never loaded. This improves (a) startup time each time the +// app runs, and (b) overall working set size in the case you never use the +// functionality. +// +// +// +// This module provides a hook helper and exception handler. The hook helper +// is used primarily in debug mode right now to determine what call stacks +// force a delay load of a dll. If these call stacks are very common, then +// you should reconsider using a delay load. +// +// The exception handler is used to catch fatal errors like library not found +// or entry point missing. If this happens you are dead and need to fail +// gracefully. +// +//***************************************************************************** +#include "stdafx.h" // Standard header. + +#if !defined(FEATURE_CORESYSTEM) + +#include "delayimp.h" // Delay load header file. +#include "winwrap.h" // Wrappers for Win32 api's. +#include "utilcode.h" // Debug helpers. +#include "corerror.h" // Error codes from this EE. +#include "shimload.h" +#include "ex.h" +#include "strsafe.h" + +//********** Locals. ********************************************************** +static DWORD _FormatMessage(__out_ecount(chMsg) __out_z LPWSTR szMsg, DWORD chMsg, DWORD dwLastError, ...); +static void _FailLoadLib(unsigned dliNotify, DelayLoadInfo *pdli); +static void _FailGetProc(unsigned dliNotify, DelayLoadInfo *pdli); + +#if defined (_DEBUG) || defined (__delay_load_trace__) +static void _DbgPreLoadLibrary(int bBreak, DelayLoadInfo *pdli); +#endif + + +//********** Globals. ********************************************************* + +// Override __pfnDllFailureHook. This will give the delay code a callback +// for when a load failure occurs. This failure hook is implemented below. +FARPROC __stdcall CorDelayErrorHook(unsigned dliNotify, DelayLoadInfo *pdli); +ExternC extern PfnDliHook __pfnDliFailureHook = CorDelayErrorHook; + +// In trace mode, override the delay load hook. Our hook does nothing but +// provide some diagnostic information for debugging. +FARPROC __stdcall CorDelayLoadHook(unsigned dliNotify, DelayLoadInfo *pdli); +ExternC extern PfnDliHook __pfnDliNotifyHook = CorDelayLoadHook; + + +//********** Code. ************************************************************ + +#undef ExitProcess + +extern void DECLSPEC_NORETURN ThrowOutOfMemory(); + +//***************************************************************************** +// Called for errors that might have occurred. +//***************************************************************************** +FARPROC __stdcall CorDelayErrorHook( // Always 0. + unsigned dliNotify, // What event has occurred, dli* flag. + DelayLoadInfo *pdli) // Description of the event. +{ + + STATIC_CONTRACT_THROWS; + STATIC_CONTRACT_FORBID_FAULT; + STATIC_CONTRACT_SO_TOLERANT; + + // Chose operation to perform based on operation. + switch (dliNotify) + { + // Failed to load the library. Need to fail gracefully. + case dliFailLoadLib: + //_FailLoadLib(dliNotify, pdli); + break; + + // Failed to get the address of the given function, fail gracefully. + case dliFailGetProc: +#ifndef FEATURE_CORECLR + _FailGetProc(dliNotify, pdli); +#endif // !FEATURE_CORECLR + break; + + // Unknown failure code. + default: + _ASSERTE(!"Unknown delay load failure code."); + break; + } + +#ifndef FEATURE_CORECLR + if (_stricmp(pdli->szDll, "ole32.dll") == 0) + { + // TODO: after interop team fixes delayload related to ole32.dll, we can throw OOM instead. + // For now, SQL preloads ole32.dll before starting CLR, so OOM for ole32 is not a concern. + ExitProcess(pdli->dwLastError); + } + else +#endif // !FEATURE_CORECLR +#ifdef MSDIS_DLL + // MSDIS_DLL is a macro defined in SOURCES.INC + if (_stricmp(pdli->szDll, MSDIS_DLL) == 0) + { + // msdisxxx.dll is used in GCStress 4 on chk/dbg builds, if it fails to load then the + // process will stack-overflow or terminate with no obvious reason of the root cause. + _ASSERTE(!"Failed to delay load " MSDIS_DLL); + } + else +#endif // MSDIS_DLL + { +#ifndef FEATURE_CORECLR + // We do not own the process. ExitProcess is bad. + // We will try to recover next time. + ThrowWin32 (pdli->dwLastError); +#endif // !FEATURE_CORECLR + } + + return (0); +} + + +//***************************************************************************** +// Format an error message using a system error (supplied through GetLastError) +// and any subtitution values required. +//***************************************************************************** +DWORD _FormatMessage( // How many characters written. + __out_ecount(chMsg) __out_z LPWSTR szMsg, // Buffer for formatted data. + DWORD chMsg, // How big is the buffer. + DWORD dwLastError, // The last error code we got. + ...) // Substitution values. +{ + WRAPPER_NO_CONTRACT; + + DWORD iRtn; + va_list marker; + + va_start(marker, dwLastError); + iRtn = WszFormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM, // Flags. + 0, // No source, use system. + dwLastError, // Error code. + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Use default langauge. + szMsg, // Output buffer. + dwLastError, // Size of buffer. + &marker); // Substitution text. + va_end(marker); + return (iRtn); +} + + +//***************************************************************************** +// A library failed to load. This is always a bad thing. +//***************************************************************************** +void _FailLoadLib( + unsigned dliNotify, // What event has occurred, dli* flag. + DelayLoadInfo *pdli) // Description of the event. +{ + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_FORBID_FAULT; + + // We're allocating strings for the purposes of putting up a critical error box. + // Obviously, OOM's aren't going to be passed up to the caller. + FAULT_NOT_FATAL(); + + + WCHAR rcMessage[_MAX_PATH+500]; // Message for display. + WCHAR rcFmt[500]; // 500 is the number used by excep.cpp for mscorrc resources. + HRESULT hr; + + // Load a detailed error message from the resource file. + if (SUCCEEDED(hr = UtilLoadStringRC(MSEE_E_LOADLIBFAILED, rcFmt, NumItems(rcFmt)))) + { + StringCchPrintf(rcMessage, COUNTOF(rcMessage), rcFmt, pdli->szDll, pdli->dwLastError); + } + else + { + // Foramt the Windows error first. + if (!_FormatMessage(rcMessage, NumItems(rcMessage), pdli->dwLastError, pdli->szDll)) + { + // Default to a hard coded error otherwise. + StringCchPrintf(rcMessage, COUNTOF(rcMessage), W("ERROR! Failed to delay load library %hs, Win32 error %d, Delay error: %d\n"), + pdli->szDll, pdli->dwLastError, dliNotify); + } + } + +#ifndef _ALPHA_ + // for some bizarre reason, calling OutputDebugString during delay load in non-debug mode on Alpha + // kills program, so only do it when in debug mode () +#if defined (_DEBUG) || defined (__delay_load_trace__) + // Give some feedback to the developer. + wprintf(W("%s\n"), rcMessage); + WszOutputDebugString(rcMessage); +#endif +#endif + + // Inform the user that we cannot continue execution anymore. + UtilMessageBoxCatastrophicNonLocalized(rcMessage, W("MSCOREE.DLL"), MB_ICONERROR | MB_OK, TRUE); + _ASSERTE(!"Failed to delay load library"); +} + + +//***************************************************************************** +// A library failed to load. This is always a bad thing. +//***************************************************************************** +void _FailGetProc( + unsigned dliNotify, // What event has occurred, dli* flag. + DelayLoadInfo *pdli) // Description of the event. +{ + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_FORBID_FAULT; + STATIC_CONTRACT_SO_TOLERANT; + + // We're allocating strings for the purposes of putting up a critical error box. + // Obviously, OOM's aren't going to be passed up to the caller. + FAULT_NOT_FATAL(); + + WCHAR rcMessage[_MAX_PATH+756]; // Message for display. + WCHAR rcProc[257] = {0}; // Name of procedure with error. + WCHAR rcFmt[500]; // 500 is the number used by excep.cpp for mscorrc resources. + HRESULT hr; + + // Get a display name for debugging information. + if (pdli->dlp.fImportByName) + Wsz_mbstowcs(rcProc, pdli->dlp.szProcName, sizeof(rcProc)/sizeof(rcProc[0])-1); + else + StringCchPrintf(rcProc, COUNTOF(rcProc), W("Ordinal: %d"), pdli->dlp.dwOrdinal); + + // Load a detailed error message from the resource file. + if (SUCCEEDED(hr = UtilLoadStringRC(MSEE_E_GETPROCFAILED, rcFmt, NumItems(rcFmt)))) + { + StringCchPrintf(rcMessage, COUNTOF(rcMessage), rcFmt, rcProc, pdli->szDll, pdli->dwLastError); + } + else + { + if (!_FormatMessage(rcMessage, NumItems(rcMessage), pdli->dwLastError, pdli->szDll)) + { + // Default to a hard coded error otherwise. + StringCchPrintf(rcMessage, COUNTOF(rcMessage), W("ERROR! Failed GetProcAddress() for %s, Win32 error %d, Delay error %d\n"), + rcProc, pdli->dwLastError, dliNotify); + } + } + +#ifndef ALPHA + // for some bizarre reason, calling OutputDebugString during delay load in non-debug mode on Alpha + // kills program, so only do it when in debug mode () +#if defined (_DEBUG) || defined (__delay_load_trace__) + // Give some feedback to the developer. + wprintf(W("%s"),rcMessage); + WszOutputDebugString(rcMessage); +#endif +#endif + + { + // We are already in a catastrophic situation so we can tolerate faults as well as SO & GC mode violations to keep going. + CONTRACT_VIOLATION(FaultNotFatal | GCViolation | ModeViolation | SOToleranceViolation); + + // Inform the user that we cannot continue execution anymore. + UtilMessageBoxCatastrophicNonLocalized(rcMessage, W("MSCOREE.DLL"), MB_ICONERROR | MB_OK, TRUE); + } + _ASSERTE(!"Failed to delay load GetProcAddress()"); +} + + + +HMODULE DoPreloadLibraryThrowing(LPCSTR szLibrary) +{ + STATIC_CONTRACT_THROWS; + STATIC_CONTRACT_SO_TOLERANT; + + HMODULE result=NULL; + BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(ThrowHR(COR_E_STACKOVERFLOW)); + DWORD dwLength = _MAX_PATH; + WCHAR pName[_MAX_PATH]; + IfFailThrow(GetInternalSystemDirectory(pName, &dwLength)); + + MAKE_WIDEPTR_FROMANSI_NOTHROW(pwLibrary, szLibrary); + if ((pwLibrary == NULL) || ovadd_ge(dwLength, __lpwLibrary, _MAX_PATH-1)) + ThrowHR(E_INVALIDARG); + + wcscpy_s(pName+dwLength-1, COUNTOF(pName) - dwLength + 1, pwLibrary); + result = CLRLoadLibraryEx(pName, NULL, GetLoadWithAlteredSearchPathFlag()); + END_SO_INTOLERANT_CODE; + return result; +} + +// +//********** Tracing code. **************************************************** +// + +//***************************************************************************** +// This routine is our Delay Load Helper. It will get called for every delay +// load event that occurs while the application is running. +//***************************************************************************** +FARPROC __stdcall CorDelayLoadHook( // Always 0. + unsigned dliNotify, // What event has occurred, dli* flag. + DelayLoadInfo *pdli) // Description of the event. +{ +#ifdef _DEBUG + if (dliNotify == dliStartProcessing) + { + BOOL fThrows = TRUE; + if (_stricmp(pdli->szDll, "ole32.dll") == 0) + { + // SQL loads ole32.dll before starting CLR. For Whidbey release, + // we do not have time to get ole32.dll delay load cleaned. + fThrows = FALSE; + } + else if (_stricmp(pdli->szDll, "oleaut32.dll") == 0) + { + extern BOOL DelayLoadOleaut32CheckDisabled(); + if (DelayLoadOleaut32CheckDisabled()) + { + fThrows = FALSE; + } + else if ((!pdli->dlp.fImportByName && pdli->dlp.dwOrdinal == 6) || + (pdli->dlp.fImportByName && strcmp(pdli->dlp.szProcName, "SysFreeString") == 0)) + { + // BSTR has been created, which means oleaut32 should have been loaded. + // Delay load will not fail. + _ASSERTE (GetModuleHandleA("oleaut32.dll") != NULL); + fThrows = FALSE; + } + } + else if (_stricmp(pdli->szDll, "mscoree.dll") == 0) // If we are attempting to delay load mscoree.dll + { + if (GetModuleHandleA("mscoree.dll") != NULL) // and mscoree.dll has already been loaded + fThrows = FALSE; // then the delay load will not fail (and hence will not throw). + } + if (fThrows) + { + CONTRACTL + { + SO_TOLERANT; + THROWS; + } + CONTRACTL_END; + } + } +#endif + + //STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_FAULT; + STATIC_CONTRACT_SO_TOLERANT; + + // We're allocating strings for the purposes of putting up a critical error box. + // Obviously, OOM's aren't going to be passed up to the caller. + HMODULE result = NULL; + CONTRACT_VIOLATION(FaultNotFatal); + + + switch(dliNotify) { + case dliNotePreLoadLibrary: + if(pdli->szDll) { + result=DoPreloadLibraryThrowing(pdli->szDll); + } + break; + default: + break; + } + +#if defined (_DEBUG) || defined (__delay_load_trace__) + SO_NOT_MAINLINE_FUNCTION; + static int bBreak = false; // true to break on events. + static int bInit = false; // true after we've checked environment. + // If we've not yet looked at our environment, then do so. + if (!bInit) + { + PathString rcBreak; + + // set DelayLoadBreak=[0|1] + if (WszGetEnvironmentVariable(W("DelayLoadBreak"), rcBreak)) + { + // "1" means to break hard and display errors. + if (rcBreak[0] == '1') + bBreak = 1; + // "2" means no break, but display errors. + else if (rcBreak[0] == '2') + bBreak = 2; + else + bBreak = false; + } + bInit = true; + } + + // Chose operation to perform based on operation. + switch (dliNotify) + { + // Called just before a load library takes place. Use this opportunity + // to display a debug trace message, and possible break if desired. + case dliNotePreLoadLibrary: + _DbgPreLoadLibrary(bBreak, pdli); + break; + } +#endif + return (FARPROC) result; +} + + +#if defined (_DEBUG) || defined (__delay_load_trace__) + +//***************************************************************************** +// Display a debug message so we know what's going on. Offer to break in +// debugger if you want to see what call stack forced this library to load. +//***************************************************************************** +void _DbgPreLoadLibrary( + int bBreak, // true to break in debugger. + DelayLoadInfo *pdli) // Description of the event. +{ + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_FORBID_FAULT; + + // We're allocating strings for the purposes of putting up a critical error box. + // Obviously, OOM's aren't going to be passed up to the caller. + FAULT_NOT_FATAL(); + + +#ifdef _ALPHA_ + // for some bizarre reason, calling OutputDebugString during delay load in non-debug mode on Alpha + // kills program, so only do it when in debug mode () + if (! IsDebuggerPresent()) + return; +#endif + + WCHAR rcMessage[_MAX_PATH*2]; // Message for display. + + // Give some feedback to the developer. + StringCchPrintf(rcMessage, COUNTOF(rcMessage), W("Delay loading %hs\n"), pdli->szDll); + WszOutputDebugString(rcMessage); + + if (bBreak) + { + wprintf(W("%s"), rcMessage); + + if (bBreak == 1) + { + _ASSERTE(!"fyi - Delay loading library. Set DelayLoadBreak=0 to disable this assert."); + } + } +} + + +#endif // _DEBUG + +#endif // !FEATURE_CORESYSTEM diff --git a/src/dlls/mscoree/dirs.proj b/src/dlls/mscoree/dirs.proj new file mode 100644 index 0000000000..8059846470 --- /dev/null +++ b/src/dlls/mscoree/dirs.proj @@ -0,0 +1,24 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!--Import the settings--> + <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" /> + + <!--The following projects will build during PHASE 1--> + <PropertyGroup> + <BuildInPhase1>true</BuildInPhase1> + <BuildInPhaseDefault>false</BuildInPhaseDefault> + <BuildCoreBinaries>true</BuildCoreBinaries> + <BuildSysBinaries>true</BuildSysBinaries> + </PropertyGroup> + + <ItemGroup Condition="'$(BuildExePhase)' == '1' and '$(FeatureCoreClr)' != 'true'"> + <ProjectFile Include="wks\clr.nativeproj" /> + </ItemGroup> + + <!--The following projects will build during PHASE 1 of the CoreCLR build--> + <ItemGroup Condition="'$(BuildExePhase)' == '1' and '$(FeatureCoreClr)' == 'true'"> + <ProjectFile Include="coreclr\coreclr.nativeproj" /> + </ItemGroup> + + <!--Import the targets--> + <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" /> +</Project> diff --git a/src/dlls/mscoree/dw20.msi b/src/dlls/mscoree/dw20.msi Binary files differnew file mode 100644 index 0000000000..f8d0752a84 --- /dev/null +++ b/src/dlls/mscoree/dw20.msi diff --git a/src/dlls/mscoree/dw20_amd64.msi b/src/dlls/mscoree/dw20_amd64.msi Binary files differnew file mode 100644 index 0000000000..53233acc1e --- /dev/null +++ b/src/dlls/mscoree/dw20_amd64.msi diff --git a/src/dlls/mscoree/mscoree.cpp b/src/dlls/mscoree/mscoree.cpp new file mode 100644 index 0000000000..3d33337c62 --- /dev/null +++ b/src/dlls/mscoree/mscoree.cpp @@ -0,0 +1,1249 @@ +// 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. +//***************************************************************************** +// MSCoree.cpp +//***************************************************************************** +#include "stdafx.h" // Standard header. + +#include <utilcode.h> // Utility helpers. +#include <posterror.h> // Error handlers +#define INIT_GUIDS +#include <corpriv.h> +#include <winwrap.h> +#include <mscoree.h> +#include "shimload.h" +#include "metadataexports.h" +#include "ex.h" +#if !defined(FEATURE_CORECLR) +#include "corsym.h" +#endif + +#if defined(FEATURE_CORECLR) +#include "product_version.h" +#endif // FEATURE_CORECLR + +#ifdef FEATURE_COMINTEROP +#include "ComCallUnmarshal.h" +#endif // FEATURE_COMINTEROP + +#if !defined(FEATURE_CORECLR) && !defined(CROSSGEN_COMPILE) +#include <metahost.h> +extern ICLRRuntimeInfo *g_pCLRRuntime; +#endif // !FEATURE_CORECLR && !CROSSGEN_COMPILE + +#include "clrprivhosting.h" + +#ifndef FEATURE_CORECLR +#include "clr/win32.h" +#endif // FEATURE_CORECLR + +#ifdef FEATURE_PROFAPI_ATTACH_DETACH +#include "../../vm/profattach.h" +#endif // FEATURE_PROFAPI_ATTACH_DETACH + + +#if defined(FEATURE_CORECLR) +#include <dbgenginemetrics.h> +#endif // FEATURE_CORECLR + +// Locals. +BOOL STDMETHODCALLTYPE EEDllMain( // TRUE on success, FALSE on error. + HINSTANCE hInst, // Instance handle of the loaded module. + DWORD dwReason, // Reason for loading. + LPVOID lpReserved); // Unused. + +#ifdef FEATURE_COMINTEROP_MANAGED_ACTIVATION +// try to load a com+ class and give out an IClassFactory +HRESULT STDMETHODCALLTYPE EEDllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID FAR *ppv); +#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION + +// Globals. +HINSTANCE g_hThisInst; // This library. + +#ifndef CROSSGEN_COMPILE +//***************************************************************************** +// Handle lifetime of loaded library. +//***************************************************************************** + +#ifdef FEATURE_CORECLR + +#include <shlwapi.h> + +#include <process.h> // for __security_init_cookie() + +void* __stdcall GetCLRFunction(LPCSTR FunctionName); + +extern "C" IExecutionEngine* __stdcall IEE(); + +#ifdef NO_CRT_INIT +#define _CRT_INIT(hInstance, dwReason, lpReserved) (TRUE) +#else +extern "C" BOOL WINAPI _CRT_INIT(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved); +#endif + +extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved); + +// For the CoreClr, this is the real DLL entrypoint. We make ourselves the first entrypoint as +// we need to capture coreclr's hInstance before the C runtine initializes. This function +// will capture hInstance, let the C runtime initialize and then invoke the "classic" +// DllMain that initializes everything else. +extern "C" BOOL WINAPI CoreDllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) +{ + STATIC_CONTRACT_NOTHROW; + + BOOL result; + switch (dwReason) + { + case DLL_PROCESS_ATTACH: +#ifndef FEATURE_PAL + // Make sure the /GS security cookie is initialized before we call anything else. + // BinScope detects the call to __security_init_cookie in its "Has Non-GS-friendly + // Initialization" check and makes it pass. + __security_init_cookie(); +#endif // FEATURE_PAL + + // It's critical that we invoke InitUtilCode() before the CRT initializes. + // We have a lot of global ctors that will break if we let the CRT initialize without + // this step having been done. + + CoreClrCallbacks cccallbacks; + cccallbacks.m_hmodCoreCLR = (HINSTANCE)hInstance; + cccallbacks.m_pfnIEE = IEE; + cccallbacks.m_pfnGetCORSystemDirectory = GetCORSystemDirectoryInternaL; + cccallbacks.m_pfnGetCLRFunction = GetCLRFunction; + InitUtilcode(cccallbacks); + + if (!(result = _CRT_INIT(hInstance, dwReason, lpReserved))) + { + // CRT_INIT may fail to initialize the CRT heap. Make sure we don't continue + // down a path that would trigger an AV and tear down the host process + break; + } + result = DllMain(hInstance, dwReason, lpReserved); + break; + + case DLL_THREAD_ATTACH: + _CRT_INIT(hInstance, dwReason, lpReserved); + result = DllMain(hInstance, dwReason, lpReserved); + break; + + case DLL_PROCESS_DETACH: // intentional fallthru + case DLL_THREAD_DETACH: + result = DllMain(hInstance, dwReason, lpReserved); + _CRT_INIT(hInstance, dwReason, lpReserved); + break; + + default: + result = FALSE; // it'd be an OS bug if we got here - not much we can do. + break; + } + return result; +} +#endif //FEATURE_CORECLR + +extern "C" +BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) +{ + STATIC_CONTRACT_NOTHROW; + + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + { + // Save the module handle. + g_hThisInst = (HINSTANCE)hInstance; + +#ifndef FEATURE_CORECLR + // clr.dll cannot be unloaded + // Normally the shim prevents it from ever being unloaded, but we now support fusion loading + // us directly, so we need to take an extra ref on our handle to ensure we don't get unloaded. + if (FAILED(clr::win32::PreventModuleUnload(g_hThisInst))) + { + return FALSE; + } +#endif // FEATURE_CORECLR + + // Prevent buffer-overruns + // If buffer is overrun, it is possible the saved callback has been trashed. + // The callback is unsafe. + //SetBufferOverrunHandler(); + if (!EEDllMain((HINSTANCE)hInstance, dwReason, lpReserved)) + { + return FALSE; + } + } + break; + + case DLL_PROCESS_DETACH: + { + EEDllMain((HINSTANCE)hInstance, dwReason, lpReserved); + } + break; + + case DLL_THREAD_DETACH: + { + EEDllMain((HINSTANCE)hInstance, dwReason, lpReserved); + } + break; + } + + return TRUE; +} + +#ifndef FEATURE_CORECLR // coreclr does not export this +// --------------------------------------------------------------------------- +// %%Function: DllGetClassObjectInternal %%Owner: NatBro %%Reviewed: 00/00/00 +// +// Parameters: +// rclsid - reference to the CLSID of the object whose +// ClassObject is being requested +// iid - reference to the IID of the interface on the +// ClassObject that the caller wants to communicate +// with +// ppv - location to return reference to the interface +// specified by iid +// +// Returns: +// S_OK - if successful, valid interface returned in *ppv, +// otherwise *ppv is set to NULL and one of the +// following errors is returned: +// E_NOINTERFACE - ClassObject doesn't support requested interface +// CLASS_E_CLASSNOTAVAILABLE - clsid does not correspond to a supported class +// +// Description: +// Returns a reference to the iid interface on the main COR ClassObject. +// This function is one of the required by-name entry points for COM +// DLL's. Its purpose is to provide a ClassObject which by definition +// supports at least IClassFactory and can therefore create instances of +// objects of the given class. +// --------------------------------------------------------------------------- + +#ifdef FEATURE_COMINTEROP +// This could be merged with Metadata's class factories! +static CComCallUnmarshalFactory g_COMCallUnmarshal; +#endif // FEATURE_COMINTEROP + +STDAPI InternalDllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID FAR *ppv) +{ + // @todo: this is called before the runtime is really started, so the contract's don't work. + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_SO_TOLERANT; + + HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; + BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return COR_E_STACKOVERFLOW); + + + if (rclsid == CLSID_CorMetaDataDispenser || rclsid == CLSID_CorMetaDataDispenserRuntime || + rclsid == CLSID_CorRuntimeHost || rclsid == CLSID_CLRRuntimeHost || + rclsid == CLSID_TypeNameFactory + || rclsid == __uuidof(CLRPrivRuntime) + ) + { + hr = MetaDataDllGetClassObject(rclsid, riid, ppv); + } +#ifdef FEATURE_PROFAPI_ATTACH_DETACH + else if (rclsid == CLSID_CLRProfiling) + { + hr = ICLRProfilingGetClassObject(rclsid, riid, ppv); + } +#endif // FEATURE_PROFAPI_ATTACH_DETACH +#ifdef FEATURE_COMINTEROP + else if (rclsid == CLSID_ComCallUnmarshal || rclsid == CLSID_ComCallUnmarshalV4) + { + // We still respond to the 1.0/1.1/2.0 CLSID so we don't break anyone who is instantiating + // this (we could be called for CLSID_ComCallUnmarshal if the process is rollForward=true) + hr = g_COMCallUnmarshal.QueryInterface(riid, ppv); + } + else if (rclsid == CLSID_CorSymBinder_SxS) + { + EX_TRY + { + + // PDB format - use diasymreader.dll with COM activation + InlineSString<_MAX_PATH> ssBuf; + if (SUCCEEDED(GetHModuleDirectory(GetModuleInst(), ssBuf))) + { + hr = FakeCoCallDllGetClassObject(rclsid, + ssBuf, + riid, + ppv, + NULL + ); + } + } + EX_CATCH_HRESULT(hr); + } + else + { +#ifdef FEATURE_COMINTEROP_MANAGED_ACTIVATION + // Returns a managed object imported into COM-classic. + hr = EEDllGetClassObject(rclsid,riid,ppv); +#endif // FEATURE_COMINTEROP_MANAGED_ACTIVATION + } +#endif // FEATURE_COMINTEROP + + END_SO_INTOLERANT_CODE; + return hr; +} // InternalDllGetClassObject + + +STDAPI DllGetClassObjectInternal( + REFCLSID rclsid, + REFIID riid, + LPVOID FAR *ppv) +{ + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_ENTRY_POINT; + + HRESULT hr = S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + // InternalDllGetClassObject exists to resolve an issue + // on FreeBSD, where libsscoree.so's DllGetClassObject's + // call to DllGetClassObjectInternal() was being bound to + // the implementation in libmscordbi.so, not the one in + // libsscoree.so. The fix is to disambiguate the name. + hr = InternalDllGetClassObject(rclsid, riid, ppv); + END_ENTRYPOINT_NOTHROW; + + return hr; +} +#endif // FEATURE_CORECLR + +#ifdef FEATURE_COMINTEROP +// --------------------------------------------------------------------------- +// %%Function: DllCanUnloadNowInternal +// +// Returns: +// S_FALSE - Indicating that COR, once loaded, may not be +// unloaded. +// --------------------------------------------------------------------------- +STDAPI DllCanUnloadNowInternal(void) +{ + STATIC_CONTRACT_NOTHROW; + STATIC_CONTRACT_ENTRY_POINT; + + //we should never unload unless the process is dying + return S_FALSE; +} // DllCanUnloadNowInternal + +// --------------------------------------------------------------------------- +// %%Function: DllRegisterServerInternal +// +// Description: +// Registers +// --------------------------------------------------------------------------- +STDAPI DllRegisterServerInternal(HINSTANCE hMod, LPCWSTR version) +{ + + CONTRACTL{ + NOTHROW; + GC_NOTRIGGER; + ENTRY_POINT; + PRECONDITION(CheckPointer(version)); + } CONTRACTL_END; + + return S_OK; +} // DllRegisterServerInternal + +// --------------------------------------------------------------------------- +// %%Function: DllUnregisterServerInternal +// --------------------------------------------------------------------------- +STDAPI DllUnregisterServerInternal(void) +{ + + CONTRACTL + { + GC_NOTRIGGER; + NOTHROW; + ENTRY_POINT; + } + CONTRACTL_END; + + return S_OK; + +} // DllUnregisterServerInternal +#endif // FEATURE_COMINTEROP + +#endif // CROSSGEN_COMPILE + +HINSTANCE GetModuleInst() +{ + LIMITED_METHOD_CONTRACT; + return (g_hThisInst); +} + +// --------------------------------------------------------------------------- +// %%Function: MetaDataGetDispenser +// This function gets the Dispenser interface given the CLSID and REFIID. +// --------------------------------------------------------------------------- +STDAPI 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; + ENTRY_POINT; + PRECONDITION(CheckPointer(ppv)); + } CONTRACTL_END; + + NonVMComHolder<IClassFactory> pcf(NULL); + HRESULT hr; + BEGIN_ENTRYPOINT_NOTHROW; + + IfFailGo(MetaDataDllGetClassObject(rclsid, IID_IClassFactory, (void **) &pcf)); + hr = pcf->CreateInstance(NULL, riid, ppv); + +ErrExit: + END_ENTRYPOINT_NOTHROW; + + return (hr); +} + +// --------------------------------------------------------------------------- +// %%Function: GetMetaDataInternalInterface +// This function gets the IMDInternalImport given the metadata on memory. +// --------------------------------------------------------------------------- +STDAPI 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; + + HRESULT hr = S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + hr = GetMDInternalInterface(pData, cbData, flags, riid, ppv); + + END_ENTRYPOINT_NOTHROW; + return hr; +} + +// --------------------------------------------------------------------------- +// %%Function: GetMetaDataInternalInterfaceFromPublic +// This function gets the internal scopeless interface given the public +// scopeless interface. +// --------------------------------------------------------------------------- +STDAPI 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; + + HRESULT hr = S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + hr = GetMDInternalInterfaceFromPublic(pv, riid, ppv); + + END_ENTRYPOINT_NOTHROW; + return hr; +} + +// --------------------------------------------------------------------------- +// %%Function: GetMetaDataPublicInterfaceFromInternal +// This function gets the public scopeless interface given the internal +// scopeless interface. +// --------------------------------------------------------------------------- +STDAPI 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; + + HRESULT hr = S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + hr = GetMDPublicInterfaceFromInternal(pv, riid, ppv); + + END_ENTRYPOINT_NOTHROW; + return hr; +} + + +// --------------------------------------------------------------------------- +// %%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; + + HRESULT hr = S_OK; + + BEGIN_ENTRYPOINT_NOTHROW; + hr = MDReOpenMetaDataWithMemory(pUnk, pData, cbData); + END_ENTRYPOINT_NOTHROW; + return hr; +} + +// --------------------------------------------------------------------------- +// %%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; + + HRESULT hr = S_OK; + + BEGIN_ENTRYPOINT_NOTHROW; + hr = MDReOpenMetaDataWithMemoryEx(pUnk, pData, cbData, dwReOpenFlags); + END_ENTRYPOINT_NOTHROW; + return hr; +} + +#ifdef FEATURE_FUSION +// --------------------------------------------------------------------------- +// %%Function: GetAssemblyMDImport +// This function gets the IMDAssemblyImport given the filename +// --------------------------------------------------------------------------- +STDAPI GetAssemblyMDImport( // Return code. + LPCWSTR szFileName, // [in] The scope to open. + REFIID riid, // [in] The interface desired. + IUnknown **ppIUnk) // [out] Return interface on success. +{ + CONTRACTL + { + NOTHROW; + ENTRY_POINT; + } + CONTRACTL_END; + HRESULT hr=S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + hr=GetAssemblyMDInternalImport(szFileName, riid, ppIUnk); + END_ENTRYPOINT_NOTHROW; + return hr; +} +#endif + +#ifndef CROSSGEN_COMPILE +// --------------------------------------------------------------------------- +// %%Function: CoInitializeCor +// +// Parameters: +// fFlags - Initialization flags for the engine. See the +// COINITICOR enumerator for valid values. +// +// Returns: +// S_OK - On success +// +// Description: +// Reserved to initialize the Cor runtime engine explicitly. This currently +// does nothing. +// --------------------------------------------------------------------------- +STDAPI CoInitializeCor(DWORD fFlags) +{ + WRAPPER_NO_CONTRACT; + + BEGIN_ENTRYPOINT_NOTHROW; + + // Since the CLR doesn't currently support being unloaded, we don't hold a ref + // count and don't even pretend to try to unload. + END_ENTRYPOINT_NOTHROW; + + return (S_OK); +} + +// --------------------------------------------------------------------------- +// %%Function: CoUninitializeCor +// +// Parameters: +// none +// +// Returns: +// Nothing +// +// Description: +// Function to indicate the client is done with the CLR. This currently does +// nothing. +// --------------------------------------------------------------------------- +STDAPI_(void) CoUninitializeCor(void) +{ + WRAPPER_NO_CONTRACT; + + BEGIN_ENTRYPOINT_VOIDRET; + + // Since the CLR doesn't currently support being unloaded, we don't hold a ref + // count and don't even pretend to try to unload. + END_ENTRYPOINT_VOIDRET; + +} + +// Undef LoadStringRC & LoadStringRCEx so we can export these functions. +#undef LoadStringRC +#undef LoadStringRCEx + +// --------------------------------------------------------------------------- +// %%Function: LoadStringRC +// +// Parameters: +// none +// +// Returns: +// Nothing +// +// Description: +// Function to load a resource based on it's ID. +// --------------------------------------------------------------------------- +STDAPI LoadStringRC( + UINT iResourceID, + __out_ecount(iMax) __out_z LPWSTR szBuffer, + int iMax, + int bQuiet +) +{ + WRAPPER_NO_CONTRACT; + + HRESULT hr = S_OK; + + if (NULL == szBuffer) + return E_INVALIDARG; + if (0 == iMax) + return E_INVALIDARG; + + BEGIN_ENTRYPOINT_NOTHROW; + hr = UtilLoadStringRC(iResourceID, szBuffer, iMax, bQuiet); + END_ENTRYPOINT_NOTHROW; + return hr; +} + +// --------------------------------------------------------------------------- +// %%Function: LoadStringRCEx +// +// Parameters: +// none +// +// Returns: +// Nothing +// +// Description: +// Ex version of the function to load a resource based on it's ID. +// --------------------------------------------------------------------------- +#ifdef FEATURE_USE_LCID +STDAPI LoadStringRCEx( + LCID lcid, + UINT iResourceID, + __out_ecount(iMax) __out_z LPWSTR szBuffer, + int iMax, + int bQuiet, + int *pcwchUsed +) +{ + WRAPPER_NO_CONTRACT; + HRESULT hr = S_OK; + + if (NULL == szBuffer) + return E_INVALIDARG; + if (0 == iMax) + return E_INVALIDARG; + + BEGIN_ENTRYPOINT_NOTHROW; + hr = UtilLoadStringRCEx(lcid, iResourceID, szBuffer, iMax, bQuiet, pcwchUsed); + END_ENTRYPOINT_NOTHROW; + return hr; +} +#endif +// Redefine them as errors to prevent people from using these from inside the rest of the compilation unit. +#define LoadStringRC __error("From inside the CLR, use UtilLoadStringRC; LoadStringRC is only meant to be exported.") +#define LoadStringRCEx __error("From inside the CLR, use UtilLoadStringRCEx; LoadStringRC is only meant to be exported.") + +#endif // CROSSGEN_COMPILE + + + + +// Note that there are currently two callers of this function: code:CCompRC.LoadLibrary +// and code:CorLaunchApplication. +STDAPI GetRequestedRuntimeInfoInternal(LPCWSTR pExe, + LPCWSTR pwszVersion, + LPCWSTR pConfigurationFile, + DWORD startupFlags, + DWORD runtimeInfoFlags, + __out_ecount_opt(dwDirectory) LPWSTR pDirectory, + DWORD dwDirectory, + __out_opt DWORD *pdwDirectoryLength, + __out_ecount_opt(cchBuffer) LPWSTR pVersion, + DWORD cchBuffer, + __out_opt DWORD* pdwLength) +{ + CONTRACTL + { + NOTHROW; + GC_NOTRIGGER; + ENTRY_POINT; + PRECONDITION( pVersion != NULL && cchBuffer > 0); + } CONTRACTL_END; + + // for simplicity we will cheat and return the entire system directory in pDirectory + pVersion[0] = 0; + if (pdwLength != NULL) + *pdwLength = 0; + HRESULT hr; + + BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(SetLastError(COR_E_STACKOVERFLOW); return COR_E_STACKOVERFLOW;) + EX_TRY + { + + PathString pDirectoryPath; + + hr = GetCORSystemDirectoryInternaL(pDirectoryPath); + *pdwLength = pDirectoryPath.GetCount() + 1; + if (dwDirectory >= *pdwLength) + { + wcscpy_s(pDirectory, pDirectoryPath.GetCount() + 1, pDirectoryPath); + } + else + { + hr = E_FAIL; + } + + } + EX_CATCH_HRESULT(hr); + END_SO_INTOLERANT_CODE + + return hr; +} + +// Replacement for legacy shim API GetCORRequiredVersion(...) used in linked libraries. +// Used in code:TiggerStorage::GetDefaultVersion#CallTo_CLRRuntimeHostInternal_GetImageVersionString. +HRESULT +CLRRuntimeHostInternal_GetImageVersionString( + __out_ecount_opt(*pcchBuffer) LPWSTR wszBuffer, + __inout DWORD *pcchBuffer) +{ + // Simply forward the call to the ICLRRuntimeHostInternal implementation. + STATIC_CONTRACT_WRAPPER; + +#if defined(FEATURE_CORECLR) || defined(CROSSGEN_COMPILE) + HRESULT hr = GetCORVersionInternal(wszBuffer, *pcchBuffer, pcchBuffer); +#else + ReleaseHolder<ICLRRuntimeHostInternal> pRuntimeHostInternal; + HRESULT hr = g_pCLRRuntime->GetInterface(CLSID_CLRRuntimeHostInternal, + IID_ICLRRuntimeHostInternal, + &pRuntimeHostInternal); + if (SUCCEEDED(hr)) + { + hr = pRuntimeHostInternal->GetImageVersionString(wszBuffer, pcchBuffer); + } +#endif + + return hr; +} // CLRRuntimeHostInternal_GetImageVersionString + + //LONGPATH:TODO: Remove this once Desktop usage has been removed +#if !defined(FEATURE_CORECLR) +STDAPI GetCORSystemDirectoryInternal(__out_ecount_part_opt(cchBuffer, *pdwLength) LPWSTR pBuffer, + DWORD cchBuffer, + __out_opt DWORD* pdwLength) +{ +#if defined(CROSSGEN_COMPILE) + + CONTRACTL{ + NOTHROW; + GC_NOTRIGGER; + ENTRY_POINT; + PRECONDITION(CheckPointer(pBuffer, NULL_OK)); + PRECONDITION(CheckPointer(pdwLength, NULL_OK)); + } CONTRACTL_END; + + HRESULT hr = S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + if (pdwLength == NULL) + IfFailGo(E_POINTER); + + if (pBuffer == NULL) + IfFailGo(E_POINTER); + + if (WszGetModuleFileName(NULL, pBuffer, cchBuffer) == 0) + { + IfFailGo(HRESULT_FROM_GetLastError()); + } + WCHAR *pSeparator; + pSeparator = wcsrchr(pBuffer, DIRECTORY_SEPARATOR_CHAR_W); + if (pSeparator == NULL) + { + IfFailGo(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)); + } + *pSeparator = W('\0'); + + // Include the null terminator in the length + *pdwLength = (DWORD)wcslen(pBuffer) + 1; + +ErrExit: + END_ENTRYPOINT_NOTHROW; + return hr; + +#else // CROSSGEN_COMPILE + + // Simply forward the call to the ICLRRuntimeInfo implementation. + STATIC_CONTRACT_WRAPPER; + HRESULT hr = S_OK; + if (g_pCLRRuntime) + { + hr = g_pCLRRuntime->GetRuntimeDirectory(pBuffer, &cchBuffer); + *pdwLength = cchBuffer; + } + else + { + // not invoked via shim (most probably loaded by Fusion) + WCHAR wszPath[_MAX_PATH]; + DWORD dwLength = WszGetModuleFileName(g_hThisInst, wszPath, NumItems(wszPath)); + + + if (dwLength == 0 || (dwLength == NumItems(wszPath) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) + { + return E_UNEXPECTED; + } + + LPWSTR pwzSeparator = wcsrchr(wszPath, W('\\')); + if (pwzSeparator == NULL) + { + return E_UNEXPECTED; + } + pwzSeparator[1] = W('\0'); // after '\' + + LPWSTR pwzDirectoryName = wszPath; + + size_t cchLength = wcslen(pwzDirectoryName) + 1; + + if (cchBuffer < cchLength) + { + hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if (pBuffer != NULL) + { + // all look good, copy the string over + wcscpy_s(pBuffer, + cchLength, + pwzDirectoryName + ); + } + } + + // hand out the length regardless of success/failure + *pdwLength = (DWORD)cchLength; + } + return hr; + +#endif // CROSSGEN_COMPILE +} +#endif // !FEATURE_CORECLR + +STDAPI GetCORSystemDirectoryInternaL(SString& pBuffer) +{ +#if defined(FEATURE_CORECLR) || defined(CROSSGEN_COMPILE) + + CONTRACTL { + NOTHROW; + GC_NOTRIGGER; + ENTRY_POINT; + } CONTRACTL_END; + + HRESULT hr = S_OK; + BEGIN_ENTRYPOINT_NOTHROW; + + +#ifdef CROSSGEN_COMPILE + + if (WszGetModuleFileName(NULL, pBuffer) > 0) + { + hr = CopySystemDirectory(pBuffer, pBuffer); + } + else { + hr = HRESULT_FROM_GetLastError(); + } + +#else + + if (!PAL_GetPALDirectoryWrapper(pBuffer)) { + hr = HRESULT_FROM_GetLastError(); + } +#endif + + END_ENTRYPOINT_NOTHROW; + return hr; + +#else // FEATURE_CORECLR || CROSSGEN_COMPILE + DWORD cchBuffer = MAX_PATH - 1; + // Simply forward the call to the ICLRRuntimeInfo implementation. + STATIC_CONTRACT_WRAPPER; + HRESULT hr = S_OK; + if (g_pCLRRuntime) + { + WCHAR* temp = pBuffer.OpenUnicodeBuffer(cchBuffer); + hr = g_pCLRRuntime->GetRuntimeDirectory(temp, &cchBuffer); + pBuffer.CloseBuffer(cchBuffer - 1); + } + else + { + // not invoked via shim (most probably loaded by Fusion) + DWORD dwLength = WszGetModuleFileName(g_hThisInst, pBuffer); + + + if (dwLength == 0 || ((dwLength == pBuffer.GetCount() + 1) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) + { + return E_UNEXPECTED; + } + + CopySystemDirectory(pBuffer, pBuffer); + } + return hr; + +#endif // FEATURE_CORECLR || CROSSGEN_COMPILE +} + +// +// Returns version of the runtime (null-terminated). +// +// Arguments: +// pBuffer - [out] Output buffer allocated by caller of size cchBuffer. +// cchBuffer - Size of pBuffer in characters. +// pdwLength - [out] Size of the version string in characters (incl. null-terminator). Will be filled +// even if ERROR_INSUFFICIENT_BUFFER is returned. +// +// Return Value: +// S_OK - Output buffer contains the version string. +// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) - *pdwLength contains required size of the buffer in +// characters. + +STDAPI GetCORVersionInternal( +__out_ecount_z_opt(cchBuffer) LPWSTR pBuffer, + DWORD cchBuffer, + __out DWORD *pdwLength) +{ +#if defined(FEATURE_CORECLR) || defined(CROSSGEN_COMPILE) + + CONTRACTL { + NOTHROW; + GC_NOTRIGGER; + ENTRY_POINT; + PRECONDITION(CheckPointer(pBuffer, NULL_OK)); + PRECONDITION(CheckPointer(pdwLength)); + } CONTRACTL_END; + + HRESULT hr; + BEGIN_ENTRYPOINT_NOTHROW; + + if ((pBuffer != NULL) && (cchBuffer > 0)) + { // Initialize the output for case the function fails + *pBuffer = W('\0'); + } + +#define VERSION_NUMBER_NOSHIM W("v") QUOTE_MACRO_L(VER_MAJORVERSION.VER_MINORVERSION.VER_PRODUCTBUILD) + + DWORD length = (DWORD)(wcslen(VERSION_NUMBER_NOSHIM) + 1); + if (length > cchBuffer) + { + hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if (pBuffer == NULL) + { + hr = E_POINTER; + } + else + { + CopyMemory(pBuffer, VERSION_NUMBER_NOSHIM, length * sizeof(WCHAR)); + hr = S_OK; + } + } + *pdwLength = length; + + END_ENTRYPOINT_NOTHROW; + return hr; + +#else // FEATURE_CORECLR || CROSSGEN_COMPILE + + // Simply forward the call to the ICLRRuntimeInfo implementation. + STATIC_CONTRACT_WRAPPER; + HRESULT hr = S_OK; + if (g_pCLRRuntime) + { + hr = g_pCLRRuntime->GetVersionString(pBuffer, &cchBuffer); + *pdwLength = cchBuffer; + } + else + { + // not invoked via shim (most probably loaded by Fusion) + WCHAR wszPath[_MAX_PATH]; + DWORD dwLength = WszGetModuleFileName(g_hThisInst, wszPath,NumItems(wszPath)); + + + if (dwLength == 0 || (dwLength == NumItems(wszPath) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) + { + return E_UNEXPECTED; + } + + LPWSTR pwzSeparator = wcsrchr(wszPath, W('\\')); + if (pwzSeparator == NULL) + { + return E_UNEXPECTED; + } + *pwzSeparator = W('\0'); + + LPWSTR pwzDirectoryName = wcsrchr(wszPath, W('\\')); + if (pwzDirectoryName == NULL) + { + return E_UNEXPECTED; + } + pwzDirectoryName++; // skip '\' + + size_t cchLength = wcslen(pwzDirectoryName) + 1; + + if (cchBuffer < cchLength) + { + hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if (pBuffer != NULL) + { + // all look good, copy the string over + wcscpy_s(pBuffer, + cchLength, + pwzDirectoryName + ); + } + } + + // hand out the length regardless of success/failure + *pdwLength = (DWORD)cchLength; + + } + return hr; + +#endif // FEATURE_CORECLR || CROSSGEN_COMPILE + +} + +#ifndef CROSSGEN_COMPILE +#ifndef FEATURE_CORECLR +STDAPI LoadLibraryShimInternal(LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE *phModDll) +{ + // Simply forward the call to the ICLRRuntimeInfo implementation. + STATIC_CONTRACT_WRAPPER; + if (g_pCLRRuntime) + { + return g_pCLRRuntime->LoadLibrary(szDllName, phModDll); + } + else + { + // no runtime info, probably loaded directly (e.g. from Fusion) + // just look next to ourselves. + WCHAR wszPath[MAX_PATH]; + DWORD dwLength = WszGetModuleFileName(g_hThisInst, wszPath,NumItems(wszPath)); + + + if (dwLength == 0 || (dwLength == NumItems(wszPath) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) + { + return E_UNEXPECTED; + } + + LPWSTR pwzSeparator = wcsrchr(wszPath, W('\\')); + if (pwzSeparator == NULL) + { + return E_UNEXPECTED; + } + pwzSeparator[1]=W('\0'); + + wcscat_s(wszPath,NumItems(wszPath),szDllName); + *phModDll= WszLoadLibraryEx(wszPath,NULL,GetLoadWithAlteredSearchPathFlag()); + + if (*phModDll == NULL) + { + return HRESULT_FROM_GetLastError(); + } + return S_OK; + } +} +#endif +#endif + +static DWORD g_dwSystemDirectory = 0; +static WCHAR * g_pSystemDirectory = NULL; + +HRESULT GetInternalSystemDirectory(__out_ecount_part_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<WCHAR> pSystemDirectory; + EX_TRY{ + + // use local buffer for thread safety + PathString wzSystemDirectory; + + hr = GetCORSystemDirectoryInternaL(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; +} + +#if defined(CROSSGEN_COMPILE) && defined(FEATURE_CORECLR) +void SetMscorlibPath(LPCWSTR wzSystemDirectory) +{ + DWORD len = (DWORD)wcslen(wzSystemDirectory); + bool appendSeparator = wzSystemDirectory[len-1] != DIRECTORY_SEPARATOR_CHAR_W; + DWORD lenAlloc = appendSeparator ? len+2 : len+1; + if (g_dwSystemDirectory < lenAlloc) + { + delete [] g_pSystemDirectory; + g_pSystemDirectory = new (nothrow) WCHAR[lenAlloc]; + + if (g_pSystemDirectory == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return; + } + } + + wcscpy_s(g_pSystemDirectory, len+1, wzSystemDirectory); + + if(appendSeparator) + { + g_pSystemDirectory[len] = DIRECTORY_SEPARATOR_CHAR_W; + g_pSystemDirectory[len+1] = W('\0'); + g_dwSystemDirectory = len + 1; + } + else + { + g_dwSystemDirectory = len; + } +} +#endif diff --git a/src/dlls/mscoree/mscoree.settings.targets b/src/dlls/mscoree/mscoree.settings.targets new file mode 100644 index 0000000000..6aa31b990f --- /dev/null +++ b/src/dlls/mscoree/mscoree.settings.targets @@ -0,0 +1,268 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <!--Leaf project Properties--> + <PropertyGroup> + + <UserIncludes> + $(UserIncludes); + .; + ..; + ..\..\inc; + ..\..\..\inc; + ..\..\..\fusion\inc + </UserIncludes> + + <DllEntryPoint Condition="'$(FeatureCoreclr)'=='true'">CoreDllMain</DllEntryPoint> + <DllEntryPoint Condition="'$(FeatureCoreclr)'!='true'">_DllMainCRTStartup</DllEntryPoint> + <TargetType Condition="'$(TargetType)'==''">DYNLINK</TargetType> + <LinkSubsystem>windows</LinkSubsystem> + + <NoLinkGdi32>true</NoLinkGdi32> + <LinkAdditionalOptions>$(LinkAdditionalOptions) /NXCOMPAT</LinkAdditionalOptions> + <!-- /NOVCFEATURE forces linker to emit old .pdb format. It is required for scan.exe tool to work --> + <LinkAdditionalOptions Condition="'$(BuildType)' == 'Checked' and '$(UseCoreToolset)' != 'true'">$(LinkAdditionalOptions) /NOVCFEATURE</LinkAdditionalOptions> + <LinkGenerateManifest Condition="'$(BuildForCoreSystem)' == 'true'">false</LinkGenerateManifest> + <CDefines>$(CDefines);UNICODE;_UNICODE</CDefines> + <PCHHeader>stdafx.h</PCHHeader> + <EnableCxxPCHHeaders>true</EnableCxxPCHHeaders> + <PCHCompile>..\stdafx.cpp</PCHCompile> + <LinkWarningsAsErrors>false</LinkWarningsAsErrors> + + <CDefines Condition="'$(_BuildType)' == 'dbg'">$(CDefines);SPECIAL_BUILD</CDefines> + <DllDef Condition="'$(TargetType)'=='DYNLINK'">$(IntermediateOutputDirectory)\$(MainClrModuleName).def</DllDef> + + <ExtDelayImpLib>true</ExtDelayImpLib> + <DoNotAddCrtLibPath>true</DoNotAddCrtLibPath> + <LinkUseDefaultLib>false</LinkUseDefaultLib> + </PropertyGroup> + + <PropertyGroup Condition="'$(BuildForCoreSystem)' != 'true'"> + <LinkDelayLoad Condition="'$(LinkDelayLoad)'!=''">$(LinkDelayLoad);</LinkDelayLoad> + <LinkDelayLoad>$(LinkDelayLoad)ole32.dll;OLEAUT32.dll;mpr.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCoreclr)'!='true'">$(LinkDelayLoad);urlmon.dll;mscoree.dll;wintrust.dll</LinkDelayLoad> + <LinkDelayLoad>$(LinkDelayLoad);wtsapi32.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCrypto)'=='true'">$(LinkDelayLoad);crypt32.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureFusion)'=='true'">$(LinkDelayLoad);wininet.dll;cabinet.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureWatson)'=='true'">$(LinkDelayLoad);version.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCominterop)'=='true'">$(LinkDelayLoad);api-ms-win-core-winrt-l1-1-0.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCominterop)'=='true'">$(LinkDelayLoad);api-ms-win-core-winrt-string-l1-1-0.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCominterop)'=='true'">$(LinkDelayLoad);api-ms-win-ro-typeresolution-l1-1-0.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCominterop)'=='true'">$(LinkDelayLoad);api-ms-win-core-winrt-roparameterizediid-l1-1-0.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureCominterop)'=='true'">$(LinkDelayLoad);bcrypt.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureFusion)'=='true'">$(LinkDelayLoad);Rstrtmgr.dll</LinkDelayLoad> + <LinkDelayLoad Condition="'$(FeatureFusion)'=='true'">$(LinkDelayLoad);msi.dll</LinkDelayLoad> + </PropertyGroup> + + <PropertyGroup Condition="'$(BuildForCoreSystem)' != 'true' and '$(DebugBuild)' == 'true'"> + <MsdisDll Condition="'$(TargetCpu)'=='i386' or '$(TargetCpu)' == 'amd64'">msvcdis$(VC_NONCRT_ProdVerX).dll</MsdisDll> + <CDefines Condition="'$(TargetCpu)'=='i386' or '$(TargetCpu)' == 'amd64'">$(CDefines);MSDIS_DLL="\"$(MsdisDll)\""</CDefines> + <LinkDelayLoad Condition="'$(TargetCpu)'=='i386' or '$(TargetCpu)' == 'amd64'">$(LinkDelayLoad);$(MsdisDll)</LinkDelayLoad> + </PropertyGroup> + + <ItemGroup Condition="'$(BuildArchitecture)' == 'arm'"> + <!--Merge GC write barrier descriptors into read-only data section.--> + <LinkMergeSections Include=".clrwb=.rdata"/> + </ItemGroup> + + <!--Leaf Project Items--> + <ItemGroup Condition="'$(BuildForCoreSystem)' == 'true'" > + <TargetLib Include="$(CoreSystemCrt)" /> + <TargetLib Include="$(SdkLibPath)\uuid.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\1.0\api-ms-win-core-winrt-l1.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\1.0\api-ms-win-core-winrt-string-l1.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\1.0\api-ms-win-ro-typeresolution-l1.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\api-ms-win-core-winrt-roparameterizediid-l1-1-0.lib" /> + </ItemGroup> + <ItemGroup Condition="'$(BuildForCoreSystem)' == 'true' and '$(BuildForWindows7)' == 'true'"> + <TargetLib Include="$(SdkLibPath)\bcrypt.lib" /> + <TargetLib Include="$(SdkLibPath)\crypt32.lib" /> + <TargetLib Include="$(SdkLibPath)\cryptspp.lib" /> + <TargetLib Include="$(SdkLibPath)\oleaut32.lib" /> + <TargetLib Include="$(SdkLibPath)\mincore_fw.lib" /> + </ItemGroup> + <ItemGroup Condition="'$(BuildForCoreSystem)' == 'true' and '$(BuildForWindows7)' != 'true'"> + <TargetLib Include="$(SdkLibPath)\mincore.lib" /> + <TargetLib Include="$(SdkLibPath)\mincore_legacy.lib" /> + <TargetLib Include="$(SdkLibPath)\mincore_private.lib" /> + <TargetLib Include="$(SdkLibPath)\mincore_obsolete.lib" /> + </ItemGroup> + + <ItemGroup> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ExternalAPIsPath)\Whidbey\lib\$(BuildArchitecture)\isolation_whidbey$(BuildSuffix).lib" /> + <ImportLib Condition="'$(UseMsvcrt)'!='true' and '$(DebugBuild)' == 'true' and '$(BuildForCoreSystem)' != 'true'" Include="$(CrtLibPath)\libcpmtd.lib" /> + </ItemGroup> + + <ItemGroup Condition="'$(FeatureMergeJitAndEngine)' == 'true'"> + <ImportLib Include="$(ClrLibPath)\clrjit.lib" /> + + <!-- We build RyuJIT only for amd64 and arm64, and use JIT32 for ARM and x86 --> + <ProjectReference Condition="'$(BuildArchitecture)' == 'amd64' or '$(BuildArchitecture)' == 'arm64'" Include="$(ClrSrcDirectory)jit\dll\jit.nativeproj" /> + <ProjectReference Condition="'$(BuildArchitecture)' != 'amd64' and '$(BuildArchitecture)' != 'arm64'" Include="$(ClrSrcDirectory)jit32\dll\jit.nativeproj" /> + </ItemGroup> + + <ItemGroup> + <ImportLib Include="$(ClrLibPath)\cee_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)vm\wks\wks.nativeproj</ProjectReference> + </ImportLib> + <LinkPreCrtLibs Include="$(ClrLibPath)\cee_wks.lib" /> + + <ImportLib Include="$(ClrLibPath)\utilcode.lib"> + <ProjectReference>$(ClrSrcDirectory)utilcode\dyncrt\dyncrt.nativeproj</ProjectReference> + </ImportLib> + <LinkPreCrtLibs Include="$(ClrLibPath)\utilcode.lib" /> + + <ImportLib Include="$(ClrLibPath)\ildbsymlib.lib"> + <ProjectReference>$(ClrSrcDirectory)debug\ildbsymlib\HostLocal\ildbsymlib.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\fusionasmc.lib"> + <ProjectReference>$(ClrSrcDirectory)fusion\asmcache\asmcache.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\fusionbind.lib"> + <ProjectReference>$(ClrSrcDirectory)fusion\binder\binder.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\fusiondl.lib"> + <ProjectReference>$(ClrSrcDirectory)fusion\download\download.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\fusionmparse.lib"> + <ProjectReference>$(ClrSrcDirectory)fusion\mparse\mparse.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\fusionutils.lib"> + <ProjectReference>$(ClrSrcDirectory)fusion\utils\utils.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\fusioninterface.lib"> + <ProjectReference>$(ClrSrcDirectory)fusion\interface\interface.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Include="$(ClrLibPath)\strongname_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)strongname\api\wks\strongname_wks.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\usagelog.lib"> + <ProjectReference>$(ClrSrcDirectory)usagelog\usagelog.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\nativebinder.lib"> + <ProjectReference>$(ClrSrcDirectory)nativebinder\nativebinder.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureFusion)'=='true'" Include="$(ClrLibPath)\xmlparser.lib"> + <ProjectReference>$(ClrSrcDirectory)xmlparser\xmlparser.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureNativeImageGeneration)'=='true'" Include="$(ClrLibPath)\corzap.lib"> + <ProjectReference>$(ClrSrcDirectory)zap\wks\zap.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(PerfcountersSupportedBuild)'=='true'" Include="$(ClrLibPath)\perfcounters.lib"> + <ProjectReference>$(ClrSrcDirectory)profile\counters\counters.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(DebuggingSupportedBuild)'=='true'" Include="$(ClrLibPath)\cordbee_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)debug\ee\wks\wks.nativeproj</ProjectReference> + </ImportLib> + <ImportLib Condition="'$(FeatureDbgipcTransportVM)' == 'true'" Include="$(ClrLibPath)\dbgrawconn.lib"> + <ProjectReference>$(ClrSrcDirectory)debug\dbgrawconn\dbgrawconn.nativeproj</ProjectReference> + </ImportLib> + <TargetLib Include="@(ImportLib)"/> + </ItemGroup> + + <ItemGroup> + <TargetLib Condition="'$(TargetCpu)'=='amd64' or '$(TargetCpu)' == 'arm' or '$(TargetCpu)' == 'arm64'" Include="$(ClrLibPath)\gcinfo.lib"> + <ProjectReference>$(ClrSrcDirectory)gcinfo\lib\gcinfo.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Condition="'$(FeatureIpcman)'=='true'" Include="$(ClrLibPath)\ipcmanager.lib"> + <ProjectReference>$(ClrSrcDirectory)ipcman\ipcman\ipcman.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\MDCompiler_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)md\compiler\wks\mdcompiler_wks.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\MDRuntime.lib"> + <ProjectReference>$(ClrSrcDirectory)md\runtime\wks\mdruntime.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\MDRuntimeRW.lib"> + <ProjectReference>$(ClrSrcDirectory)md\enc\wks\mdruntimerw.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\MDWinMD_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)md\winmd\wks\MDWinMD_wks.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\MDHotData.lib"> + <ProjectReference>$(ClrSrcDirectory)md\hotdata\full\mdhotdata.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\comfloat_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)classlibnative\float\float.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\comnls_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)classlibnative\nls\nls.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\comcrypt_wks.lib"> + <ProjectReference>$(ClrSrcDirectory)classlibnative\cryptography\cryptography.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\bcltype.lib"> + <ProjectReference>$(ClrSrcDirectory)classlibnative\bcltype\bcltype.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Condition="'$(FeatureRemoting)'=='true'" Include="$(ClrLibPath)\remoting.lib"> + <ProjectReference>$(ClrSrcDirectory)classlibnative\remoting\remoting.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Include="$(ClrLibPath)\ceefgen.lib"> + <ProjectReference>$(ClrSrcDirectory)md\ceefilegen\ceefgen.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Condition="'$(FeatureFusion)'!='true'" Include="$(ClrLibPath)\v3binder.lib"> + <ProjectReference>$(ClrSrcDirectory)binder\v3binder\v3binder.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Condition="'$(FeatureCoreclr)'!='true'" Include="$(ClrLibPath)\shimload.lib"> + <ProjectReference>$(ClrSrcDirectory)shimload\shimload.nativeproj</ProjectReference> + </TargetLib> + <TargetLib Condition="'$(FeatureCoreClr)'!='true'" Include="$(ClrLibPath)\delayimp.lib"> + <ProjectReference>$(ClrSrcDirectory)delayimp\delayimp.nativeproj</ProjectReference> + </TargetLib> + </ItemGroup> + + <ItemGroup> + <TargetLib Include="$(ClrLibPath)\corguids.lib" /> + <TargetLib Condition="'$(FeatureCoreclr)'!='true'" Include="$(SdkLibPath)\mscoree.lib" /> + </ItemGroup> + + <ItemGroup Condition="'$(BuildForCoreSystem)' != 'true'" > + <TargetLib Include="$(VCToolsLibPath)\diaguids.lib" /> + <TargetLib Include="$(SdkLibPath)\ntdll.lib" /> + <TargetLib Include="$(SdkLibPath)\kernel32.lib" /> + <TargetLib Include="$(SdkLibPath)\user32.lib" /> + <TargetLib Include="$(SdkLibPath)\advapi32.lib" /> + <TargetLib Include="$(SdkLibPath)\ole32.lib" /> + <TargetLib Include="$(SdkLibPath)\uuid.lib" /> + <TargetLib Include="$(SdkLibPath)\oleaut32.lib" /> + <TargetLib Include="$(SdkLibPath)\wintrust.lib" /> + <TargetLib Include="$(SdkLibPath)\shlwapi.lib" /> + <TargetLib Condition="'$(FeatureCrypto)'=='true' or '$(FeatureX509)'=='true'" Include="$(SdkLibPath)\crypt32.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\urlmon.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\bcrypt.lib" /> + <TargetLib Condition="'$(FeatureCominterop)'=='true'" Include="$(SdkLibPath)\RuntimeObject.lib" /> + <TargetLib Condition="'$(FeatureFusion)'=='true'" Include="$(SdkLibPath)\cabinet.lib" /> + <TargetLib Condition="'$(FeatureFusion)'=='true'" Include="$(SdkLibPath)\wininet.lib" /> + <TargetLib Include="$(SdkLibPath)\mpr.lib" /> + <TargetLib Include="$(SdkLibPath)\version.lib" /> + <TargetLib Include="$(SdkLibPath)\aux_ulib.lib" /> + <TargetLib Include="$(SdkLibPath)\wtsapi32.lib" /> + <TargetLib Condition="'$(FeatureFusion)'=='true'" Include="$(SdkLibPath)\Rstrtmgr.lib" /> + <TargetLib Condition="'$(FeatureFusion)'=='true'" Include="$(SdkLibPath)\msi.lib" /> + <TargetLib Condition="'$(FeatureDbgipcTransportVM)' == 'true'" Include="$(SdkLibPath)\ws2_32.lib" /> + </ItemGroup> + + <ItemGroup> + <TargetLib Condition="('$(TargetCpu)'=='i386' or '$(TargetCpu)' == 'amd64') and '$(BuildForCoreSystem)' != 'true'" Include="$(VCToolsLibPath)\msvcdis.lib" /> + </ItemGroup> + + <ItemGroup> + <RCResourceFile Include="..\Native.rc" /> + <CppPreprocess Include="..\mscorwks_ntdef.src"> + <Defines>@(CommonPreprocessDefines);$(CDefines);$(TargetDefines)</Defines> + <OutputFile>$(DllDef)</OutputFile> + <AdditionalOptions>/TC</AdditionalOptions> + </CppPreprocess> + </ItemGroup> + + <ItemGroup> + <CppCompile Include="..\MSCoree.cpp" /> + </ItemGroup> + + <ItemGroup> + <CppCompile Include="..\ComCallUnmarshal.cpp" /> + <CppCompile Include="..\DelayLoad.cpp" /> + </ItemGroup> + + <ItemGroup Condition="'$(FeatureCoreclr)'=='true'"> + <CppCompile Include="..\unixinterface.cpp" /> + </ItemGroup> +</Project> diff --git a/src/dlls/mscoree/mscoree.targets b/src/dlls/mscoree/mscoree.targets new file mode 100644 index 0000000000..9f4bd674a9 --- /dev/null +++ b/src/dlls/mscoree/mscoree.targets @@ -0,0 +1,198 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <ItemGroup> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordbi\HostWinx86\mscordbi.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordac\HostWinx86\mscordac.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordbi\HostWinAmd64\mscordbi.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordac\HostWinAmd64\mscordac.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordbi\HostOneCorex86\mscordbi.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordac\HostOneCorex86\mscordac.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordbi\HostOneCoreAmd64\mscordbi.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordac\HostOneCoreAmd64\mscordac.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordbi\HostLocal\mscordbi.nativeproj" /> + <ProjectReference Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'" Include="$(ClrSrcDirectory)dlls\mscordac\HostLocal\mscordac.nativeproj" /> + </ItemGroup> + + <PropertyGroup> + <!-- Sadly, this is duplicated from ndp\clr\src\Debug\SetDebugTargetLocal.props + I don't want to include that props directly because it would change the defines for all compilation files, and we only want these + defines set for preprocessing daccess.i --> + <DaccessTargetDefines Condition="('$(BuildArchitecture)' == 'i386' or '$(_BuildArch)'=='rotor_x86')">$(DaccessTargetDefines);DBG_TARGET_X86=1</DaccessTargetDefines> + <DbgTargetAmd64 Condition="'$(BuildArchitecture)' == 'amd64'">1</DbgTargetAmd64> + <DaccessTargetDefines Condition="'$(BuildArchitecture)' == 'amd64'">$(DaccessTargetDefines);DBG_TARGET_AMD64=1</DaccessTargetDefines> + <DaccessTargetDefines Condition="'$(BuildArchitecture)' == 'arm'">$(DaccessTargetDefines);DBG_TARGET_ARM=1;</DaccessTargetDefines> + <DbgTargetArm64 Condition="'$(BuildArchitecture)' == 'arm64'">1</DbgTargetArm64> + <DaccessTargetDefines Condition="'$(BuildArchitecture)' == 'arm64'">$(DaccessTargetDefines);DBG_TARGET_ARM64=1;</DaccessTargetDefines> + <DbgTargetWin64 Condition="'$(DbgTargetAmd64)' == '1' Or'$(DbgTargetArm64)' == '1'">1</DbgTargetWin64> + <DaccessTargetDefines Condition="'$(DbgTargetAmd64)' == '1' Or'$(DbgTargetArm64)' == '1' ">$(DaccessTargetDefines);DBG_TARGET_WIN64=1</DaccessTargetDefines> + <DbgTarget64bit Condition="'$(DbgTargetWin64)' == '1'">1</DbgTarget64bit> + <DaccessTargetDefines Condition="'$(DbgTargetWin64)' == '1'">$(DaccessTargetDefines);DBG_TARGET_64BIT=1</DaccessTargetDefines> + + <!-- When embedding the debug resource into clr.dll/coreclr.dll we need to know what SKU the dll is from--> + <ClrDebugResourceSku>clr</ClrDebugResourceSku> + <ClrDebugResourceSku Condition="'$(FeatureCoresystem)'=='true'">onecoreclr</ClrDebugResourceSku> + </PropertyGroup> + + <ItemGroup> + <CppPreprocess Include="$(ClrSrcDirectory)\debug\daccess\daccess.cpp"> + <Defines>@(CommonPreprocessDefines);$(CDefines);$(DaccessTargetDefines);DACCESS_COMPILE</Defines> + <FinalOutput>$(IntermediateOutputDirectory)\daccess.i</FinalOutput> + <Includes> + $(UserIncludes); + $(ClrSrcDirectory)\debug\daccess; + $(ClrSrcDirectory)\vm; + $(ClrSrcDirectory)\gc; + $(ClrSrcDirectory)\vm\$(TargetCpu); + $(ClrSrcDirectory)\debug\inc; + $(ClrSrcDirectory)\debug\inc\$(TargetCpu); + $(ClrSrcDirectory)\debug\inc\dump; + $(ClrSrcDirectory)\debug\ee; + $(ClrSrcDirectory)\inc; + $(ClrSrcDirectory)\inc\$(IntermediateOutputDirectory); + $(VCToolsIncPath); + $(ClrSrcDirectory)\gcdump; + $(ClrSrcDirectory)\md\inc; + $(ClrSrcDirectory)\strongname\inc; + $(CrtIncPath); + $(AtlIncPath); + $(SdkIncPath); + $(SdkIncInternalPath); + $(DevDivSdkIncPath); + $(DdkIncPath); + $(VSCommonIncPath); + $(ConfigIncPath); + $(IntermediateOutputDirectory); + $(OakIncPath) + </Includes> + </CppPreprocess> + </ItemGroup> + + <ItemGroup> + <Clean Include="$(IntermediateOutputDirectory)\wks.bin" /> + </ItemGroup> + + <Target Name="GenerateExportsForDac" + Inputs="$(IntermediateOutputDirectory)\daccess.i;$(ProductOutputPdb);$(ProductOutputFile)" + Outputs="$(IntermediateOutputDirectory)\wks.bin" + DependsOnTargets="Link"> + <Exec Command="$(DacTableGen) /dac:$(IntermediateOutputDirectory)\daccess.i /pdb:$(ProductOutputPdb) /dll:$(ProductOutputFile) /bin:$(IntermediateOutputDirectory)\wks.bin" StandardOutputImportance="Normal" /> + </Target> + + <Target Name="GenerateDebugResources"> + <!-- Windows X86 --> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordbi\HostWinx86\mscordbi.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_winx86mscordbiOutputPath"/> + </MSBuild> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordac\HostWinx86\mscordac.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_winx86mscordacOutputPath"/> + </MSBuild> + <Exec Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'" + Command="$(GenClrDebugResource) /dac:@(_winx86mscordacOutputPath) /dbi:@(_winx86mscordbiOutputPath) /sku:$(ClrDebugResourceSku) /out:$(IntermediateOutputDirectory)\clrDebugResource_winx86.bin" + StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'" + Command="$(PdbTypeMatch) $(ProductOutputPdb) @(_winx86mscordacOutputPath->'%(RootDir)%(Directory)%(Filename).pdb') $(ClrSrcDirectory)\dlls\mscoree\type_exclusion_list.txt" + StandardOutputImportance="Normal" /> + + <!-- Windows AMD64 --> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordbi\HostWinAmd64\mscordbi.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_winamd64mscordbiOutputPath"/> + </MSBuild> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordac\HostWinAmd64\mscordac.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_winamd64mscordacOutputPath"/> + </MSBuild> + <Exec Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'" + Command="$(GenClrDebugResource) /dac:@(_winamd64mscordacOutputPath) /dbi:@(_winamd64mscordbiOutputPath) /sku:$(ClrDebugResourceSku) /out:$(IntermediateOutputDirectory)\clrDebugResource_winamd64.bin" + StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'" + Command="$(PdbTypeMatch) $(ProductOutputPdb) @(_winamd64mscordacOutputPath->'%(RootDir)%(Directory)%(Filename).pdb') $(ClrSrcDirectory)\dlls\mscoree\type_exclusion_list.txt" + StandardOutputImportance="Normal" /> + + <!-- OneCore X86 --> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordbi\HostOneCorex86\mscordbi.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_onecorex86mscordbiOutputPath"/> + </MSBuild> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordac\HostOneCorex86\mscordac.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_onecorex86mscordacOutputPath"/> + </MSBuild> + <Exec Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)'=='true'" + Command="$(GenClrDebugResource) /dac:@(_onecorex86mscordacOutputPath) /dbi:@(_onecorex86mscordbiOutputPath) /sku:$(ClrDebugResourceSku) /out:$(IntermediateOutputDirectory)\clrDebugResource_onecorex86.bin" + StandardOutputImportance="Normal" /> + + <!-- OneCore AMD64 --> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordbi\HostOneCoreAmd64\mscordbi.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_onecoreamd64mscordbiOutputPath"/> + </MSBuild> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordac\HostOneCoreAmd64\mscordac.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_onecoreamd64mscordacOutputPath"/> + </MSBuild> + <Exec Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)'=='true'" + Command="$(GenClrDebugResource) /dac:@(_onecoreamd64mscordacOutputPath) /dbi:@(_onecoreamd64mscordbiOutputPath) /sku:$(ClrDebugResourceSku) /out:$(IntermediateOutputDirectory)\clrDebugResource_onecoreamd64.bin" + StandardOutputImportance="Normal" /> + + <!-- Local --> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordbi\HostLocal\mscordbi.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_mscordbiOutputPath"/> + </MSBuild> + <MSBuild Projects="$(ClrSrcDirectory)dlls\mscordac\HostLocal\mscordac.nativeproj" + Targets="Link" + BuildInParallel="$(BuildInParallel)" + Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'"> + <Output TaskParameter="TargetOutputs" ItemName="_mscordacOutputPath"/> + </MSBuild> + <Exec Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'" + Command="$(GenClrDebugResource) /dac:@(_mscordacOutputPath) /dbi:@(_mscordbiOutputPath) /sku:$(ClrDebugResourceSku) /out:$(IntermediateOutputDirectory)\clrDebugResource.bin" + StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'" + Command="$(PdbTypeMatch) $(ProductOutputPdb) @(_mscordacOutputPath->'%(RootDir)%(Directory)%(Filename).pdb') $(ClrSrcDirectory)\dlls\mscoree\type_exclusion_list.txt" + StandardOutputImportance="Normal" /> + + </Target> + + <Target Name="EmbedExportsForDac" + DependsOnTargets="GenerateExportsForDac" + AfterTargets="Link" + BeforeTargets="EmbedDebugResources" + Condition="'$(PogoInstrument)' != 'true' or '$(PogoOptimize)' == 'true' or '$(PogoUpdate)' == 'true'"> + <Exec Command="$(InjectResource) /bin:$(IntermediateOutputDirectory)\wks.bin /dll:$(ProductOutputFile)" StandardOutputImportance="Normal" /> + </Target> + + <Target Name="EmbedDebugResources" + DependsOnTargets="GenerateDebugResources" + AfterTargets="EmbedExportsForDac" + BeforeTargets="CoreCopyProductFiles;PlaceSymbols" + Condition="'$(PogoInstrument)' != 'true' or '$(PogoOptimize)' == 'true' or '$(PogoUpdate)' == 'true'"> + <Exec Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)'=='true'" Command="$(InjectResource) /bin:$(IntermediateOutputDirectory)\clrDebugResource_winx86.bin /dll:$(ProductOutputFile) /name:CLRDEBUGINFOWINDOWSX86" StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)'=='true'" Command="$(InjectResource) /bin:$(IntermediateOutputDirectory)\clrDebugResource_winamd64.bin /dll:$(ProductOutputFile) /name:CLRDEBUGINFOWINDOWSAMD64" StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)'=='true'" Command="$(InjectResource) /bin:$(IntermediateOutputDirectory)\clrDebugResource_onecorex86.bin /dll:$(ProductOutputFile) /name:CLRDEBUGINFOCORESYSX86" StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)'=='true'" Command="$(InjectResource) /bin:$(IntermediateOutputDirectory)\clrDebugResource_onecoreamd64.bin /dll:$(ProductOutputFile) /name:CLRDEBUGINFOCORESYSAMD64" StandardOutputImportance="Normal" /> + <Exec Condition="'$(FeatureDbiOopDebugging_HostLocal)'=='true'" Command="$(InjectResource) /bin:$(IntermediateOutputDirectory)\clrDebugResource.bin /dll:$(ProductOutputFile) /name:CLRDEBUGINFO" StandardOutputImportance="Normal" /> + </Target> + +</Project> diff --git a/src/dlls/mscoree/mscoree.vrg b/src/dlls/mscoree/mscoree.vrg new file mode 100644 index 0000000000..465bfc151c --- /dev/null +++ b/src/dlls/mscoree/mscoree.vrg @@ -0,0 +1,177 @@ +VSREG 7 + +[HKEY_CLASSES_ROOT\CCWU.ComCallWrapper.1] +@="Com Call Wrapper Unmarshal Class" + +[HKEY_CLASSES_ROOT\CCWU.ComCallWrapper.1\CLSID] +@="{3F281000-E95A-11d2-886B-00C04F869F04}" + + +[HKEY_CLASSES_ROOT\CCWU.ComCallWrapper] +@="Com Call Wrapper Unmarshal Class" + +[HKEY_CLASSES_ROOT\CCWU.ComCallWrapper\CurVer] +@="CCWU.ComCallWrapper.1" + +[HKEY_CLASSES_ROOT\CCWU.ComCallWrapper\CLSID] +@="{3F281000-E95A-11d2-886B-00C04F869F04}" + + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}] +@="Com Call Wrapper Unmarshal Class" + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}\ProgID] +@="CCWU.ComCallWrapper.1" + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}\VersionIndependentProgID] +@="CCWU.ComCallWrapper" + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}\NotInsertable] + + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}\InprocServer32] +@="[#FilePath]" + + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}\InprocServer32] +"ThreadingModel"="Both" + + +[HKEY_CLASSES_ROOT\CLSID\{45FB4600-E6E8-4928-B25E-50476FF79425}] +@="Com Call Wrapper Unmarshal Class 4.0" + +[HKEY_CLASSES_ROOT\CLSID\{45FB4600-E6E8-4928-B25E-50476FF79425}\NotInsertable] + +[HKEY_CLASSES_ROOT\CLSID\{45FB4600-E6E8-4928-B25E-50476FF79425}\InprocServer32] +@="[#FilePath]" + +[HKEY_CLASSES_ROOT\CLSID\{45FB4600-E6E8-4928-B25E-50476FF79425}\InprocServer32] +"ThreadingModel"="Both" + +[HKEY_CLASSES_ROOT\CLSID\{45FB4600-E6E8-4928-B25E-50476FF79425}\InprocServer32\[RTM_ProductVersion]] +"ImplementedInThisVersion"="" + + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenser.2] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenser.2\CLSID] +@="{E5CB7A31-7512-11D2-89CE-0080C792E5D8}" + + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenser] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenser\CurVer] +@="CLRMetaData.CorMetaDataDispenser.2" + + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}\ProgID] +@="CLRMetaData.CorMetaDataDispenser.2" + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}\VersionIndependentProgID] +@="CLRMetaData.CorMetaDataDispenser" + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}\NotInsertable] + + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}\InprocServer32] +@="[#FilePath]" + + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}\InprocServer32] +"ThreadingModel"="Both" + + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}] +"MasterVersion"=dword:2 + + + + + + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenserRuntime.2] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenserRuntime.2\CLSID] +@="{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}" + + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenserRuntime] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLRMetaData.CorMetaDataDispenserRuntime\CurVer] +@="CLRMetaData.CorMetaDataDispenserRuntime.2" + + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}\ProgID] +@="CLRMetaData.CorMetaDataDispenserRuntime.2" + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}\VersionIndependentProgID] +@="CLRMetaData.CorMetaDataDispenserRuntime" + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}\NotInsertable] + + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}\InprocServer32] +@="[#FilePath]" + + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}\InprocServer32] +"ThreadingModel"="Both" + + + + +[HKEY_CLASSES_ROOT\CLRMetaData.CorRuntimeHost.2] +@="Microsoft Common Language Runtime Host" + +[HKEY_CLASSES_ROOT\CLRMetaData.CorRuntimeHost.2\CLSID] +@="{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}" + + +[HKEY_CLASSES_ROOT\CLRMetaData.CorRuntimeHost] +@="Microsoft Common Language Runtime Host" + +[HKEY_CLASSES_ROOT\CLRMetaData.CorRuntimeHost\CurVer] +@="CLRMetaData.CorRuntimeHost.2" + + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}] +@="Microsoft Common Language Runtime Meta Data" + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}\ProgID] +@="CLRMetaData.CorRuntimeHost.2" + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}\VersionIndependentProgID] +@="CLRMetaData.CorRuntimeHost" + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}\NotInsertable] + + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}\InprocServer32] +@="[#FilePath]" + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}\InprocServer32] +"ThreadingModel"="Both" + +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\.NET Runtime] +"TypesSupported"=dword:00000007 +"EventMessageFile"="[#FilePath]" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] +"InstallRoot"="[Framework.3643236F_FC70_11D3_A536_0090278A1BB8]" + +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management] +"WriteWatch"=dword:1 + +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel] +"obcaseinsensitive"=dword:00000001 +"ObUnsecureGlobalNames"="netfxcustomperfcounters.1.0[~]SharedPerfIPCBlock[~]Cor_Private_IPCBlock[~]Cor_Public_IPCBlock_" diff --git a/src/dlls/mscoree/mscoree20_shared_neutral.vrg b/src/dlls/mscoree/mscoree20_shared_neutral.vrg new file mode 100644 index 0000000000..b138cd8f89 --- /dev/null +++ b/src/dlls/mscoree/mscoree20_shared_neutral.vrg @@ -0,0 +1,286 @@ +VSREG 7 + +[HKEY_CLASSES_ROOT\CLSID\{B81FF171-20F3-11d2-8DCC-00A0C9B00525}] +@="Type name parser and builder" + +[HKEY_CLASSES_ROOT\CLSID\{B81FF171-20F3-11d2-8DCC-00A0C9B00525}\NotInsertable] + +[HKEY_CLASSES_ROOT\CLSID\{B81FF171-20F3-11d2-8DCC-00A0C9B00525}\InprocServer32] +@="[SystemFolder.3643236F_FC70_11D3_A536_0090278A1BB8]mscoree.dll" + +[HKEY_CLASSES_ROOT\CLSID\{B81FF171-20F3-11d2-8DCC-00A0C9B00525}\InprocServer32] +"ThreadingModel"="Both" + + +[HKEY_CLASSES_ROOT\CLRMetaData.CLRRuntimeHost] +@="Microsoft Common Language Runtime Host V2" + +[HKEY_CLASSES_ROOT\CLRMetaData.CLRRuntimeHost\CurVer] +@="CLRMetaData.CLRRuntimeHost.2" + +[HKEY_CLASSES_ROOT\CLRMetaData.CLRRuntimeHost.2] +@="Microsoft Common Language Runtime Host V2" + +[HKEY_CLASSES_ROOT\CLRMetaData.CLRRuntimeHost.2\CLSID] +@="{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}" + + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}] +@="Microsoft Common Language Runtime Meta Data V2" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}\ProgID] +@="CLRMetaData.CLRRuntimeHost.2" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}\VersionIndependentProgID] +@="CLRMetaData.CLRRuntimeHost" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}\NotInsertable] + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}\InprocServer32] +@="[SystemFolder.3643236F_FC70_11D3_A536_0090278A1BB8]mscoree.dll" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}\InprocServer32] +"ThreadingModel"="Both" + +[HKEY_CLASSES_ROOT\CLRMetaData.CLRRuntimeHost.1] +@="Microsoft Common Language Runtime Host V2" + +[HKEY_CLASSES_ROOT\CLRMetaData.CLRRuntimeHost.1\CLSID] +@="{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}" + + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}] +@="Microsoft Common Language Runtime Meta Data V2" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}\ProgID] +@="CLRMetaData.CLRRuntimeHost.1" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}\VersionIndependentProgID] +@="CLRMetaData.CLRRuntimeHost" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}\NotInsertable] + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}\InprocServer32] +@="[SystemFolder.3643236F_FC70_11D3_A536_0090278A1BB8]mscoree.dll" + +[HKEY_CLASSES_ROOT\CLSID\{90F1A06E-7712-4762-86B5-7A5EBA6BDB01}\InprocServer32] +"ThreadingModel"="Both" + +[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\MiniDumpAuxiliaryDlls] +"[URTInstallPath.3643236F_FC70_11D3_A536_0090278A1BB8]clr.dll"="[URTInstallPath.3643236F_FC70_11D3_A536_0090278A1BB8]mscordacwks.dll" + +[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\.NET Runtime Optimization Service] +"TypesSupported"=dword:00000007 +"EventMessageFile"="[SystemFolder.3643236F_FC70_11D3_A536_0090278A1BB8]mscoree.dll" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\winword.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\winword.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}] +"Target Version"="v1.1.4322" +"Maximum File Version Number"="11.0.9999.9999" +"Minimum File Version Number"="11.0.0.0" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\winword.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}\Registry Keys] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\winword.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}\Registry Keys\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}] +"Key Name"="HKEY_CLASSES_ROOT\\Interface\\{000C0601-0000-0000-C000-000000000046}" +"Key Presence"=dword:00000000 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\excel.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\excel.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}] +"Target Version"="v1.1.4322" +"Maximum File Version Number"="11.0.9999.9999" +"Minimum File Version Number"="11.0.0.0" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\excel.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}\Registry Keys] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\excel.exe\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}\Registry Keys\{2CCAA9FE-6884-4AF2-99DD-5217B94115DF}] +"Key Name"="HKEY_CLASSES_ROOT\\Interface\\{000C0601-0000-0000-C000-000000000046}" +"Key Presence"=dword:00000000 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehmsas.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehmsas.exe\{04A93A93-ABBA-44AF-948F-50B7182C631A}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="eHMSAS" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehrec.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehrec.exe\{44D9F380-9050-4365-AA06-DA121F6F2B7D}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="eHRec" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehSched.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehSched.exe\{EE19C1D5-4D4B-4D19-874A-FD6633C9293E}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="ehSched" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehShell.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehShell.exe\{95736FC3-FC2F-4ED5-9632-0216DF1B8019}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="ehshell.exe" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehtray.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\ehtray.exe\{FECCD425-B48B-4062-A580-642302E20A30}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="ehtray" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\medctrro.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\medctrro.exe\{DA93B8AF-F88E-438D-A5A3-CB78BB4E6BF9}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="MedCtrRO.exe" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\snchk.exe] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\AppPatch\v[RTM_ProductVersion].00000\snchk.exe\{1CF3A71C-18F9-41EF-8BAD-EA355F4DB250}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® Windows® Operating System" +"Internal Name"="SnChk.exe" +"Maximum File Version"="5.1.2600.9999" +"Minimum File Version"="5.1.2600.0000" +"Target Version"="v1.0.3705" + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\BTSNTSvc.exe\{CA109828-7CE7-40F4-AD73-C7575455A7D5}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server 2004" +"Internal Name"="BTSNTSvc" +"Maximum File Version"="3.0.9999.9999" +"Minimum File Version"="3.0.0.0" +"Target Version"="v1.1.4322" + + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\compeif.exe\{6AA1435F-1473-4A6D-B82A-1DD4E3A20E34}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server" +"Internal Name"="compeif.exe" +"Maximum File Version"="4.0.9999.9999" +"Minimum File Version"="4.0.0.0" +"Target Version"="v1.1.4322" + + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\ConfigFramework.exe\{CF59770F-C96E-472D-B532-2F9AE8D895DC}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server 2004" +"Internal Name"="ConfigFramework" +"Maximum File Version"="3.0.9999.9999" +"Minimum File Version"="3.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\DW15.exe\{18B0BD4E-298B-4CB1-98E4-F49CFCE6CFB4}] +"File Size"=dword:2da48 +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\esp_srv.exe\{D044DE85-EC81-4A04-BA4B-DF316E80DF61}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server" +"Internal Name"="esp_srv.exe" +"Maximum File Version"="4.0.9999.9999" +"Minimum File Version"="4.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\Setup.exe\{83E0F69E-84FA-4961-9FD4-3025FCEE92EA}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server 2004" +"Internal Name"="Setup" +"Maximum File Version"="3.0.9999.9999" +"Minimum File Version"="3.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\testmess.exe\{11856902-6A4D-4AFB-AF94-E1FCA58C8BAF}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server" +"Internal Name"="testmess.exe" +"Maximum File Version"="4.0.9999.9999" +"Minimum File Version"="4.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\TrackingDbHelper.exe\{162E7914-3267-46E2-82C8-8E72484BD554}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server 2004" +"Internal Name"="TrackingDbHelper" +"Maximum File Version"="3.0.9999.9999" +"Minimum File Version"="3.0.0.0" +"Target Version"="v1.1.4322" + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\Trigcon.exe\{3C010CA2-7989-4C96-91C3-1564E33F9A42}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server" +"Internal Name"="trigcon.exe" +"Maximum File Version"="4.0.9999.9999" +"Minimum File Version"="4.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\validins.exe\{00BBFD35-5011-4117-9DA1-2D3BFAAF9561}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server" +"Internal Name"="validins.exe" +"Maximum File Version"="4.0.9999.9999" +"Minimum File Version"="4.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\xsd2edi.exe\{B469F89A-19A5-44B2-A12F-E93394003755}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server" +"Internal Name"="XSD2EDI.EXE" +"Maximum File Version"="4.0.9999.9999" +"Minimum File Version"="4.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\XSharpP.EXE\{BDC69590-00EE-408A-B21F-58D9EF182CF6}] +"Company"="Microsoft Corporation" +"Product Name"="Microsoft® BizTalk® Server 2004" +"Internal Name"="XSharpP" +"Maximum File Version"="3.0.9999.9999" +"Minimum File Version"="3.0.0.0" +"Target Version"="v1.1.4322" + + +[HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\Policy\AppPatch\v[RTM_ProductVersion].00000\msi.dll\{462EF42B-ABA4-4eac-9843-9EED260F54D0}] +"Company"="Microsoft Corporation" +"Maximum File Version"="5.0.9999.99999" +"Minimum File Version"="2.0.0000.00000" +"Target Version"="v[RTM_ProductVersion]" + diff --git a/src/dlls/mscoree/mscoreeBBT.bat b/src/dlls/mscoree/mscoreeBBT.bat new file mode 100644 index 0000000000..e8a3bb3eae --- /dev/null +++ b/src/dlls/mscoree/mscoreeBBT.bat @@ -0,0 +1,83 @@ +@rem Licensed to the .NET Foundation under one or more agreements. +@rem The .NET Foundation licenses this file to you under the MIT license. +@rem See the LICENSE file in the project root for more information. + +setlocal +rem @echo off +REM Args are 1) full path to here 2) compile output dir 3) target platform 4) resulting binary +REM The script gets called for lib's too, so skip them. +if /i "%~x3" EQU ".lib" goto :EOF + +REM Clean up from any previous runs. +del /s /f /q %1\bbt\%4 + +REM Set up the BBT environment. +if not exist %1\bbt\%4 md %1\bbt\%4 +cd %1\bbt\%4 +xcopy %3 +xcopy %~dpn3.pdb +xcopy %1\bbt\*.* + +REM Do the actual BBT run. +call :BBTize %~nx3 + +endlocal +goto :EOF + + + +:BBTize +setlocal +@echo BBTizing %1 + +REM Build the instrumented executable. +call :bbtstart %1 + +REM Call the perf script. +@echo calling performance script +setlocal +call BBTScript +endlocal + +REM Build the optimized executable. +call :bbtend %1 + +endlocal +goto :EOF + + + +:bbtstart +@echo bbflow, bbinstr, bblink +bbflow /odb %~n1.bbcfg %~nx1 +bbinstr /odb %~n1.ins.bbcfg /idfmax 4096 /idf %~n1.bbidf %~n1.bbcfg +bblink /o %~n1.ins.%~x1 %~n1.ins.bbcfg +if exist %~n1.sav del /f %~n1.sav +ren %~nx1 %~n1.sav +copy %~n1.ins.%~x1 %~nx1 +if /i "%~x1" EQU ".dll" echo Registering DLL %1 & regsvr32 /s %1 +goto :EOF + + + +:bbtend +copy %~n1.sav %~nx1 + +@echo Building an Optimized Program. +bbmerge /idf %~n1.bbidf %~n1.bbcfg +if %ERRORLEVEL% NEQ 0 goto :EOF +bbopt /odb %~n1.opt.bbcfg %~n1.bbcfg +if %ERRORLEVEL% NEQ 0 goto :EOF +bblink /map %~n1.map /o %~n1.opt.%~x1 %~n1.opt.bbcfg +if %ERRORLEVEL% NEQ 0 goto :EOF + +@echo Writing reports. +bbrpt /funcov %~n1.bbcfg > %~n1.fcv +if %ERRORLEVEL% NEQ 0 goto :EOF +bbrpt /deadsym %~n1.bbcfg > %~n1.ded +if %ERRORLEVEL% NEQ 0 goto :EOF +copy %~n1.opt.%~x1 %~nx1 + +splitsym %~nx1 +goto :EOF + diff --git a/src/dlls/mscoree/mscoreeDoNotEverRemove.vrg b/src/dlls/mscoree/mscoreeDoNotEverRemove.vrg new file mode 100644 index 0000000000..0f7bf07ffa --- /dev/null +++ b/src/dlls/mscoree/mscoreeDoNotEverRemove.vrg @@ -0,0 +1,4 @@ +VSREG 7 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Secure Mime Handlers] +"CorTransientLoader.CorLoad.1"="" diff --git a/src/dlls/mscoree/mscoreeVersioned.vrg b/src/dlls/mscoree/mscoreeVersioned.vrg new file mode 100644 index 0000000000..39aa5a8e23 --- /dev/null +++ b/src/dlls/mscoree/mscoreeVersioned.vrg @@ -0,0 +1,22 @@ +VSREG 7 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\Standards\Standard CLI 2002] +"v[RTM_ProductVersion]"=dword:fff + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\Standards\Standard CLI 2005] +"v[RTM_ProductVersion]"=dword:fff + +[HKEY_CLASSES_ROOT\CLSID\{3F281000-E95A-11d2-886B-00C04F869F04}\InprocServer32\[RTM_ProductVersion]] +"ImplementedInThisVersion"="" + +[HKEY_CLASSES_ROOT\CLSID\{E5CB7A31-7512-11D2-89CE-0080C792E5D8}\InProcServer32\[RTM_ProductVersion]] +"ImplementedInThisVersion"="" + +[HKEY_CLASSES_ROOT\CLSID\{1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}\InprocServer32\[RTM_ProductVersion]] +"ImplementedInThisVersion"="" + +[HKEY_CLASSES_ROOT\CLSID\{CB2F6723-AB3A-11d2-9C40-00C04FA30A3E}\InprocServer32\[RTM_ProductVersion]] +"ImplementedInThisVersion"="" + +[HKEY_CLASSES_ROOT\CLSID\{B81FF171-20F3-11d2-8DCC-00A0C9B00525}\InprocServer32\[RTM_ProductVersion]] +"ImplementedInThisVersion"="" diff --git a/src/dlls/mscoree/mscorwks_ntdef.src b/src/dlls/mscoree/mscorwks_ntdef.src new file mode 100644 index 0000000000..13656d7aca --- /dev/null +++ b/src/dlls/mscoree/mscorwks_ntdef.src @@ -0,0 +1,198 @@ +; 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. + +EXPORTS +; +; Common exports +; + +#ifdef FEATURE_CORECLR + + + GetCLRRuntimeHost + + ; dbgshim.dll depends on g_CLREngineMetrics having an ordinal of 2. + ; This cannot change, or else CoreCLR debugging will not work. + ; See clr\src\DLLS\dbgshim\dbgshim.cpp. + g_CLREngineMetrics @2 data + + ; Unix hosting API + coreclr_create_delegate + coreclr_execute_assembly + coreclr_initialize + coreclr_shutdown + + ; il{d}asm + MetaDataGetDispenser + GetMetaDataInternalInterface + GetMetaDataInternalInterfaceFromPublic + GetMetaDataPublicInterfaceFromInternal + +#else //FEATURE_CORECLR + +; VM + DllGetClassObjectInternal private + DllGetActivationFactoryImpl private + GetClassActivatorForApplicationImpl private + MetaDataGetDispenser + GetMetaDataInternalInterface + GetMetaDataInternalInterfaceFromPublic + GetMetaDataPublicInterfaceFromInternal + _CorExeMain2 + _CorDllMain + CoInitializeEE + CoUninitializeEE + CoInitializeCor + CoUninitializeCor + PostErrorVA + + LoadStringRC @22 + ReOpenMetaDataWithMemory @23 + + LoadStringRCEx + ReOpenMetaDataWithMemoryEx private + TranslateSecurityAttributes private + GetPermissionRequests + CorExitProcess +#ifdef FEATURE_CLICKONCE + CorLaunchApplication +#endif + + CorMarkThreadInThreadPool + + LogHelp_LogAssert private + LogHelp_NoGuiOnAssert private + LogHelp_TerminateOnAssert private + + GetPrivateContextsPerfCounters private + + GetAssemblyMDImport private + + IEE private + +#ifdef FEATURE_FUSION +; Fusion + GetCachePath + CreateAssemblyNameObject + CreateApplicationContext + CreateAssemblyCache + CreateAssemblyEnum + CreateHistoryReader + LookupHistoryAssembly + GetHistoryFileDirectory + PreBindAssembly + PreBindAssemblyEx + SetMSIHandleForLogging + NukeDownloadedCache + ClearDownloadCache + GetCLRIdentityManager + CreateAssemblyConfigCookie + DestroyAssemblyConfigCookie + CompareAssemblyIdentity + CompareAssemblyIdentityWithConfig + InitializeFusion private + CopyPDBs private + DeleteShadowCache private +#endif +; Strong Name + StrongNameErrorInfo + StrongNameFreeBuffer + StrongNameKeyGen + StrongNameKeyGenEx + StrongNameKeyInstall + StrongNameKeyDelete + StrongNameGetPublicKey + StrongNameSignatureGeneration + StrongNameSignatureGenerationEx + StrongNameTokenFromAssembly + StrongNameTokenFromAssemblyEx + StrongNameTokenFromPublicKey + StrongNameSignatureVerification + StrongNameCompareAssemblies + StrongNameHashSize + StrongNameSignatureSize + StrongNameSignatureVerificationEx + GetHashFromAssemblyFile + GetHashFromAssemblyFileW + GetHashFromBlob + GetHashFromFile + GetHashFromFileW + GetHashFromHandle + StrongNameSignatureVerificationFromImage + StrongNameGetBlob + StrongNameGetBlobFromImage + StrongNameSignatureVerificationEx2 + StrongNameGetPublicKeyEx + StrongNameDigestGenerate + StrongNameDigestSign + StrongNameDigestEmbed + +; VM +#ifdef FEATURE_COMINTEROP + DllCanUnloadNowInternal private +#endif +#ifdef FEATURE_COMINTEROP_REGISTRATION + ClrCreateManagedInstance + DllRegisterServerInternal private + DllUnregisterServerInternal private + EEDllRegisterServer private + EEDllUnregisterServer private +#endif + SetRuntimeInfo + _CorExeMain +#ifdef FEATURE_MIXEDMODE + CorDllMainForThunk private +#endif + CoEEShutDownCOM +#ifdef FEATURE_PREJIT + NGenCreateNGenWorker + LegacyNGenCreateZapper + LegacyNGenFreeZapper + LegacyNGenTryEnumerateFusionCache + LegacyNGenCompile +#endif + GetAddrOfContractShutoffFlag private + GetCLRFunction private + +#ifdef PROFILING_SUPPORTED + AttachProfiler private +#endif // PROFILING_SUPPORTED + +#ifdef FEATURE_FUSION +; Fusion + CreateInstallReferenceEnum + InstallCustomModule + GetAssemblyIdentityFromFile + GetIdentityAuthority private + ParseManifest private + CreateCMSFromXml private + GetAppIdAuthority private + GetUserStore private + CreateActContext private + GetUserStateManager private +; CreateCMSFromXmlInternal private +; GetUserStoreInternal private +; ParseManifestInternal private +; CreateActContextInternal private +; GetUserStateManagerInternal private + CertCreateAuthenticodeLicense private + CertTimestampAuthenticodeLicense private + CertVerifyAuthenticodeLicense private + CertFreeAuthenticodeSignerInfo private + CertFreeAuthenticodeTimestamperInfo private + _AxlPublicKeyBlobToPublicKeyToken private + _AxlRSAKeyValueToPublicKeyToken private + _AxlGetIssuerPublicKeyHash private +#endif // FEATURE_FUSION + +; +; win64 common +; +#ifdef _WIN64 + GetRuntimeStackWalkInfo +#endif + + Nirvana_Dummy @24 NONAME PRIVATE + +#endif //FEATURE_CORECLR diff --git a/src/dlls/mscoree/mscorwks_unixexports.src b/src/dlls/mscoree/mscorwks_unixexports.src new file mode 100644 index 0000000000..9c151a942c --- /dev/null +++ b/src/dlls/mscoree/mscorwks_unixexports.src @@ -0,0 +1,103 @@ +; Unix hosting API +coreclr_create_delegate +coreclr_execute_assembly +coreclr_initialize +coreclr_shutdown + +; il{d}asm +MetaDataGetDispenser +GetMetaDataInternalInterface +GetMetaDataInternalInterfaceFromPublic +GetMetaDataPublicInterfaceFromInternal + +; PAL module registration +PAL_RegisterModule +PAL_UnregisterModule + +; Functions exported by the coreclr +CoreDllMain +DllMain +GetCLRRuntimeHost + +; Win32 API and other PAL functions used by the mscorlib +CloseHandle +CoCreateGuid +CopyFileW +CoTaskMemAlloc +CoTaskMemRealloc +CoTaskMemFree +CreateDirectoryW +CreateEventW +CreateFileW +CreateMutexW +CreateSemaphoreW +DeleteFileW +DuplicateHandle +FindClose +FindFirstFileW +FindNextFileW +FlushFileBuffers +FormatMessageW +FreeEnvironmentStringsW +GetACP +GetComputerNameW +GetConsoleCP +GetConsoleOutputCP +GetCurrentDirectoryW +GetCurrentProcess +GetCurrentProcessId +GetCurrentThreadId +GetEnvironmentStringsW +GetEnvironmentVariableW +GetFileAttributesExW +GetFileSize +GetFileType +GetFullPathNameW +GetLongPathNameW +GetProcAddress +GetStdHandle +GetSystemInfo +GetTempFileNameW +GetTempPathW +LocalAlloc +LocalReAlloc +LocalFree +LockFile +lstrlenA +lstrlenW +MapViewOfFile +MetaDataGetDispenser +MoveFileExW +MultiByteToWideChar +OpenEventW +OpenMutexW +OpenSemaphoreW +OutputDebugStringW +PAL_Random +QueryPerformanceCounter +QueryPerformanceFrequency +RaiseException +ReadFile +ReleaseMutex +ReleaseSemaphore +RemoveDirectoryW +ResetEvent +RtlZeroMemory +SetCurrentDirectoryW +SetEndOfFile +SetEnvironmentVariableW +SetErrorMode +SetEvent +SetFileAttributesW +SetFilePointer +SetFileTime +SysAllocStringLen +SysFreeString +SysStringLen +UnlockFile +UnmapViewOfFile +VirtualAlloc +VirtualFree +VirtualQuery +WideCharToMultiByte +WriteFile diff --git a/src/dlls/mscoree/shim.reg b/src/dlls/mscoree/shim.reg new file mode 100644 index 0000000000..bddf047c0a --- /dev/null +++ b/src/dlls/mscoree/shim.reg @@ -0,0 +1,9 @@ +REGEDIT4 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy] + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v4.0] +"[URTBuildNum]"="[URTBuildNum]-[URTBuildNum]" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\standards\v1.0.0] +"v4.0.[URTBuildNum]"=DWORD:[URTBuildNum] diff --git a/src/dlls/mscoree/stdafx.cpp b/src/dlls/mscoree/stdafx.cpp new file mode 100644 index 0000000000..a23e304c22 --- /dev/null +++ b/src/dlls/mscoree/stdafx.cpp @@ -0,0 +1,10 @@ +// 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. +//***************************************************************************** +// stdafx.cpp +// +// Precompiled headers. +// +//***************************************************************************** +#include "stdafx.h" diff --git a/src/dlls/mscoree/stdafx.h b/src/dlls/mscoree/stdafx.h new file mode 100644 index 0000000000..4df1417ebf --- /dev/null +++ b/src/dlls/mscoree/stdafx.h @@ -0,0 +1,25 @@ +// 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. +//***************************************************************************** +// stdafx.h +// +// Precompiled headers. +// +//***************************************************************************** +#ifndef __STDAFX_H__ +#define __STDAFX_H__ + +#include <crtwrap.h> +#include <winwrap.h> // Windows wrappers. + +#include <ole2.h> // OLE definitions + + +#include "intrinsic.h" // Functions to make intrinsic. + + +// Helper function returns the instance handle of this module. +HINSTANCE GetModuleInst(); + +#endif // __STDAFX_H__ diff --git a/src/dlls/mscoree/type_exclusion_list.txt b/src/dlls/mscoree/type_exclusion_list.txt new file mode 100644 index 0000000000..b93bfeee84 --- /dev/null +++ b/src/dlls/mscoree/type_exclusion_list.txt @@ -0,0 +1,142 @@ +# Add types names to this exclusion list by adding it on a separate line. +# If types from clr.pdb and mscordacwks_x86_arm.pdb don't match you have 3 options: +# 1. If the type is not used by the DAC simply remove it. +# 2. Fix the layout mismatch taking care of #defines used in declaration. +# 3. Add it to this file (type_exclusion_list.txt) as a final option. If you choose this option make sure you are +# not leaking a silent bug into the DAC. (if the type is not used in the DAC is better to use option 1). +# For any question regarding PdbTypeMatch tool and build validation process please contact clrdbgpriv. +CLiteWeightStgdb<CMiniMdRW> +CLiteWeightStgdbRW +CMiniMdRW +DoFullyLoadLocals +Generics::RecursionGraph +SyncBlock +_ACTIVATION_CONTEXT_STACK +_CONTEXT +_DISPATCHER_CONTEXT +_PEB +_RTL_CRITICAL_SECTION_DEBUG +_TEB +_XSTATE_CONTEXT +_JUMP_BUFFER +$_s__RTTIBaseClassArray$_extraBytes_4 +$_s__RTTIBaseClassArray$_extraBytes_8 +CVirtualThunks::tagThunkCode +CrossDomainOptimizationInfo +DebuggerController +EHExceptionRecord +EHExceptionRecord::EHParameters +FastTable +IBCLogger +IBCLoggingDisabler +RegMeta +ScanContext +StubManagerIterator +ThreadLocalIBCInfo +_PEB_LDR_DATA +_RTL_USER_PROCESS_PARAMETERS +_s__RTTIBaseClassArray +_s_ESTypeList +_s_FuncInfo +_s_HandlerType +_s_TryBlockMapEntry +_tiddata +FieldDesc +TypeHandle +SecurityUtil +UMEntryThunk +FrameInfo +SPLIT64 +#Remove all Holder based types as DAC Holder base class includes two extra fields +*Holder +SYSTEM_POWER_CAPABILITIES +*_CERT_ +*_CMSG_ +_CRYPT_RETRIEVE_AUX_INFO +_CRYPT_KEY_SIGN_MESSAGE_PARA +*_EVENT_ +_FULL_PTR_XLAT_TABLES +*_IMAGE_AUX_SYMBOL +*_MIDL_STUB_ +_QUOTA_LIMITS_EX +_RDR_CALLOUT_STATE +_TOKEN_AUDIT_POLICY +tagI_RpcProxyCallbackInterface +tagRID_DEVICE_INFO_MOUSE +_GCStress::CoopGcModePolicy +_KUSER_SHARED_DATA +_TP_TASK +CsFrame +stat +#Added for new changes in the CRT structs +tagLC_ID +threadlocaleinfostruct +WINTRUST_CATALOG_INFO_ +_CRYPT_PROVIDER_DATA +_WINTRUST_DATA +__lc_time_data +setloc_struct +tagLC_STRINGS +tagLOCALETAB +threadmbcinfostruct +BINDER_SPACE::Variables +_SYMCRYPT_MARVIN32_EXPANDED_SEED +_SYMCRYPT_CCM_STATE +_SYMCRYPT_GCM_EXPANDED_KEY +_SYMCRYPT_GHASH_EXPANDED_KEY +_SYMCRYPT_HMAC_SHA1_EXPANDED_KEY +_SYMCRYPT_MD2_STATE +_SYMCRYPT_RC4_STATE +_SYMCRYPT_SHA1_CHAINING_STATE +_SYMCRYPT_3DES_EXPANDED_KEY +_SYMCRYPT_AES_CMAC_EXPANDED_KEY +_SYMCRYPT_AES_CMAC_STATE +_SYMCRYPT_AES_EXPANDED_KEY +_SYMCRYPT_DESX_EXPANDED_KEY +_SYMCRYPT_DES_EXPANDED_KEY +_SYMCRYPT_GCM_STATE +_SYMCRYPT_GCM_SUPPORTED_BLOCKCIPHER_KEYS +_SYMCRYPT_HMAC_MD5_EXPANDED_KEY +_SYMCRYPT_HMAC_SHA256_EXPANDED_KEY +_SYMCRYPT_MARVIN32_STATE +_SYMCRYPT_RC2_EXPANDED_KEY +_SYMCRYPT_GF128_ELEMENT +_nlsversioninfo +_XSTATE_CONFIGURATION +MARK_HANDLE_INFO +_STORAGE_ADAPTER_DESCRIPTOR +_STORAGE_MINIPORT_DESCRIPTOR +FILE_ID_DESCRIPTOR +# Added to workaround mismatch of _UNWIND_INFO in x64 CoreSys chk build. The ret build is clean. +_UNWIND_INFO +# DevDiv2:672407 Workaround a build sequencing hole that resulted in a mismatch between +# coreclr.pdb and mscoredaccore_x86.pdb around the WinRTExceptionInfo type, which is +# part of the VCTools CRT. The type (which mirrors the WinRT Platform.Exception type) +# was out-of-date and the update exposed this hole. Bug#672407 is tracking the investigation +# of the build hole. +WinRTExceptionInfo +# Build issue 452821 (http://ddweb/buildstatus/issues/issues.aspx?iid=452821) +# The vctools partition is now building against the WinBlue SDK instead of the Win8 SDK. +# The struct _FLOATING_SAVE_AREA is defined in both winnt.h and vdmctxt.h. In the WinBlue +# SDK, these definitions differ in the name of the last field ('Cr0NpxState' in vdmctxt.h, +# 'Spare0' in winnt.h). In Win8, both definitions used 'Cr0NpxState'. This is causing a +# PdbTypeMismatch build error because the vctools component pulled into clr.dll causes clr.pdb +# to contain a version of _FLOATING_SAVE_AREA that uses 'Spare0' while mscordacwks does not. +_FLOATING_SAVE_AREA +# Added due to mismatch for arm64 coresys build +_SLIST_HEADER +_KNONVOLATILE_CONTEXT_POINTERS +_IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY +_TOKEN_ACCESS_INFORMATION +# These types added because we are statically linking the OS CRT +_GDI_TEB_BATCH +DNameNode +DNameStatusNode +Replicator +UnDecorator +__type_info_node +charNode +ioinfo +pDNameNode +pcharNode +DispLocals diff --git a/src/dlls/mscoree/unixinterface.cpp b/src/dlls/mscoree/unixinterface.cpp new file mode 100644 index 0000000000..8d75ff2721 --- /dev/null +++ b/src/dlls/mscoree/unixinterface.cpp @@ -0,0 +1,378 @@ +// 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. + + +//***************************************************************************** +// unixinterface.cpp +// +// Implementation for the interface exposed by libcoreclr.so +// + +//***************************************************************************** + +#include "stdafx.h" +#include <utilcode.h> +#include <corhost.h> +#include <configuration.h> +#ifdef FEATURE_GDBJIT +#include "../../vm/gdbjithelpers.h" +#endif // FEATURE_GDBJIT + +typedef int (STDMETHODCALLTYPE *HostMain)( + const int argc, + const wchar_t** argv + ); + +#define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS(__FILE__, (expr)) + +// Holder for const wide strings +typedef NewArrayHolder<const WCHAR> ConstWStringHolder; + +// Holder for array of wide strings +class ConstWStringArrayHolder : public NewArrayHolder<LPCWSTR> +{ + int m_cElements; + +public: + ConstWStringArrayHolder() : + NewArrayHolder<LPCWSTR>(), + m_cElements(0) + { + } + + void Set(LPCWSTR* value, int cElements) + { + NewArrayHolder<LPCWSTR>::operator=(value); + m_cElements = cElements; + } + + ~ConstWStringArrayHolder() + { + for (int i = 0; i < m_cElements; i++) + { + delete [] this->m_value[i]; + } + } +}; + +// Convert 8 bit string to unicode +static LPCWSTR StringToUnicode(LPCSTR str) +{ + int length = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0); + ASSERTE_ALL_BUILDS(length != 0); + + LPWSTR result = new (nothrow) WCHAR[length]; + ASSERTE_ALL_BUILDS(result != NULL); + + length = MultiByteToWideChar(CP_UTF8, 0, str, -1, result, length); + ASSERTE_ALL_BUILDS(length != 0); + + return result; +} + +// Convert 8 bit string array to unicode string array +static LPCWSTR* StringArrayToUnicode(int argc, LPCSTR* argv) +{ + LPCWSTR* argvW = nullptr; + + if (argc > 0) + { + argvW = new (nothrow) LPCWSTR[argc]; + ASSERTE_ALL_BUILDS(argvW != 0); + + for (int i = 0; i < argc; i++) + { + argvW[i] = StringToUnicode(argv[i]); + } + } + + return argvW; +} + +static void InitializeStartupFlags(STARTUP_FLAGS* startupFlagsRef) +{ + STARTUP_FLAGS startupFlags = static_cast<STARTUP_FLAGS>( + STARTUP_FLAGS::STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN | + STARTUP_FLAGS::STARTUP_SINGLE_APPDOMAIN); + + if (Configuration::GetKnobBooleanValue(W("System.GC.Concurrent"), CLRConfig::UNSUPPORTED_gcConcurrent)) + { + startupFlags = static_cast<STARTUP_FLAGS>(startupFlags | STARTUP_CONCURRENT_GC); + } + if (Configuration::GetKnobBooleanValue(W("System.GC.Server"), CLRConfig::UNSUPPORTED_gcServer)) + { + startupFlags = static_cast<STARTUP_FLAGS>(startupFlags | STARTUP_SERVER_GC); + } + if (Configuration::GetKnobBooleanValue(W("System.GC.RetainVM"), CLRConfig::UNSUPPORTED_GCRetainVM)) + { + startupFlags = static_cast<STARTUP_FLAGS>(startupFlags | STARTUP_HOARD_GC_VM); + } + + *startupFlagsRef = startupFlags; +} + +static void ConvertConfigPropertiesToUnicode( + const char** propertyKeys, + const char** propertyValues, + int propertyCount, + LPCWSTR** propertyKeysWRef, + LPCWSTR** propertyValuesWRef) +{ + LPCWSTR* propertyKeysW = new (nothrow) LPCWSTR[propertyCount]; + ASSERTE_ALL_BUILDS(propertyKeysW != nullptr); + + LPCWSTR* propertyValuesW = new (nothrow) LPCWSTR[propertyCount]; + ASSERTE_ALL_BUILDS(propertyValuesW != nullptr); + + for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex) + { + propertyKeysW[propertyIndex] = StringToUnicode(propertyKeys[propertyIndex]); + propertyValuesW[propertyIndex] = StringToUnicode(propertyValues[propertyIndex]); + } + + *propertyKeysWRef = propertyKeysW; + *propertyValuesWRef = propertyValuesW; +} + +#if !defined(FEATURE_MERGE_JIT_AND_ENGINE) +// Reference to the global holding the path to the JIT +extern "C" LPCWSTR g_CLRJITPath; +#endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE) + +#ifdef FEATURE_GDBJIT +GetInfoForMethodDelegate getInfoForMethodDelegate = NULL; +extern "C" int coreclr_create_delegate(void*, unsigned int, const char*, const char*, const char*, void**); +#endif //FEATURE_GDBJIT + +// +// Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain +// +// Parameters: +// exePath - Absolute path of the executable that invoked the ExecuteAssembly +// appDomainFriendlyName - Friendly name of the app domain that will be created to execute the assembly +// propertyCount - Number of properties (elements of the following two arguments) +// propertyKeys - Keys of properties of the app domain +// propertyValues - Values of properties of the app domain +// hostHandle - Output parameter, handle of the created host +// domainId - Output parameter, id of the created app domain +// +// Returns: +// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed +// +extern "C" +int coreclr_initialize( + const char* exePath, + const char* appDomainFriendlyName, + int propertyCount, + const char** propertyKeys, + const char** propertyValues, + void** hostHandle, + unsigned int* domainId) +{ + HRESULT hr; +#ifdef FEATURE_PAL + DWORD error = PAL_InitializeCoreCLR(exePath); + hr = HRESULT_FROM_WIN32(error); + + // If PAL initialization failed, then we should return right away and avoid + // calling any other APIs because they can end up calling into the PAL layer again. + if (FAILED(hr)) + { + return hr; + } +#endif + + ReleaseHolder<ICLRRuntimeHost2> host; + + hr = CorHost2::CreateObject(IID_ICLRRuntimeHost2, (void**)&host); + IfFailRet(hr); + + ConstWStringHolder appDomainFriendlyNameW = StringToUnicode(appDomainFriendlyName); + + LPCWSTR* propertyKeysW; + LPCWSTR* propertyValuesW; + ConvertConfigPropertiesToUnicode( + propertyKeys, + propertyValues, + propertyCount, + &propertyKeysW, + &propertyValuesW); + + // This will take ownership of propertyKeysWTemp and propertyValuesWTemp + Configuration::InitializeConfigurationKnobs(propertyCount, propertyKeysW, propertyValuesW); + +#if !defined(FEATURE_MERGE_JIT_AND_ENGINE) + // Fetch the path to JIT binary, if specified + g_CLRJITPath = Configuration::GetKnobStringValue(W("JIT_PATH")); +#endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE) + + STARTUP_FLAGS startupFlags; + InitializeStartupFlags(&startupFlags); + + hr = host->SetStartupFlags(startupFlags); + IfFailRet(hr); + + hr = host->Start(); + IfFailRet(hr); + + hr = host->CreateAppDomainWithManager( + appDomainFriendlyNameW, + // Flags: + // APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS + // - By default CoreCLR only allows platform neutral assembly to be run. To allow + // assemblies marked as platform specific, include this flag + // + // APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP + // - Allows sandboxed applications to make P/Invoke calls and use COM interop + // + // APPDOMAIN_SECURITY_SANDBOXED + // - Enables sandboxing. If not set, the app is considered full trust + // + // APPDOMAIN_IGNORE_UNHANDLED_EXCEPTION + // - Prevents the application from being torn down if a managed exception is unhandled + // + APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS | + APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP | + APPDOMAIN_DISABLE_TRANSPARENCY_ENFORCEMENT, + NULL, // Name of the assembly that contains the AppDomainManager implementation + NULL, // The AppDomainManager implementation type name + propertyCount, + propertyKeysW, + propertyValuesW, + (DWORD *)domainId); + + if (SUCCEEDED(hr)) + { + host.SuppressRelease(); + *hostHandle = host; +#ifdef FEATURE_GDBJIT + + hr = coreclr_create_delegate(*hostHandle, + *domainId, + "SOS.NETCore", + "SOS.SymbolReader", + "GetInfoForMethod", + (void**)&getInfoForMethodDelegate); + + if (!SUCCEEDED(hr)) + { + fprintf(stderr, + "Can't create delegate for 'System.Diagnostics.Debug.SymbolReader.SymbolReader.GetInfoForMethod' " + "method - status: 0x%08x\n", hr); + } + hr = S_OK; // We don't need to fail if we can't create delegate +#endif + } + return hr; +} + +// +// Shutdown CoreCLR. It unloads the app domain and stops the CoreCLR host. +// +// Parameters: +// hostHandle - Handle of the host +// domainId - Id of the domain +// +// Returns: +// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed +// +extern "C" +int coreclr_shutdown( + void* hostHandle, + unsigned int domainId) +{ + ReleaseHolder<ICLRRuntimeHost2> host(reinterpret_cast<ICLRRuntimeHost2*>(hostHandle)); + + HRESULT hr = host->UnloadAppDomain(domainId, true); // Wait until done + IfFailRet(hr); + + hr = host->Stop(); + +#ifdef FEATURE_PAL + PAL_Shutdown(); +#endif + + return hr; +} + +// +// Create a native callable delegate for a managed method. +// +// Parameters: +// hostHandle - Handle of the host +// domainId - Id of the domain +// entryPointAssemblyName - Name of the assembly which holds the custom entry point +// entryPointTypeName - Name of the type which holds the custom entry point +// entryPointMethodName - Name of the method which is the custom entry point +// delegate - Output parameter, the function stores a pointer to the delegate at the specified address +// +// Returns: +// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed +// +extern "C" +int coreclr_create_delegate( + void* hostHandle, + unsigned int domainId, + const char* entryPointAssemblyName, + const char* entryPointTypeName, + const char* entryPointMethodName, + void** delegate) +{ + ICLRRuntimeHost2* host = reinterpret_cast<ICLRRuntimeHost2*>(hostHandle); + + ConstWStringHolder entryPointAssemblyNameW = StringToUnicode(entryPointAssemblyName); + ConstWStringHolder entryPointTypeNameW = StringToUnicode(entryPointTypeName); + ConstWStringHolder entryPointMethodNameW = StringToUnicode(entryPointMethodName); + + HRESULT hr = host->CreateDelegate( + domainId, + entryPointAssemblyNameW, + entryPointTypeNameW, + entryPointMethodNameW, + (INT_PTR*)delegate); + + return hr; +} + +// +// Execute a managed assembly with given arguments +// +// Parameters: +// hostHandle - Handle of the host +// domainId - Id of the domain +// argc - Number of arguments passed to the executed assembly +// argv - Array of arguments passed to the executed assembly +// managedAssemblyPath - Path of the managed assembly to execute (or NULL if using a custom entrypoint). +// exitCode - Exit code returned by the executed assembly +// +// Returns: +// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed +// +extern "C" +int coreclr_execute_assembly( + void* hostHandle, + unsigned int domainId, + int argc, + const char** argv, + const char* managedAssemblyPath, + unsigned int* exitCode) +{ + if (exitCode == NULL) + { + return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); + } + *exitCode = -1; + + ICLRRuntimeHost2* host = reinterpret_cast<ICLRRuntimeHost2*>(hostHandle); + + ConstWStringArrayHolder argvW; + argvW.Set(StringArrayToUnicode(argc, argv), argc); + + ConstWStringHolder managedAssemblyPathW = StringToUnicode(managedAssemblyPath); + + HRESULT hr = host->ExecuteAssembly(domainId, managedAssemblyPathW, argc, argvW, (DWORD *)exitCode); + IfFailRet(hr); + + return hr; +} |