summaryrefslogtreecommitdiff
path: root/src/dlls
diff options
context:
space:
mode:
Diffstat (limited to 'src/dlls')
-rw-r--r--src/dlls/.gitmirror1
-rw-r--r--src/dlls/CMakeLists.txt9
-rw-r--r--src/dlls/clretwrc/.gitmirror1
-rw-r--r--src/dlls/clretwrc/CMakeLists.txt23
-rw-r--r--src/dlls/clretwrc/clretwrc.nativeproj27
-rw-r--r--src/dlls/clretwrc/clretwrc.rc9
-rw-r--r--src/dlls/dbgshim/.gitmirror1
-rw-r--r--src/dlls/dbgshim/CMakeLists.txt85
-rw-r--r--src/dlls/dbgshim/dbgshim.cpp1791
-rw-r--r--src/dlls/dbgshim/dbgshim.h75
-rw-r--r--src/dlls/dbgshim/dbgshim.ntdef17
-rw-r--r--src/dlls/dbgshim/dbgshim.rc10
-rw-r--r--src/dlls/dbgshim/dbgshim.targets94
-rw-r--r--src/dlls/dbgshim/dbgshim_unixexports.src16
-rw-r--r--src/dlls/dbgshim/dirs.proj19
-rw-r--r--src/dlls/dbgshim/resource.h3
-rw-r--r--src/dlls/dirs.proj50
-rw-r--r--src/dlls/mscordac/.gitmirror1
-rw-r--r--src/dlls/mscordac/CMakeLists.txt123
-rw-r--r--src/dlls/mscordac/GetFileVersion.dllbin0 -> 5120 bytes
-rw-r--r--src/dlls/mscordac/GetFileVersion.pdbbin0 -> 11776 bytes
-rw-r--r--src/dlls/mscordac/Native.rc8
-rw-r--r--src/dlls/mscordac/dirs.proj21
-rw-r--r--src/dlls/mscordac/mscordac.cpp21
-rw-r--r--src/dlls/mscordac/mscordac.src16
-rw-r--r--src/dlls/mscordac/mscordac.targets142
-rw-r--r--src/dlls/mscordac/mscordac.vrg10
-rw-r--r--src/dlls/mscordac/mscordac_unixexports.src174
-rw-r--r--src/dlls/mscordac/update.pl34
-rw-r--r--src/dlls/mscordbi/.gitmirror1
-rw-r--r--src/dlls/mscordbi/CMakeLists.txt114
-rw-r--r--src/dlls/mscordbi/DIRS.proj23
-rw-r--r--src/dlls/mscordbi/Native.rc8
-rw-r--r--src/dlls/mscordbi/mscordbi.cpp29
-rw-r--r--src/dlls/mscordbi/mscordbi.settings.targets144
-rw-r--r--src/dlls/mscordbi/mscordbi.src29
-rw-r--r--src/dlls/mscordbi/mscordbi.vrg78
-rw-r--r--src/dlls/mscordbi/mscordbi_unixexports.src18
-rw-r--r--src/dlls/mscordbi/mscordbiv.vrg4
-rw-r--r--src/dlls/mscordbi/stdafx.cpp10
-rw-r--r--src/dlls/mscordbi/stdafx.h15
-rw-r--r--src/dlls/mscoree/.gitmirror1
-rw-r--r--src/dlls/mscoree/CMakeLists.txt30
-rw-r--r--src/dlls/mscoree/Native.rc8
-rw-r--r--src/dlls/mscoree/comcallunmarshal.cpp305
-rw-r--r--src/dlls/mscoree/comcallunmarshal.h70
-rw-r--r--src/dlls/mscoree/coreclr/.gitmirror1
-rw-r--r--src/dlls/mscoree/coreclr/CMakeLists.txt179
-rw-r--r--src/dlls/mscoree/coreclr/coreclr.nativeproj53
-rw-r--r--src/dlls/mscoree/delayload.cpp455
-rw-r--r--src/dlls/mscoree/dirs.proj24
-rw-r--r--src/dlls/mscoree/dw20.msibin0 -> 599552 bytes
-rw-r--r--src/dlls/mscoree/dw20_amd64.msibin0 -> 1956352 bytes
-rw-r--r--src/dlls/mscoree/mscoree.cpp1249
-rw-r--r--src/dlls/mscoree/mscoree.settings.targets268
-rw-r--r--src/dlls/mscoree/mscoree.targets198
-rw-r--r--src/dlls/mscoree/mscoree.vrg177
-rw-r--r--src/dlls/mscoree/mscoree20_shared_neutral.vrg286
-rw-r--r--src/dlls/mscoree/mscoreeBBT.bat83
-rw-r--r--src/dlls/mscoree/mscoreeDoNotEverRemove.vrg4
-rw-r--r--src/dlls/mscoree/mscoreeVersioned.vrg22
-rw-r--r--src/dlls/mscoree/mscorwks_ntdef.src198
-rw-r--r--src/dlls/mscoree/mscorwks_unixexports.src103
-rw-r--r--src/dlls/mscoree/shim.reg9
-rw-r--r--src/dlls/mscoree/stdafx.cpp10
-rw-r--r--src/dlls/mscoree/stdafx.h25
-rw-r--r--src/dlls/mscoree/type_exclusion_list.txt142
-rw-r--r--src/dlls/mscoree/unixinterface.cpp378
-rw-r--r--src/dlls/mscorpe/.gitmirrorall1
-rw-r--r--src/dlls/mscorpe/CMakeLists.txt23
-rw-r--r--src/dlls/mscorpe/Native.rc8
-rw-r--r--src/dlls/mscorpe/ceefilegenwriter.cpp2007
-rw-r--r--src/dlls/mscorpe/ceefilegenwritertokens.cpp266
-rw-r--r--src/dlls/mscorpe/dirs.proj15
-rw-r--r--src/dlls/mscorpe/iceefilegen.cpp732
-rw-r--r--src/dlls/mscorpe/mscorpe/mscorpe.def11
-rw-r--r--src/dlls/mscorpe/mscorpe/mscorpe.nativeproj46
-rw-r--r--src/dlls/mscorpe/mscorpe/wrapper.cpp149
-rw-r--r--src/dlls/mscorpe/mscorpehost/mscorpehost.def12
-rw-r--r--src/dlls/mscorpe/mscorpehost/mscorpehost.nativeproj68
-rw-r--r--src/dlls/mscorpe/pewriter.cpp2401
-rw-r--r--src/dlls/mscorpe/pewriter.h337
-rw-r--r--src/dlls/mscorpe/stdafx.cpp10
-rw-r--r--src/dlls/mscorpe/stdafx.h24
-rw-r--r--src/dlls/mscorpe/stubs.h169
-rw-r--r--src/dlls/mscorpe/utilcodeinit.cpp11
-rw-r--r--src/dlls/mscorrc/.gitmirror1
-rw-r--r--src/dlls/mscorrc/CMakeLists.txt22
-rw-r--r--src/dlls/mscorrc/dirs.proj18
-rw-r--r--src/dlls/mscorrc/full/.gitmirror1
-rw-r--r--src/dlls/mscorrc/full/CMakeLists.txt19
-rw-r--r--src/dlls/mscorrc/full/mscorrc.nativeproj25
-rw-r--r--src/dlls/mscorrc/fuslog.rc349
-rw-r--r--src/dlls/mscorrc/fusres.h310
-rw-r--r--src/dlls/mscorrc/include.rc7
-rw-r--r--src/dlls/mscorrc/mscorrc.common.rc12
-rw-r--r--src/dlls/mscorrc/mscorrc.rc2173
-rw-r--r--src/dlls/mscorrc/mscorrc.rc252
-rw-r--r--src/dlls/mscorrc/mscorrc.small.rc42
-rw-r--r--src/dlls/mscorrc/nativelog.rc32
-rw-r--r--src/dlls/mscorrc/nativeres.h35
-rw-r--r--src/dlls/mscorrc/resource.h950
-rw-r--r--src/dlls/mscorrc/small/.gitmirror1
-rw-r--r--src/dlls/mscorrc/small/CMakeLists.txt8
-rw-r--r--src/dlls/mscorrc/small/mscorrc.nativeproj22
105 files changed, 17901 insertions, 0 deletions
diff --git a/src/dlls/.gitmirror b/src/dlls/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/.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/CMakeLists.txt b/src/dlls/CMakeLists.txt
new file mode 100644
index 0000000000..932e65e350
--- /dev/null
+++ b/src/dlls/CMakeLists.txt
@@ -0,0 +1,9 @@
+if(WIN32)
+ add_subdirectory(clretwrc)
+endif(WIN32)
+add_subdirectory(dbgshim)
+add_subdirectory(mscordbi)
+add_subdirectory(mscordac)
+add_subdirectory(mscoree)
+add_subdirectory(mscorpe)
+add_subdirectory(mscorrc)
diff --git a/src/dlls/clretwrc/.gitmirror b/src/dlls/clretwrc/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/clretwrc/.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/clretwrc/CMakeLists.txt b/src/dlls/clretwrc/CMakeLists.txt
new file mode 100644
index 0000000000..b1f7a49088
--- /dev/null
+++ b/src/dlls/clretwrc/CMakeLists.txt
@@ -0,0 +1,23 @@
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+if(WIN32)
+ # remove /ltcg from resource-only libraries
+ string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
+ string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
+ string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})
+ string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
+
+ # remove /guard:cf from resource-only libraries
+ string(REPLACE "/guard:cf" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
+
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NOENTRY")
+endif(WIN32)
+
+add_definitions(-DFX_VER_INTERNALNAME_STR=clretwrc.dll)
+
+add_library_clr(clretwrc SHARED
+ clretwrc.rc
+)
+
+# add the install targets
+install_clr(clretwrc) \ No newline at end of file
diff --git a/src/dlls/clretwrc/clretwrc.nativeproj b/src/dlls/clretwrc/clretwrc.nativeproj
new file mode 100644
index 0000000000..6a9b227258
--- /dev/null
+++ b/src/dlls/clretwrc/clretwrc.nativeproj
@@ -0,0 +1,27 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+ <!--*****************************************************-->
+ <!--This MSBuild project file was automatically generated-->
+ <!--from the original SOURCES/DIRS file by the KBC tool.-->
+ <!--*****************************************************-->
+ <!--Import the settings-->
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+ <!--Leaf project Properties-->
+ <PropertyGroup>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ <OutputName>clretwrc</OutputName>
+ <DllDef>$(OutputName).def</DllDef>
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <LinkResourceOnlyDll>true</LinkResourceOnlyDll>
+ <IsProjectKLibrary>true</IsProjectKLibrary>
+ <IsTestNetCoreRuntimeLibrary>true</IsTestNetCoreRuntimeLibrary>
+ <IsPhoneLibrary>true</IsPhoneLibrary>
+ </PropertyGroup>
+ <!--Leaf Project Items-->
+ <ItemGroup>
+ <RCResourceFile Include="clretwrc.rc" />
+ </ItemGroup>
+ <!--Import the targets-->
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+</Project>
diff --git a/src/dlls/clretwrc/clretwrc.rc b/src/dlls/clretwrc/clretwrc.rc
new file mode 100644
index 0000000000..3c6f69b9d0
--- /dev/null
+++ b/src/dlls/clretwrc/clretwrc.rc
@@ -0,0 +1,9 @@
+// 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 resources\0"
+
+#include <fxver.h>
+#include <fxver.rc>
+#include "ClrEtwAll.rc"
diff --git a/src/dlls/dbgshim/.gitmirror b/src/dlls/dbgshim/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/dbgshim/.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/dbgshim/CMakeLists.txt b/src/dlls/dbgshim/CMakeLists.txt
new file mode 100644
index 0000000000..4e72ee219a
--- /dev/null
+++ b/src/dlls/dbgshim/CMakeLists.txt
@@ -0,0 +1,85 @@
+add_definitions(-DFEATURE_NO_HOST)
+add_definitions(-DSELF_NO_HOST)
+
+include_directories(${CLR_DIR}/src/debug/shim)
+
+set(DBGSHIM_SOURCES
+ dbgshim.cpp
+)
+
+if(WIN32)
+ # Use static crt
+ add_definitions(-MT)
+ add_definitions(-DFX_VER_INTERNALNAME_STR=dbgshim.dll)
+
+ list(APPEND DBGSHIM_SOURCES
+ dbgshim.rc
+ )
+
+ preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/dbgshim.ntdef ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
+ list(APPEND DBGSHIM_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.def)
+else(WIN32)
+ set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dbgshim_unixexports.src)
+ set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/dbgshim.exports)
+ generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
+endif(WIN32)
+
+if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_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")
+
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
+
+if(CLR_CMAKE_PLATFORM_DARWIN)
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_DARWIN)
+
+add_library_clr(dbgshim SHARED ${DBGSHIM_SOURCES})
+
+if(CLR_CMAKE_PLATFORM_UNIX)
+ add_compile_options(-fPIC)
+
+ add_custom_target(dbgshim_exports DEPENDS ${EXPORTS_FILE})
+ add_dependencies(dbgshim dbgshim_exports)
+
+ set_property(TARGET dbgshim APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
+ set_property(TARGET dbgshim APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+set(DBGSHIM_LIBRARIES
+ debug-pal
+ debugshim
+ corguids
+ dbgutil
+ utilcodestaticnohost
+)
+
+if(WIN32)
+ list(APPEND DBGSHIM_LIBRARIES
+ kernel32.lib
+ ${STATIC_MT_CRT_LIB}
+ ${STATIC_MT_VCRT_LIB}
+ uuid.lib
+ user32.lib
+ advapi32.lib
+ oleaut32.lib
+ WtsApi32.lib
+ version.lib
+ psapi.lib
+ )
+else()
+ list(APPEND DBGSHIM_LIBRARIES
+ coreclrpal
+ mscorrc_debug
+ palrt
+ )
+endif(WIN32)
+
+target_link_libraries(dbgshim ${DBGSHIM_LIBRARIES})
+
+# add the install targets
+install_clr(dbgshim)
diff --git a/src/dlls/dbgshim/dbgshim.cpp b/src/dlls/dbgshim/dbgshim.cpp
new file mode 100644
index 0000000000..4d6dc5a6e3
--- /dev/null
+++ b/src/dlls/dbgshim/dbgshim.cpp
@@ -0,0 +1,1791 @@
+// 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.
+//*****************************************************************************
+// DbgShim.cpp
+//
+// This contains the APIs for creating a telesto managed-debugging session. These APIs serve to locate an
+// mscordbi.dll for a given telesto dll and then instantiate the ICorDebug object.
+//
+//*****************************************************************************
+
+#include <winwrap.h>
+#include <utilcode.h>
+#include <log.h>
+#include <tlhelp32.h>
+#include <cor.h>
+#include <sstring.h>
+#ifndef FEATURE_PAL
+#include <securityutil.h>
+#endif
+
+#include <ex.h>
+#include <cordebug.h> // for Version nunmbers
+#include <pedecoder.h>
+#include <getproductversionnumber.h>
+#include <dbgenginemetrics.h>
+
+#ifndef FEATURE_PAL
+#define PSAPI_VERSION 2
+#include <psapi.h>
+#endif
+
+#include "dbgshim.h"
+
+/*
+
+// Here's a High-level overview of the API usage
+
+From the debugger:
+A debugger calls GetStartupNotificationEvent(pid of debuggee) to get an event, which is signalled when
+that process loads a Telesto. The debugger thus waits on that event, and when it's signalled, it can call
+EnumerateCLRs / CloseCLREnumeration to get an array of Telestos in the target process (including the one
+that was just loaded). It can then call CreateVersionStringFromModule, CreateDebuggingInterfaceFromVersion
+to attach to any or all Telestos of interest.
+
+From the debuggee:
+When a new Telesto spins up, it checks for the startup event (created via GetStartupNotificationEvent), and
+if it exists, it will:
+- signal it
+- wait on the "Continue" event, thus giving a debugger a chance to attach to the telesto
+
+Notes:
+- There is no CreateProcess (Launch) case. All Launching is really an "Early-attach case".
+
+*/
+
+#ifdef FEATURE_PAL
+#define INITIALIZE_SHIM { if (PAL_InitializeDLL() != 0) return E_FAIL; }
+#else
+#define INITIALIZE_SHIM
+#endif
+
+// Contract for public APIs. These must be NOTHROW.
+#define PUBLIC_CONTRACT \
+ INITIALIZE_SHIM \
+ CONTRACTL \
+ { \
+ NOTHROW; \
+ } \
+ CONTRACTL_END;
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// CreateProcessForLaunch - a stripped down version of the Windows CreateProcess
+// that can be supported cross-platform.
+//
+//-----------------------------------------------------------------------------
+HRESULT
+CreateProcessForLaunch(
+ __in LPWSTR lpCommandLine,
+ __in BOOL bSuspendProcess,
+ __in LPVOID lpEnvironment,
+ __in LPCWSTR lpCurrentDirectory,
+ __out PDWORD pProcessId,
+ __out HANDLE *pResumeHandle)
+{
+ PUBLIC_CONTRACT;
+
+ PROCESS_INFORMATION processInfo;
+ STARTUPINFOW startupInfo;
+ DWORD dwCreationFlags = 0;
+
+ ZeroMemory(&processInfo, sizeof(processInfo));
+ ZeroMemory(&startupInfo, sizeof(startupInfo));
+
+ startupInfo.cb = sizeof(startupInfo);
+
+ if (bSuspendProcess)
+ {
+ dwCreationFlags = CREATE_SUSPENDED;
+ }
+
+ BOOL result = CreateProcessW(
+ NULL,
+ lpCommandLine,
+ NULL,
+ NULL,
+ FALSE,
+ dwCreationFlags,
+ lpEnvironment,
+ lpCurrentDirectory,
+ &startupInfo,
+ &processInfo);
+
+ if (!result) {
+ *pProcessId = 0;
+ *pResumeHandle = NULL;
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ if (processInfo.hProcess != NULL)
+ {
+ CloseHandle(processInfo.hProcess);
+ }
+
+ *pProcessId = processInfo.dwProcessId;
+ *pResumeHandle = processInfo.hThread;
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// ResumeProcess - to be used with the CreateProcessForLaunch resume handle
+//
+//-----------------------------------------------------------------------------
+HRESULT
+ResumeProcess(
+ __in HANDLE hResumeHandle)
+{
+ PUBLIC_CONTRACT;
+ if (ResumeThread(hResumeHandle) == (DWORD)-1)
+ {
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// CloseResumeHandle - to be used with the CreateProcessForLaunch resume handle
+//
+//-----------------------------------------------------------------------------
+HRESULT
+CloseResumeHandle(
+ __in HANDLE hResumeHandle)
+{
+ PUBLIC_CONTRACT;
+ if (!CloseHandle(hResumeHandle))
+ {
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+ return S_OK;
+}
+
+#ifdef FEATURE_PAL
+
+static
+void
+RuntimeStartupHandler(
+ char *pszModulePath,
+ HMODULE hModule,
+ PVOID parameter);
+
+#else // FEATURE_PAL
+
+static
+DWORD
+StartupHelperThread(
+ LPVOID p);
+
+static
+HRESULT
+GetContinueStartupEvent(
+ DWORD debuggeePID,
+ LPCWSTR szTelestoFullPath,
+ __out HANDLE *phContinueStartupEvent);
+
+#endif // FEATURE_PAL
+
+// Functions that we'll look for in the loaded Mscordbi module.
+typedef HRESULT (STDAPICALLTYPE *FPCoreCLRCreateCordbObject)(
+ int iDebuggerVersion,
+ DWORD pid,
+ HMODULE hmodTargetCLR,
+ IUnknown **ppCordb);
+
+//
+// Helper class for RegisterForRuntimeStartup
+//
+class RuntimeStartupHelper
+{
+ LONG m_ref;
+ DWORD m_processId;
+ PSTARTUP_CALLBACK m_callback;
+ PVOID m_parameter;
+#ifdef FEATURE_PAL
+ PVOID m_unregisterToken;
+#else
+ bool m_canceled;
+ HANDLE m_startupEvent;
+ DWORD m_threadId;
+ HANDLE m_threadHandle;
+#endif // FEATURE_PAL
+
+public:
+ RuntimeStartupHelper(DWORD dwProcessId, PSTARTUP_CALLBACK pfnCallback, PVOID parameter) :
+ m_ref(1),
+ m_processId(dwProcessId),
+ m_callback(pfnCallback),
+ m_parameter(parameter),
+#ifdef FEATURE_PAL
+ m_unregisterToken(NULL)
+#else
+ m_canceled(false),
+ m_startupEvent(NULL),
+ m_threadId(0),
+ m_threadHandle(NULL)
+#endif // FEATURE_PAL
+ {
+ }
+
+ ~RuntimeStartupHelper()
+ {
+#ifndef FEATURE_PAL
+ if (m_startupEvent != NULL)
+ {
+ CloseHandle(m_startupEvent);
+ }
+ if (m_threadHandle != NULL)
+ {
+ CloseHandle(m_threadHandle);
+ }
+#endif // FEATURE_PAL
+ }
+
+ LONG AddRef()
+ {
+ LONG ref = InterlockedIncrement(&m_ref);
+ return ref;
+ }
+
+ LONG Release()
+ {
+ LONG ref = InterlockedDecrement(&m_ref);
+ if (ref == 0)
+ {
+ delete this;
+ }
+ return ref;
+ }
+
+#ifdef FEATURE_PAL
+
+ HRESULT Register()
+ {
+ DWORD pe = PAL_RegisterForRuntimeStartup(m_processId, RuntimeStartupHandler, this, &m_unregisterToken);
+ if (pe != NO_ERROR)
+ {
+ return HRESULT_FROM_WIN32(pe);
+ }
+ return S_OK;
+ }
+
+ void Unregister()
+ {
+ PAL_UnregisterForRuntimeStartup(m_unregisterToken);
+ }
+
+ void InvokeStartupCallback(char *pszModulePath, HMODULE hModule)
+ {
+ IUnknown *pCordb = NULL;
+ HMODULE hMod = NULL;
+ HRESULT hr = S_OK;
+
+ // If either of these are NULL, there was an error from the PAL
+ // callback. GetLastError returns the error code from the PAL.
+ if (pszModulePath == NULL || hModule == NULL)
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ goto exit;
+ }
+
+ PAL_CPP_TRY
+ {
+ FPCoreCLRCreateCordbObject fpCreate = NULL;
+ char dbiPath[MAX_LONGPATH];
+
+ char *pszLast = strrchr(pszModulePath, DIRECTORY_SEPARATOR_CHAR_A);
+ if (pszLast == NULL)
+ {
+ _ASSERT(!"InvokeStartupCallback: can find separator in coreclr path\n");
+ hr = E_INVALIDARG;
+ goto exit;
+ }
+
+ strncpy_s(dbiPath, _countof(dbiPath), pszModulePath, pszLast - pszModulePath);
+ strcat_s(dbiPath, _countof(dbiPath), DIRECTORY_SEPARATOR_STR_A MAKEDLLNAME_A("mscordbi"));
+
+ hMod = LoadLibraryA(dbiPath);
+ if (hMod == NULL)
+ {
+ hr = CORDBG_E_DEBUG_COMPONENT_MISSING;
+ goto exit;
+ }
+
+ fpCreate = (FPCoreCLRCreateCordbObject)GetProcAddress(hMod, "CoreCLRCreateCordbObject");
+ if (fpCreate == NULL)
+ {
+ hr = CORDBG_E_INCOMPATIBLE_PROTOCOL;
+ goto exit;
+ }
+
+ HRESULT hr = fpCreate(CorDebugVersion_2_0, m_processId, hModule, &pCordb);
+ _ASSERTE((pCordb == NULL) == FAILED(hr));
+ if (FAILED(hr))
+ {
+ goto exit;
+ }
+
+ m_callback(pCordb, m_parameter, S_OK);
+ }
+ PAL_CPP_CATCH_ALL
+ {
+ hr = E_FAIL;
+ goto exit;
+ }
+ PAL_CPP_ENDTRY
+
+ exit:
+ if (FAILED(hr))
+ {
+ _ASSERTE(pCordb == NULL);
+
+ if (hMod != NULL)
+ {
+ FreeLibrary(hMod);
+ }
+
+ // Invoke the callback on error
+ m_callback(NULL, m_parameter, hr);
+ }
+ }
+
+#else // FEATURE_PAL
+
+ HRESULT Register()
+ {
+ HRESULT hr = GetStartupNotificationEvent(m_processId, &m_startupEvent);
+ if (FAILED(hr))
+ {
+ goto exit;
+ }
+
+ // Add a reference for the thread handler
+ AddRef();
+
+ m_threadHandle = CreateThread(
+ NULL,
+ 0,
+ ::StartupHelperThread,
+ this,
+ 0,
+ &m_threadId);
+
+ if (m_threadHandle == NULL)
+ {
+ hr = E_OUTOFMEMORY;
+ Release();
+ goto exit;
+ }
+
+ exit:
+ return hr;
+ }
+
+ HRESULT InternalEnumerateCLRs(HANDLE** ppHandleArray, _In_reads_(*pdwArrayLength) LPWSTR** ppStringArray, DWORD* pdwArrayLength)
+ {
+ int numTries = 0;
+ HRESULT hr;
+
+ while (numTries < 25)
+ {
+ // EnumerateCLRs uses the OS API CreateToolhelp32Snapshot which can return ERROR_BAD_LENGTH or
+ // ERROR_PARTIAL_COPY. If we get either of those, we try wait 1/10th of a second try again (that
+ // is the recommendation of the OS API owners)
+ hr = EnumerateCLRs(m_processId, ppHandleArray, ppStringArray, pdwArrayLength);
+ if ((hr != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && (hr != HRESULT_FROM_WIN32(ERROR_BAD_LENGTH)))
+ {
+ break;
+ }
+ Sleep(100);
+ numTries++;
+ }
+
+ return hr;
+ }
+
+ void WakeRuntimes(HANDLE *handleArray, DWORD arrayLength)
+ {
+ if (handleArray != NULL)
+ {
+ for (int i = 0; i < (int)arrayLength; i++)
+ {
+ HANDLE h = handleArray[i];
+ if (h != NULL && h != INVALID_HANDLE_VALUE)
+ {
+ SetEvent(h);
+ }
+ }
+ }
+ }
+
+ void Unregister()
+ {
+ m_canceled = true;
+
+ HANDLE *handleArray = NULL;
+ LPWSTR *stringArray = NULL;
+ DWORD arrayLength = 0;
+
+ // Wake up runtime(s)
+ HRESULT hr = InternalEnumerateCLRs(&handleArray, &stringArray, &arrayLength);
+ if (SUCCEEDED(hr))
+ {
+ WakeRuntimes(handleArray, arrayLength);
+ CloseCLREnumeration(handleArray, stringArray, arrayLength);
+ }
+
+ // Wake up worker thread
+ SetEvent(m_startupEvent);
+
+ // Don't need to wake up and wait for the worker thread if called on it
+ if (m_threadId != GetCurrentThreadId())
+ {
+ // Wait for work thread to exit
+ WaitForSingleObject(m_threadHandle, INFINITE);
+ }
+ }
+
+ HRESULT InvokeStartupCallback(bool *pCoreClrExists)
+ {
+ HANDLE *handleArray = NULL;
+ LPWSTR *stringArray = NULL;
+ DWORD arrayLength = 0;
+ HRESULT hr = S_OK;
+
+ PAL_CPP_TRY
+ {
+ IUnknown *pCordb = NULL;
+ WCHAR verStr[MAX_LONGPATH];
+ DWORD verLen;
+
+ *pCoreClrExists = FALSE;
+
+ hr = InternalEnumerateCLRs(&handleArray, &stringArray, &arrayLength);
+ if (FAILED(hr))
+ {
+ goto exit;
+ }
+
+ for (int i = 0; i < (int)arrayLength; i++)
+ {
+ *pCoreClrExists = TRUE;
+
+ hr = CreateVersionStringFromModule(m_processId, stringArray[i], verStr, _countof(verStr), &verLen);
+ if (FAILED(hr))
+ {
+ goto exit;
+ }
+
+ hr = CreateDebuggingInterfaceFromVersion(verStr, &pCordb);
+ if (FAILED(hr))
+ {
+ goto exit;
+ }
+
+ m_callback(pCordb, m_parameter, S_OK);
+
+ // Currently only the first coreclr module in a process is supported
+ break;
+ }
+ }
+ PAL_CPP_CATCH_ALL
+ {
+ hr = E_FAIL;
+ goto exit;
+ }
+ PAL_CPP_ENDTRY
+
+ exit:
+ if (*pCoreClrExists)
+ {
+ // Wake up all the runtimes
+ WakeRuntimes(handleArray, arrayLength);
+ }
+ CloseCLREnumeration(handleArray, stringArray, arrayLength);
+
+ return hr;
+ }
+
+ void StartupHelperThread()
+ {
+ bool coreclrExists = false;
+
+ HRESULT hr = InvokeStartupCallback(&coreclrExists);
+ // Because the target process is suspended on create, the toolhelp apis fail with the below errors even
+ // with the retry logic in InternalEnumerateCLRs.
+ if (SUCCEEDED(hr) || (hr == HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) || (hr == HRESULT_FROM_WIN32(ERROR_BAD_LENGTH)))
+ {
+ if (!coreclrExists && !m_canceled)
+ {
+ // Wait until the coreclr runtime (debuggee) starts up
+ if (WaitForSingleObject(m_startupEvent, INFINITE) == WAIT_OBJECT_0)
+ {
+ if (!m_canceled)
+ {
+ hr = InvokeStartupCallback(&coreclrExists);
+ if (SUCCEEDED(hr))
+ {
+ // We should always find a coreclr module
+ _ASSERTE(coreclrExists);
+ }
+ }
+ }
+ else
+ {
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ }
+ }
+ }
+
+ if (FAILED(hr) && !m_canceled)
+ {
+ m_callback(NULL, m_parameter, hr);
+ }
+ }
+
+#endif // FEATURE_PAL
+};
+
+#ifdef FEATURE_PAL
+
+static
+void
+RuntimeStartupHandler(char *pszModulePath, HMODULE hModule, PVOID parameter)
+{
+ RuntimeStartupHelper *helper = (RuntimeStartupHelper *)parameter;
+ helper->InvokeStartupCallback(pszModulePath, hModule);
+}
+
+#else // FEATURE_PAL
+
+static
+DWORD
+StartupHelperThread(LPVOID p)
+{
+ RuntimeStartupHelper *helper = (RuntimeStartupHelper *)p;
+ helper->StartupHelperThread();
+ helper->Release();
+ return 0;
+}
+
+#endif // FEATURE_PAL
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// RegisterForRuntimeStartup -- executes the callback when the coreclr runtime
+// starts in the specified process. The callback is passed the proper ICorDebug
+// instance for the version of the runtime or an error if something fails. This
+// API works for launch and attach (and even the attach scenario if the runtime
+// hasn't been loaded yet) equally on both xplat and Windows. The callback is
+// always called on a separate thread. This API returns immediately.
+//
+// The callback is invoked when the coreclr runtime module is loaded during early
+// initialization. The runtime is blocked during initialization until the callback
+// returns.
+//
+// If the runtime is already loaded in the process (as in the normal attach case),
+// the callback is executed and the runtime is not blocked.
+//
+// The callback is always invoked on a separate thread and this API returns immediately.
+//
+// Only the first coreclr module instance found in the target process is currently
+// supported.
+//
+// dwProcessId -- process id of the target process
+// pfnCallback -- invoked when coreclr runtime starts
+// parameter -- data to pass to callback
+// ppUnregisterToken -- pointer to put the UnregisterForRuntimeStartup token.
+//
+//-----------------------------------------------------------------------------
+HRESULT
+RegisterForRuntimeStartup(
+ __in DWORD dwProcessId,
+ __in PSTARTUP_CALLBACK pfnCallback,
+ __in PVOID parameter,
+ __out PVOID *ppUnregisterToken)
+{
+ PUBLIC_CONTRACT;
+
+ if (pfnCallback == NULL || ppUnregisterToken == NULL)
+ {
+ return E_INVALIDARG;
+ }
+
+ HRESULT hr = S_OK;
+
+ RuntimeStartupHelper *helper = new (nothrow) RuntimeStartupHelper(dwProcessId, pfnCallback, parameter);
+ if (helper == NULL)
+ {
+ hr = E_OUTOFMEMORY;
+ }
+ else
+ {
+ hr = helper->Register();
+ if (FAILED(hr))
+ {
+ helper->Release();
+ helper = NULL;
+ }
+ }
+
+ *ppUnregisterToken = helper;
+ return hr;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// UnregisterForRuntimeStartup -- stops/cancels runtime startup notification. Needs
+// to be called during the debugger's shutdown to cleanup the internal data.
+//
+// This API can be called in the startup callback. Otherwise, it will block until
+// the callback thread finishes and no more callbacks will be initiated after this
+// API returns.
+//
+// pUnregisterToken -- unregister token from RegisterForRuntimeStartup or NULL.
+//-----------------------------------------------------------------------------
+HRESULT
+UnregisterForRuntimeStartup(
+ __in PVOID pUnregisterToken)
+{
+ PUBLIC_CONTRACT;
+
+ if (pUnregisterToken != NULL)
+ {
+ RuntimeStartupHelper *helper = (RuntimeStartupHelper *)pUnregisterToken;
+ helper->Unregister();
+ helper->Release();
+ }
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// GetStartupNotificationEvent -- creates a global, named event that is PID-
+// qualified (i.e. process global) that is used to notify the debugger of
+// any CLR instance startup in the process.
+//
+// debuggeePID -- process ID of the target process
+// phStartupEvent -- out param for the returned event handle
+//
+//-----------------------------------------------------------------------------
+#define StartupNotifyEventNamePrefix W("TelestoStartupEvent_")
+#define SessionIdPrefix W("Session\\")
+
+// NULL terminator is included in sizeof(StartupNotifyEventNamePrefix)
+const int cchEventNameBufferSize = (sizeof(StartupNotifyEventNamePrefix) + sizeof(SessionIdPrefix)) / sizeof(WCHAR)
+ + 8 // + hex process id DWORD
+ + 10 // + decimal session id DWORD
+ + 1; // '\' after session id
+
+HRESULT
+GetStartupNotificationEvent(
+ __in DWORD debuggeePID,
+ __out HANDLE* phStartupEvent)
+{
+ PUBLIC_CONTRACT;
+
+ if (phStartupEvent == NULL)
+ return E_INVALIDARG;
+
+#ifndef FEATURE_PAL
+ HRESULT hr;
+ DWORD currentSessionId = 0, debuggeeSessionId = 0;
+ if (!ProcessIdToSessionId(GetCurrentProcessId(), &currentSessionId))
+ {
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ if (!ProcessIdToSessionId(debuggeePID, &debuggeeSessionId))
+ {
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ // Here we could just add "Global\" to the event name and this would solve cross-session debugging scenario, but that would require event name change
+ // in CoreCLR, and break backward compatibility. Instead if we see that debugee is in a different session, we explicitly create startup event
+ // in that session (by adding "Session\#\"). We could do it even for our own session, but that's vaguely documented behavior and we'd
+ // like to use it as little as possible.
+ WCHAR szEventName[cchEventNameBufferSize];
+ if (currentSessionId == debuggeeSessionId)
+ {
+ swprintf_s(szEventName, cchEventNameBufferSize, StartupNotifyEventNamePrefix W("%08x"), debuggeePID);
+ }
+ else
+ {
+ swprintf_s(szEventName, cchEventNameBufferSize, SessionIdPrefix W("%u\\") StartupNotifyEventNamePrefix W("%08x"), debuggeeSessionId, debuggeePID);
+ }
+
+ // Determine an appropriate ACL and SECURITY_ATTRIBUTES to apply to this event. We use the same logic
+ // here as the debugger uses for other events (like the setup-sync-event). Specifically, this does
+ // the work to ensure a debuggee running as another user, or with a low integrity level can signal
+ // this event.
+ PACL pACL = NULL;
+ SECURITY_ATTRIBUTES * pSA = NULL;
+ IfFailRet(SecurityUtil::GetACLOfPid(debuggeePID, &pACL));
+ SecurityUtil secUtil(pACL);
+
+ HandleHolder hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, debuggeePID);
+ if (hProcess == NULL)
+ {
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ IfFailRet(secUtil.Init(hProcess));
+ IfFailRet(secUtil.GetSA(&pSA));
+
+ HANDLE startupEvent = WszCreateEvent(pSA,
+ FALSE, // false -> auto-reset
+ FALSE, // false -> initially non-signaled
+ szEventName);
+ DWORD dwStatus = GetLastError();
+ if (NULL == startupEvent)
+ {
+ // if the event already exists, try to open it, otherwise we fail.
+
+ if (ERROR_ALREADY_EXISTS != dwStatus)
+ return E_FAIL;
+
+ startupEvent = WszOpenEvent(SYNCHRONIZE, FALSE, szEventName);
+
+ if (NULL == startupEvent)
+ return E_FAIL;
+ }
+
+ *phStartupEvent = startupEvent;
+ return S_OK;
+#else
+ *phStartupEvent = NULL;
+ return E_NOTIMPL;
+#endif // FEATURE_PAL
+}
+// Refer to clr\src\mscoree\mscorwks_ntdef.src.
+const WORD kOrdinalForMetrics = 2;
+
+//-----------------------------------------------------------------------------
+// The CLR_ENGINE_METRICS is a static struct in coreclr.dll. It's exported by coreclr.dll at ordinal 2 in
+// the export address table. This function returns the CLR_ENGINE_METRICS and the RVA to the continue
+// startup event for a coreclr.dll specified by its full path.
+//
+// Arguments:
+// szTelestoFullPath - (in) full path of telesto
+// pEngineMetricsOut - (out) filled in based on metrics from target telesto.
+// pdwRVAContinueStartupEvent - (out; optional) return the RVA to the continue startup event
+//
+// Returns:
+// Throwss on error.
+//
+// Notes:
+// When VS pops up the attach dialog box, it is actually enumerating all the processes on the machine
+// (if the appropiate checkbox is checked) and checking each process to see if a DLL named "coreclr.dll"
+// is loaded. If there is one, we will go down this code path, but there is no guarantee that the
+// coreclr.dll is ours. A malicious user can be running a process with a bogus coreclr.dll loaded.
+// That's why we need to be extra careful reading coreclr.dll in this function.
+//-----------------------------------------------------------------------------
+static
+void
+GetTargetCLRMetrics(
+ LPCWSTR szTelestoFullPath,
+ CLR_ENGINE_METRICS *pEngineMetricsOut,
+ DWORD *pdwRVAContinueStartupEvent = NULL)
+{
+ CONTRACTL
+ {
+ THROWS;
+ }
+ CONTRACTL_END;
+
+ CONSISTENCY_CHECK(szTelestoFullPath != NULL);
+ CONSISTENCY_CHECK(pEngineMetricsOut != NULL);
+
+#ifndef FEATURE_PAL
+ HRESULT hr = S_OK;
+
+ HandleHolder hCoreClrFile = WszCreateFile(szTelestoFullPath,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL, // default security descriptor
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (hCoreClrFile == INVALID_HANDLE_VALUE)
+ {
+ ThrowLastError();
+ }
+
+ DWORD cbFileHigh = 0;
+ DWORD cbFileLow = GetFileSize(hCoreClrFile, &cbFileHigh);
+ if (cbFileLow == INVALID_FILE_SIZE)
+ {
+ ThrowLastError();
+ }
+
+ // A maximum size of 100 MB should be more than enough for coreclr.dll.
+ if ((cbFileHigh != 0) || (cbFileLow > 0x6400000) || (cbFileLow == 0))
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ HandleHolder hCoreClrMap = WszCreateFileMapping(hCoreClrFile, NULL, PAGE_READONLY, cbFileHigh, cbFileLow, NULL);
+ if (hCoreClrMap == NULL)
+ {
+ ThrowLastError();
+ }
+
+ MapViewHolder hCoreClrMapView = MapViewOfFile(hCoreClrMap, FILE_MAP_READ, 0, 0, 0);
+ if (hCoreClrMapView == NULL)
+ {
+ ThrowLastError();
+ }
+
+ // At this point we have read the file into the process, but be careful because it is flat, i.e. not mapped.
+ // We need to translate RVAs into file offsets, but fortunately PEDecoder can do all of that for us.
+ PEDecoder pedecoder(hCoreClrMapView, (COUNT_T)cbFileLow);
+
+ // Check the NT headers.
+ if (!pedecoder.CheckNTFormat())
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ // At this point we can safely read anything in the NT headers.
+
+ if (!pedecoder.HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXPORT) ||
+ !pedecoder.CheckDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXPORT))
+ {
+ ThrowHR(E_FAIL);
+ }
+ IMAGE_DATA_DIRECTORY * pExportDirectoryEntry = pedecoder.GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXPORT);
+
+ // At this point we can safely read the IMAGE_DATA_DIRECTORY of the export directory.
+
+ if (!pedecoder.CheckDirectory(pExportDirectoryEntry))
+ {
+ ThrowHR(E_FAIL);
+ }
+ IMAGE_EXPORT_DIRECTORY * pExportDir =
+ reinterpret_cast<IMAGE_EXPORT_DIRECTORY *>(pedecoder.GetDirectoryData(pExportDirectoryEntry));
+
+ // At this point we have checked that everything in the export directory is readable.
+
+ // Check to make sure the ordinal we have fits in the table in the export directory.
+ // The "base" here is like the starting index of the arrays in the export directory.
+ if ((pExportDir->Base > kOrdinalForMetrics) ||
+ (pExportDir->NumberOfFunctions < (kOrdinalForMetrics - pExportDir->Base)))
+ {
+ ThrowHR(E_FAIL);
+ }
+ DWORD dwRealIndex = kOrdinalForMetrics - pExportDir->Base;
+
+ // Check that we can read the RVA at the element (specified by the ordinal) in the export address table.
+ // Then read the RVA to the CLR_ENGINE_METRICS.
+ if (!pedecoder.CheckRva(pExportDir->AddressOfFunctions, (dwRealIndex + 1) * sizeof(DWORD)))
+ {
+ ThrowHR(E_FAIL);
+ }
+ DWORD rvaMetrics = *reinterpret_cast<DWORD *>(
+ pedecoder.GetRvaData(pExportDir->AddressOfFunctions + dwRealIndex * sizeof(DWORD)));
+
+ // Make sure we can safely read the CLR_ENGINE_METRICS at the RVA we have retrieved.
+ if (!pedecoder.CheckRva(rvaMetrics, sizeof(*pEngineMetricsOut)))
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ // Finally, copy the CLR_ENGINE_METRICS into the output buffer.
+ CLR_ENGINE_METRICS * pMetricsInFile = reinterpret_cast<CLR_ENGINE_METRICS *>(pedecoder.GetRvaData(rvaMetrics));
+ *pEngineMetricsOut = *pMetricsInFile;
+
+ // At this point, we have retrieved the CLR_ENGINE_METRICS from the target process and
+ // stored it in output buffer.
+ if (pEngineMetricsOut->cbSize != sizeof(*pEngineMetricsOut))
+ {
+ ThrowHR(E_INVALIDARG);
+ }
+
+ if (pdwRVAContinueStartupEvent != NULL)
+ {
+ // Note that the pointer stored in the CLR_ENGINE_METRICS is assuming that the DLL is loaded at its
+ // preferred base address. We need to translate that to an RVA.
+ if (((SIZE_T)pEngineMetricsOut->phContinueStartupEvent < (SIZE_T)pedecoder.GetPreferredBase()) ||
+ ((SIZE_T)pEngineMetricsOut->phContinueStartupEvent >
+ ((SIZE_T)pedecoder.GetPreferredBase() + pedecoder.GetVirtualSize())))
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ DWORD rvaContinueStartupEvent =
+ (DWORD)((SIZE_T)pEngineMetricsOut->phContinueStartupEvent - (SIZE_T)pedecoder.GetPreferredBase());
+
+ // We can't use CheckRva() here because for unmapped files it actually checks the RVA against the file
+ // size as well. We have already checked the RVA above. Now just check that the entire HANDLE
+ // falls in the loaded image.
+ if ((rvaContinueStartupEvent + sizeof(HANDLE)) > pedecoder.GetVirtualSize())
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ *pdwRVAContinueStartupEvent = rvaContinueStartupEvent;
+ }
+
+ // Holder will call FreeLibrary()
+#else
+ //TODO: So far on POSIX systems we only support one version of debugging interface
+ // in future we might want to detect it the same way we do it on Windows.
+ pEngineMetricsOut->cbSize = sizeof(*pEngineMetricsOut);
+ pEngineMetricsOut->dwDbiVersion = CorDebugLatestVersion;
+ pEngineMetricsOut->phContinueStartupEvent = NULL;
+
+ if (pdwRVAContinueStartupEvent != NULL)
+ {
+ *pdwRVAContinueStartupEvent = NULL;
+ }
+#endif // FEATURE_PAL
+}
+
+// Returns true iff the module represents CoreClr.
+static
+bool
+IsCoreClr(
+ const WCHAR* pModulePath)
+{
+ _ASSERTE(pModulePath != NULL);
+
+ //strip off everything up to and including the last slash in the path to get name
+ const WCHAR* pModuleName = pModulePath;
+ while(wcschr(pModuleName, DIRECTORY_SEPARATOR_CHAR_W) != NULL)
+ {
+ pModuleName = wcschr(pModuleName, DIRECTORY_SEPARATOR_CHAR_W);
+ pModuleName++; // pass the slash
+ }
+
+ // MAIN_CLR_MODULE_NAME_W gets changed for desktop builds, so we directly code against the CoreClr name.
+ return _wcsicmp(pModuleName, MAKEDLLNAME_W(W("coreclr"))) == 0;
+}
+
+// Returns true iff the module sent is named CoreClr.dll and has the metrics expected in it's PE header.
+static
+bool
+IsCoreClrWithGoodHeader(
+ HANDLE hProcess,
+ HMODULE hModule)
+{
+ HRESULT hr = S_OK;
+
+ WCHAR modulePath[MAX_LONGPATH];
+ modulePath[0] = W('\0');
+ if(0 == GetModuleFileNameEx(hProcess, hModule, modulePath, MAX_LONGPATH))
+ {
+ return false;
+ }
+ else
+ {
+ modulePath[MAX_LONGPATH-1] = 0; // on older OS'es this doesn't get null terminated automatically on truncation
+ }
+
+ if (IsCoreClr(modulePath))
+ {
+ // We don't care about the particular error returned, only that
+ // what we tried wasn't a 'real' coreclr.dll.
+ EX_TRY
+ {
+ CLR_ENGINE_METRICS metricsStruct;
+ GetTargetCLRMetrics(modulePath, &metricsStruct); // throws
+
+ // If we got this far, then we think it's a good one.
+ }
+ EX_CATCH_HRESULT(hr);
+ return (hr == S_OK);
+ }
+
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// EnumerateCLRs -- returns an array of full paths to each coreclr.dll in the
+// target process. Also returns a corresponding array of continue events
+// that *MUST* be signaled by the caller in order to allow the CLRs in the
+// target process to proceed.
+//
+// debuggeePID -- process ID of the target process
+// ppHandleArrayOut -- out parameter in which an array of handles is returned.
+// the length of this array is returned by the pdwArrayLengthOut out param
+// ppStringArrayOut -- out parameter in which an array of full paths to each
+// coreclr.dll in the process is returned. The length of this array is the
+// same as the handle array and is returned by the pdwArrayLengthOut param
+// pdwArrayLengthOut -- out param in which the length of the two returned arrays
+// are returned.
+//
+// Notes:
+// Callers use code:CloseCLREnumeration to free the returned arrays.
+//-----------------------------------------------------------------------------
+HRESULT
+EnumerateCLRs(
+ DWORD debuggeePID,
+ __out HANDLE** ppHandleArrayOut,
+ __out LPWSTR** ppStringArrayOut,
+ __out DWORD* pdwArrayLengthOut)
+{
+ PUBLIC_CONTRACT;
+
+ // All out params must be non-NULL.
+ if ((ppHandleArrayOut == NULL) || (ppStringArrayOut == NULL) || (pdwArrayLengthOut == NULL))
+ return E_INVALIDARG;
+
+ HandleHolder hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, debuggeePID);
+ if (NULL == hProcess)
+ return E_FAIL;
+
+ // These shouldn't be freed
+ HMODULE modules[1000];
+ DWORD cbNeeded;
+ if(!EnumProcessModules(hProcess, modules, sizeof(modules), &cbNeeded))
+ {
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ //
+ // count the number of coreclr.dll entries
+ //
+ DWORD count = 0;
+ DWORD countModules = cbNeeded/sizeof(HMODULE);
+ for(DWORD i = 0; i < countModules; i++)
+ {
+ if (IsCoreClrWithGoodHeader(hProcess, modules[i]))
+ {
+ count++;
+ }
+ }
+
+ // If we didn't find anything, no point in continuing.
+ if (count == 0)
+ {
+ *ppHandleArrayOut = NULL;
+ *ppStringArrayOut = NULL;
+ *pdwArrayLengthOut = 0;
+
+ return S_OK;
+ }
+
+ size_t cbEventArrayData = sizeof(HANDLE) * count; // event array data
+ size_t cbStringArrayData = sizeof(LPWSTR) * count; // string array data
+ size_t cbStringData = sizeof(WCHAR) * count * MAX_LONGPATH; // strings data
+ size_t cbBuffer = cbEventArrayData + cbStringArrayData + cbStringData;
+
+ BYTE* pOutBuffer = new (nothrow) BYTE[cbBuffer];
+ if (NULL == pOutBuffer)
+ return E_OUTOFMEMORY;
+
+ ZeroMemory(pOutBuffer, cbBuffer);
+
+ HANDLE* pEventArray = (HANDLE*) &pOutBuffer[0];
+ LPWSTR* pStringArray = (LPWSTR*) &pOutBuffer[cbEventArrayData];
+ WCHAR* pStringData = (WCHAR*) &pOutBuffer[cbEventArrayData + cbStringArrayData];
+ DWORD idx = 0;
+
+ // There's no guarantee that another coreclr hasn't loaded already anyhow,
+ // so if we get the corner case that the second time through we enumerate
+ // more coreclrs, just ignore the extras.
+ // This mismatch could happen when
+ // a) take module shapshot
+ // b) underlying file is opened for exclusive access/deleted/moved/ACL'd etc so we can't open it
+ // c) count is determined
+ // d) file is closed/copied/moved/ACL'd etc so we can find/open it again
+ // e) this loop runs
+ // Thus the loop checks idx < count
+
+ for(DWORD i = 0; i < countModules && idx < count; i++)
+ {
+ if (IsCoreClrWithGoodHeader(hProcess, modules[i]))
+ {
+ // fill in path
+ pStringArray[idx] = &pStringData[idx * MAX_LONGPATH];
+ GetModuleFileNameEx(hProcess, modules[i], pStringArray[idx], MAX_LONGPATH);
+
+#ifndef FEATURE_PAL
+ // fill in event handle -- if GetContinueStartupEvent fails, it will still return
+ // INVALID_HANDLE_VALUE in hContinueStartupEvent, which is what we want. we don't
+ // want to bail out of the enumeration altogether if we can't get an event from
+ // one telesto.
+
+ HANDLE hContinueStartupEvent = INVALID_HANDLE_VALUE;
+ HRESULT hr = GetContinueStartupEvent(debuggeePID, pStringArray[idx], &hContinueStartupEvent);
+ _ASSERTE(SUCCEEDED(hr) == (hContinueStartupEvent != INVALID_HANDLE_VALUE));
+
+ pEventArray[idx] = hContinueStartupEvent;
+#else
+ pEventArray[idx] = NULL;
+#endif // FEATURE_PAL
+
+ idx++;
+ }
+ }
+
+ // Patch things up so CloseCLREnumeration() can still have it's
+ // pointer arithmatic checks succeed, and the user doesn't see a 'dead' entry.
+ // Specifically, it's expected that pEventArray and pStringArray point to the
+ // same contiguous chunk of memory so that pStringArray == pEventArray[*pdwArrayLengthOut].
+ // This is expected to be a very rare case.
+ if (idx < count)
+ {
+ // Move the string pointers back.
+ LPWSTR* pSATemp = (LPWSTR*)&pOutBuffer[sizeof(HANDLE)*idx];
+ for (DWORD i = 0; i < idx; i++)
+ {
+ pSATemp[i] = pStringArray[i];
+ }
+
+ // Fix up string array pointer.
+ pStringArray = (LPWSTR*)&pOutBuffer[sizeof(HANDLE)*idx];
+
+ // Strings themselves don't need moved.
+ }
+
+ *ppHandleArrayOut = pEventArray;
+ *ppStringArrayOut = pStringArray;
+ *pdwArrayLengthOut = idx;
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// CloseCLREnumeration -- used to free resources allocated by EnumerateCLRs
+//
+// pHandleArray -- handle array originally returned by EnumerateCLRs
+// pStringArray -- string array originally returned by EnumerateCLRs
+// dwArrayLength -- array length originally returned by EnumerateCLRs
+//
+//-----------------------------------------------------------------------------
+HRESULT
+CloseCLREnumeration(
+ __in HANDLE* pHandleArray,
+ __in LPWSTR* pStringArray,
+ __in DWORD dwArrayLength)
+{
+ PUBLIC_CONTRACT;
+
+ if ((pHandleArray + dwArrayLength) != (HANDLE*)pStringArray)
+ return E_INVALIDARG;
+
+ // It's possible that EnumerateCLRs found nothing to enumerate, in which case
+ // pointers and count are zeroed. If a debugger calls this function in that
+ // case, let's not try to delete [] on NULL.
+ if (pHandleArray == NULL)
+ return S_OK;
+
+#ifndef FEATURE_PAL
+ for (DWORD i = 0; i < dwArrayLength; i++)
+ {
+ HANDLE hTemp = pHandleArray[i];
+ if ( (NULL != hTemp)
+ && (INVALID_HANDLE_VALUE != hTemp))
+ {
+ CloseHandle(hTemp);
+ }
+ }
+#endif // FEATURE_PAL
+
+ delete[] pHandleArray;
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Get the base address of a module from the remote process.
+//
+// Returns:
+// - On success, base address (in remote process) of mscoree,
+// - NULL if the module is not loaded.
+// - else Throws. *ppBaseAddress = NULL
+//-----------------------------------------------------------------------------
+static
+BYTE*
+GetRemoteModuleBaseAddress(
+ DWORD dwPID,
+ LPCWSTR szFullModulePath)
+{
+ CONTRACTL
+ {
+ THROWS;
+ }
+ CONTRACTL_END;
+
+ HandleHolder hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPID);
+ if (NULL == hProcess)
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ // These shouldn't be freed
+ HMODULE modules[1000];
+ DWORD cbNeeded;
+ if(!EnumProcessModules(hProcess, modules, sizeof(modules), &cbNeeded))
+ {
+ ThrowHR(HRESULT_FROM_WIN32(GetLastError()));
+ }
+
+ DWORD countModules = min(cbNeeded, sizeof(modules)) / sizeof(HMODULE);
+ for(DWORD i = 0; i < countModules; i++)
+ {
+ WCHAR modulePath[MAX_LONGPATH];
+ if(0 == GetModuleFileNameEx(hProcess, modules[i], modulePath, MAX_LONGPATH))
+ {
+ continue;
+ }
+ else
+ {
+ modulePath[MAX_LONGPATH-1] = 0; // on older OS'es this doesn't get null terminated automatically
+ if (_wcsicmp(modulePath, szFullModulePath) == 0)
+ {
+ return (BYTE*) modules[i];
+ }
+ }
+ }
+
+ // Successfully enumerated modules but couldn't find the requested one.
+ return NULL;
+}
+
+// DBI version: max 8 hex chars
+// SEMICOLON: 1
+// PID: max 8 hex chars
+// SEMICOLON: 1
+// HMODULE: max 16 hex chars (64-bit)
+// SEMICOLON: 1
+// PROTOCOL STRING: (variable length)
+const int c_iMaxVersionStringLen = 8 + 1 + 8 + 1 + 16; // 64-bit hmodule
+const int c_iMinVersionStringLen = 8 + 1 + 8 + 1 + 8; // 32-bit hmodule
+const int c_idxFirstSemi = 8;
+const int c_idxSecondSemi = 17;
+const WCHAR *c_versionStrFormat = W("%08x;%08x;%p");
+
+//-----------------------------------------------------------------------------
+// Public API.
+// Given a path to a coreclr.dll, get the Version string.
+//
+// Arguments:
+// pidDebuggee - OS process ID of debuggee.
+// szModuleName - a full or relative path to a valid coreclr.dll in the debuggee.
+// pBuffer - the buffer to fill the version string into
+// if pdwLength != NULL, we set *pdwLength to the length of the version string on
+// output (including the null terminator).
+// cchBuffer - length of pBuffer on input in characters
+//
+// Returns:
+// S_OK - on success.
+// E_INVALIDARG -
+// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) if the buffer is too small.
+// COR_E_FILENOTFOUND - module is not found in a given debugee process
+//
+// Notes:
+// The null-terminated version string including null, is
+// copied to pVersion on output. Thus *pdwLength == wcslen(pBuffer)+1.
+// The version string is an opaque string that can only be passed back to other
+// DbgShim APIs.
+//-----------------------------------------------------------------------------
+HRESULT
+CreateVersionStringFromModule(
+ __in DWORD pidDebuggee,
+ __in LPCWSTR szModuleName,
+ __out_ecount_part(cchBuffer, *pdwLength) LPWSTR pBuffer,
+ __in DWORD cchBuffer,
+ __out DWORD* pdwLength)
+{
+ PUBLIC_CONTRACT;
+
+ if (szModuleName == NULL)
+ {
+ return E_INVALIDARG;
+ }
+
+ // it is ok for both to be null (to query the required buffer size) or both to be non-null.
+ if ((pBuffer == NULL) != (cchBuffer == 0))
+ {
+ return E_INVALIDARG;
+ }
+
+ SIZE_T nLengthWithNull = c_iMaxVersionStringLen + 1;
+ _ASSERTE(nLengthWithNull > 0);
+
+ if (pdwLength != NULL)
+ {
+ *pdwLength = (DWORD) nLengthWithNull;
+ }
+
+ if (nLengthWithNull > cchBuffer)
+ {
+ return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+ }
+ else if (pBuffer != NULL)
+ {
+
+ HRESULT hr = S_OK;
+ EX_TRY
+ {
+ CorDebugInterfaceVersion dbiVersion = CorDebugInvalidVersion;
+ BYTE* hmodTargetCLR = NULL;
+ CLR_ENGINE_METRICS metricsStruct;
+
+ GetTargetCLRMetrics(szModuleName, &metricsStruct); // throws
+ dbiVersion = (CorDebugInterfaceVersion) metricsStruct.dwDbiVersion;
+
+ hmodTargetCLR = GetRemoteModuleBaseAddress(pidDebuggee, szModuleName); // throws
+ if (hmodTargetCLR == NULL)
+ {
+ hr = COR_E_FILENOTFOUND;
+ }
+ else
+ {
+ swprintf_s(pBuffer, cchBuffer, c_versionStrFormat, dbiVersion, pidDebuggee, hmodTargetCLR);
+ }
+ }
+ EX_CATCH_HRESULT(hr);
+ return hr;
+ }
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Parse a version string into useful data.
+//
+// Arguments:
+// szDebuggeeVersion - (in) null terminated version string
+// piDebuggerVersion - (out) interface number that the debugger expects to use.
+// pdwPidDebuggee - (out) OS process ID of debuggee
+// phmodTargetCLR - (out) module handle of CoreClr within the debuggee.
+//
+// Returns:
+// S_OK on success. Else failures.
+//
+// Notes:
+// The version string is coming from the target CoreClr and in the case of a corrupted target, could be
+// an arbitrary string. It should be treated as untrusted public input.
+//-----------------------------------------------------------------------------
+static
+HRESULT
+ParseVersionString(
+ LPCWSTR szDebuggeeVersion,
+ CorDebugInterfaceVersion *piDebuggerVersion,
+ DWORD *pdwPidDebuggee,
+ HMODULE *phmodTargetCLR)
+{
+ if ((piDebuggerVersion == NULL) ||
+ (pdwPidDebuggee == NULL) ||
+ (phmodTargetCLR == NULL) ||
+ (wcslen(szDebuggeeVersion) < c_iMinVersionStringLen) ||
+ (W(';') != szDebuggeeVersion[c_idxFirstSemi]) ||
+ (W(';') != szDebuggeeVersion[c_idxSecondSemi]))
+ {
+ return E_INVALIDARG;
+ }
+
+ int numFieldsAssigned = swscanf_s(szDebuggeeVersion, c_versionStrFormat, piDebuggerVersion, pdwPidDebuggee, phmodTargetCLR);
+ if (numFieldsAssigned != 3)
+ {
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+//-----------------------------------------------------------------------------
+// Appends "\mscordbi.dll" to the path. This converts a directory name into the full path to mscordbi.dll.
+//
+// Arguments:
+// szFullDbiPath - (in/out): on input, the directory containing dbi. On output, the full path to dbi.dll.
+//-----------------------------------------------------------------------------
+static
+void
+AppendDbiDllName(SString & szFullDbiPath)
+{
+ const WCHAR * pDbiDllName = DIRECTORY_SEPARATOR_STR_W MAKEDLLNAME_W(W("mscordbi"));
+ szFullDbiPath.Append(pDbiDllName);
+}
+
+//-----------------------------------------------------------------------------
+// Return a path to the dbi next to the runtime, if present.
+//
+// Arguments:
+// pidDebuggee - OS process ID of debuggee
+// hmodTargetCLR - handle to CoreClr within debuggee process
+// szFullDbiPath - (out) the full path of Mscordbi.dll next to the debuggee's CoreClr.dll.
+//
+// Notes:
+// This just calculates a filename and does not determine if the file actually exists.
+//-----------------------------------------------------------------------------
+static
+void
+GetDbiFilenameNextToRuntime(
+ DWORD pidDebuggee,
+ HMODULE hmodTargetCLR,
+ SString & szFullDbiPath,
+ SString & szFullCoreClrPath)
+{
+ szFullDbiPath.Clear();
+
+ //
+ // Step 1: (pid, hmodule) --> full path
+ //
+ HandleHolder hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pidDebuggee);
+ WCHAR modulePath[MAX_LONGPATH];
+ if(0 == GetModuleFileNameEx(hProcess, hmodTargetCLR, modulePath, MAX_LONGPATH))
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ //
+ // Step 2: 'Coreclr.dll' --> 'mscordbi.dll'
+ //
+ WCHAR * pCoreClrPath = modulePath;
+ WCHAR * pLast = wcsrchr(pCoreClrPath, DIRECTORY_SEPARATOR_CHAR_W);
+ if (pLast == NULL)
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ // c:\abc\coreclr.dll
+ // 01234567890
+ // c:\abc\mscordbi.dll
+
+ // Copy everything up to but not including the last '\', thus excluding '\coreclr.dll'
+ // Then append '\mscordbi.dll' to get a full path to dbi.
+ COUNT_T len = (COUNT_T) (pLast - pCoreClrPath); // length not including final '\'
+ szFullDbiPath.Set(pCoreClrPath, len);
+
+ AppendDbiDllName(szFullDbiPath);
+
+ szFullCoreClrPath.Set(pCoreClrPath, (COUNT_T)wcslen(pCoreClrPath));
+}
+
+
+//---------------------------------------------------------------------------------------
+//
+// The current policy is that the DBI DLL must live right next to the coreclr DLL. We check the product
+// version number of both of them to make sure they match.
+//
+// Arguments:
+// szFullDbiPath - full path to mscordbi.dll
+// szFullCoreClrPath - full path to coreclr.dll
+//
+// Return Value:
+// true if the versions match
+//
+static
+bool
+CheckDbiAndRuntimeVersion(
+ SString & szFullDbiPath,
+ SString & szFullCoreClrPath)
+{
+#ifndef FEATURE_PAL
+ DWORD dwDbiVersionMS = 0;
+ DWORD dwDbiVersionLS = 0;
+ DWORD dwCoreClrVersionMS = 0;
+ DWORD dwCoreClrVersionLS = 0;
+
+ // The version numbers follow the convention used by VS_FIXEDFILEINFO.
+ GetProductVersionNumber(szFullDbiPath, &dwDbiVersionMS, &dwDbiVersionLS);
+ GetProductVersionNumber(szFullCoreClrPath, &dwCoreClrVersionMS, &dwCoreClrVersionLS);
+
+ if ((dwDbiVersionMS == dwCoreClrVersionMS) &&
+ (dwDbiVersionLS == dwCoreClrVersionLS))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+#else
+ return true;
+#endif // FEATURE_PAL
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+// Given a version string, create the matching mscordbi.dll for it.
+// Create a managed debugging interface for the specified version.
+//
+// Parameters:
+// iDebuggerVersion - the version of interface the debugger (eg, Cordbg) expects.
+// szDebuggeeVersion - the version of the debuggee. This will map to a version of mscordbi.dll
+// ppCordb - the outparameter used to return the debugging interface object.
+//
+// Return:
+// S_OK on success. *ppCordb will be non-null.
+// CORDBG_E_INCOMPATIBLE_PROTOCOL - if the proper DBI is not available. This can be a very common error if
+// the right debug pack is not installed.
+// else Error. (*ppCordb will be null)
+//-----------------------------------------------------------------------------
+HRESULT
+CreateDebuggingInterfaceFromVersionEx(
+ __in int iDebuggerVersion,
+ __in LPCWSTR szDebuggeeVersion,
+ __out IUnknown ** ppCordb)
+{
+ PUBLIC_CONTRACT;
+
+ HRESULT hrIgnore = S_OK; // ignored HResult
+ HRESULT hr = S_OK;
+ HMODULE hMod = NULL;
+ IUnknown * pCordb = NULL;
+ FPCoreCLRCreateCordbObject fpCreate2 = NULL;
+
+ LOG((LF_CORDB, LL_EVERYTHING, "Calling CreateDebuggerInterfaceFromVersion, ver=%S\n", szDebuggeeVersion));
+
+ if ((szDebuggeeVersion == NULL) || (ppCordb == NULL))
+ {
+ hr = E_INVALIDARG;
+ goto Exit;
+ }
+
+ //
+ // Step 1: Parse version information into internal data structures
+ //
+
+ CorDebugInterfaceVersion iTargetVersion; // the CorDebugInterfaceVersion (CorDebugVersion_2_0)
+ DWORD pidDebuggee; // OS process ID of the debuggee
+ HMODULE hmodTargetCLR; // module of Telesto in target (the clrInstanceId)
+
+ hr = ParseVersionString(szDebuggeeVersion, &iTargetVersion, &pidDebuggee, &hmodTargetCLR);
+ if (FAILED(hr))
+ goto Exit;
+
+ //
+ // Step 2: Find the proper dbi module (mscordbi) and load it.
+ //
+
+ // Check for dbi next to target CLR.
+ // This will be very common for internal developer setups, but not common in end-user setups.
+ EX_TRY
+ {
+ SString szFullDbiPath;
+ SString szFullCoreClrPath;
+
+ GetDbiFilenameNextToRuntime(pidDebuggee, hmodTargetCLR, szFullDbiPath, szFullCoreClrPath);
+
+ if (!CheckDbiAndRuntimeVersion(szFullDbiPath, szFullCoreClrPath))
+ {
+ hr = CORDBG_E_INCOMPATIBLE_PROTOCOL;
+ goto Exit;
+ }
+
+ // We calculated where dbi would be, but haven't yet verified if it's there.
+ // Try to load it. We're using this to check for file existence.
+
+ // Issue:951525: coreclr mscordbi load fails on downlevel OS since LoadLibraryEx can't find
+ // dependent forwarder DLLs. Force LoadLibrary to look for dependencies in szFullDbiPath plus the default
+ // search paths.
+#ifndef FEATURE_PAL
+ hMod = WszLoadLibraryEx(szFullDbiPath, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+#else
+ hMod = LoadLibraryExW(szFullDbiPath, NULL, 0);
+#endif
+ }
+ EX_CATCH_HRESULT(hrIgnore); // failure leaves hMod null
+
+ // Couldn't find Dbi, likely because the right debug pack is not installed. Failure.
+ if (NULL == hMod)
+ {
+ // Check for the following two HRESULTs and return them specifically. These are returned by
+ // CreateToolhelp32Snapshot() and could be transient errors. The debugger may choose to retry.
+ if ((hrIgnore == HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) || (hrIgnore == HRESULT_FROM_WIN32(ERROR_BAD_LENGTH)))
+ {
+ hr = hrIgnore;
+ }
+ else
+ {
+ hr = CORDBG_E_DEBUG_COMPONENT_MISSING;
+ }
+ goto Exit;
+ }
+
+ //
+ // Step 3: Now that module is loaded, instantiate an ICorDebug.
+ //
+ fpCreate2 = (FPCoreCLRCreateCordbObject)GetProcAddress(hMod, "CoreCLRCreateCordbObject");
+ if (fpCreate2 == NULL)
+ {
+ // New-style creation API didn't exist - this DBI must be the wrong version, for the Mix07 protocol
+ hr = CORDBG_E_INCOMPATIBLE_PROTOCOL;
+ goto Exit;
+ }
+
+ // Invoke to instantiate an ICorDebug. This export was introduced after the Mix'07 release.
+ hr = fpCreate2(iDebuggerVersion, pidDebuggee, hmodTargetCLR, &pCordb);
+ _ASSERTE((pCordb == NULL) == FAILED(hr));
+
+Exit:
+ if (FAILED(hr))
+ {
+ if (pCordb != NULL)
+ {
+ pCordb->Release();
+ pCordb = NULL;
+ }
+
+ if (hMod != NULL)
+ {
+ _ASSERTE(pCordb == NULL);
+ FreeLibrary(hMod);
+ }
+ }
+
+ // Set our outparam.
+ *ppCordb = pCordb;
+
+ // On success case, mscordbi.dll is leaked.
+ // - We never give the caller back the module handle, so our caller can't do FreeLibrary().
+ // - ICorDebug can't unload itself.
+
+ return hr;
+}
+
+//-----------------------------------------------------------------------------
+// Public API.
+// Superceded by CreateDebuggingInterfaceFromVersionEx in SLv4.
+// Given a version string, create the matching mscordbi.dll for it.
+// Create a managed debugging interface for the specified version.
+//
+// Parameters:
+// szDebuggeeVersion - the version of the debuggee. This will map to a version of mscordbi.dll
+// ppCordb - the outparameter used to return the debugging interface object.
+//
+// Return:
+// S_OK on success. *ppCordb will be non-null.
+// CORDBG_E_INCOMPATIBLE_PROTOCOL - if the proper DBI is not available. This can be a very common error if
+// the right debug pack is not installed.
+// else Error. (*ppCordb will be null)
+//-----------------------------------------------------------------------------
+HRESULT
+CreateDebuggingInterfaceFromVersion(
+ __in LPCWSTR szDebuggeeVersion,
+ __out IUnknown ** ppCordb
+)
+{
+ PUBLIC_CONTRACT;
+
+ return CreateDebuggingInterfaceFromVersionEx(CorDebugVersion_2_0, szDebuggeeVersion, ppCordb);
+}
+
+#ifndef FEATURE_PAL
+
+//------------------------------------------------------------------------------
+// Manually retrieves the "continue startup" event from the correct CLR instance
+// in the target process.
+//
+// Arguments:
+// debuggeePID - (in) OS Process ID of debuggee
+// szTelestoFullPath - (in) full path to telesto within the process.
+// phContinueStartupEvent - (out)
+//
+// Returns:
+// S_OK on success.
+//------------------------------------------------------------------------------
+HRESULT
+GetContinueStartupEvent(
+ DWORD debuggeePID,
+ LPCWSTR szTelestoFullPath,
+ __out HANDLE* phContinueStartupEvent)
+{
+ if ((phContinueStartupEvent == NULL) || (szTelestoFullPath == NULL))
+ return E_INVALIDARG;
+
+ HRESULT hr = S_OK;
+ EX_TRY
+ {
+ *phContinueStartupEvent = INVALID_HANDLE_VALUE;
+
+ DWORD dwCoreClrContinueEventOffset = 0;
+ CLR_ENGINE_METRICS metricsStruct;
+
+ GetTargetCLRMetrics(szTelestoFullPath, &metricsStruct, &dwCoreClrContinueEventOffset); // throws
+
+
+ BYTE* pbBaseAddress = GetRemoteModuleBaseAddress(debuggeePID, szTelestoFullPath); // throws
+
+
+ HandleHolder hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, debuggeePID);
+ if (NULL == hProcess)
+ ThrowHR(E_FAIL);
+
+ HANDLE continueEvent = NULL;
+
+ SIZE_T nBytesRead;
+ if (!ReadProcessMemory(hProcess, pbBaseAddress + dwCoreClrContinueEventOffset, &continueEvent,
+ sizeof(continueEvent), &nBytesRead))
+ {
+ ThrowHR(E_FAIL);
+ }
+
+ if (NULL != continueEvent)
+ {
+ if (!DuplicateHandle(hProcess, continueEvent, GetCurrentProcess(), &continueEvent,
+ EVENT_MODIFY_STATE, FALSE, 0))
+ {
+ ThrowHR(E_FAIL);
+ }
+ }
+
+ *phContinueStartupEvent = continueEvent;
+ }
+ EX_CATCH_HRESULT(hr)
+ return hr;
+}
+
+#endif // !FEATURE_PAL
+
+#if defined(FEATURE_CORESYSTEM)
+#include "debugshim.h"
+#endif
+
+//-----------------------------------------------------------------------------
+// Public API.
+//
+// Parameters:
+// clsid
+// riid
+// ppInterface
+//
+// Return:
+// S_OK on success.
+//-----------------------------------------------------------------------------
+HRESULT
+CLRCreateInstance(
+ REFCLSID clsid,
+ REFIID riid,
+ LPVOID *ppInterface)
+{
+#if defined(FEATURE_CORESYSTEM)
+
+ if (ppInterface == NULL)
+ return E_POINTER;
+
+ if (clsid != CLSID_CLRDebugging || riid != IID_ICLRDebugging)
+ return E_NOINTERFACE;
+
+#if defined(FEATURE_CORESYSTEM)
+ GUID skuId = CLR_ID_ONECORE_CLR;
+#elif defined(FEATURE_CORECLR)
+ GUID skuId = CLR_ID_CORECLR;
+#else
+ GUID skuId = CLR_ID_V4_DESKTOP;
+#endif
+
+ CLRDebuggingImpl *pDebuggingImpl = new CLRDebuggingImpl(skuId);
+ return pDebuggingImpl->QueryInterface(riid, ppInterface);
+#else
+ return E_NOTIMPL;
+#endif
+} \ No newline at end of file
diff --git a/src/dlls/dbgshim/dbgshim.h b/src/dlls/dbgshim/dbgshim.h
new file mode 100644
index 0000000000..777c706ade
--- /dev/null
+++ b/src/dlls/dbgshim/dbgshim.h
@@ -0,0 +1,75 @@
+// 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.
+//*****************************************************************************
+// DbgShim.h
+//
+//*****************************************************************************
+
+#include <windows.h>
+
+typedef VOID (*PSTARTUP_CALLBACK)(IUnknown *pCordb, PVOID parameter, HRESULT hr);
+
+EXTERN_C HRESULT
+CreateProcessForLaunch(
+ __in LPWSTR lpCommandLine,
+ __in BOOL bSuspendProcess,
+ __in LPVOID lpEnvironment,
+ __in LPCWSTR lpCurrentDirectory,
+ __out PDWORD pProcessId,
+ __out HANDLE *pResumeHandle);
+
+EXTERN_C HRESULT
+ResumeProcess(
+ __in HANDLE hResumeHandle);
+
+EXTERN_C HRESULT
+CloseResumeHandle(
+ __in HANDLE hResumeHandle);
+
+EXTERN_C HRESULT
+RegisterForRuntimeStartup(
+ __in DWORD dwProcessId,
+ __in PSTARTUP_CALLBACK pfnCallback,
+ __in PVOID parameter,
+ __out PVOID *ppUnregisterToken);
+
+EXTERN_C HRESULT
+UnregisterForRuntimeStartup(
+ __in PVOID pUnregisterToken);
+
+EXTERN_C HRESULT
+GetStartupNotificationEvent(
+ __in DWORD debuggeePID,
+ __out HANDLE* phStartupEvent);
+
+EXTERN_C HRESULT
+EnumerateCLRs(DWORD debuggeePID,
+ __out HANDLE** ppHandleArrayOut,
+ __out LPWSTR** ppStringArrayOut,
+ __out DWORD* pdwArrayLengthOut);
+
+EXTERN_C HRESULT
+CloseCLREnumeration(
+ __in HANDLE* pHandleArray,
+ __in LPWSTR* pStringArray,
+ __in DWORD dwArrayLength);
+
+EXTERN_C HRESULT
+CreateVersionStringFromModule(
+ __in DWORD pidDebuggee,
+ __in LPCWSTR szModuleName,
+ __out_ecount_part(cchBuffer, *pdwLength) LPWSTR pBuffer,
+ __in DWORD cchBuffer,
+ __out DWORD* pdwLength);
+
+EXTERN_C HRESULT
+CreateDebuggingInterfaceFromVersionEx(
+ __in int iDebuggerVersion,
+ __in LPCWSTR szDebuggeeVersion,
+ __out IUnknown ** ppCordb);
+
+EXTERN_C HRESULT
+CreateDebuggingInterfaceFromVersion(
+ __in LPCWSTR szDebuggeeVersion,
+ __out IUnknown ** ppCordb);
diff --git a/src/dlls/dbgshim/dbgshim.ntdef b/src/dlls/dbgshim/dbgshim.ntdef
new file mode 100644
index 0000000000..6915beebf9
--- /dev/null
+++ b/src/dlls/dbgshim/dbgshim.ntdef
@@ -0,0 +1,17 @@
+; 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
+ CreateProcessForLaunch
+ ResumeProcess
+ CloseResumeHandle
+ RegisterForRuntimeStartup
+ UnregisterForRuntimeStartup
+ GetStartupNotificationEvent
+ EnumerateCLRs
+ CloseCLREnumeration
+ CreateVersionStringFromModule
+ CreateDebuggingInterfaceFromVersion
+ CreateDebuggingInterfaceFromVersionEx
+ CLRCreateInstance
diff --git a/src/dlls/dbgshim/dbgshim.rc b/src/dlls/dbgshim/dbgshim.rc
new file mode 100644
index 0000000000..c1d53acc7d
--- /dev/null
+++ b/src/dlls/dbgshim/dbgshim.rc
@@ -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.
+
+#include "resource.h"
+
+#define FX_VER_FILEDESCRIPTION_STR "Microsoft .NET Runtime Multi-CLR Debugging Helper\0"
+
+#include <fxver.h>
+#include <fxver.rc>
diff --git a/src/dlls/dbgshim/dbgshim.targets b/src/dlls/dbgshim/dbgshim.targets
new file mode 100644
index 0000000000..8332befa5a
--- /dev/null
+++ b/src/dlls/dbgshim/dbgshim.targets
@@ -0,0 +1,94 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\xplat\utility.props"/>
+ <PropertyGroup>
+ <LinkUseCMT>true</LinkUseCMT>
+ <UserIncludes>
+ $(UserIncludes);
+ ..\;
+ $(VCToolsIncPath);
+ $(Clrbase)\src\Debug\shim;
+ </UserIncludes>
+ <OutputName>dbgshim</OutputName>
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <CDefines>$(CDefines);UNICODE;_UNICODE;FEATURE_NO_HOST;SELF_NO_HOST</CDefines>
+ <DllDef>..\dbgshim.ntdef</DllDef>
+ <DllEntryPoint>_DllMainCRTStartup</DllEntryPoint>
+ <ExtDelayImpLib >false</ExtDelayImpLib>
+ <UseMsvcrt>false</UseMsvcrt>
+ <NoLinkGdi32>true</NoLinkGdi32>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(HostMachineOS)' == 'windows'">
+ <LinkDelayLoad Condition="'$(LinkDelayLoad)'!=''">$(LinkDelayLoad);</LinkDelayLoad>
+ <LinkDelayLoad>$(LinkDelayLoad)user32.dll;advapi32.dll;oleaut32.dll</LinkDelayLoad>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <LinkPreCrtLibs Include="$(ClrLibPath)\utilcodestaticnohost$(XPlatHostLibSuffix).lib" >
+ <!-- This project isn't factored like the others... there are many projects pointing to the current path of corguids -->
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'">$(ClrSrcDirectory)utilcode\staticnohost\staticnohost.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'">$(ClrSrcDirectory)utilcode\staticnohostx86\staticnohost.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'">$(ClrSrcDirectory)utilcode\staticnohostamd64\staticnohost.nativeproj</ProjectReference>
+ </LinkPreCrtLibs>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- This lib differs between Win32 and CoreSys, so I am specifically using XPlatHostSuffix, not XPlatHostLibSuffix -->
+ <!-- In retrospect the naming on those props aren't great, but I don't want to undo all the testing already done on this change
+ with potential errors refactoring to a new prop name. XPlatHostLibSuffix only varies on architecture whereas XPlatHostSuffix
+ varies on arch and OS -->
+ <TargetLib Include="$(ClrLibPath)\debugshim$(XPlatHostSuffix).lib" />
+ <ProjectReference Include="$(ClrSrcDirectory)\Debug\shim\$(XPlatHostBuildDir)\debugshim.nativeproj" />
+ <TargetLib Include="$(ClrLibPath)\dbgutil$(XPlatHostLibSuffix).lib" />
+ <ProjectReference Include="$(ClrSrcDirectory)\Debug\dbgutil\$(XPlatHostLibBuildDir)\dbgutil.nativeproj" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'windows'">
+ <TargetLib Include="$(ClrLibPath)\CorGUIDS$(XPlatHostLibSuffix).lib">
+ <!-- This project isn't factored like the others... there are many projects pointing to the current path of corguids -->
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'">$(ClrSrcDirectory)inc\corguids.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'">$(ClrSrcDirectory)incx86\corguids.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'">$(ClrSrcDirectory)incamd64\corguids.nativeproj</ProjectReference>
+ </TargetLib>
+ <Targetlib Include="$(SdkLibPath)\kernel32.lib" />
+ <Targetlib Include="$(CrtLibPath)\libcmt$(BuildSuffix).lib" />
+ <Targetlib Include="$(SdkLibPath)\uuid.lib" />
+ <Targetlib Include="$(SdkLibPath)\user32.lib" />
+ <Targetlib Include="$(SdkLibPath)\advapi32.lib" />
+ <Targetlib Include="$(SdkLibPath)\oleaut32.lib" />
+ <Targetlib Include="$(SdkLibPath)\WtsApi32.lib" />
+ <Targetlib Include="$(SdkLibPath)\version.lib" />
+ <Targetlib Include="$(SdkLibPath)\psapi.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCore' or '$(HostMachineOS)'=='OneCoreWin7Compat'">
+ <TargetLib Include="$(CoreSystemCrt)" />
+ <TargetLib Include="$(SdkLibPath)\uuid.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCoreWin7Compat'">
+ <TargetLib Include="$(SdkLibPath)\bcrypt.lib" />
+ <TargetLib Include="$(SdkLibPath)\crypt32.lib" />
+ <TargetLib Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Include="$(SdkLibPath)\mincore_fw.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCore'">
+ <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>
+ <RCResourceFile Include="..\dbgshim.rc" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <CppCompile Include="..\dbgshim.cpp" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <DataFile Include="..\dbgshim.h" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+
+</Project>
diff --git a/src/dlls/dbgshim/dbgshim_unixexports.src b/src/dlls/dbgshim/dbgshim_unixexports.src
new file mode 100644
index 0000000000..b1cc36bc2f
--- /dev/null
+++ b/src/dlls/dbgshim/dbgshim_unixexports.src
@@ -0,0 +1,16 @@
+; 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.
+
+CreateProcessForLaunch
+ResumeProcess
+CloseResumeHandle
+RegisterForRuntimeStartup
+UnregisterForRuntimeStartup
+GetStartupNotificationEvent
+EnumerateCLRs
+CloseCLREnumeration
+CreateVersionStringFromModule
+CreateDebuggingInterfaceFromVersion
+CreateDebuggingInterfaceFromVersionEx
+CLRCreateInstance
diff --git a/src/dlls/dbgshim/dirs.proj b/src/dlls/dbgshim/dirs.proj
new file mode 100644
index 0000000000..dc91ac22f0
--- /dev/null
+++ b/src/dlls/dbgshim/dirs.proj
@@ -0,0 +1,19 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ </PropertyGroup>
+
+ <!--The following projects will build during the CoreCLR build-->
+ <ItemGroup Condition="'$(FeatureCoreclr)' == 'true'">
+ <ProjectFile Include="HostLocal\dbgshim.nativeproj" />
+ <ProjectFile Include="HostWinx86\dbgshim.nativeproj" Condition="'$(BuildArchitecture)'=='i386'" />
+ <ProjectFile Include="HostWinamd64\dbgshim.nativeproj" Condition="'$(BuildArchitecture)'=='amd64'" />
+ <ProjectFile Include="HostOneCorex86\dbgshim.nativeproj" Condition="'$(BuildArchitecture)'=='i386'" />
+ <ProjectFile Include="HostOneCoreamd64\dbgshim.nativeproj" Condition="'$(BuildArchitecture)'=='amd64'" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
+</Project>
diff --git a/src/dlls/dbgshim/resource.h b/src/dlls/dbgshim/resource.h
new file mode 100644
index 0000000000..45274bad55
--- /dev/null
+++ b/src/dlls/dbgshim/resource.h
@@ -0,0 +1,3 @@
+// 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.
diff --git a/src/dlls/dirs.proj b/src/dlls/dirs.proj
new file mode 100644
index 0000000000..de81b7f5d3
--- /dev/null
+++ b/src/dlls/dirs.proj
@@ -0,0 +1,50 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildInPhase1>true</BuildInPhase1>
+ <BuildInPhaseDefault>false</BuildInPhaseDefault>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ </PropertyGroup>
+
+ <!--The following projects will build during PHASE 1-->
+ <ItemGroup Condition="'$(BuildExePhase)' == '1'">
+ <ProjectFile Include="clretwrc\clretwrc.nativeproj" />
+ <ProjectFile Include="mscoree\dirs.proj" />
+ <ProjectFile Include="mscorrc\dirs.proj" />
+ <ProjectFile Include="mscordac\dirs.proj" />
+ <ProjectFile Include="mscordbi\dirs.proj" />
+ <ProjectFile Include="standalonemd-ro\standalonemd-ro.nativeproj" />
+ </ItemGroup>
+
+ <!--The following projects will build during PHASE 1 of the Desktop build-->
+ <ItemGroup Condition="'$(BuildExePhase)' == '1' and '$(FeatureCoreClr)' != 'true'">
+ <ProjectFile Include="mscoruef\mscoruef.nativeproj" />
+ <ProjectFile Include="shim\mscoreei.nativeproj" />
+ <ProjectFile Include="shimr_v2\mscorees.proj" />
+ <ProjectFile Include="shell_shim\mscoree.proj" />
+ <ProjectFile Include="shimr\mscoreeis.nativeproj" />
+ <ProjectFile Include="mscorpe\dirs.proj" />
+ <ProjectFile Include="mscorsn\mscorsn.nativeproj" />
+ <ProjectFile Include="culture\dirs.proj" />
+ <ProjectFile Include="normalization\dirs.proj" />
+ <ProjectFile Include="nlssorting\nlssorting.nativeproj" />
+ <ProjectFile Include="sort00001000\sort00001000.nativeproj" />
+ <ProjectFile Include="sort00060101\sort00060101.nativeproj" />
+ <ProjectFile Include="fusion\fusion.nativeproj" />
+ <ProjectFile Include="mscorier\mscorier.proj" />
+ <ProjectFile Include="mscorsecimpl\mscorsecimpl.nativeproj" />
+ <ProjectFile Include="mscorsecr\mscorsecr.nativeproj" />
+ <ProjectFile Include="mscorsvc\dirs.proj" />
+ <ProjectFile Include="bindingdisplay\bindingdisplay.nativeproj" />
+ <ProjectFile Include="standalonemd-rw\Standalonemd-rw.nativeproj" />
+ </ItemGroup>
+
+ <!--The following projects will build during PHASE 1 of the CoreCLR build-->
+ <ItemGroup Condition="'$(BuildExePhase)' == '1' and '$(FeatureCoreclr)' == 'true'">
+ <ProjectFile Include="dbgshim\dirs.proj" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
+</Project>
diff --git a/src/dlls/mscordac/.gitmirror b/src/dlls/mscordac/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/mscordac/.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/mscordac/CMakeLists.txt b/src/dlls/mscordac/CMakeLists.txt
new file mode 100644
index 0000000000..02bba4a058
--- /dev/null
+++ b/src/dlls/mscordac/CMakeLists.txt
@@ -0,0 +1,123 @@
+include(${CLR_DIR}/dac.cmake)
+
+add_definitions(-DFEATURE_NO_HOST)
+
+if(CLR_CMAKE_PLATFORM_UNIX)
+ add_compile_options(-fPIC)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+set(CLR_DAC_SOURCES
+ mscordac.cpp
+)
+
+add_definitions(-DFX_VER_INTERNALNAME_STR=mscordaccore.dll)
+
+if(WIN32)
+ list(APPEND CLR_DAC_SOURCES
+ Native.rc
+ )
+ set(DEF_SOURCES
+ mscordac.src
+ )
+
+ #Preprocess exports definition file
+ preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordac.def)
+
+ #create target to add file dependency on mscordac.def
+ add_custom_target(mscordaccore_def DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mscordac.def)
+
+ # No library groups for Win32
+ set(START_LIBRARY_GROUP)
+ set(END_LIBRARY_GROUP)
+else(WIN32)
+ set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordac_unixexports.src)
+ set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordac.exports)
+ generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
+endif(WIN32)
+
+if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_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)
+
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
+
+if(CLR_CMAKE_PLATFORM_DARWIN)
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_DARWIN)
+
+add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES})
+
+if(CLR_CMAKE_PLATFORM_UNIX)
+ add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE})
+ add_dependencies(mscordaccore mscordaccore_exports)
+
+ set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
+ set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+# 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(COREDAC_LIBRARIES
+ ${START_LIBRARY_GROUP} # Start group of libraries that have circular references
+ cee_dac
+ cordbee_dac
+ corguids
+ daccess
+ dbgutil
+ mdcompiler_dac
+ mdhotdata_dac
+ mdruntime_dac
+ mdruntimerw_dac
+ strongname_dac
+ utilcode_dac
+ unwinder_dac
+ gc_dac
+ ${END_LIBRARY_GROUP} # End group of libraries that have circular references
+)
+
+if(WIN32)
+ # mscordac.def should be generated before mscordaccore.dll is built
+ add_dependencies(mscordaccore mscordaccore_def)
+
+ # Generate export file
+ add_custom_command(TARGET mscordaccore
+ PRE_LINK
+ COMMAND lib.exe /OUT:"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/mscordaccore.lib" /DEF:"${CMAKE_CURRENT_BINARY_DIR}/mscordac.def" "$<TARGET_FILE:daccess>" $<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/LTCG> ${STATIC_LIBRARY_FLAGS} "${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.dir/$<CONFIG>/mscordac.obj"
+ COMMENT "Generating mscordaccore.exp export file"
+ )
+
+ set(COREDAC_LIBRARIES
+ ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/mscordaccore.exp # export file
+ ${COREDAC_LIBRARIES}
+ mdwinmd_dac
+ kernel32.lib
+ advapi32.lib
+ ole32.lib
+ oleaut32.lib
+ uuid.lib
+ user32.lib
+ ${STATIC_MT_CRT_LIB}
+ ${STATIC_MT_VCRT_LIB}
+ )
+else(WIN32)
+ list(APPEND COREDAC_LIBRARIES
+ mscorrc_debug
+ coreclrpal
+ palrt
+ )
+endif(WIN32)
+
+target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})
+
+# add the install targets
+install_clr(mscordaccore) \ No newline at end of file
diff --git a/src/dlls/mscordac/GetFileVersion.dll b/src/dlls/mscordac/GetFileVersion.dll
new file mode 100644
index 0000000000..4479d7cad7
--- /dev/null
+++ b/src/dlls/mscordac/GetFileVersion.dll
Binary files differ
diff --git a/src/dlls/mscordac/GetFileVersion.pdb b/src/dlls/mscordac/GetFileVersion.pdb
new file mode 100644
index 0000000000..73d3587eaa
--- /dev/null
+++ b/src/dlls/mscordac/GetFileVersion.pdb
Binary files differ
diff --git a/src/dlls/mscordac/Native.rc b/src/dlls/mscordac/Native.rc
new file mode 100644
index 0000000000..b98bc187e6
--- /dev/null
+++ b/src/dlls/mscordac/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 External Data Access Support\0"
+
+#include <fxver.h>
+#include <fxver.rc>
diff --git a/src/dlls/mscordac/dirs.proj b/src/dlls/mscordac/dirs.proj
new file mode 100644
index 0000000000..46a2052403
--- /dev/null
+++ b/src/dlls/mscordac/dirs.proj
@@ -0,0 +1,21 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildInPhase1>true</BuildInPhase1>
+ <BuildInPhaseDefault>false</BuildInPhaseDefault>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ </PropertyGroup>
+
+ <!--The following projects will build during PHASE 1-->
+ <ItemGroup Condition="'$(BuildExePhase)' == '1'">
+ <ProjectFile Include="HostLocal\mscordac.nativeproj" />
+ <ProjectFile Condition="'$(FeatureXPlatDacDebugging_HostWindowsx86)'=='true'" Include="HostWinx86\mscordac.nativeproj" />
+ <ProjectFile Condition="'$(FeatureXPlatDacDebugging_HostWindowsAMD64)' == 'true'" Include="HostWinAMD64\mscordac.nativeproj" />
+ <ProjectFile Condition="'$(FeatureXPlatDacDebugging_HostOneCorex86)'=='true'" Include="HostOneCorex86\mscordac.nativeproj" />
+ <ProjectFile Condition="'$(FeatureXPlatDacDebugging_HostOneCoreAMD64)' == 'true'" Include="HostOneCoreAMD64\mscordac.nativeproj" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
+</Project>
diff --git a/src/dlls/mscordac/mscordac.cpp b/src/dlls/mscordac/mscordac.cpp
new file mode 100644
index 0000000000..94fdac5809
--- /dev/null
+++ b/src/dlls/mscordac/mscordac.cpp
@@ -0,0 +1,21 @@
+// 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.
+
+#ifdef FEATURE_PAL
+
+#include <clrdata.h>
+
+//
+// This dummy reference to CLRDataCreateInstance prevents the LLVM toolchain from optimizing this important export out.
+//
+#ifdef __llvm__
+__attribute__((used))
+#endif // __llvm__
+void
+DummyReferenceToExportedAPI()
+{
+ CLRDataCreateInstance(IID_ICLRDataTarget, NULL, NULL);
+}
+
+#endif // FEATURE_PAL
diff --git a/src/dlls/mscordac/mscordac.src b/src/dlls/mscordac/mscordac.src
new file mode 100644
index 0000000000..a107d4b504
--- /dev/null
+++ b/src/dlls/mscordac/mscordac.src
@@ -0,0 +1,16 @@
+; 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
+ OutOfProcessFunctionTableCallback
+ OutOfProcessFunctionTableCallbackEx
+ DacDbiInterfaceInstance
+
+#ifndef FEATURE_PAL
+ OutOfProcessExceptionEventCallback
+ OutOfProcessExceptionEventSignatureCallback
+#endif // FEATURE_PAL
+ OutOfProcessExceptionEventDebuggerLaunchCallback
+
+ CLRDataCreateInstance
diff --git a/src/dlls/mscordac/mscordac.targets b/src/dlls/mscordac/mscordac.targets
new file mode 100644
index 0000000000..3e0474f9a8
--- /dev/null
+++ b/src/dlls/mscordac/mscordac.targets
@@ -0,0 +1,142 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+
+ <UsingTask TaskName="GetFileVersionTask" AssemblyFile="GetFileVersion.dll"/>
+ <Import Project="..\..\debug\XPlatCommon.props" />
+
+ <PropertyGroup>
+ <CDefines>$(CDefines);UNICODE;_UNICODE;$(USER_SPECIFIC_C_DEFINES);FEATURE_NO_HOST</CDefines>
+ <OutputName Condition="'$(BuildForCoreSystem)'!='true'">mscordacwks$(XPlatHostSuffix)</OutputName>
+ <OutputName Condition="'$(BuildForCoreSystem)'=='true'">mscordaccore</OutputName>
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <DllDef>$(IntermediateOutputDirectory)\mscordac.def</DllDef>
+ <DllEntryPoint>_DllMainCRTStartup</DllEntryPoint>
+ <GenerateBrowserFile>false</GenerateBrowserFile>
+ <CDefines Condition="'$(_BuildType)' == 'dbg'">$(CDefines);SPECIAL_BUILD</CDefines>
+ <UseMsvcrt>false</UseMsvcrt>
+ <ExtDelayImpLib>true</ExtDelayImpLib>
+ <DoNotAddCrtLibPath>true</DoNotAddCrtLibPath>
+ <LinkUseDefaultLib>false</LinkUseDefaultLib>
+ <LinkLibIgnore>$(LinkLibIgnore);4198</LinkLibIgnore>
+ <UseStl>true</UseStl>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(BuildForCoreSystem)' != 'true'">
+ <LinkDelayLoad Condition="'$(LinkDelayLoad)'!=''">$(LinkDelayLoad);</LinkDelayLoad>
+ <LinkDelayLoad>$(LinkDelayLoad)user32.dll;advapi32.dll;ole32.dll;oleaut32.dll</LinkDelayLoad>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <RCResourceFile Include="..\native.rc">
+ <IncludeInLib>true</IncludeInLib>
+ </RCResourceFile >
+ </ItemGroup>
+ <ItemGroup>
+ <CppCompile Include="..\mscordac.cpp" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <CppPreprocess Include="..\mscordac.src">
+ <Defines>@(CommonPreprocessDefines);$(CDefines);$(TargetDefines)</Defines>
+ <FinalOutput>$(IntermediateOutputDirectory)\mscordac.def</FinalOutput>
+ <AdditionalOptions>/TC</AdditionalOptions>
+ </CppPreprocess>
+ </ItemGroup>
+ <ItemGroup>
+ <ImportLib Include="$(ClrLibPath)\dac_wks$(XPlatHostLibSuffix).lib"/>
+ <LinkPreCrtLibs Include="$(ClrLibPath)\dac_wks$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)debug\daccess\$(XPlatHostLibBuildDir)\daccess.nativeproj</ProjectReference>
+ </LinkPreCrtLibs>
+ <LinkPreCrtLibs Include="$(ClrLibPath)\utilcode_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)utilcode\dac\$(XPlatHostLibBuildDir)\dac.nativeproj</ProjectReference>
+ </LinkPreCrtLibs>
+ <TargetLib Include="$(ClrLibPath)\cee_wks_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)vm\dac\$(XPlatHostLibBuildDir)\dacwks.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\cordbee_wks_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)debug\ee\dac\$(XPlatHostLibBuildDir)\dacwks.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDCompiler_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\compiler\dac\$(XPlatHostLibBuildDir)\mdcompiler_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDRuntime_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\runtime\dac\$(XPlatHostLibBuildDir)\mdruntime_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDRuntimeRW_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\enc\dac\$(XPlatHostLibBuildDir)\mdruntimerw_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDWinMD_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\winmd\dac\$(XPlatHostLibBuildDir)\mdwinmd_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDHotData_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\hotdata\dac\$(XPlatHostLibBuildDir)\mdhotdata_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\ipcmanager_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)ipcman\ipcman_dac\$(XPlatHostLibBuildDir)\ipcman_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\strongname_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)StrongName\api\dac\$(XPlatHostLibBuildDir)\strongname_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Condition="'$(TargetArch)' != 'i386'" Include="$(ClrLibPath)\unwinder_dac$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)unwinder\dac\$(XPlatHostLibBuildDir)\unwinder_dac.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\dbgutil$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)debug\dbgutil\$(XPlatHostLibBuildDir)\dbgutil.nativeproj</ProjectReference>
+ </TargetLib>
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' != 'mac'">
+ <TargetLib Include="$(ClrLibPath)\CorGUIDS$(XPlatHostLibSuffix).lib">
+ <!-- This project isn't factored like the others above... there are many projects pointing to the current path of corguids -->
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'">$(ClrSrcDirectory)inc\corguids.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'">$(ClrSrcDirectory)incx86\corguids.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'">$(ClrSrcDirectory)incamd64\corguids.nativeproj</ProjectReference>
+ </TargetLib>
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'windows'">
+ <TargetLib Include="$(ClrLibPath)\delayimp$(XPlatHostLibSuffix).lib">
+ <!-- This project isn't factored like the others above... there are many projects pointing to the current path of delayimp -->
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'">$(ClrSrcDirectory)delayimp\delayimp.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'">$(ClrSrcDirectory)delayimpx86\delayimp.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'">$(ClrSrcDirectory)delayimpamd64\delayimp.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(CrtLibPath)\libcmt$(BuildSuffix).lib" />
+ <TargetLib Include="$(SdkLibPath)\kernel32.lib" />
+ <TargetLib Include="$(SdkLibPath)\advapi32.lib" />
+ <TargetLib Include="$(SdkLibPath)\user32.lib" />
+ <TargetLib Include="$(SdkLibPath)\ole32.lib" />
+ <TargetLib Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Include="$(SdkLibPath)\uuid.lib" />
+ <TargetLib Include="$(SdkLibPath)\wtsapi32.lib" />
+ <TargetLib Include="$(CrtLibPath)\delayimp.lib" />
+ <TargetLib Include="$(SdkLibPath)\ntdll.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCore' or '$(HostMachineOS)'=='OneCoreWin7Compat'">
+ <TargetLib Include="$(CoreSystemCrt)" />
+ <TargetLib Include="$(SdkLibPath)\uuid.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCoreWin7Compat'">
+ <TargetLib Include="$(SdkLibPath)\bcrypt.lib" />
+ <TargetLib Include="$(SdkLibPath)\crypt32.lib" />
+ <TargetLib Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Include="$(SdkLibPath)\mincore_fw.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCore'">
+ <TargetLib Include="$(SdkLibPath)\mincore.lib" />
+ <TargetLib Include="$(SdkLibPath)\mincore_legacy.lib" />
+ <TargetLib Include="$(SdkLibPath)\mincore_private.lib" />
+ <TargetLib Include="$(SdkLibPath)\mincore_obsolete.lib" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+
+
+ <Target Name="CreateLongNameDacForWindbg"
+ Condition="'$(HostMachineOS)'=='windows'"
+ AfterTargets="Link">
+ <GetFileVersionTask FilePath="$(ProductOutputFile)">
+ <Output TaskParameter="FileVersion" PropertyName="DacFileVersion"/>
+ </GetFileVersionTask>
+ <Exec Command="$(PerlCommand) -I$(DevDivToolsPath) $(ClrSrcDirectory)\dlls\mscordac\Update.pl $(ProductOutputFile) $(MainDacMouleName) $(XPlatHostMachineOSSuffix)$(HostMachineArch) $(TargetMachineArch) $(DacFileVersion) $(BinariesDirectory)"
+ StandardOutputImportance="Normal" />
+ </Target>
+</Project>
diff --git a/src/dlls/mscordac/mscordac.vrg b/src/dlls/mscordac/mscordac.vrg
new file mode 100644
index 0000000000..b8cb17547e
--- /dev/null
+++ b/src/dlls/mscordac/mscordac.vrg
@@ -0,0 +1,10 @@
+VSREG 7
+
+[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\KnownFunctionTableDlls]
+"[#FilePath]"=dword:0
+
+[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\KnownManagedDebuggingDlls]
+"[#FilePath]"=dword:0
+
+[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\RuntimeExceptionHelperModules]
+"[#FilePath]"=dword:0
diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src
new file mode 100644
index 0000000000..466a1bf1f5
--- /dev/null
+++ b/src/dlls/mscordac/mscordac_unixexports.src
@@ -0,0 +1,174 @@
+; 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.
+
+DacDbiInterfaceInstance
+CLRDataCreateInstance
+
+; PAL module registration
+DllMain
+PAL_RegisterModule
+PAL_UnregisterModule
+
+PAL_BindResources
+PAL_bsearch
+PAL_errno
+PAL_fflush
+PAL__flushall
+PAL_free
+PAL_fwprintf
+PAL_swprintf
+PAL_GetPALDirectoryW
+PAL_GetResourceString
+PAL_get_stdout
+PAL_get_stderr
+PAL_GetSymbolModuleBase
+PAL_GetTransportPipeName
+PAL_InitializeDLL
+PAL_IsDebuggerPresent
+PAL_iswspace
+PAL_memcpy
+PAL_malloc
+PAL_realloc
+PAL_printf
+PAL_qsort
+PAL_Reenter
+PAL_fprintf
+PAL__vsnprintf
+PAL__wcstoui64
+PAL_wcstoul
+PAL_iswprint
+PAL_wcslen
+PAL_wcsncmp
+PAL_wcsrchr
+PAL_wcscmp
+PAL_wcschr
+PAL_wcscspn
+PAL_wcscat
+PAL_wcsstr
+
+_wcsicmp
+_stricmp
+_snprintf
+_snwprintf
+_vsnwprintf
+_itow
+_i64tow
+memcpy_s
+
+CoCreateGuid
+CopyFileW
+CreateDirectoryW
+CreateFileMappingA
+CreateFileMappingW
+CreateFileA
+CreateFileW
+CreateMutexW
+CreateEventW
+CreateProcessW
+CreateSemaphoreExW
+CreateStreamOnHGlobal
+CreateThread
+CloseHandle
+DebugBreak
+DeleteCriticalSection
+DeleteFileW
+DuplicateHandle
+EnterCriticalSection
+FindClose
+FindFirstFileW
+FindNextFileW
+FlushFileBuffers
+FlushInstructionCache
+FormatMessageW
+FreeLibrary
+FileTimeToSystemTime
+GetACP
+GetCPInfo
+GetCurrentDirectoryW
+GetCurrentProcess
+GetCurrentProcessId
+GetCurrentThreadId
+GetEnvironmentVariableA
+GetEnvironmentVariableW
+GetFileAttributesExW
+GetFileAttributesW
+GetFileSize
+GetFullPathNameW
+GetLastError
+GetLongPathNameW
+GetModuleFileNameW
+GetProcAddress
+GetProcessHeap
+GetShortPathNameW
+GetStdHandle
+GetSystemInfo
+GetSystemTime
+GetSystemTimeAsFileTime
+GetTempFileNameW
+GetTempPathW
+HeapAlloc
+HeapFree
+HeapSetInformation
+IIDFromString
+IID_IClassFactory
+IID_ISequentialStream
+IID_IStream
+IID_IUnknown
+InitializeCriticalSection
+IsDBCSLeadByte
+LeaveCriticalSection
+LoadLibraryA
+LoadLibraryW
+LoadLibraryExW
+LocalAlloc
+LocalReAlloc
+LocalFree
+MapViewOfFile
+MoveFileExW
+MultiByteToWideChar
+OpenProcess
+OutputDebugStringW
+OpenEventW
+OutputDebugStringA
+QueryPerformanceCounter
+QueryPerformanceFrequency
+RaiseException
+ReadFile
+ReleaseMutex
+ReleaseSemaphore
+RemoveDirectoryW
+ResetEvent
+ResumeThread
+SearchPathW
+SetEvent
+SetFileAttributesW
+SetFilePointer
+SetLastError
+SetErrorMode
+Sleep
+SleepEx
+SwitchToThread
+TerminateProcess
+TlsAlloc
+TlsFree
+TlsGetValue
+TlsSetValue
+VirtualAlloc
+VirtualFree
+VirtualProtect
+VirtualQuery
+UnmapViewOfFile
+WaitForMultipleObjectsEx
+WaitForSingleObject
+WaitForSingleObjectEx
+WideCharToMultiByte
+WriteFile
+YieldProcessor
+
+nativeStringResourceTable_mscorrc_debug
+_ZN25NativeExceptionHolderBase4PushEv
+_ZN25NativeExceptionHolderBaseC2Ev
+_ZN25NativeExceptionHolderBaseD2Ev
+_ZN28CatchHardwareExceptionHolderC1Ev
+_ZN28CatchHardwareExceptionHolderD1Ev \ No newline at end of file
diff --git a/src/dlls/mscordac/update.pl b/src/dlls/mscordac/update.pl
new file mode 100644
index 0000000000..353e1a177d
--- /dev/null
+++ b/src/dlls/mscordac/update.pl
@@ -0,0 +1,34 @@
+#!perl -w
+
+#
+# Renames the DAC to a long name form that windbg looks for
+#
+
+my $sSrcFile = shift or &Usage();
+my $sDestName = shift or &Usage();
+my $sHostMach = shift or &Usage();
+my $sTargMach = shift or &Usage();
+my $sVersion = shift or &Usage();
+my $sDestDir = shift or &Usage();
+
+my $sName = "$sDestDir\\${sDestName}_${sHostMach}_${sTargMach}_" .
+ "$sVersion";
+
+if ($ENV{'_BuildType'} eq "dbg" ||
+ $ENV{'_BuildType'} eq "chk") {
+ $sName .= "." . $ENV{'_BuildType'};
+}
+
+$sName .= ".dll";
+
+if (system("copy $sSrcFile $sName") / 256) {
+ die("$0: Unable to copy $sSrcFile to $sName\n");
+}
+
+exit 0;
+
+sub Usage
+{
+ die("usage: $0 <srcfile> <destname> <hostmach> <targmach> " .
+ "<version> <destdir> <applycommand>\n");
+}
diff --git a/src/dlls/mscordbi/.gitmirror b/src/dlls/mscordbi/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/mscordbi/.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/mscordbi/CMakeLists.txt b/src/dlls/mscordbi/CMakeLists.txt
new file mode 100644
index 0000000000..5f5ad5139e
--- /dev/null
+++ b/src/dlls/mscordbi/CMakeLists.txt
@@ -0,0 +1,114 @@
+
+# Set the RPATH of mscordbi so that it can find dependencies without needing to set LD_LIBRARY_PATH
+# For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling.
+if(CORECLR_SET_RPATH)
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+ if(CLR_CMAKE_PLATFORM_DARWIN)
+ set(CMAKE_INSTALL_RPATH "@loader_path")
+ else()
+ set(CMAKE_INSTALL_RPATH "\$ORIGIN")
+ endif(CLR_CMAKE_PLATFORM_DARWIN)
+endif(CORECLR_SET_RPATH)
+
+set(MSCORDBI_SOURCES
+ mscordbi.cpp
+)
+
+if(WIN32)
+ add_precompiled_header(stdafx.h stdafx.cpp MSCORDBI_SOURCES)
+
+ add_definitions(-DFX_VER_INTERNALNAME_STR=mscordbi.dll)
+
+ list(APPEND MSCORDBI_SOURCES
+ Native.rc
+ )
+
+ set(DEF_SOURCES
+ mscordbi.src
+ )
+
+ convert_to_absolute_path(DEF_SOURCES ${DEF_SOURCES})
+
+ preprocess_def_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
+
+ list(APPEND MSCORDBI_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.def)
+else(WIN32)
+ set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordbi_unixexports.src)
+ set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.exports)
+ generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
+endif(WIN32)
+
+if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
+ # This option is necessary to ensure that the overloaded new/delete operators 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")
+
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
+
+if(CLR_CMAKE_PLATFORM_DARWIN)
+ # Add linker exports file option
+ set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_DARWIN)
+
+add_library_clr(mscordbi SHARED ${MSCORDBI_SOURCES})
+
+if(CLR_CMAKE_PLATFORM_UNIX)
+ add_custom_target(mscordbi_exports DEPENDS ${EXPORTS_FILE})
+ add_dependencies(mscordbi mscordbi_exports)
+
+ set_property(TARGET mscordbi APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
+ set_property(TARGET mscordbi APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+set(COREDBI_LIBRARIES
+ debug-pal
+ cordbdi
+ utilcodestaticnohost
+ ildbsymlib
+ mdcompiler-dbi
+ mdruntime-dbi
+ mdruntimerw-dbi
+ mddatasource_dbi
+ corguids
+)
+
+if(WIN32)
+ list(APPEND COREDBI_LIBRARIES
+ ipcmanager-staticcrt
+ mdhotdata-staticcrt
+ mdwinmd_dbi
+ kernel32.lib
+ advapi32.lib
+ ole32.lib
+ oleaut32.lib
+ uuid.lib
+ user32.lib
+ version.lib
+ ${STATIC_MT_CRT_LIB}
+ ${STATIC_MT_VCRT_LIB}
+ )
+
+ target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
+
+elseif(CLR_CMAKE_PLATFORM_UNIX)
+
+ list(APPEND COREDBI_LIBRARIES
+ mdhotdata_full
+ palrt
+ # share the PAL in the dac module
+ mscordaccore
+ )
+
+ add_dependencies(mscordbi mscordaccore)
+
+ # COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
+ # if they are defined after they are used. Having all libs twice makes sure that ld will actually
+ # find all symbols.
+ target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})
+
+endif(WIN32)
+
+# add the install targets
+install_clr(mscordbi) \ No newline at end of file
diff --git a/src/dlls/mscordbi/DIRS.proj b/src/dlls/mscordbi/DIRS.proj
new file mode 100644
index 0000000000..fb7248524d
--- /dev/null
+++ b/src/dlls/mscordbi/DIRS.proj
@@ -0,0 +1,23 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <!--Import the settings-->
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildInPhase1>true</BuildInPhase1>
+ <BuildInPhaseDefault>false</BuildInPhaseDefault>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ </PropertyGroup>
+
+ <!--The following projects will build during PHASE 1-->
+ <ItemGroup Condition="'$(BuildExePhase)' == '1'">
+ <ProjectFile Condition="'$(FeatureDbiDebugging)' == 'true'" Include="hostlocal\mscordbi.nativeproj" />
+ <ProjectFile Condition="'$(FeatureDbiOopDebugging_HostWindowsx86)' == 'true'" Include="hostwinx86\mscordbi.nativeproj" />
+ <ProjectFile Condition="'$(FeatureDbiOopDebugging_HostWindowsamd64)' == 'true'" Include="HostWinAMD64\mscordbi.nativeproj" />
+ <ProjectFile Condition="'$(FeatureDbiOopDebugging_HostOneCorex86)' == 'true'" Include="HostOneCorex86\mscordbi.nativeproj" />
+ <ProjectFile Condition="'$(FeatureDbiOopDebugging_HostOneCoreamd64)' == 'true'" Include="HostOneCoreAMD64\mscordbi.nativeproj" />
+ </ItemGroup>
+
+ <!--Import the targets-->
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
+</Project>
diff --git a/src/dlls/mscordbi/Native.rc b/src/dlls/mscordbi/Native.rc
new file mode 100644
index 0000000000..529ae06f6b
--- /dev/null
+++ b/src/dlls/mscordbi/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 Debugging Services\0"
+
+#include <fxver.h>
+#include <fxver.rc>
diff --git a/src/dlls/mscordbi/mscordbi.cpp b/src/dlls/mscordbi/mscordbi.cpp
new file mode 100644
index 0000000000..4ef92c7ee8
--- /dev/null
+++ b/src/dlls/mscordbi/mscordbi.cpp
@@ -0,0 +1,29 @@
+// 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.
+//*****************************************************************************
+// MSCorDBI.cpp
+//
+// COM+ Debugging Services -- Debugger Interface DLL
+//
+// Dll* routines for entry points, and support for COM framework.
+//
+//*****************************************************************************
+#include "stdafx.h"
+
+extern BOOL STDMETHODCALLTYPE DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
+ LPVOID lpReserved);
+
+//*****************************************************************************
+// The main dll entry point for this module. This routine is called by the
+// OS when the dll gets loaded. Control is simply deferred to the main code.
+//*****************************************************************************
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+ //<TODO> Shoud we call DisableThreadLibraryCalls? Or does this code
+ // need native thread attatch/detatch notifications? </TODO>
+
+ // Defer to the main debugging code.
+ return DbgDllMain(hInstance, dwReason, lpReserved);
+}
diff --git a/src/dlls/mscordbi/mscordbi.settings.targets b/src/dlls/mscordbi/mscordbi.settings.targets
new file mode 100644
index 0000000000..c9fa97cbef
--- /dev/null
+++ b/src/dlls/mscordbi/mscordbi.settings.targets
@@ -0,0 +1,144 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <Import Project="..\..\debug\XPlatCommon.props" />
+
+ <PropertyGroup>
+ <FileToMarkForSigning>$(BinariesDirectory)\$(OutputName).dll</FileToMarkForSigning>
+ <UserIncludes>$(UserIncludes);
+ ..</UserIncludes>
+ <ClAdditionalOptions>$(ClAdditionalOptions) -DUNICODE -D_UNICODE</ClAdditionalOptions>
+ <PCHHeader>stdafx.h</PCHHeader>
+ <EnableCxxPCHHeaders>true</EnableCxxPCHHeaders>
+ <!--PCH: Both precompiled header and cpp are on the same ..\ path this is likely to be wrong.-->
+ <PCHCompile>..\stdafx.cpp</PCHCompile>
+
+ <!--
+ # We explicitly must not link with mscoree because mscordbi needs to
+ # be able to run on a machine without the runtime installed.
+ # Also, for this reason explicitly use the static CRT
+ -->
+ <LinkNoLibraries>true</LinkNoLibraries>
+ <UseMsvcrt>false</UseMsvcrt>
+ <DoNotAddCrtLibPath>true</DoNotAddCrtLibPath>
+ <LinkUseDefaultLib>false</LinkUseDefaultLib>
+ <NoLinkGdi32>true</NoLinkGdi32>
+ <!-- <LinkUseCMT>true</LinkUseCMT> -->
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <PogoOptimized>true</PogoOptimized>
+
+ <DllEntryPoint>_DllMainCRTStartup</DllEntryPoint>
+ <DllDef>$(IntermediateOutputDirectory)\mscordbi.def</DllDef>
+
+ </PropertyGroup>
+
+
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCore' or '$(HostMachineOS)' == 'OneCoreWin7Compat'">
+ <TargetLib Include="$(CoreSystemCrt)" />
+ <TargetLib Include="$(SdkLibPath)\uuid.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCoreWin7Compat'">
+ <TargetLib Include="$(SdkLibPath)\bcrypt.lib" />
+ <TargetLib Include="$(SdkLibPath)\crypt32.lib" />
+ <TargetLib Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Include="$(SdkLibPath)\mincore_fw.lib" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(HostMachineOS)' == 'OneCore'">
+ <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>
+
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\uuid.lib" />
+ <LinkPreCrtLibs Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\ntdll.lib" />
+ <LinkPreCrtLibs Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\kernel32.lib" />
+ <LinkPreCrtLibs Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\user32.lib" />
+ <LinkPreCrtLibs Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\advapi32.lib" />
+ <LinkPreCrtLibs Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\wtsapi32.lib" />
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\ole32.lib" />
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\version.lib" />
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\mscoree.lib" />
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(SdkLibPath)\shlwapi.lib" />
+ <TargetLib Condition="'$(HostMachineOS)'=='windows'" Include="$(CrtLibPath)\libcmt$(BuildSuffix).lib" />
+
+
+
+ <LinkPreCrtLibs Include="$(Dbilib)">
+ <ProjectReference>$(DbiProject)</ProjectReference>
+ </LinkPreCrtLibs>
+ <LinkPreCrtLibs Include="$(ClrLibPath)\utilcodestaticnohost$(XPlatHostLibSuffix).lib" >
+ <!-- Another project with a bunch of pre-existing references so it doesn't follow the normal path convention -->
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'">$(ClrSrcDirectory)utilcode\staticnohost\staticnohost.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'">$(ClrSrcDirectory)utilcode\staticnohostx86\staticnohost.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'">$(ClrSrcDirectory)utilcode\staticnohostamd64\staticnohost.nativeproj</ProjectReference>
+ </LinkPreCrtLibs>
+ <TargetLib Include="$(ClrLibPath)\ipcmanager-staticcrt$(XPlatHostLibSuffix).lib" >
+ <ProjectReference>$(ClrSrcDirectory)ipcman\ipcman-staticcrt\$(XPlatHostLibBuildDir)\ipcman-staticcrt.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\ildbsymlib$(XPlatHostLibSuffix).lib" >
+ <ProjectReference>$(ClrSrcDirectory)debug\ildbsymlib\$(XPlatHostLibBuildDir)\ildbsymlib.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDCompiler-dbi$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\compiler\dbi\$(XPlatHostLibBuildDir)\mdcompiler-dbi.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDWinMD_dbi$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\winmd\dbi\$(XPlatHostLibBuildDir)\MDWinMD-dbi.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDRuntime-dbi$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\runtime\dbi\$(XPlatHostLibBuildDir)\mdruntime-dbi.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDRuntimeRW-dbi$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\enc\dbi\$(XPlatHostLibBuildDir)\mdruntimerw-dbi.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDHotData-StaticCrt$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\hotdata\full-staticcrt\$(XPlatHostLibBuildDir)\mdhotdata-staticcrt.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\MDDataSource_dbi$(XPlatHostLibSuffix).lib">
+ <ProjectReference>$(ClrSrcDirectory)md\DataSource\dbi\$(XPlatHostLibBuildDir)\DataSource-dbi.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\CorGUIDS$(XPlatHostLibSuffix).lib">
+ <!-- This project isn't factored like the others above... there are many projects pointing to the current path of corguids -->
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'">$(ClrSrcDirectory)inc\corguids.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'">$(ClrSrcDirectory)incx86\corguids.nativeproj</ProjectReference>
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'">$(ClrSrcDirectory)incamd64\corguids.nativeproj</ProjectReference>
+ </TargetLib>
+
+ </ItemGroup>
+
+ <ItemGroup>
+
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostLocal'" Include="$(ClrSrcDirectory)inc\corguids.nativeproj" />
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinx86'" Include="$(ClrSrcDirectory)incx86\corguids.nativeproj" />
+ <ProjectReference Condition="'$(XPlatHostLibBuildDir)'=='HostWinAMD64'" Include="$(ClrSrcDirectory)incamd64\corguids.nativeproj" />
+
+ </ItemGroup>
+
+ <ItemGroup>
+ <CppPreprocess Include="..\mscordbi.src">
+ <Defines>@(CommonPreprocessDefines);$(CDefines);$(TargetDefines)</Defines>
+ <FinalOutput>$(IntermediateOutputDirectory)\mscordbi.def</FinalOutput>
+ <AdditionalOptions>/TC</AdditionalOptions>
+ </CppPreprocess>
+ </ItemGroup>
+ <ItemGroup>
+ <ImportLib Include="$(ClrLibPath)\ipcmanager-staticcrt$(XPlatHostLibSuffix).lib" />
+ <ImportLib Include="$(ClrLibPath)\ildbsymlib$(XPlatHostLibSuffix).lib" />
+ <ImportLib Include="$(Dbilib)"/>
+ <ImportLib Include="$(ClrLibPath)\MDCompiler-dbi$(XPlatHostLibSuffix).lib" />
+ <ImportLib Include="$(ClrLibPath)\MDRuntime-dbi$(XPlatHostLibSuffix).lib" />
+ <ImportLib Include="$(ClrLibPath)\MDRuntimeRW-dbi$(XPlatHostLibSuffix).lib" />
+ <ImportLib Include="$(ClrLibPath)\MDHotData-StaticCrt$(XPlatHostLibSuffix).lib" />
+ </ItemGroup>
+ <ItemGroup>
+ <RCResourceFile Include="..\Native.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <CppCompile Include="..\mscordbi.cpp" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+</Project>
diff --git a/src/dlls/mscordbi/mscordbi.src b/src/dlls/mscordbi/mscordbi.src
new file mode 100644
index 0000000000..0baa49537e
--- /dev/null
+++ b/src/dlls/mscordbi/mscordbi.src
@@ -0,0 +1,29 @@
+; 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.
+
+LIBRARY mscordbi
+
+EXPORTS
+ // COM-instantiation - for CorPublish
+ DllGetClassObjectInternal private
+
+ // In-proc (Whidbey-style) creation path from the shim - CDIFV and it's replacement
+ CreateCordbObject private
+
+ // Out-of-proc creation path from the shim - ICLRDebugging
+ OpenVirtualProcessImpl
+
+ // DEPRECATED - use OpenVirtualProcessImpl
+ OpenVirtualProcess private
+ OpenVirtualProcess2
+
+#ifdef FEATURE_CORECLR
+ CoreCLRCreateCordbObject private
+#endif // FEATURE_CORECLR
+
+#if defined(FEATURE_DBGIPC_TRANSPORT_DI)
+ DllGetClassObject private
+#endif // FEATURE_DBGIPC_TRANSPORT_DI
+
+
diff --git a/src/dlls/mscordbi/mscordbi.vrg b/src/dlls/mscordbi/mscordbi.vrg
new file mode 100644
index 0000000000..2c7289633b
--- /dev/null
+++ b/src/dlls/mscordbi/mscordbi.vrg
@@ -0,0 +1,78 @@
+VSREG 7
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorDebug.1]
+@="Microsoft Common Language Runtime Debugger"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorDebug.1\CLSID]
+@="{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}"
+
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorDebug]
+@="Microsoft Common Language Runtime Debugger"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorDebug\CurVer]
+@="ComPlusDebug.CorDebug.1"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorDebug\CLSID]
+@="{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}"
+
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}]
+@="Microsoft Common Language Runtime Debugger"
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}\ProgID]
+@="ComPlusDebug.CorDebug.1"
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}\VersionIndependentProgID]
+@="ComPlusDebug.CorDebug"
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}\NotInsertable]
+
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}\InprocServer32]
+@="[SystemFolder.3643236F_FC70_11D3_A536_0090278A1BB8]mscoree.dll"
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}\Server]
+@="mscordbi.dll"
+
+
+[HKEY_CLASSES_ROOT\CLSID\{6FEF44D0-39E7-4C77-BE8E-C9F8CF988630}\InprocServer32]
+"ThreadingModel"="Both"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorpubPublish.1]
+@="Microsoft Common Language Runtime Debugger Publisher"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorpubPublish.1\CLSID]
+@="{047A9A40-657E-11D3-8D5B-00104B35E7EF}"
+
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorpubPublish]
+@="Microsoft Common Language Runtime Debugger Publisher"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorpubPublish\CurVer]
+@="ComPlusDebug.CorpubPublish.1"
+
+[HKEY_CLASSES_ROOT\ComPlusDebug.CorpubPublish\CLSID]
+@="{047A9A40-657E-11D3-8D5B-00104B35E7EF}"
+
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}]
+@="Microsoft Common Language Runtime Debugger Publisher"
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}\ProgID]
+@="ComPlusDebug.CorpubPublish.1"
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}\VersionIndependentProgID]
+@="ComPlusDebug.CorpubPublish"
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}\NotInsertable]
+
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}\InprocServer32]
+@="[SystemFolder.3643236F_FC70_11D3_A536_0090278A1BB8]mscoree.dll"
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}\Server]
+@="mscordbi.dll"
+
+[HKEY_CLASSES_ROOT\CLSID\{047A9A40-657E-11D3-8D5B-00104B35E7EF}\InprocServer32]
+"ThreadingModel"="Both"
diff --git a/src/dlls/mscordbi/mscordbi_unixexports.src b/src/dlls/mscordbi/mscordbi_unixexports.src
new file mode 100644
index 0000000000..b4704aef63
--- /dev/null
+++ b/src/dlls/mscordbi/mscordbi_unixexports.src
@@ -0,0 +1,18 @@
+; 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.
+
+; COM-instantiation
+DllGetClassObjectInternal
+DllGetClassObject
+
+; CoreClr API
+CoreCLRCreateCordbObject
+
+; Out-of-proc creation path from the shim - ICLRDebugging
+OpenVirtualProcessImpl
+
+; PAL module registration
+DllMain
+PAL_RegisterModule
+PAL_UnregisterModule \ No newline at end of file
diff --git a/src/dlls/mscordbi/mscordbiv.vrg b/src/dlls/mscordbi/mscordbiv.vrg
new file mode 100644
index 0000000000..5cb038647a
--- /dev/null
+++ b/src/dlls/mscordbi/mscordbiv.vrg
@@ -0,0 +1,4 @@
+VSREG 7
+
+[HKEY_CLASSES_ROOT\CLSID\{047a9a40-657e-11d3-8d5b-00104b35e7ef}\InprocServer32\[RTM_ProductVersion]]
+"ImplementedInThisVersion"=""
diff --git a/src/dlls/mscordbi/stdafx.cpp b/src/dlls/mscordbi/stdafx.cpp
new file mode 100644
index 0000000000..a23e304c22
--- /dev/null
+++ b/src/dlls/mscordbi/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/mscordbi/stdafx.h b/src/dlls/mscordbi/stdafx.h
new file mode 100644
index 0000000000..feb0145d55
--- /dev/null
+++ b/src/dlls/mscordbi/stdafx.h
@@ -0,0 +1,15 @@
+// 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 "winwrap.h" // Windows wrappers.
+
+#endif // __STDAFX_H__
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
new file mode 100644
index 0000000000..f8d0752a84
--- /dev/null
+++ b/src/dlls/mscoree/dw20.msi
Binary files differ
diff --git a/src/dlls/mscoree/dw20_amd64.msi b/src/dlls/mscoree/dw20_amd64.msi
new file mode 100644
index 0000000000..53233acc1e
--- /dev/null
+++ b/src/dlls/mscoree/dw20_amd64.msi
Binary files differ
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;
+}
diff --git a/src/dlls/mscorpe/.gitmirrorall b/src/dlls/mscorpe/.gitmirrorall
new file mode 100644
index 0000000000..9ee5c57b99
--- /dev/null
+++ b/src/dlls/mscorpe/.gitmirrorall
@@ -0,0 +1 @@
+This folder will be mirrored by the Git-TFS Mirror recursively. \ No newline at end of file
diff --git a/src/dlls/mscorpe/CMakeLists.txt b/src/dlls/mscorpe/CMakeLists.txt
new file mode 100644
index 0000000000..e8f22f2e9b
--- /dev/null
+++ b/src/dlls/mscorpe/CMakeLists.txt
@@ -0,0 +1,23 @@
+project(mscorpe)
+
+add_definitions(-DFEATURE_CORECLR)
+
+set(MSCORPE_SOURCES
+ iceefilegen.cpp
+ ceefilegenwriter.cpp
+ pewriter.cpp
+ ceefilegenwritertokens.cpp
+ utilcodeinit.cpp
+)
+
+if(WIN32)
+ list(APPEND MSCORPE_SOURCES
+ Native.rc
+ )
+else()
+ add_compile_options(-Wno-delete-non-virtual-dtor)
+endif(WIN32)
+
+add_library_clr(mscorpe STATIC
+ ${MSCORPE_SOURCES}
+)
diff --git a/src/dlls/mscorpe/Native.rc b/src/dlls/mscorpe/Native.rc
new file mode 100644
index 0000000000..e652bf3f1d
--- /dev/null
+++ b/src/dlls/mscorpe/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 PE File Generator\0"
+
+#include <fxver.h>
+#include <fxver.rc>
diff --git a/src/dlls/mscorpe/ceefilegenwriter.cpp b/src/dlls/mscorpe/ceefilegenwriter.cpp
new file mode 100644
index 0000000000..cfd1ebb644
--- /dev/null
+++ b/src/dlls/mscorpe/ceefilegenwriter.cpp
@@ -0,0 +1,2007 @@
+// 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.
+// Derived class from CCeeGen which handles writing out
+// the exe. All references to PEWriter pulled out of CCeeGen,
+// and moved here
+//
+//
+
+#include "stdafx.h"
+
+#include <string.h>
+#include <limits.h>
+
+#include "corerror.h"
+#include "stubs.h"
+#include <posterror.h>
+#include <shlwapi.h>
+
+// Globals.
+HINSTANCE g_hThisInst; // This library.
+
+
+#ifdef EMIT_FIXUPS
+
+// Emitted PEFIXUP structure looks like this
+struct PEFIXUP
+{
+ WORD wType;
+ WORD wSpare;
+ DWORD rva;
+ DWORD rvaTarget;
+};
+
+// Following structure is used to store the reloc information which
+// will be used at UpdateFixups time to get the final data from the section
+// bytes to update the fixup information.
+//
+struct DBG_FIXUP
+{
+ WORD wType;
+ WORD wSpare;
+
+ union
+ {
+ DWORD rva;
+ unsigned offset;
+ };
+
+ union
+ {
+ DWORD rvaTarget;
+ CeeSection * sectionSource;
+ };
+};
+
+enum
+{
+ IMAGE_REL_I386_DIR24NB = 0x0081, // 24-bit base relative
+ IMAGE_REL_I386_FILEPOS = 0x0082, // 32-bit file relative
+ // all other relocation types are
+ // in winnt.h, for some reason
+ // this one is missing
+ IMAGE_REL_I386_DIR30NB = 0x0083, // 30-bit base relative
+};
+
+#endif // EMIT_FIXUPS
+
+// Get the Symbol entry given the head and a 0-based index
+inline IMAGE_SYMBOL* GetSymbolEntry(IMAGE_SYMBOL* pHead, SIZE_T idx)
+{
+ return (IMAGE_SYMBOL*) (((BYTE*) pHead) + IMAGE_SIZEOF_SYMBOL * idx);
+}
+
+#ifdef EnC_SUPPORTED
+#define ENC_DELTA_HACK
+#endif
+
+#ifdef ENC_DELTA_HACK
+ BOOL g_EnCMode = FALSE;
+#endif
+
+//*****************************************************************************
+// To get a new instance, call CreateNewInstance() or CreateNewInstanceEx() instead of new
+//*****************************************************************************
+
+HRESULT CeeFileGenWriter::CreateNewInstance(CCeeGen *pCeeFileGenFrom,
+ CeeFileGenWriter* & pGenWriter,
+ DWORD createFlags)
+{
+ return CreateNewInstanceEx(pCeeFileGenFrom, pGenWriter, createFlags);
+}
+
+//
+// Seed file is used as the base file. The new file data will be "appended" to the seed file
+//
+
+HRESULT CeeFileGenWriter::CreateNewInstanceEx(CCeeGen *pCeeFileGenFrom,
+ CeeFileGenWriter* & pGenWriter,
+ DWORD createFlags,
+ LPCWSTR seedFileName)
+{
+ HRESULT hr = S_OK;
+ ULONG preallocatedOffset = 0;
+ NewHolder<PEWriter> pPEWriter(NULL);
+ NewHolder<CeeFileGenWriter> pPrivateGenWriter;
+ CeeSection *corHeaderSection = NULL;
+
+ pPrivateGenWriter = new (nothrow) CeeFileGenWriter;
+ if (pPrivateGenWriter == NULL)
+ IfFailGo(E_OUTOFMEMORY);
+
+ pPEWriter = new (nothrow) PEWriter;
+ if (pPEWriter == NULL)
+ IfFailGo(E_OUTOFMEMORY);
+
+ //workaround
+ //What's really the correct thing to be doing here?
+ //HRESULT hr = pPEWriter->Init(pCeeFileGenFrom ? pCeeFileGenFrom->getPESectionMan() : NULL);
+ hr = pPEWriter->Init(NULL, createFlags, seedFileName);
+ IfFailGo(hr);
+
+ //Create the general PEWriter.
+ pPrivateGenWriter->m_peSectionMan = pPEWriter;
+ hr = pPrivateGenWriter->Init(); // base class member to finish init
+ IfFailGo(hr);
+
+ if (!seedFileName) // Use base file's preferred base (if present)
+ {
+ if (pPEWriter->isPE32())
+ {
+ pPrivateGenWriter->setImageBase((DWORD) CEE_IMAGE_BASE_32); // use same default as linker
+ }
+ else
+ {
+ pPrivateGenWriter->setImageBase64((ULONGLONG) CEE_IMAGE_BASE_64); // use same default as linker
+ }
+ }
+
+ pPrivateGenWriter->setSubsystem(IMAGE_SUBSYSTEM_WINDOWS_CUI, CEE_IMAGE_SUBSYSTEM_MAJOR_VERSION, CEE_IMAGE_SUBSYSTEM_MINOR_VERSION);
+
+ if (pPEWriter->createCorMainStub())
+ {
+ hr = pPrivateGenWriter->allocateIAT(); // so the IAT goes out first
+ IfFailGo(hr);
+ }
+
+ hr = pPrivateGenWriter->allocateCorHeader(); // get COR header near front
+ IfFailGo(hr);
+
+#if 0 // Need to add this if we want to propagate the old COM+ header
+ if (seedFileName)
+ {
+ memcpy(m_corHeader, baseFileDecoder->ntHeaders32()->corHeader, sizeof(IMAGE_COR20_HEADER));
+ }
+#endif
+
+ //If we were passed a CCeeGen at the beginning, copy it's data now.
+ if (pCeeFileGenFrom) {
+ pCeeFileGenFrom->cloneInstance((CCeeGen*)pPrivateGenWriter);
+ }
+
+ hr = pPrivateGenWriter->getSectionCreate(".text0", sdExecute, &corHeaderSection);
+ IfFailGo(hr);
+ preallocatedOffset = corHeaderSection->dataLen();
+
+
+ // set il RVA to be after the preallocated sections
+ pPEWriter->setIlRva(preallocatedOffset);
+
+#ifdef EMIT_FIXUPS
+ if (createFlags & ICEE_CREATE_FILE_EMIT_FIXUPS)
+ {
+ pPrivateGenWriter->setEmitFixups();
+ }
+#endif
+
+ pPEWriter.SuppressRelease();
+ pPrivateGenWriter.SuppressRelease();
+ pGenWriter = pPrivateGenWriter;
+
+ErrExit:
+ return hr;
+} // HRESULT CeeFileGenWriter::CreateNewInstance()
+
+CeeFileGenWriter::CeeFileGenWriter() // ctor is protected
+{
+ m_outputFileName = NULL;
+ m_resourceFileName = NULL;
+ m_dllSwitch = false;
+ m_objSwitch = false;
+ m_libraryName = NULL;
+ m_libraryGuid = GUID_NULL;
+
+ m_entryPoint = 0;
+ m_comImageFlags = COMIMAGE_FLAGS_ILONLY; // ceegen PEs don't have native code
+ m_iatOffset = 0;
+ m_dllCount = 0;
+
+ m_dwMacroDefinitionSize = 0;
+ m_dwMacroDefinitionRVA = NULL;
+
+ m_dwManifestSize = 0;
+ m_dwManifestRVA = NULL;
+
+ m_dwStrongNameSize = 0;
+ m_dwStrongNameRVA = NULL;
+
+ m_dwVTableSize = 0;
+ m_dwVTableRVA = NULL;
+
+ m_iDataDlls = NULL;
+
+ m_linked = false;
+ m_fixed = false;
+
+#ifdef EMIT_FIXUPS
+
+ m_fEmitFixups = false;
+ m_fFixupsUpdated = false;
+ m_sectionFixups = NULL;
+ m_pDebugDir = NULL;
+
+#endif
+
+#ifdef ENC_DELTA_HACK
+ // for EnC we want the RVA to be right at the front of the IL stream
+ PathString szFileName;
+ DWORD len = WszGetEnvironmentVariable(W("COMP_ENC_EMIT"), szFileName);
+ if (len > 0)
+ g_EnCMode = TRUE;
+#endif
+
+} // CeeFileGenWriter::CeeFileGenWriter()
+
+//*****************************************************************************
+// Cleanup
+//*****************************************************************************
+HRESULT CeeFileGenWriter::Cleanup() // virtual
+{
+ ((PEWriter *)m_peSectionMan)->Cleanup(); // call derived cleanup
+ delete m_peSectionMan;
+ m_peSectionMan = NULL; // so base class won't delete
+
+ delete[] m_outputFileName;
+ delete[] m_resourceFileName;
+
+ if (m_iDataDlls) {
+ for (int i=0; i < m_dllCount; i++) {
+ if (m_iDataDlls[i].m_methodName)
+ delete[] m_iDataDlls[i].m_methodName;
+ }
+ delete[] m_iDataDlls;
+ }
+
+ return CCeeGen::Cleanup();
+} // HRESULT CeeFileGenWriter::Cleanup()
+
+HRESULT CeeFileGenWriter::EmitMacroDefinitions(void *pData, DWORD cData)
+{
+ // OBSOLETE
+ m_dwMacroDefinitionSize = 0;
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::EmitMacroDefinitions()
+
+HRESULT CeeFileGenWriter::link()
+{
+ HRESULT hr = checkForErrors();
+ if (! SUCCEEDED(hr))
+ return hr;
+
+#ifdef EMIT_FIXUPS
+
+ // The fixups describe each relocation. Each fixup contains the relocation's
+ // type, source RVA, and target RVA. Since the reloc target can be filled
+ // in after the relocation creation, the fixup target RVA discovery needs to
+ // be deferred.
+ // At this point all bytes should be filled in, ensuring that the final
+ // target information is available.
+ // UpdateFixups is called at this point to discover the final relocation target info.
+ //
+ hr = UpdateFixups();
+ if (! SUCCEEDED(hr))
+ return hr;
+
+#endif
+
+ // Don't set this if SetManifestEntry was not called - zapper sets the
+ // resource directory explicitly
+ if (m_dwManifestSize != 0)
+ {
+ m_corHeader->Resources.VirtualAddress = VAL32(m_dwManifestRVA);
+ m_corHeader->Resources.Size = VAL32(m_dwManifestSize);
+ }
+
+ if (m_dwStrongNameSize != 0)
+ {
+ m_corHeader->StrongNameSignature.VirtualAddress = VAL32(m_dwStrongNameRVA);
+ m_corHeader->StrongNameSignature.Size = VAL32(m_dwStrongNameSize);
+ }
+
+ if (m_dwVTableSize != 0)
+ {
+ m_corHeader->VTableFixups.VirtualAddress = VAL32(m_dwVTableRVA);
+ m_corHeader->VTableFixups.Size = VAL32(m_dwVTableSize);
+ }
+
+ unsigned characteristicsMask = IMAGE_FILE_EXECUTABLE_IMAGE;
+
+ if (getPEWriter().isPE32())
+ characteristicsMask |= IMAGE_FILE_32BIT_MACHINE;
+ if (!getPEWriter().isPE32())
+ characteristicsMask |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
+
+ getPEWriter().setCharacteristics(characteristicsMask);
+
+ m_corHeader->cb = VAL32(sizeof(IMAGE_COR20_HEADER));
+ m_corHeader->MajorRuntimeVersion = VAL16(COR_VERSION_MAJOR);
+ m_corHeader->MinorRuntimeVersion = VAL16(COR_VERSION_MINOR);
+ if (m_dllSwitch)
+ getPEWriter().setCharacteristics(IMAGE_FILE_DLL);
+ if (m_objSwitch)
+ getPEWriter().clearCharacteristics(IMAGE_FILE_DLL | IMAGE_FILE_EXECUTABLE_IMAGE);
+ m_corHeader->Flags = VAL32(m_comImageFlags);
+ IMAGE_COR20_HEADER_FIELD(*m_corHeader, EntryPointToken) = VAL32(m_entryPoint);
+ _ASSERTE(TypeFromToken(m_entryPoint) == mdtMethodDef || m_entryPoint == mdTokenNil ||
+ TypeFromToken(m_entryPoint) == mdtFile);
+ setDirectoryEntry(getCorHeaderSection(), IMAGE_DIRECTORY_ENTRY_COMHEADER, sizeof(IMAGE_COR20_HEADER), m_corHeaderOffset);
+
+ if ((m_comImageFlags & COMIMAGE_FLAGS_IL_LIBRARY) == 0
+ && !m_linked && !m_objSwitch)
+ {
+ hr = emitExeMain();
+ if (FAILED(hr))
+ return hr;
+#ifndef FEATURE_PAL
+ hr = emitResourceSection();
+ if (FAILED(hr))
+ return hr;
+#endif
+ }
+
+ m_linked = true;
+
+ IfFailRet(getPEWriter().link());
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::link()
+
+
+HRESULT CeeFileGenWriter::fixup()
+{
+ HRESULT hr;
+
+ m_fixed = true;
+
+ if (!m_linked)
+ IfFailRet(link());
+
+ CeeGenTokenMapper *pMapper = getTokenMapper();
+
+ // Apply token remaps if there are any.
+ if (! m_fTokenMapSupported && pMapper != NULL) {
+ IMetaDataImport *pImport;
+ hr = pMapper->GetMetaData(&pImport);
+ _ASSERTE(SUCCEEDED(hr));
+ hr = MapTokens(pMapper, pImport);
+ pImport->Release();
+
+ }
+
+ // remap the entry point if entry point token has been moved
+ if (pMapper != NULL && !m_objSwitch)
+ {
+ mdToken tk = m_entryPoint;
+ pMapper->HasTokenMoved(tk, tk);
+ IMAGE_COR20_HEADER_FIELD(*m_corHeader, EntryPointToken) = VAL32(tk);
+ }
+
+ IfFailRet(getPEWriter().fixup(pMapper));
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::fixup()
+
+HRESULT CeeFileGenWriter::generateImage(void **ppImage)
+{
+ HRESULT hr = S_OK;
+ LPCWSTR outputFileName = NULL;
+
+#ifndef FEATURE_PAL
+ HANDLE hThreadToken = NULL;
+ // Impersonation is only supported on Win2k and above.
+ if (!OpenThreadToken(GetCurrentThread(), TOKEN_READ | TOKEN_IMPERSONATE, TRUE, &hThreadToken))
+ {
+ if (GetLastError() != ERROR_NO_TOKEN)
+ {
+ _ASSERTE(!"Failed to get thread token!");
+ return HRESULT_FROM_GetLastError();
+ }
+ }
+
+ if (hThreadToken != NULL)
+ {
+ if (!RevertToSelf())
+ {
+ _ASSERTE(!"Failed to revert impersonation!");
+ CloseHandle(hThreadToken);
+ return HRESULT_FROM_GetLastError();
+ }
+ }
+#endif // !FEATURE_PAL
+
+#ifdef ENC_DELTA_HACK
+ // fixups break because we've set the base RVA to 0 for the delta stream
+ if (! g_EnCMode)
+#endif
+ if (!m_fixed)
+ IfFailGo(fixup());
+
+ outputFileName = m_outputFileName;
+
+ if (! outputFileName && ppImage == NULL) {
+ if (m_comImageFlags & COMIMAGE_FLAGS_IL_LIBRARY)
+ outputFileName = W("output.ill");
+ else if (m_dllSwitch)
+ outputFileName = W("output.dll");
+ else if (m_objSwitch)
+ outputFileName = W("output.exe");
+ else
+ outputFileName = W("output.obj");
+ }
+
+ // output file name and ppImage are mutually exclusive
+ _ASSERTE((NULL == outputFileName && ppImage != NULL) || (outputFileName != NULL && NULL == ppImage));
+
+ if (outputFileName != NULL)
+ IfFailGo(getPEWriter().write(outputFileName));
+ else
+ IfFailGo(getPEWriter().write(ppImage));
+
+ErrExit:
+#ifndef FEATURE_PAL
+ if (hThreadToken != NULL)
+ {
+ BOOL success = SetThreadToken(NULL, hThreadToken);
+ CloseHandle(hThreadToken);
+
+ if (!success)
+ {
+ _ASSERTE(!"Failed to reimpersonate!");
+ hr = HRESULT_FROM_GetLastError();
+ }
+ }
+#endif // !FEATURE_PAL
+ return hr;
+} // HRESULT CeeFileGenWriter::generateImage()
+
+HRESULT CeeFileGenWriter::setOutputFileName(__in LPWSTR fileName)
+{
+ if (m_outputFileName)
+ delete[] m_outputFileName;
+ int len = lstrlenW(fileName) + 1;
+ m_outputFileName = (LPWSTR)new (nothrow) WCHAR[len];
+ TESTANDRETURN(m_outputFileName!=NULL, E_OUTOFMEMORY);
+ wcscpy_s(m_outputFileName, len, fileName);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setOutputFileName()
+
+HRESULT CeeFileGenWriter::setResourceFileName(__in LPWSTR fileName)
+{
+ if (m_resourceFileName)
+ delete[] m_resourceFileName;
+ int len = lstrlenW(fileName) + 1;
+ m_resourceFileName = (LPWSTR)new (nothrow) WCHAR[len];
+ TESTANDRETURN(m_resourceFileName!=NULL, E_OUTOFMEMORY);
+ wcscpy_s(m_resourceFileName, len, fileName);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setResourceFileName()
+
+HRESULT CeeFileGenWriter::setLibraryName(__in LPWSTR libraryName)
+{
+ if (m_libraryName)
+ delete[] m_libraryName;
+ int len = lstrlenW(libraryName) + 1;
+ m_libraryName = (LPWSTR)new (nothrow) WCHAR[len];
+ TESTANDRETURN(m_libraryName != NULL, E_OUTOFMEMORY);
+ wcscpy_s(m_libraryName, len, libraryName);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setLibraryName()
+
+HRESULT CeeFileGenWriter::setLibraryGuid(__in LPWSTR libraryGuid)
+{
+ return IIDFromString(libraryGuid, &m_libraryGuid);
+} // HRESULT CeeFileGenWriter::setLibraryGuid()
+
+HRESULT CeeFileGenWriter::emitLibraryName(IMetaDataEmit *emitter)
+{
+ HRESULT hr;
+ IfFailRet(emitter->SetModuleProps(m_libraryName));
+
+ // Set the GUID as a custom attribute, if it is not NULL_GUID.
+ if (m_libraryGuid != GUID_NULL)
+ {
+ static COR_SIGNATURE _SIG[] = INTEROP_GUID_SIG;
+ mdTypeRef tr;
+ mdMemberRef mr;
+ WCHAR wzGuid[40];
+ BYTE rgCA[50];
+ IfFailRet(emitter->DefineTypeRefByName(mdTypeRefNil, INTEROP_GUID_TYPE_W, &tr));
+ IfFailRet(emitter->DefineMemberRef(tr, W(".ctor"), _SIG, sizeof(_SIG), &mr));
+ StringFromGUID2(m_libraryGuid, wzGuid, lengthof(wzGuid));
+ memset(rgCA, 0, sizeof(rgCA));
+ // Tag is 0x0001
+ rgCA[0] = 1;
+ // Length of GUID string is 36 characters.
+ rgCA[2] = 0x24;
+ // Convert 36 characters, skipping opening {, into 3rd byte of buffer.
+ WszWideCharToMultiByte(CP_ACP,0, wzGuid+1,36, reinterpret_cast<char*>(&rgCA[3]),36, 0,0);
+ hr = emitter->DefineCustomAttribute(1,mr,rgCA,41,0);
+ }
+ return (hr);
+} // HRESULT CeeFileGenWriter::emitLibraryName()
+
+HRESULT CeeFileGenWriter::setImageBase(size_t imageBase)
+{
+ _ASSERTE(getPEWriter().isPE32());
+ getPEWriter().setImageBase32((DWORD)imageBase);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setImageBase()
+
+HRESULT CeeFileGenWriter::setImageBase64(ULONGLONG imageBase)
+{
+ _ASSERTE(!getPEWriter().isPE32());
+ getPEWriter().setImageBase64(imageBase);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setImageBase64()
+
+HRESULT CeeFileGenWriter::setFileAlignment(ULONG fileAlignment)
+{
+ getPEWriter().setFileAlignment(fileAlignment);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setFileAlignment()
+
+HRESULT CeeFileGenWriter::setSubsystem(DWORD subsystem, DWORD major, DWORD minor)
+{
+ getPEWriter().setSubsystem(subsystem, major, minor);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setSubsystem()
+
+HRESULT CeeFileGenWriter::checkForErrors()
+{
+ if (TypeFromToken(m_entryPoint) == mdtMethodDef) {
+ if (m_dllSwitch) {
+ //current spec would need to check the binary sig of the entry point method
+ }
+ return S_OK;
+ }
+ return S_OK;
+} // HRESULT CeeFileGenWriter::checkForErrors()
+
+HRESULT CeeFileGenWriter::getMethodRVA(ULONG codeOffset, ULONG *codeRVA)
+{
+ _ASSERTE(codeRVA);
+#ifdef ENC_DELTA_HACK
+ // for EnC we want the RVA to be right be relative to the front of the delta IL stream rather
+ // than take into account the .text section and the cor header as we would for a real PE file
+ if (g_EnCMode)
+ *codeRVA = codeOffset;
+ else
+#endif
+ *codeRVA = getPEWriter().getIlRva() + codeOffset;
+ return S_OK;
+} // HRESULT CeeFileGenWriter::getMethodRVA()
+
+HRESULT CeeFileGenWriter::setDirectoryEntry(CeeSection &section, ULONG entry, ULONG size, ULONG offset)
+{
+ return getPEWriter().setDirectoryEntry((PEWriterSection*)(&section.getImpl()), entry, size, offset);
+} // HRESULT CeeFileGenWriter::setDirectoryEntry()
+
+HRESULT CeeFileGenWriter::getFileTimeStamp(DWORD *pTimeStamp)
+{
+ return getPEWriter().getFileTimeStamp(pTimeStamp);
+} // HRESULT CeeFileGenWriter::getFileTimeStamp()
+
+HRESULT CeeFileGenWriter::setAddrReloc(UCHAR *instrAddr, DWORD value)
+{
+ *(DWORD *)instrAddr = VAL32(value);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setAddrReloc()
+
+HRESULT CeeFileGenWriter::addAddrReloc(CeeSection &thisSection, UCHAR *instrAddr, DWORD offset, CeeSection *targetSection)
+{
+ if (!targetSection) {
+ thisSection.addBaseReloc(offset, srRelocHighLow);
+ } else {
+ thisSection.addSectReloc(offset, *targetSection, srRelocHighLow);
+ }
+ return S_OK;
+} // HRESULT CeeFileGenWriter::addAddrReloc()
+
+// create CorExeMain and import directory into .text and the .iat into .data
+//
+// The structure of the import directory information is as follows, but it is not contiguous in
+// section. All the r/o data goes into the .text section and the iat array (which the loader
+// updates with the imported addresses) goes into the .data section because WINCE needs it to be writable.
+//
+// struct IData {
+// // one for each DLL, terminating in NULL
+// IMAGE_IMPORT_DESCRIPTOR iid[];
+// // import lookup table: a set of entries for the methods of each DLL,
+// // terminating each set with NULL
+// IMAGE_THUNK_DATA32/64 ilt[];
+// // hint/name table: an set of entries for each method of each DLL wiht
+// // no terminating entry
+// struct {
+// WORD Hint;
+// // null terminated string
+// BYTE Name[];
+// } ibn; // Hint/name table
+// // import address table: a set of entries for the methods of each DLL,
+// // terminating each set with NULL
+// IMAGE_THUNK_DATA32/64 iat[];
+// // one for each DLL, null terminated strings
+// BYTE DllName[];
+// };
+//
+
+// IAT must be first in its section, so have code here to allocate it up front
+// prior to knowing other info such as if dll or not. This won't work if have > 1
+// function imported, but we'll burn that bridge when we get to it.
+HRESULT CeeFileGenWriter::allocateIAT()
+{
+ m_dllCount = 1;
+ m_iDataDlls = new (nothrow) IDataDllInfo[m_dllCount];
+ if (m_iDataDlls == NULL) {
+ return E_OUTOFMEMORY;
+ }
+ memset(m_iDataDlls, '\0', m_dllCount * sizeof(IDataDllInfo));
+ m_iDataDlls[0].m_name = "mscoree.dll";
+ m_iDataDlls[0].m_numMethods = 1;
+ m_iDataDlls[0].m_methodName = new (nothrow) const char*[m_iDataDlls[0].m_numMethods];
+ if (! m_iDataDlls[0].m_methodName) {
+ return E_OUTOFMEMORY;
+ }
+ m_iDataDlls[0].m_methodName[0] = NULL;
+
+ int iDataSizeIAT = 0;
+
+ for (int i=0; i < m_dllCount; i++) {
+ m_iDataDlls[i].m_iatOffset = iDataSizeIAT;
+ iDataSizeIAT += (m_iDataDlls[i].m_numMethods + 1)
+ * (getPEWriter().isPE32() ? sizeof(IMAGE_THUNK_DATA32)
+ : sizeof(IMAGE_THUNK_DATA64));
+ }
+
+ HRESULT hr = getSectionCreate(".text0", sdExecute, &m_iDataSectionIAT);
+ TESTANDRETURNHR(hr);
+ m_iDataOffsetIAT = m_iDataSectionIAT->dataLen();
+ _ASSERTE(m_iDataOffsetIAT == 0);
+ m_iDataIAT = m_iDataSectionIAT->getBlock(iDataSizeIAT);
+ if (! m_iDataIAT) {
+ return E_OUTOFMEMORY;
+ }
+ memset(m_iDataIAT, '\0', iDataSizeIAT);
+
+ // Don't set the IAT directory entry yet, since we may not actually end up doing
+ // an emitExeMain.
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::allocateIAT()
+
+HRESULT CeeFileGenWriter::emitExeMain()
+{
+ if (m_dllCount == 0)
+ return S_OK;
+
+ // Note: code later on in this method assumes that mscoree.dll is at
+ // index m_iDataDlls[0], with CorDllMain or CorExeMain at method[0]
+
+ _ASSERTE(getPEWriter().createCorMainStub());
+
+ if (m_dllSwitch) {
+ m_iDataDlls[0].m_methodName[0] = "_CorDllMain";
+ } else {
+ m_iDataDlls[0].m_methodName[0] = "_CorExeMain";
+ }
+
+ // IMAGE_IMPORT_DESCRIPTOR on PE/PE+ must be 4-byte or 8-byte aligned
+ int align = (getPEWriter().isPE32()) ? 4 : 8;
+ int curOffset = getTextSection().dataLen();
+
+ int diff = ((curOffset + align -1) & ~(align-1)) - curOffset;
+ if (diff)
+ {
+ char* pDiff = getTextSection().getBlock(diff);
+ if (NULL==pDiff) return E_OUTOFMEMORY;
+ memset(pDiff,0,diff);
+ }
+
+ int iDataSizeRO = (m_dllCount + 1) * sizeof(IMAGE_IMPORT_DESCRIPTOR);
+ CeeSection &iDataSectionRO = getTextSection();
+ int iDataOffsetRO = iDataSectionRO.dataLen();
+ int iDataSizeIAT = 0;
+ int i;
+ for (i=0; i < m_dllCount; i++) {
+ m_iDataDlls[i].m_iltOffset = iDataSizeRO + iDataSizeIAT;
+ iDataSizeIAT += (m_iDataDlls[i].m_numMethods + 1)
+ * (getPEWriter().isPE32() ? sizeof(IMAGE_THUNK_DATA32)
+ : sizeof(IMAGE_THUNK_DATA64));
+ }
+
+ iDataSizeRO += iDataSizeIAT;
+
+ for (i=0; i < m_dllCount; i++) {
+ int delta = (iDataSizeRO + iDataOffsetRO) % 16;
+ // make sure is on a 16-byte offset
+ if (delta != 0)
+ iDataSizeRO += (16 - delta);
+ _ASSERTE((iDataSizeRO + iDataOffsetRO) % 16 == 0);
+ m_iDataDlls[i].m_ibnOffset = iDataSizeRO;
+ for (int j=0; j < m_iDataDlls[i].m_numMethods; j++) {
+ int nameLen = (int)(strlen(m_iDataDlls[i].m_methodName[j]) + 1);
+ iDataSizeRO += sizeof(WORD) + nameLen + nameLen%2;
+ }
+ }
+ for (i=0; i < m_dllCount; i++) {
+ m_iDataDlls[i].m_nameOffset = iDataSizeRO;
+ iDataSizeRO += (int)(strlen(m_iDataDlls[i].m_name) + 2);
+ }
+
+ char *iDataRO = iDataSectionRO.getBlock(iDataSizeRO);
+
+ if (!iDataRO) return E_OUTOFMEMORY;
+
+ memset(iDataRO, '\0', iDataSizeRO);
+
+ setDirectoryEntry(iDataSectionRO, IMAGE_DIRECTORY_ENTRY_IMPORT, iDataSizeRO, iDataOffsetRO);
+
+ IMAGE_IMPORT_DESCRIPTOR *iid = (IMAGE_IMPORT_DESCRIPTOR *)iDataRO;
+ for (i=0; i < m_dllCount; i++) {
+
+ // fill in the import descriptors for each DLL
+ IMAGE_IMPORT_DESC_FIELD(iid[i], OriginalFirstThunk) = VAL32((ULONG)(m_iDataDlls[i].m_iltOffset + iDataOffsetRO));
+ iid[i].Name = VAL32(m_iDataDlls[i].m_nameOffset + iDataOffsetRO);
+ iid[i].FirstThunk = VAL32((ULONG)(m_iDataDlls[i].m_iatOffset + m_iDataOffsetIAT));
+
+ iDataSectionRO.addSectReloc(
+ (unsigned)(iDataOffsetRO + (char *)(&IMAGE_IMPORT_DESC_FIELD(iid[i], OriginalFirstThunk)) - iDataRO), iDataSectionRO, srRelocAbsolute);
+ iDataSectionRO.addSectReloc(
+ (unsigned)(iDataOffsetRO + (char *)(&iid[i].Name) - iDataRO), iDataSectionRO, srRelocAbsolute);
+ iDataSectionRO.addSectReloc(
+ (unsigned)(iDataOffsetRO + (char *)(&iid[i].FirstThunk) - iDataRO), *m_iDataSectionIAT, srRelocAbsolute);
+
+ if (getPEWriter().isPE32())
+ {
+ // now fill in the import lookup table for each DLL
+ IMAGE_THUNK_DATA32 *ilt = (IMAGE_THUNK_DATA32*) (iDataRO + m_iDataDlls[i].m_iltOffset);
+ IMAGE_THUNK_DATA32 *iat = (IMAGE_THUNK_DATA32*) (m_iDataIAT + m_iDataDlls[i].m_iatOffset);
+
+ int ibnOffset = m_iDataDlls[i].m_ibnOffset;
+ for (int j=0; j < m_iDataDlls[i].m_numMethods; j++)
+ {
+ ilt[j].u1.AddressOfData = VAL32((ULONG)(ibnOffset + iDataOffsetRO));
+ iat[j].u1.AddressOfData = VAL32((ULONG)(ibnOffset + iDataOffsetRO));
+
+ iDataSectionRO.addSectReloc( (unsigned)(iDataOffsetRO + (char *)(&ilt[j].u1.AddressOfData) - iDataRO),
+ iDataSectionRO, srRelocAbsolute);
+ m_iDataSectionIAT->addSectReloc( (unsigned)(m_iDataOffsetIAT + (char *)(&iat[j].u1.AddressOfData) - m_iDataIAT),
+ iDataSectionRO, srRelocAbsolute);
+ int nameLen = (int)(strlen(m_iDataDlls[i].m_methodName[j]) + 1);
+ memcpy(iDataRO + ibnOffset + offsetof(IMAGE_IMPORT_BY_NAME, Name),
+ m_iDataDlls[i].m_methodName[j], nameLen);
+ ibnOffset += sizeof(WORD) + nameLen + nameLen%2;
+ }
+ }
+ else
+ {
+ // now fill in the import lookup table for each DLL
+ IMAGE_THUNK_DATA64 *ilt = (IMAGE_THUNK_DATA64*) (iDataRO + m_iDataDlls[i].m_iltOffset);
+ IMAGE_THUNK_DATA64 *iat = (IMAGE_THUNK_DATA64*) (m_iDataIAT + m_iDataDlls[i].m_iatOffset);
+
+ int ibnOffset = m_iDataDlls[i].m_ibnOffset;
+ for (int j=0; j < m_iDataDlls[i].m_numMethods; j++)
+ {
+ ilt[j].u1.AddressOfData = VAL64((ULONG)(ibnOffset + iDataOffsetRO));
+ iat[j].u1.AddressOfData = VAL64((ULONG)(ibnOffset + iDataOffsetRO));
+
+ iDataSectionRO.addSectReloc( (unsigned)(iDataOffsetRO + (char *)(&ilt[j].u1.AddressOfData) - iDataRO),
+ iDataSectionRO, srRelocAbsolute);
+ m_iDataSectionIAT->addSectReloc( (unsigned)(m_iDataOffsetIAT + (char *)(&iat[j].u1.AddressOfData) - m_iDataIAT),
+ iDataSectionRO, srRelocAbsolute);
+ int nameLen = (int)(strlen(m_iDataDlls[i].m_methodName[j]) + 1);
+ memcpy(iDataRO + ibnOffset + offsetof(IMAGE_IMPORT_BY_NAME, Name),
+ m_iDataDlls[i].m_methodName[j], nameLen);
+ ibnOffset += sizeof(WORD) + nameLen + nameLen%2;
+ }
+ }
+
+ // now fill in the import lookup table for each DLL
+ strcpy_s(iDataRO + m_iDataDlls[i].m_nameOffset,
+ iDataSizeRO - m_iDataDlls[i].m_nameOffset,
+ m_iDataDlls[i].m_name);
+
+ } // end of for loop i < m_dllCount
+
+
+ if (getPEWriter().isI386())
+ {
+ // Put the entry point code into the PE file
+ unsigned entryPointOffset = getTextSection().dataLen();
+ int iatOffset = (int) (entryPointOffset + (m_dllSwitch ? CorDllMainX86IATOffset : CorExeMainX86IATOffset));
+ align = 4; // x86 fixups must be 4-byte aligned
+
+ // The IAT offset must be aligned because fixup is applied to it.
+ diff = ((iatOffset + align -1) & ~(align-1)) - iatOffset;
+ if (diff)
+ {
+ char* pDiff = getTextSection().getBlock(diff);
+ if(NULL==pDiff) return E_OUTOFMEMORY;
+ memset(pDiff,0,diff);
+ entryPointOffset += diff;
+ }
+ _ASSERTE((getTextSection().dataLen() + (m_dllSwitch ? CorDllMainX86IATOffset : CorExeMainX86IATOffset)) % align == 0);
+
+ getPEWriter().setEntryPointTextOffset(entryPointOffset);
+ if (m_dllSwitch)
+ {
+ UCHAR *dllMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(DllMainX86Template));
+ if(dllMainBuf==NULL) return E_OUTOFMEMORY;
+ memcpy(dllMainBuf, DllMainX86Template, sizeof(DllMainX86Template));
+ //mscoree.dll
+ setAddrReloc(dllMainBuf+CorDllMainX86IATOffset, m_iDataDlls[0].m_iatOffset + m_iDataOffsetIAT);
+ addAddrReloc(getTextSection(), dllMainBuf, entryPointOffset+CorDllMainX86IATOffset, m_iDataSectionIAT);
+ }
+ else
+ {
+ UCHAR *exeMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(ExeMainX86Template));
+ if(exeMainBuf==NULL) return E_OUTOFMEMORY;
+ memcpy(exeMainBuf, ExeMainX86Template, sizeof(ExeMainX86Template));
+ //mscoree.dll
+ setAddrReloc(exeMainBuf+CorExeMainX86IATOffset, m_iDataDlls[0].m_iatOffset + m_iDataOffsetIAT);
+ addAddrReloc(getTextSection(), exeMainBuf, entryPointOffset+CorExeMainX86IATOffset, m_iDataSectionIAT);
+ }
+ }
+ else if (getPEWriter().isAMD64())
+ {
+ // Put the entry point code into the PE file
+ unsigned entryPointOffset = getTextSection().dataLen();
+ int iatOffset = (int) (entryPointOffset + (m_dllSwitch ? CorDllMainAMD64IATOffset : CorExeMainAMD64IATOffset));
+ align = 16; // AMD64 fixups must be 8-byte aligned
+
+ // The IAT offset must be aligned because fixup is applied to it.
+ diff = ((iatOffset + align -1) & ~(align-1)) - iatOffset;
+ if (diff)
+ {
+ char* pDiff = getTextSection().getBlock(diff);
+ if(NULL==pDiff) return E_OUTOFMEMORY;
+ memset(pDiff,0,diff);
+ entryPointOffset += diff;
+ }
+ _ASSERTE((getTextSection().dataLen() + (m_dllSwitch ? CorDllMainAMD64IATOffset : CorExeMainAMD64IATOffset)) % align == 0);
+
+ getPEWriter().setEntryPointTextOffset(entryPointOffset);
+ if (m_dllSwitch)
+ {
+ UCHAR *dllMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(DllMainAMD64Template));
+ if(dllMainBuf==NULL) return E_OUTOFMEMORY;
+ memcpy(dllMainBuf, DllMainAMD64Template, sizeof(DllMainAMD64Template));
+ //mscoree.dll
+ setAddrReloc(dllMainBuf+CorDllMainAMD64IATOffset, m_iDataDlls[0].m_iatOffset + m_iDataOffsetIAT);
+ addAddrReloc(getTextSection(), dllMainBuf, entryPointOffset+CorDllMainAMD64IATOffset, m_iDataSectionIAT);
+ }
+ else
+ {
+ UCHAR *exeMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(ExeMainAMD64Template));
+ if(exeMainBuf==NULL) return E_OUTOFMEMORY;
+ memcpy(exeMainBuf, ExeMainAMD64Template, sizeof(ExeMainAMD64Template));
+ //mscoree.dll
+ setAddrReloc(exeMainBuf+CorExeMainAMD64IATOffset, m_iDataDlls[0].m_iatOffset + m_iDataOffsetIAT);
+ addAddrReloc(getTextSection(), exeMainBuf, entryPointOffset+CorExeMainAMD64IATOffset, m_iDataSectionIAT);
+ }
+ }
+ else if (getPEWriter().isIA64())
+ {
+ // Must have a PE+ PE64 file
+ //_ASSERTE(!getPEWriter().isPE32());
+
+ // Put the entry point code into the PE+ file
+ curOffset = getTextSection().dataLen();
+ align = 16; // instructions on ia64 must be 16-byte aligned
+
+ // The entry point address be aligned
+ diff = ((curOffset + align -1) & ~(align-1)) - curOffset;
+ if (diff)
+ {
+ char* pDiff = getTextSection().getBlock(diff);
+ if(NULL==pDiff) return E_OUTOFMEMORY;
+ memset(pDiff,0,diff);
+ }
+
+ unsigned entryPointOffset = getTextSection().dataLen();
+
+ if (m_dllSwitch)
+ {
+ UCHAR *dllMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(DllMainIA64Template));
+ if (dllMainBuf==NULL) return E_OUTOFMEMORY;
+ memcpy(dllMainBuf, DllMainIA64Template, sizeof(DllMainIA64Template));
+ }
+ else
+ {
+ UCHAR *exeMainBuf = (UCHAR*)getTextSection().getBlock(sizeof(ExeMainIA64Template));
+ if (exeMainBuf==NULL) return E_OUTOFMEMORY;
+ memcpy(exeMainBuf, ExeMainIA64Template, sizeof(ExeMainIA64Template));
+ }
+
+ // Put the entry point function pointer into the PE file
+ unsigned entryPlabelOffset = getTextSection().dataLen();
+ getPEWriter().setEntryPointTextOffset(entryPlabelOffset);
+
+ UCHAR * entryPtr = (UCHAR*)getTextSection().getBlock(sizeof(ULONGLONG));
+ UCHAR * gpPtr = (UCHAR*)getTextSection().getBlock(sizeof(ULONGLONG));
+
+ memset(entryPtr,0,sizeof(ULONGLONG));
+ memset(gpPtr,0,sizeof(ULONGLONG));
+
+ setAddrReloc(entryPtr, entryPointOffset);
+ addAddrReloc(getTextSection(), entryPtr, entryPlabelOffset, &getTextSection());
+
+ setAddrReloc(gpPtr, m_iDataDlls[0].m_iatOffset + m_iDataOffsetIAT);
+ addAddrReloc(getTextSection(), gpPtr, entryPlabelOffset+8, m_iDataSectionIAT);
+ }
+ else
+ {
+ _ASSERTE(!"Unknown target machine");
+ }
+
+ // Now set our IAT entry since we're using the IAT
+ setDirectoryEntry(*m_iDataSectionIAT, IMAGE_DIRECTORY_ENTRY_IAT, iDataSizeIAT, m_iDataOffsetIAT);
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::emitExeMain()
+
+
+HRESULT GetClrSystemDirectory(SString& pbuffer)
+{
+ HRESULT hr = S_OK;
+
+
+ PathString pPath;
+ DWORD dwPath;
+
+ _ASSERTE (g_hThisInst);
+
+ dwPath = WszGetModuleFileName(g_hThisInst, pPath);
+ if(dwPath == 0)
+ {
+ hr = HRESULT_FROM_GetLastErrorNA();
+ return (hr);
+ }
+
+ return CopySystemDirectory(pPath, pbuffer);
+}
+
+#ifndef FEATURE_PAL
+BOOL RunProcess(LPCWSTR tempResObj, LPCWSTR pszFilename, DWORD* pdwExitCode, PEWriter &pewriter)
+{
+ BOOL fSuccess = FALSE;
+
+ PROCESS_INFORMATION pi;
+
+ PathString wszSystemDir;
+ if (FAILED(GetClrSystemDirectory(wszSystemDir)))
+ return FALSE;
+
+ WCHAR* wzMachine;
+ if(pewriter.isIA64())
+ wzMachine = L"IA64";
+ else if(pewriter.isAMD64())
+ wzMachine = L"AMD64";
+ else if(pewriter.isARM())
+ wzMachine = L"ARM";
+ else
+ wzMachine = L"IX86";
+
+ // Res file, so convert it
+ StackSString ssCmdLine;
+
+ LPWSTR ext = PathFindExtension(pszFilename);
+ if(*ext == NULL)
+ {
+ ssCmdLine.Printf(L"%scvtres.exe /NOLOGO /READONLY /MACHINE:%s \"/OUT:%s\" \"%s.\"",
+ wszSystemDir.GetUnicode(),
+ wzMachine,
+ tempResObj,
+ pszFilename);
+ }
+ else
+ {
+ ssCmdLine.Printf(L"%scvtres.exe /NOLOGO /READONLY /MACHINE:%s \"/OUT:%s\" \"%s\"",
+ wszSystemDir.GetUnicode(),
+ wzMachine,
+ tempResObj,
+ pszFilename);
+ }
+
+ STARTUPINFOW start;
+ ZeroMemory(&start, sizeof(start));
+ start.cb = sizeof(start);
+ start.dwFlags = STARTF_USESHOWWINDOW;
+ start.wShowWindow = SW_HIDE;
+
+ fSuccess = WszCreateProcess(
+ NULL,
+ ssCmdLine.GetUnicode(),
+ NULL,
+ NULL,
+ true,
+ 0,
+ 0,
+ NULL,
+ &start,
+ &pi);
+
+ // If process runs, wait for it to finish
+ if (fSuccess) {
+ WaitForSingleObject(pi.hProcess, INFINITE);
+
+ GetExitCodeProcess(pi.hProcess, pdwExitCode);
+
+ CloseHandle(pi.hProcess);
+
+ CloseHandle(pi.hThread);
+ }
+ return fSuccess;
+} // BOOL RunProcess()
+
+// Ensure that pszFilename is an object file (not just a binary resource)
+// If we convert, then return obj filename in pszTempFilename
+HRESULT ConvertResource(const WCHAR * pszFilename, __in_ecount(cchTempFilename) WCHAR *pszTempFilename, size_t cchTempFilename, PEWriter &pewriter)
+{
+ HANDLE hFile = WszCreateFile(pszFilename, GENERIC_READ,
+ FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+// failure
+ if (!hFile || (hFile == INVALID_HANDLE_VALUE))
+ {
+ //dbprintf("Can't find resource files:%S\n", pszFilename);
+ return HRESULT_FROM_GetLastError();
+ }
+
+// Read first 4 bytes. If they're all 0, we have a win32 .res file which must be
+// converted. (So call CvtRes.exe). Else it's an obj file.
+
+ DWORD dwCount = -1;
+ DWORD dwData = -1;
+
+ BOOL fRet = ReadFile(hFile,
+ &dwData,
+ 4,
+ &dwCount,
+ NULL
+ );
+
+ CloseHandle(hFile);
+
+ if (!fRet) {
+ //dbprintf("Invalid resource file:%S\n", pszFilename);
+ return HRESULT_FROM_GetLastError();
+ }
+
+ if (dwData != 0)
+ {
+ return S_OK;
+ }
+
+ PathString tempResObj;
+ PathString tempResPath;
+
+ // Create the temp file where the temp path is at rather than where the application is at.
+ if (!WszGetTempPath( tempResPath))
+ {
+ return HRESULT_FROM_GetLastError();
+ }
+
+ if (!WszGetTempFileName(tempResPath, L"RES", 0, tempResObj))
+ {
+ //dbprintf("GetTempFileName failed\n");
+ return HRESULT_FROM_GetLastError();
+ }
+
+ DWORD dwExitCode;
+ fRet = RunProcess(tempResObj, pszFilename, &dwExitCode, pewriter);
+
+ if (!fRet)
+ { // Couldn't run cvtres.exe
+ return PostError(CEE_E_CVTRES_NOT_FOUND);
+ }
+ else if (dwExitCode != 0)
+ { // CvtRes.exe ran, but failed
+ return HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ }
+ else
+ { // Conversion succesful, so return filename.
+ wcscpy_s(pszTempFilename, cchTempFilename, tempResObj);
+ }
+
+ return S_OK;
+} // HRESULT ConvertResource()
+
+
+
+// This function reads a resource file and emits it into the generated PE file.
+// 1. We can only link resources in obj format. Must convert from .res to .obj
+// with CvtRes.exe.
+// 2. Must touch up all COFF relocs from .rsrc$01 (resource header) to .rsrc$02
+// (resource raw data)
+HRESULT CeeFileGenWriter::emitResourceSection()
+{
+ if (m_resourceFileName == NULL)
+ return S_OK;
+
+ // Make sure szResFileName is an obj, not just a .res; change name if we convert
+ WCHAR szTempFileName[MAX_PATH+1];
+ szTempFileName[0] = L'\0';
+ HRESULT hr = ConvertResource(m_resourceFileName, szTempFileName,
+ MAX_PATH+1, getPEWriter());
+ if (FAILED(hr)) return hr;
+
+ // Filename may change (if we convert .res to .obj), so have floating pointer
+ const WCHAR* szResFileName;
+ if (*szTempFileName)
+ szResFileName = szTempFileName;
+ else
+ szResFileName = m_resourceFileName;
+
+ _ASSERTE(szResFileName);
+
+ // read the resource file and spit it out in the .rsrc section
+
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+ HANDLE hMap = NULL;
+ IMAGE_FILE_HEADER *hMod = NULL;
+
+ hr = S_OK;
+
+ struct Param
+ {
+ HANDLE hFile;
+ HANDLE hMap;
+ IMAGE_FILE_HEADER *hMod;
+ const WCHAR* szResFileName;
+ CeeFileGenWriter *genWriter;
+ HRESULT hr;
+ } param;
+
+ param.hFile = hFile;
+ param.hMap = hMap;
+ param.hMod = hMod;
+ param.szResFileName = szResFileName;
+ param.genWriter = this;
+ param.hr = S_OK;
+
+ PAL_TRY(Param *, pParam, &param)
+ {
+ SIZE_T cbFileSize;
+ const BYTE *pbStartOfMappedMem;
+ IMAGE_SECTION_HEADER *rsrc[2] = { NULL, NULL };
+ S_SIZE_T cbTotalSizeOfRawData;
+ // create a mapped view of the .res file
+ pParam->hFile = WszCreateFile(pParam->szResFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (pParam->hFile == INVALID_HANDLE_VALUE)
+ {
+ //dbprintf("Resource file %S not found\n", szResFileName);
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ // Grab the file size for verification checks.
+ {
+ DWORD dwFileSizeHigh;
+ DWORD dwFileSize = SafeGetFileSize(pParam->hFile, &dwFileSizeHigh);
+ if (dwFileSize == (DWORD)(-1))
+ {
+ pParam->hr = HRESULT_FROM_GetLastError();
+ goto lDone;
+ }
+
+ // Since we intend to memory map this file, the size of the file can not need 64 bits to represent!
+ if (dwFileSizeHigh != 0)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ cbFileSize = static_cast<SIZE_T>(dwFileSize);
+ }
+
+ pParam->hMap = WszCreateFileMapping(pParam->hFile, 0, PAGE_READONLY, 0, 0, NULL);
+
+ if (pParam->hMap == NULL)
+ {
+ //dbprintf("Invalid .res file: %S\n", szResFileName);
+ pParam->hr = HRESULT_FROM_GetLastError();
+ goto lDone;
+ }
+
+ pbStartOfMappedMem = reinterpret_cast<const BYTE *>(MapViewOfFile(pParam->hMap, FILE_MAP_READ, 0, 0, 0));
+
+ // test failure conditions
+ if (pbStartOfMappedMem == NULL)
+ {
+ //dbprintf("Invalid .res file: %S:Can't get header\n", szResFileName);
+ pParam->hr = HRESULT_FROM_GetLastError();
+ goto lDone;
+ }
+
+ // Check that the file contains an IMAGE_FILE_HEADER structure.
+ if (IMAGE_SIZEOF_FILE_HEADER > cbFileSize)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ pParam->hMod = (IMAGE_FILE_HEADER*)pbStartOfMappedMem;
+
+ if (VAL16(pParam->hMod->SizeOfOptionalHeader) != 0)
+ {
+ //dbprintf("Invalid .res file: %S:Illegal optional header\n", szResFileName);
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND); // GetLastError() = 0 since API worked.
+ goto lDone;
+ }
+
+ // Scan all section headers and grab .rsrc$01 and .rsrc$02
+ {
+ // First section is directly after header
+ SIZE_T cSections = static_cast<SIZE_T>(VAL16(pParam->hMod->NumberOfSections));
+ SIZE_T cbStartOfSections = IMAGE_SIZEOF_FILE_HEADER;
+ S_SIZE_T cbEndOfSections(S_SIZE_T(cbStartOfSections) +
+ (S_SIZE_T(cSections) * S_SIZE_T(IMAGE_SIZEOF_SECTION_HEADER)));
+
+ // Check that all sections are within the bounds of the mapped file.
+ if (cbEndOfSections.IsOverflow() ||
+ cbEndOfSections.Value() > cbFileSize)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ {
+ IMAGE_SECTION_HEADER *pSection =
+ (IMAGE_SECTION_HEADER *)(pbStartOfMappedMem + cbStartOfSections);
+ IMAGE_SECTION_HEADER *pSectionEnd = pSection + cSections;
+
+ for (; pSection < pSectionEnd; pSection++)
+ {
+ if (strcmp(".rsrc$01", (char *)pSection->Name) == 0)
+ {
+ rsrc[0] = pSection;
+ }
+ else if (strcmp(".rsrc$02", (char *)pSection->Name) == 0)
+ {
+ rsrc[1] = pSection;
+ }
+ }
+ }
+ }
+
+ // If we don't have both resources, fail.
+ if (!rsrc[0] || !rsrc[1])
+ {
+ //dbprintf("Invalid .res file: %S: Missing sections .rsrc$01 or .rsrc$02\n", szResFileName);
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ // Verify the resource data starts and sizes
+ {
+ cbTotalSizeOfRawData = S_SIZE_T(0);
+
+ for (int i = 0; i < 2; i++)
+ {
+ S_SIZE_T cbStartOfResourceData(static_cast<SIZE_T>(VAL32(rsrc[i]->PointerToRawData)));
+ S_SIZE_T cbSizeOfResourceData(static_cast<SIZE_T>(VAL32(rsrc[i]->SizeOfRawData)));
+ S_SIZE_T cbEndOfResourceData(cbStartOfResourceData + cbSizeOfResourceData);
+
+ if (cbEndOfResourceData.IsOverflow() ||
+ cbEndOfResourceData.Value() > cbFileSize)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ cbTotalSizeOfRawData += cbSizeOfResourceData;
+ }
+
+ // Check that the total raw data doesn't overflow.
+ if (cbTotalSizeOfRawData.IsOverflow() ||
+ cbTotalSizeOfRawData.Value() > cbFileSize)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+ }
+
+ PESection *rsrcSection;
+ pParam->hr = pParam->genWriter->getPEWriter().getSectionCreate(".rsrc", sdReadOnly, &rsrcSection);
+ if (FAILED(pParam->hr)) goto lDone;
+
+ rsrcSection->directoryEntry(IMAGE_DIRECTORY_ENTRY_RESOURCE);
+ char *data = rsrcSection->getBlock(static_cast<unsigned>(cbTotalSizeOfRawData.Value()), 8);
+ if(data == NULL)
+ {
+ pParam->hr = E_OUTOFMEMORY;
+ goto lDone;
+ }
+
+ // Copy resource header
+ memcpy(data, (char *)pParam->hMod + VAL32(rsrc[0]->PointerToRawData), VAL32(rsrc[0]->SizeOfRawData));
+
+ // Map all the relocs in .rsrc$01 using the reloc and symbol tables in the COFF object.,
+ SIZE_T cReloc = 0; // Total number of relocs
+ IMAGE_RELOCATION *pReloc = NULL; // Reloc table start
+
+ SIZE_T cSymbol = 0; // Total number of symbols
+ IMAGE_SYMBOL *pSymbolTable = NULL; // Symbol table start
+
+ {
+ // Check that the relocations and symbols lie within the resource
+ cReloc = VAL16(rsrc[0]->NumberOfRelocations);
+ SIZE_T cbStartOfRelocations = static_cast<SIZE_T>(VAL32(rsrc[0]->PointerToRelocations));
+ S_SIZE_T cbEndOfRelocations(S_SIZE_T(cbStartOfRelocations) +
+ (S_SIZE_T(cReloc) * S_SIZE_T(sizeof(IMAGE_RELOCATION))));
+
+
+ // Verify the number of symbols fit into the resource.
+ cSymbol = static_cast<SIZE_T>(VAL32(pParam->hMod->NumberOfSymbols));
+ SIZE_T cbStartOfSymbolTable = static_cast<SIZE_T>(VAL32(pParam->hMod->PointerToSymbolTable));
+ S_SIZE_T cbEndOfSymbolTable(S_SIZE_T(cbStartOfSymbolTable) +
+ (S_SIZE_T(cSymbol) * S_SIZE_T(IMAGE_SIZEOF_SYMBOL)));
+
+ if (cbEndOfRelocations.IsOverflow() ||
+ cbEndOfRelocations.Value() > cbFileSize ||
+ cbEndOfSymbolTable.IsOverflow() ||
+ cbEndOfSymbolTable.Value() > cbFileSize)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ pReloc = (IMAGE_RELOCATION *)(pbStartOfMappedMem + cbStartOfRelocations);
+ pSymbolTable = (IMAGE_SYMBOL *)(pbStartOfMappedMem + cbStartOfSymbolTable);
+ }
+
+ _ASSERTE(pReloc != NULL && pSymbolTable != NULL);
+
+ for(SIZE_T iReloc = 0; iReloc < cReloc; iReloc++, pReloc++)
+ {
+ // Ensure this is a valid reloc
+ {
+ S_SIZE_T cbRelocEnd = S_SIZE_T(VAL32(pReloc->VirtualAddress)) + S_SIZE_T(sizeof(DWORD));
+ if (cbRelocEnd.IsOverflow() ||
+ cbRelocEnd.Value() > static_cast<SIZE_T>(VAL32(rsrc[0]->SizeOfRawData)))
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+ }
+
+ // index into symbol table, provides address into $02
+ DWORD iSymbol = VAL32(pReloc->SymbolTableIndex);
+
+ // Make sure the index is in range
+ if (iSymbol >= cSymbol)
+ {
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ IMAGE_SYMBOL* pSymbolEntry = GetSymbolEntry(pSymbolTable, iSymbol);
+
+ // Ensure the symbol entry is valid for a resource.
+ if ((pSymbolEntry->StorageClass != IMAGE_SYM_CLASS_STATIC) ||
+ (VAL16(pSymbolEntry->Type) != IMAGE_SYM_TYPE_NULL) ||
+ (VAL16(pSymbolEntry->SectionNumber) != 3)) // 3rd section is .rsrc$02
+ {
+ //dbprintf("Invalid .res file: %S:Illegal symbol entry\n", szResFileName);
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ // Ensure that RVA is valid address (inside rsrc[1])
+ if (VAL32(pSymbolEntry->Value) >= VAL32(rsrc[1]->SizeOfRawData))
+ {
+ //dbprintf("Invalid .res file: %S:Illegal rva into .rsrc$02\n", szResFileName);
+ pParam->hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ goto lDone;
+ }
+
+ DWORD dwOffsetInRsrc2 = VAL32(pSymbolEntry->Value) + VAL32(rsrc[0]->SizeOfRawData);
+
+ // Create reloc
+ *(DWORD*)(data + VAL32(pReloc->VirtualAddress)) = VAL32(dwOffsetInRsrc2);
+ rsrcSection->addSectReloc(pReloc->VirtualAddress, rsrcSection, srRelocAbsolute);
+ }
+
+ // Copy $02 (resource raw) data
+ memcpy(data+VAL32(rsrc[0]->SizeOfRawData),
+ (char *)pParam->hMod + VAL32(rsrc[1]->PointerToRawData),
+ VAL32(rsrc[1]->SizeOfRawData));
+
+lDone: ;
+ }
+ PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ //dbprintf("Exception occured manipulating .res file %S\n", szResFileName);
+ param.hr = HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND);
+ }
+ PAL_ENDTRY
+
+ hMod = param.hMod;
+ hFile = param.hFile;
+ szResFileName = param.szResFileName;
+ hr = param.hr;
+
+ if (hMod != NULL)
+ UnmapViewOfFile(hMod);
+ if (hMap != NULL)
+ CloseHandle(hMap);
+ if (hFile != INVALID_HANDLE_VALUE)
+ CloseHandle(hFile);
+ if (szResFileName == szTempFileName)
+ // delete temporary file if we created one
+ WszDeleteFile(szResFileName);
+
+ return hr;
+} // HRESULT CeeFileGenWriter::emitResourceSection()
+#endif // !FEATURE_PAL
+
+HRESULT CeeFileGenWriter::setManifestEntry(ULONG size, ULONG offset)
+{
+ if (offset)
+ m_dwManifestRVA = offset;
+ else {
+ CeeSection TextSection = getTextSection();
+ getMethodRVA(TextSection.dataLen() - size, &m_dwManifestRVA);
+ }
+
+ m_dwManifestSize = size;
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setManifestEntry()
+
+HRESULT CeeFileGenWriter::setStrongNameEntry(ULONG size, ULONG offset)
+{
+ m_dwStrongNameRVA = offset;
+ m_dwStrongNameSize = size;
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setStrongNameEntry()
+
+HRESULT CeeFileGenWriter::setVTableEntry64(ULONG size, void* ptr)
+{
+ if (ptr && size)
+ {
+ void * pv;
+ CeeSection TextSection = getTextSection();
+ // make it DWORD-aligned
+ ULONG L = TextSection.dataLen();
+ if((L &= ((ULONG)sizeof(DWORD)-1)))
+ {
+ L = (ULONG)sizeof(DWORD) - L;
+ if((pv = TextSection.getBlock(L)))
+ memset(pv,0,L);
+ else
+ return E_OUTOFMEMORY;
+ }
+ getMethodRVA(TextSection.dataLen(), &m_dwVTableRVA);
+ if((pv = TextSection.getBlock(size)))
+ {
+ memcpy(pv,ptr,size);
+ }
+ else
+ return E_OUTOFMEMORY;
+ m_dwVTableSize = size;
+ }
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setVTableEntry()
+
+HRESULT CeeFileGenWriter::setVTableEntry(ULONG size, ULONG offset)
+{
+ return setVTableEntry64(size,(void*)(ULONG_PTR)offset);
+} // HRESULT CeeFileGenWriter::setVTableEntry()
+
+HRESULT CeeFileGenWriter::setEnCRvaBase(ULONG dataBase, ULONG rdataBase)
+{
+ setEnCMode();
+ getPEWriter().setEnCRvaBase(dataBase, rdataBase);
+ return S_OK;
+} // HRESULT CeeFileGenWriter::setEnCRvaBase()
+
+HRESULT CeeFileGenWriter::computeSectionOffset(CeeSection &section, __in char *ptr,
+ unsigned *offset)
+{
+ *offset = section.computeOffset(ptr);
+
+ return S_OK;
+} // HRESULT CeeFileGenWriter::computeSectionOffset()
+
+HRESULT CeeFileGenWriter::computeOffset(__in char *ptr,
+ CeeSection **pSection, unsigned *offset)
+{
+ TESTANDRETURNPOINTER(pSection);
+
+ CeeSection **s = m_sections;
+ CeeSection **sEnd = s + m_numSections;
+ while (s < sEnd)
+ {
+ if ((*s)->containsPointer(ptr))
+ {
+ *pSection = *s;
+ *offset = (*s)->computeOffset(ptr);
+
+ return S_OK;
+ }
+ s++;
+ }
+
+ return E_FAIL;
+} // HRESULT CeeFileGenWriter::computeOffset()
+
+HRESULT CeeFileGenWriter::getCorHeader(IMAGE_COR20_HEADER **ppHeader)
+{
+ *ppHeader = m_corHeader;
+ return S_OK;
+} // HRESULT CeeFileGenWriter::getCorHeader()
+
+
+#ifdef EMIT_FIXUPS
+
+HRESULT CeeFileGenWriter::InitFixupSection()
+{
+ if (!m_fEmitFixups)
+ {
+ return(E_UNEXPECTED);
+ }
+
+ HRESULT hr;
+
+ hr = getSectionCreate(".fixups",
+ IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ,
+ &m_sectionFixups);
+ if (SUCCEEDED(hr))
+ {
+ size_t cbDebugDir = sizeof(IMAGE_DEBUG_DIRECTORY);
+ hr = GetSectionBlock(m_sectionFixups, (ULONG) cbDebugDir, 32, (void **) &m_pDebugDir);
+ if (SUCCEEDED(hr))
+ {
+ memset(m_pDebugDir, 0, cbDebugDir);
+ m_pDebugDir->Type = IMAGE_DEBUG_TYPE_FIXUP;
+ m_fFixupsUpdated = false;
+
+ return(S_OK);
+ }
+ }
+
+ m_pDebugDir = NULL;
+ m_sectionFixups = NULL;
+ m_fEmitFixups = false;
+
+ return(E_FAIL);
+
+} // HRESULT CeeFileGenWriter::InitFixupSection()
+
+HRESULT CeeFileGenWriter::addFixup(CeeSection& sectionSource, unsigned offset, CeeSectionRelocType relocType, CeeSection * psectionTarget, CeeSectionRelocExtra *extra)
+{
+ if (!m_fEmitFixups)
+ {
+ return(S_OK);
+ }
+
+ _ASSERTE(sizeof(DBG_FIXUP) == sizeof(PEFIXUP));
+ _ASSERTE(m_fFixupsUpdated == false);
+
+ DBG_FIXUP * pfixup;
+
+ if (m_sectionFixups == NULL)
+ {
+ HRESULT hr = InitFixupSection();
+ if (FAILED(hr))
+ {
+ return(hr);
+ }
+
+ // The fixup section begins with a IMAGE_DEBUG_DIRECTORY containing a
+ // IMAGE_DEBUG_TYPE_FIXUP directory entry, which describes the array
+ // of fixups which follows it.
+
+ // The very first item of this array is aligned on a 32 bit boundary.
+ // All other fixup entries follow unaligned.
+ pfixup = (DBG_FIXUP *) m_sectionFixups->getBlock(sizeof(DBG_FIXUP), 32);
+ TESTANDRETURN(pfixup != NULL, E_OUTOFMEMORY);
+
+ // Initialize the IMAGE_DEBUG_TYPE_FIXUP entry relocations
+#ifdef _WIN64
+ _ASSERTE(!"Base relocs are not yet implemented for 64-bit");
+ m_pDebugDir->AddressOfRawData = 0; // @ToDo: srRelocAbsolutePtr can't take a 64-bit address
+#else
+ m_pDebugDir->AddressOfRawData = (size_t) pfixup;
+ m_sectionFixups->addSectReloc(offsetof(IMAGE_DEBUG_DIRECTORY, AddressOfRawData), *m_sectionFixups, srRelocAbsolutePtr);
+#endif
+
+ m_pDebugDir->PointerToRawData = m_sectionFixups->computeOffset((char *) pfixup);
+
+ m_sectionFixups->addSectReloc(offsetof(IMAGE_DEBUG_DIRECTORY, PointerToRawData), *m_sectionFixups, srRelocFilePos);
+
+ unsigned offsetDir = m_sectionFixups->computeOffset((char *) m_pDebugDir);
+ setDirectoryEntry(*m_sectionFixups, IMAGE_DIRECTORY_ENTRY_DEBUG, sizeof(IMAGE_DEBUG_DIRECTORY), offsetDir);
+
+#ifdef TEST_EMIT_FIXUPS
+ TestEmitFixups();
+#endif
+ }
+ else
+ {
+ pfixup = (DBG_FIXUP *) m_sectionFixups->getBlock(sizeof(DBG_FIXUP), 1);
+ TESTANDRETURN(pfixup != NULL, E_OUTOFMEMORY);
+ }
+
+ // Save off the relocation information for use later. The relocation's
+ // target information can be filled in later.
+ // The relocation target info is not always immediately available, so it needs
+ // to be extracted later, during the link phase. For now the relocation info
+ // is stored so the target can be extracted at link time in the UpdateFixups
+ // function.
+ //
+ unsigned offsetFixup = m_sectionFixups->computeOffset((char *) pfixup);
+ pfixup->wSpare = 0;
+ pfixup->wType = relocType;
+ _ASSERTE(pfixup->wType == relocType);
+ pfixup->offset = offset;
+ pfixup->sectionSource = &sectionSource;
+
+ m_pDebugDir->SizeOfData += sizeof(DBG_FIXUP);
+
+ // Add a relocation for the fixup's source RVA field, (no fixup on this reloc)
+ m_sectionFixups->addSectReloc(offsetFixup + offsetof(DBG_FIXUP, rva), sectionSource, srRelocAbsolutePtr);
+
+ // Add a relocation for the fixup's target RVA field. Correct target extracted
+ // later in UpdateFixups, (no fixup on this reloc)
+ CeeSectionRelocType tgtRelocType;
+
+ switch (relocType)
+ {
+ case srRelocMapToken:
+ // not an RVA
+ tgtRelocType = srRelocMapToken;
+ break;
+
+ case srRelocFilePos:
+ tgtRelocType = srRelocFilePos;
+ break;
+
+ case srRelocHighAdj:
+ tgtRelocType = srRelocHighAdj;
+ break;
+
+ default:
+ tgtRelocType = (relocType & srRelocPtr) ? srRelocAbsolutePtr : srRelocAbsolute;
+ break;
+ }
+
+ if (psectionTarget != NULL)
+ {
+ m_sectionFixups->addSectReloc(offsetFixup + offsetof(DBG_FIXUP, rvaTarget), *psectionTarget, tgtRelocType, extra);
+ }
+ else
+ {
+ m_sectionFixups->addBaseReloc(offsetFixup + offsetof(DBG_FIXUP, rvaTarget), tgtRelocType, extra);
+ }
+
+ return(S_OK);
+} // HRESULT CeeFileGenWriter::addFixup()
+
+HRESULT CeeFileGenWriter::UpdateFixups()
+{
+ // This method extracts the correct relocation target. See addFixup method.
+
+ if (!m_fEmitFixups || m_fFixupsUpdated)
+ {
+ return(S_OK);
+ }
+ m_fFixupsUpdated = true; // prevent UpdateFixups from being called again.
+
+ size_t cfixups = m_pDebugDir->SizeOfData / sizeof(DBG_FIXUP);
+ _ASSERT(m_pDebugDir->SizeOfData % sizeof(DBG_FIXUP) == 0);
+ unsigned ibFixup = m_pDebugDir->PointerToRawData;
+
+ for (size_t idx = 0; idx < cfixups; idx++, ibFixup += sizeof(DBG_FIXUP))
+ {
+ DBG_FIXUP * pfixup = (DBG_FIXUP *) m_sectionFixups->computePointer(ibFixup);
+ CeeSection * sectionSource = pfixup->sectionSource;
+ CeeSectionRelocType relocType = (CeeSectionRelocType) pfixup->wType;
+ unsigned offset = pfixup->offset;
+
+ // Get current data for replacing fixup contents
+ const DWORD * pdw = (DWORD *) sectionSource->computePointer(offset);
+ pfixup->rva = (DWORD) (UINT_PTR) pdw;
+ pfixup->rvaTarget = *pdw;
+
+ switch (relocType)
+ {
+#ifdef _X86_
+ case srRelocAbsolute:
+ // Emitted bytes: RVA, offset relative to image base
+ // reloc src contains target offset relative to target section
+ if ((*pdw & 0xFF000000) == 0)
+ {
+ pfixup->wType = IMAGE_REL_I386_DIR32NB;
+ }
+ else
+ {
+ // MethodDesc::Fixup function creates a 24 bit RVA, where the
+ // high byte of the DWORD stores the flag value: METHOD_NEEDS_PRESTUB_RUN_FLAG.
+ // work around it by converting the type to 24 bits here
+ pfixup->wType = IMAGE_REL_I386_DIR24NB;
+ pfixup->rvaTarget = *pdw & 0x00FFFFFF;
+ }
+ break;
+
+ case srRelocAbsolutePtr:
+ // Emitted bytes: RVA, offset relative to image base
+ // reloc src contains target pointer
+ pfixup->wType = IMAGE_REL_I386_DIR32NB;
+ break;
+
+ case srRelocHighLow:
+ // Emitted bytes: full address of target
+ // reloc src contains target offset relative to target section
+ pfixup->wType = IMAGE_REL_I386_DIR32;
+ break;
+
+ case srRelocHighLowPtr:
+ // Emitted bytes: full address of target
+ // reloc src contains target pointer
+ pfixup->wType = IMAGE_REL_I386_DIR32;
+ break;
+
+ case srRelocRelative:
+ // Emitted bytes: value of reloc tgt - (reloc source + sizeof(DWORD))
+ // reloc src contains offset relative to target section, minus sizeof(DWORD)
+ // the reloc type for pFixup->rvaTarget is srRelocAbsolute
+ // so contents of pFixup->rvaTarget need to be offset Target + sizeof(DWORD)
+ // which is offset Target == Source contents + sizeof(DWORD) == *pdw + sizeof(DWORD)
+ pfixup->wType = IMAGE_REL_I386_REL32;
+ pfixup->rvaTarget = *pdw + sizeof(DWORD);
+ break;
+
+ case srRelocRelativePtr:
+ // Emitted bytes: value of reloc tgt - (reloc source + sizeof(DWORD))
+ // reloc src contains disp, disp = pTarget - (pSource + sizeof(DWORD))
+ // the reloc type for pFixup->rvaTarget is srRelocAbsolutePtr
+ // so contents of pFixup->rvaTarget need to be pTarget
+ // which is pTarget == pSource + sizeof(DWORD) + disp == pdw + 4 + *pdw
+ pfixup->wType = IMAGE_REL_I386_REL32;
+ pfixup->rvaTarget = (int) (INT_PTR) pdw + sizeof(DWORD) + (int) *pdw;
+ break;
+
+ case srRelocMapToken:
+ // Emitted bytes: contents of reloc source unchanged.
+ // reloc src contains token value
+ pfixup->wType = IMAGE_REL_I386_TOKEN;
+ break;
+
+#elif defined(_AMD64_)
+ /*
+ //
+ // X86-64 relocations
+ //
+ IMAGE_REL_AMD64_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
+ IMAGE_REL_AMD64_ADDR64 0x0001 // 64-bit address (VA).
+ IMAGE_REL_AMD64_ADDR32 0x0002 // 32-bit address (VA).
+ IMAGE_REL_AMD64_ADDR32NB 0x0003 // 32-bit address w/o image base (RVA).
+ IMAGE_REL_AMD64_REL32 0x0004 // 32-bit relative address from byte following reloc
+ IMAGE_REL_AMD64_REL32_1 0x0005 // 32-bit relative address from byte distance 1 from reloc
+ IMAGE_REL_AMD64_REL32_2 0x0006 // 32-bit relative address from byte distance 2 from reloc
+ IMAGE_REL_AMD64_REL32_3 0x0007 // 32-bit relative address from byte distance 3 from reloc
+ IMAGE_REL_AMD64_REL32_4 0x0008 // 32-bit relative address from byte distance 4 from reloc
+ IMAGE_REL_AMD64_REL32_5 0x0009 // 32-bit relative address from byte distance 5 from reloc
+ IMAGE_REL_AMD64_SECTION 0x000A // Section index
+ IMAGE_REL_AMD64_SECREL 0x000B // 32 bit offset from base of section containing target
+ IMAGE_REL_AMD64_SECREL7 0x000C // 7 bit unsigned offset from base of section containing target
+ IMAGE_REL_AMD64_TOKEN 0x000D // 32 bit metadata token
+ IMAGE_REL_AMD64_SREL32 0x000E // 32 bit signed span-dependent value emitted into object
+ IMAGE_REL_AMD64_PAIR 0x000F
+ IMAGE_REL_AMD64_SSPAN32 0x0010 // 32 bit signed span-dependent value applied at link time
+ */
+ case srRelocAbsolute:
+ // Emitted bytes: RVA, offset relative to image base
+ pfixup->wType = IMAGE_REL_AMD64_ADDR32NB;
+ break;
+
+ case srRelocAbsolutePtr:
+ // Emitted bytes: RVA, offset relative to image base
+ // reloc src contains target pointer
+ pfixup->wType = IMAGE_REL_AMD64_ADDR32NB;
+ break;
+
+ case srRelocDir64Ptr:
+ // Emitted bytes: full address of target
+ // reloc src contains target pointer
+ pfixup->wType = IMAGE_REL_IA64_DIR64;
+ break;
+
+ case srRelocMapToken:
+ // Emitted bytes: contents of reloc source unchanged.
+ // reloc src contains token value
+ pfixup->wType = IMAGE_REL_AMD64_TOKEN;
+ break;
+#endif
+ case srRelocFilePos:
+ // Emitted bytes: offset relative to start of file, differs from RVA.
+ pfixup->wType = IMAGE_REL_I386_FILEPOS;
+ break;
+
+ case srRelocAbsoluteTagged:
+ pfixup->wType = IMAGE_REL_I386_DIR30NB;
+ pfixup->rvaTarget = (*pdw & ~0x80000001) >> 1;
+ break;
+
+ case srRelocHighAdj:
+ // Emitted bytes: 2 part relocation, with high part adjusted by constant.
+ pfixup->wType = IMAGE_REL_BASED_HIGHADJ;
+ break;
+
+ default:
+ _ASSERTE(!"Unknown relocation type");
+ return(E_UNEXPECTED);
+ break;
+ }
+ }
+
+ return(S_OK);
+
+} // HRESULT CeeFileGenWriter::UpdateFixups()
+
+
+HRESULT CeeFileGenWriter::setEmitFixups()
+{
+ m_fEmitFixups = true;
+ return(S_OK);
+
+} // HRESULT CeeFileGenWriter::setEmitFixups()
+
+#ifdef TEST_EMIT_FIXUPS
+
+HRESULT CeeFileGenWriter::TestEmitFixups()
+{
+ HRESULT hr;
+ // Test fixups
+
+ CeeSection * testSection;
+ hr = getSectionCreate(".test",
+ IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ,
+ &testSection);
+ if (SUCCEEDED(hr))
+ {
+ struct FixupEntry
+ {
+ char sz[18];
+ DWORD wTargets[8];
+ };
+
+ struct FixupTypes
+ {
+ char * pszType;
+ CeeSectionRelocType relocType;
+ };
+
+ FixupTypes rgTypes[] =
+ {
+ { "srRelocAbsolute ", srRelocAbsolute },
+ { "srRelocAbsolutePtr", srRelocAbsolutePtr },
+ { "srRelocHighLow ", srRelocHighLow },
+ { "srRelocHighLowPtr ", srRelocHighLowPtr },
+ // { "srRelocRelative ", srRelocRelative },
+ // { "srRelocRelativePtr", srRelocRelativePtr },
+ { "srRelocMapToken ", srRelocMapToken },
+ // { "srRelocFilePos ", srRelocFilePos },
+ // { "srRelocHighAdj ", srRelocHighAdj },
+ };
+
+ const size_t cFixups = sizeof(rgTypes) / sizeof(rgTypes[0]);
+
+ DWORD * pdwTargets[20];
+
+ // Target Blocks:
+
+ for (size_t idx = 0; idx < cFixups; idx++)
+ {
+ hr = GetSectionBlock(testSection, sizeof(DWORD), 1, (void **) &pdwTargets[idx]);
+ _ASSERTE(SUCCEEDED(hr));
+
+ DWORD * pdw = pdwTargets[idx];
+ *pdw = idx;
+ }
+
+ for (size_t idxType = 0; idxType < cFixups; idxType++)
+ {
+ // Fixup Entries
+ FixupEntry * pEntry;
+ hr = GetSectionBlock(testSection, sizeof(FixupEntry), 1, (void **) &pEntry);
+ _ASSERTE(SUCCEEDED(hr));
+
+ memset(pEntry, 0, sizeof(FixupEntry));
+ strcpy_s(pEntry->sz, sizeof(pEntry->sz), rgTypes[idxType].pszType);
+
+ size_t ibBlock = testSection->computeOffset((char *) pEntry);
+
+ for (size_t idx = 0; idx < cFixups; idx++)
+ {
+ size_t ibFixup = ((size_t) &pEntry->wTargets[idx]) - (size_t) pEntry;
+
+ switch (rgTypes[idxType].relocType)
+ {
+ case srRelocAbsolute:
+ pEntry->wTargets[idx] = idx * sizeof(DWORD);
+ break;
+
+ case srRelocAbsolutePtr:
+ pEntry->wTargets[idx] = (DWORD) pdwTargets[idx];
+ break;
+
+ case srRelocHighLow:
+ pEntry->wTargets[idx] = idx * sizeof(DWORD);
+ break;
+
+ case srRelocHighLowPtr:
+ pEntry->wTargets[idx] = (DWORD) pdwTargets[idx];
+ break;
+
+ case srRelocRelative:
+ pEntry->wTargets[idx] = idx;
+ break;
+
+ case srRelocRelativePtr:
+ {
+ size_t ibTgt = (size_t) pdwTargets[idx];
+ size_t ibSrc = ((size_t) &pEntry->wTargets[idx]) + sizeof(DWORD);
+ pEntry->wTargets[idx] = (DWORD)( ibTgt - ibSrc );
+ ibFixup += sizeof(DWORD); // offset needs to point at end of DWORD
+ break;
+ }
+
+ case srRelocHighAdj:
+ pEntry->wTargets[idx] = idx * sizeof(DWORD);
+ break;
+
+ case srRelocMapToken:
+ pEntry->wTargets[idx] = idx * sizeof(DWORD);
+ break;
+
+ case srRelocFilePos:
+ pEntry->wTargets[idx] = idx * sizeof(DWORD);
+ break;
+ }
+
+ addFixup(*testSection, ibBlock + ibFixup, rgTypes[idxType].relocType, testSection);
+ testSection->addSectReloc(ibBlock + ibFixup, *testSection, rgTypes[idxType].relocType);
+ }
+ }
+ }
+
+ return(S_OK);
+}
+#endif // TEST_EMIT_FIXUPS
+#endif // EMIT_FIXUPS
+
+#ifndef FEATURE_MERGE_JIT_AND_ENGINE
+
+//*****************************************************************************
+// Handle lifetime of loaded library.
+//*****************************************************************************
+extern "C"
+BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ { // Save the module handle.
+ g_hThisInst = (HINSTANCE)hInstance;
+ DisableThreadLibraryCalls((HMODULE)hInstance);
+ }
+ break;
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+
+ return (true);
+} // BOOL WINAPI DllMain()
+
+
+HINSTANCE GetModuleInst()
+{
+ return (g_hThisInst);
+} // HINSTANCE GetModuleInst()
+
+#endif //FEATURE_MERGE_JIT_AND_ENGINE
diff --git a/src/dlls/mscorpe/ceefilegenwritertokens.cpp b/src/dlls/mscorpe/ceefilegenwritertokens.cpp
new file mode 100644
index 0000000000..e2d448552d
--- /dev/null
+++ b/src/dlls/mscorpe/ceefilegenwritertokens.cpp
@@ -0,0 +1,266 @@
+// 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.
+//*****************************************************************************
+// CeeFileGenWriterTokens.cpp
+//
+// This code will walk the byte codes for all methods before they are saved
+// to disk and apply the token fix-ups if they have moved.
+//
+//*****************************************************************************
+#include "stdafx.h"
+#include "ceegen.h"
+#ifndef FEATURE_CORECLR
+#define DECLARE_DATA
+#endif
+#include "../../ildasm/dasmenum.hpp"
+#define MAX_CLASSNAME_LENGTH 1024
+
+//********** Locals. **********************************************************
+OPCODE DecodeOpcode(const BYTE *pCode, DWORD *pdwLen);
+
+
+
+//********** Code. ************************************************************
+
+
+//*****************************************************************************
+// Method bodies are kept in the text section. The meta data contains the
+// RVA of each method body in the image. The TextSection object contains the
+// actual raw bytes where the method bodies are located. This code will
+// determine the raw offset of each method based on the RVA kept in the meta
+// data.
+//*****************************************************************************
+
+HRESULT CeeFileGenWriter::MapTokens(
+ CeeGenTokenMapper *pMapper,
+ IMetaDataImport *pImport)
+{
+ mdTypeDef td;
+ mdMethodDef md;
+ ULONG count;
+ ULONG MethodRVA;
+ ULONG codeOffset;
+ ULONG BaseRVA;
+ DWORD dwFlags;
+ DWORD iFlags;
+ HCORENUM hTypeDefs = 0, hEnum = 0;
+ WCHAR rcwName[MAX_CLASSNAME_LENGTH];
+ HRESULT hr;
+ CeeSection TextSection = getTextSection();
+
+ // Ask for the base RVA of the first method in the stream. All other
+ // method RVA's are >= that value, and will give us the raw offset required.
+
+ hr = getMethodRVA(0, &BaseRVA);
+ _ASSERTE(SUCCEEDED(hr));
+ // do globals first
+ while ((hr = pImport->EnumMethods(&hEnum, mdTokenNil, &md, 1, &count)) == S_OK)
+ {
+ hr = pImport->GetMethodProps(md, NULL,
+ rcwName, lengthof(rcwName), NULL,
+ &dwFlags, NULL, NULL,
+ &MethodRVA, &iFlags);
+ _ASSERTE(SUCCEEDED(hr));
+
+ if (MethodRVA == 0 || ((IsMdAbstract(dwFlags) || IsMiInternalCall(iFlags)) ||
+ (! IsMiIL(iFlags) && ! IsMiOPTIL(iFlags))))
+ continue;
+
+ // The raw offset of the method is the RVA in the image minus
+ // the first method in the text section.
+ codeOffset = MethodRVA - BaseRVA;
+ hr = MapTokensForMethod(pMapper,
+ (BYTE *) TextSection.computePointer(codeOffset),
+ rcwName);
+ if (FAILED(hr))
+ goto ErrExit;
+ }
+ if (hEnum) pImport->CloseEnum(hEnum);
+ hEnum = 0;
+
+ while ((hr = pImport->EnumTypeDefs(&hTypeDefs, &td, 1, &count)) == S_OK)
+ {
+ while ((hr = pImport->EnumMethods(&hEnum, td, &md, 1, &count)) == S_OK)
+ {
+ hr = pImport->GetMethodProps(md, NULL,
+ rcwName, lengthof(rcwName), NULL,
+ &dwFlags, NULL, NULL,
+ &MethodRVA, &iFlags);
+ _ASSERTE(SUCCEEDED(hr));
+
+ if (MethodRVA == 0 || ((IsMdAbstract(dwFlags) || IsMiInternalCall(iFlags)) ||
+ (! IsMiIL(iFlags) && ! IsMiOPTIL(iFlags))))
+ continue;
+
+
+ // The raw offset of the method is the RVA in the image minus
+ // the first method in the text section.
+ codeOffset = MethodRVA - BaseRVA;
+ hr = MapTokensForMethod(pMapper,
+ (BYTE *) TextSection.computePointer(codeOffset),
+ rcwName);
+ if (FAILED(hr))
+ goto ErrExit;
+ }
+
+ if (hEnum) pImport->CloseEnum(hEnum);
+ hEnum = 0;
+ }
+
+ErrExit:
+ if (hTypeDefs) pImport->CloseEnum(hTypeDefs);
+ if (hEnum) pImport->CloseEnum(hEnum);
+ return (hr);
+}
+
+
+//*****************************************************************************
+// This method will walk the byte codes of an IL method looking for tokens.
+// For each token found, it will check to see if it has been moved, and if
+// so, apply the new token value in its place.
+//*****************************************************************************
+HRESULT CeeFileGenWriter::MapTokensForMethod(
+ CeeGenTokenMapper *pMapper,
+ BYTE *pCode,
+ LPCWSTR szMethodName)
+{
+ mdToken tkTo;
+ DWORD PC;
+
+ COR_ILMETHOD_DECODER method((COR_ILMETHOD*) pCode);
+
+ // If compressed IL is being emitted, this routine will have no idea how to walk the tokens,
+ // so don't do it
+ if (m_dwMacroDefinitionSize != 0)
+ return S_OK;
+
+ pCode = const_cast<BYTE*>(method.Code);
+
+ PC = 0;
+ while (PC < method.GetCodeSize())
+ {
+ DWORD Len;
+ DWORD i;
+ OPCODE instr;
+
+ instr = DecodeOpcode(&pCode[PC], &Len);
+
+ if (instr == CEE_COUNT)
+ {
+ _ASSERTE(0 && "Instruction decoding error\n");
+ return E_FAIL;
+ }
+
+
+ PC += Len;
+
+ switch (OpcodeInfo[instr].Type)
+ {
+ DWORD tk;
+
+ default:
+ {
+ _ASSERTE(0 && "Unknown instruction\n");
+ return E_FAIL;
+ }
+
+ case InlineNone:
+ break;
+
+ case ShortInlineI:
+ case ShortInlineVar:
+ case ShortInlineBrTarget:
+ PC++;
+ break;
+
+ case InlineVar:
+ PC += 2;
+ break;
+
+ case InlineI:
+ case ShortInlineR:
+ case InlineBrTarget:
+ case InlineRVA:
+ PC += 4;
+ break;
+
+ case InlineI8:
+ case InlineR:
+ PC += 8;
+ break;
+
+ case InlinePhi:
+ {
+ DWORD cases = pCode[PC];
+ PC += 2 * cases + 1;
+ break;
+ }
+
+ case InlineSwitch:
+ {
+ DWORD cases = pCode[PC] + (pCode[PC+1] << 8) + (pCode[PC+2] << 16) + (pCode[PC+3] << 24);
+
+ PC += 4;
+ for (i = 0; i < cases; i++)
+ {
+ PC += 4;
+ }
+
+ // skip bottom of loop which prints szString
+ continue;
+ }
+
+ case InlineTok:
+ case InlineSig:
+ case InlineMethod:
+ case InlineField:
+ case InlineType:
+ case InlineString:
+ {
+ tk = GET_UNALIGNED_VAL32(&pCode[PC]);
+
+ if (pMapper->HasTokenMoved(tk, tkTo))
+ {
+ SET_UNALIGNED_VAL32(&pCode[PC], tkTo);
+ }
+
+ PC += 4;
+ break;
+ }
+ }
+ }
+
+ return S_OK;
+}
+
+
+
+
+OPCODE DecodeOpcode(const BYTE *pCode, DWORD *pdwLen)
+{
+ OPCODE opcode;
+
+ *pdwLen = 1;
+ opcode = OPCODE(pCode[0]);
+ switch(opcode) {
+ case CEE_PREFIX1:
+ opcode = OPCODE(pCode[1] + 256);
+ if (opcode < 0 || opcode >= CEE_COUNT)
+ opcode = CEE_COUNT;
+ *pdwLen = 2;
+ break;
+ case CEE_PREFIXREF:
+ case CEE_PREFIX2:
+ case CEE_PREFIX3:
+ case CEE_PREFIX4:
+ case CEE_PREFIX5:
+ case CEE_PREFIX6:
+ case CEE_PREFIX7:
+ *pdwLen = 3;
+ return CEE_COUNT;
+ default:
+ break;
+ }
+ return opcode;
+}
diff --git a/src/dlls/mscorpe/dirs.proj b/src/dlls/mscorpe/dirs.proj
new file mode 100644
index 0000000000..46bb0ce64d
--- /dev/null
+++ b/src/dlls/mscorpe/dirs.proj
@@ -0,0 +1,15 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <!--The following projects will build during PHASE 1-->
+ <PropertyGroup>
+ <BuildInPhaseDefault>false</BuildInPhaseDefault>
+ <BuildInPhase1>true</BuildInPhase1>
+ </PropertyGroup>
+ <ItemGroup Condition="'$(BuildExePhase)' == '1'">
+ <ProjectFile Include="mscorpe\mscorpe.nativeproj" />
+ <ProjectFile Include="mscorpehost\mscorpehost.nativeproj" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
+</Project>
diff --git a/src/dlls/mscorpe/iceefilegen.cpp b/src/dlls/mscorpe/iceefilegen.cpp
new file mode 100644
index 0000000000..f4323b9e8c
--- /dev/null
+++ b/src/dlls/mscorpe/iceefilegen.cpp
@@ -0,0 +1,732 @@
+// 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: CEEGEN.CPP
+// ===========================================================================
+#include "stdafx.h"
+#include "iceefilegen.h"
+#include "ceefilegenwriter.h"
+
+#ifdef EnC_SUPPORTED
+#define ENC_DELTA_HACK
+#endif
+
+#ifdef ENC_DELTA_HACK
+extern BOOL g_EnCMode;
+#endif
+
+// Deprecated
+//****************************************************************************
+ HRESULT ICeeFileGen::EmitMethod ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::EmitSignature ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::SetEntryClassToken ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::GetEntryClassToken ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::SetEntryPointDescr ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::GetEntryPointDescr ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::SetEntryPointFlags ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::GetEntryPointFlags ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::CreateSig ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::AddSigArg ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::SetSigReturnType ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::SetSigCallingConvention ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+ HRESULT ICeeFileGen::DeleteSig ()
+ {
+ _ASSERTE("Deprecated" && 0);
+ return (E_FAIL);
+ }
+//****************************************************************************
+
+EXTERN_C HRESULT __stdcall CreateICeeFileGen(ICeeFileGen** pCeeFileGen)
+{
+ if (!pCeeFileGen)
+ return E_POINTER;
+
+ ICeeFileGen *gen = new (nothrow) ICeeFileGen();
+ IfNullRet(gen);
+
+ *pCeeFileGen = gen;
+ return S_OK;
+}
+
+EXTERN_C HRESULT __stdcall DestroyICeeFileGen(ICeeFileGen** pCeeFileGen)
+{
+ if (!pCeeFileGen)
+ return E_POINTER;
+ delete *pCeeFileGen;
+ *pCeeFileGen = NULL;
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::CreateCeeFile (HCEEFILE *ceeFile)
+{
+ return CreateCeeFileEx(ceeFile, ICEE_CREATE_FILE_PURE_IL);
+}
+
+HRESULT ICeeFileGen::CreateCeeFileEx (HCEEFILE *ceeFile, DWORD createFlags)
+{
+ return CreateCeeFileEx2(ceeFile, createFlags, NULL);
+}
+
+//
+// Seed file is used as the base file. The new file data will be "appended" to the seed file
+//
+
+HRESULT ICeeFileGen::CreateCeeFileEx2 (HCEEFILE *ceeFile, DWORD createFlags, LPCWSTR seedFileName)
+{
+ if (!ceeFile)
+ return E_POINTER;
+
+ CeeFileGenWriter *gen = NULL;
+ HRESULT hr;
+ IfFailRet(CeeFileGenWriter::CreateNewInstanceEx(NULL, gen, createFlags, seedFileName));
+ TESTANDRETURN(gen != NULL, E_OUTOFMEMORY);
+ *ceeFile = gen;
+
+#ifdef ENC_DELTA_HACK
+ // for EnC we want the RVA to be right be relative to the front of the delta IL stream rather
+ // than take into account the .text section and the cor header as we would for a real PE file
+ // However, the RVA must be non-zero, so just stick a dword on the front to push it out.
+ if (g_EnCMode)
+ {
+ CeeSection *sec = &gen->getIlSection();
+ sec->getBlock(sizeof(DWORD), sizeof(DWORD));
+ }
+#endif
+
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::CreateCeeFileFromICeeGen(ICeeGen *pICeeGen, HCEEFILE *ceeFile, DWORD createFlags)
+{
+ if (!ceeFile)
+ return E_POINTER;
+ CCeeGen *genFrom = reinterpret_cast<CCeeGen*>(pICeeGen);
+ CeeFileGenWriter *gen = NULL;
+ if (FAILED(CeeFileGenWriter::CreateNewInstance(genFrom, gen, createFlags))) return FALSE;
+ TESTANDRETURN(gen != NULL, E_OUTOFMEMORY);
+ *ceeFile = gen;
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::DestroyCeeFile(HCEEFILE *ceeFile)
+{
+ if (!ceeFile)
+ return E_POINTER;
+ if (!*ceeFile)
+ return E_POINTER;
+
+ CeeFileGenWriter **gen = reinterpret_cast<CeeFileGenWriter**>(ceeFile);
+ (*gen)->Cleanup();
+ delete *gen;
+ *ceeFile = NULL;
+ return S_OK;
+}
+
+//
+
+HRESULT ICeeFileGen::GetRdataSection (HCEEFILE ceeFile, HCEESECTION *section)
+{
+ TESTANDRETURNPOINTER(section);
+ TESTANDRETURNARG(ceeFile != 0);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ *section = &gen->getStringSection();
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::GetIlSection (HCEEFILE ceeFile, HCEESECTION *section)
+{
+ TESTANDRETURNPOINTER(section);
+ TESTANDRETURNARG(ceeFile != 0);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ *section = &gen->getIlSection();
+ return S_OK;
+}
+
+
+HRESULT ICeeFileGen::GetSectionCreate (HCEEFILE ceeFile, const char *name, DWORD flags,
+ HCEESECTION *section)
+{
+ TESTANDRETURNPOINTER(section);
+ TESTANDRETURNARG(ceeFile != 0);
+ TESTANDRETURNPOINTER(name);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ CeeSection **ceeSection = reinterpret_cast<CeeSection**>(section);
+
+ HRESULT hr = gen->getSectionCreate(name, flags, ceeSection);
+
+ return hr;
+}
+
+HRESULT ICeeFileGen::SetDirectoryEntry(HCEEFILE ceeFile, HCEESECTION section, ULONG num, ULONG size, ULONG offset)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(section);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ CeeSection &sec = *(reinterpret_cast<CeeSection*>(section));
+ return(gen->setDirectoryEntry(sec, num, size, offset));
+}
+
+HRESULT ICeeFileGen::GetSectionDataLen (HCEESECTION section, ULONG *dataLen)
+{
+ TESTANDRETURNPOINTER(section);
+ TESTANDRETURNPOINTER(dataLen);
+
+ CeeSection *sec = reinterpret_cast<CeeSection*>(section);
+ *dataLen = sec->dataLen();
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::GetSectionRVA (HCEESECTION section, ULONG *rva)
+{
+ TESTANDRETURNPOINTER(section);
+ TESTANDRETURNPOINTER(rva);
+
+ CeeSection *sec = reinterpret_cast<CeeSection*>(section);
+ *rva = sec->getBaseRVA();
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::GetSectionBlock (HCEESECTION section, ULONG len,
+ ULONG align, void **ppBytes)
+{
+ TESTANDRETURNPOINTER(section);
+ TESTANDRETURNPOINTER(ppBytes);
+
+ CeeSection *sec = reinterpret_cast<CeeSection*>(section);
+ void *bytes = sec->getBlock(len, align);
+ TESTANDRETURN(bytes != NULL, E_OUTOFMEMORY);
+ *ppBytes = bytes;
+
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::TruncateSection (HCEESECTION section, ULONG len)
+{
+ _ASSERTE(!"This is an obsolete function!");
+ return E_NOTIMPL;
+}
+
+HRESULT ICeeFileGen::AddSectionReloc (HCEESECTION section, ULONG offset, HCEESECTION relativeTo, CeeSectionRelocType relocType)
+{
+ TESTANDRETURNPOINTER(section);
+
+ CeeSection *sec = reinterpret_cast<CeeSection*>(section);
+ CeeSection *relSec = reinterpret_cast<CeeSection*>(relativeTo);
+
+ if (relSec)
+ {
+#ifdef EMIT_FIXUPS
+ CeeFileGenWriter * gen = reinterpret_cast<CeeFileGenWriter*>(&sec->ceeFile());
+ HRESULT hr = gen->addFixup(*sec, offset, relocType, relSec);
+ if (FAILED(hr))
+ {
+ return(hr);
+ }
+#endif
+ return(sec->addSectReloc(offset, *relSec, relocType));
+ }
+ else
+ {
+#ifdef EMIT_FIXUPS
+ CeeFileGenWriter * gen = reinterpret_cast<CeeFileGenWriter*>(&sec->ceeFile());
+ HRESULT hr = gen->addFixup(*sec, offset, relocType);
+ if (FAILED(hr))
+ {
+ return(hr);
+ }
+#endif
+ return(sec->addBaseReloc(offset, relocType));
+ }
+}
+
+HRESULT ICeeFileGen::SetSectionDirectoryEntry(HCEESECTION section, ULONG num)
+{
+ TESTANDRETURNPOINTER(section);
+
+ printf("Warning: deprecated method. Use SetDirectoryEntry instead\n");
+ CeeSection *sec = reinterpret_cast<CeeSection*>(section);
+ return(sec->directoryEntry(num));
+}
+
+HRESULT ICeeFileGen::SetOutputFileName (HCEEFILE ceeFile, __in LPWSTR outputFileName)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(outputFileName);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->setOutputFileName(outputFileName));
+}
+
+__success(return == S_OK) HRESULT ICeeFileGen::GetOutputFileName (HCEEFILE ceeFile, __out LPWSTR *outputFileName)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(outputFileName);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ TESTANDRETURNPOINTER(outputFileName);
+ *outputFileName = gen->getOutputFileName();
+ return S_OK;
+}
+
+
+HRESULT ICeeFileGen::SetResourceFileName (HCEEFILE ceeFile, __in LPWSTR resourceFileName)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(resourceFileName);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->setResourceFileName(resourceFileName));
+}
+
+__success(return == S_OK)
+HRESULT ICeeFileGen::GetResourceFileName (HCEEFILE ceeFile, __out LPWSTR *resourceFileName)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(resourceFileName);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ TESTANDRETURNPOINTER(resourceFileName);
+ *resourceFileName = gen->getResourceFileName();
+ return S_OK;
+}
+
+
+HRESULT ICeeFileGen::SetImageBase(HCEEFILE ceeFile, size_t imageBase)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ gen->setImageBase(imageBase);
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::SetImageBase64(HCEEFILE ceeFile, ULONGLONG imageBase)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ gen->setImageBase64(imageBase);
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::SetFileAlignment(HCEEFILE ceeFile, ULONG fileAlignment)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ gen->setFileAlignment(fileAlignment);
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::SetSubsystem(HCEEFILE ceeFile, DWORD subsystem, DWORD major, DWORD minor)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ gen->setSubsystem(subsystem, major, minor);
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::GetIMapTokenIface(HCEEFILE ceeFile, IMetaDataEmit *emitter, IUnknown **pIMapToken)
+{
+ _ASSERTE(!"This is an obsolete function!");
+ return E_NOTIMPL;
+}
+
+HRESULT ICeeFileGen::EmitMetaData (HCEEFILE ceeFile, IMetaDataEmit *emitter,
+ mdScope scopeE)
+{
+ _ASSERTE(!"This is an obsolete function!");
+ return E_NOTIMPL;
+}
+
+HRESULT ICeeFileGen::EmitLibraryName (HCEEFILE ceeFile, IMetaDataEmit *emitter,
+ mdScope scopeE)
+{
+ _ASSERTE(!"This is an obsolete function!");
+ return E_NOTIMPL;
+}
+
+HRESULT ICeeFileGen::GetMethodRVA(HCEEFILE ceeFile, ULONG codeOffset, ULONG *codeRVA)
+{
+ TESTANDRETURNARG(ceeFile != 0);
+ TESTANDRETURNPOINTER(codeRVA);
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ gen->getMethodRVA(codeOffset, codeRVA);
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::EmitString(HCEEFILE ceeFile, __in LPWSTR strValue, ULONG *strRef)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->getStringSection().getEmittedStringRef(strValue, strRef));
+}
+
+HRESULT ICeeFileGen::LinkCeeFile (HCEEFILE ceeFile)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->link();
+}
+
+HRESULT ICeeFileGen::FixupCeeFile (HCEEFILE ceeFile)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->fixup();
+}
+
+HRESULT ICeeFileGen::GetHeaderInfo (HCEEFILE ceeFile, PIMAGE_NT_HEADERS *ppNtHeaders, PIMAGE_SECTION_HEADER *ppSections, ULONG *pNumSections)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ gen->getPEWriter().getHeaderInfo(ppNtHeaders, ppSections, pNumSections);
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::GenerateCeeFile (HCEEFILE ceeFile)
+{
+ SO_NOT_MAINLINE_FUNCTION;
+
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->generateImage(NULL); // NULL means don't write in-memory buffer, uses outputFileName
+}
+
+// GenerateCeeMemoryImage - returns in ppImage an in-memory PE image allocated by CoTaskMemAlloc()
+// the caller is responsible for calling CoTaskMemFree on this memory image
+HRESULT ICeeFileGen::GenerateCeeMemoryImage (HCEEFILE ceeFile, void **ppImage)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(ppImage);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->generateImage(ppImage);
+}
+
+HRESULT ICeeFileGen::SetEntryPoint(HCEEFILE ceeFile, mdMethodDef method)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setEntryPoint(method);
+}
+
+HRESULT ICeeFileGen::GetEntryPoint(HCEEFILE ceeFile, mdMethodDef *method)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ TESTANDRETURNPOINTER(method);
+ *method = gen->getEntryPoint();
+ return S_OK;
+}
+
+
+HRESULT ICeeFileGen::SetComImageFlags (HCEEFILE ceeFile, DWORD mask)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setComImageFlags(mask);
+}
+
+HRESULT ICeeFileGen::ClearComImageFlags (HCEEFILE ceeFile, DWORD mask)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->clearComImageFlags(mask);
+}
+
+HRESULT ICeeFileGen::GetComImageFlags (HCEEFILE ceeFile, DWORD *mask)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ TESTANDRETURNPOINTER(mask);
+ *mask = gen->getComImageFlags();
+ return S_OK;
+}
+
+
+HRESULT ICeeFileGen::SetDllSwitch (HCEEFILE ceeFile, BOOL dllSwitch)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->setDllSwitch(dllSwitch==TRUE));
+}
+
+HRESULT ICeeFileGen::GetDllSwitch (HCEEFILE ceeFile, BOOL *dllSwitch)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ TESTANDRETURNPOINTER(dllSwitch);
+ *dllSwitch = gen->getDllSwitch();
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::SetObjSwitch (HCEEFILE ceeFile, BOOL objSwitch)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->setObjSwitch(objSwitch==TRUE));
+}
+
+HRESULT ICeeFileGen::GetObjSwitch (HCEEFILE ceeFile, BOOL *objSwitch)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ TESTANDRETURNPOINTER(objSwitch);
+ *objSwitch = gen->getObjSwitch();
+ return S_OK;
+}
+
+
+HRESULT ICeeFileGen::SetLibraryName (HCEEFILE ceeFile, __in LPWSTR LibraryName)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(LibraryName);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->setLibraryName(LibraryName));
+}
+
+HRESULT ICeeFileGen::SetLibraryGuid (HCEEFILE ceeFile, __in LPWSTR LibraryGuid)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(LibraryGuid);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->setLibraryGuid(LibraryGuid));
+}
+
+__success(return == S_OK) HRESULT ICeeFileGen::GetLibraryName (HCEEFILE ceeFile, __out LPWSTR *LibraryName)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(LibraryName);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ *LibraryName = gen->getLibraryName();
+ return S_OK;
+}
+
+
+
+HRESULT ICeeFileGen::EmitMetaDataEx (HCEEFILE ceeFile, IMetaDataEmit *emitter)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(emitter);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->emitMetaData(emitter));
+}
+
+HRESULT ICeeFileGen::EmitMetaDataAt (HCEEFILE ceeFile, IMetaDataEmit *emitter, HCEESECTION section, DWORD offset, BYTE* buffer, unsigned buffLen)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(emitter);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ CeeSection* sec = reinterpret_cast<CeeSection*>(section);
+
+ return(gen->emitMetaData(emitter, sec, offset, buffer, buffLen));
+}
+
+HRESULT ICeeFileGen::EmitLibraryNameEx (HCEEFILE ceeFile, IMetaDataEmit *emitter)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(emitter);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->emitLibraryName(emitter));
+}
+
+HRESULT ICeeFileGen::GetIMapTokenIfaceEx(HCEEFILE ceeFile, IMetaDataEmit *emitter, IUnknown **pIMapToken)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(pIMapToken);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->getMapTokenIface(pIMapToken);
+}
+
+HRESULT ICeeFileGen::AddNotificationHandler(HCEEFILE ceeFile,
+ IUnknown *pHandler)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(pHandler);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->addNotificationHandler(pHandler);
+}
+
+HRESULT ICeeFileGen::EmitMacroDefinitions(HCEEFILE ceeFile, void *pData, DWORD cData)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->EmitMacroDefinitions(pData, cData);
+}
+
+HRESULT ICeeFileGen::SetManifestEntry(HCEEFILE ceeFile, ULONG size, ULONG offset)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setManifestEntry(size, offset);
+}
+
+HRESULT ICeeFileGen::SetStrongNameEntry(HCEEFILE ceeFile, ULONG size, ULONG offset)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setStrongNameEntry(size, offset);
+}
+
+HRESULT ICeeFileGen::ComputeSectionOffset(HCEESECTION section, __in char *ptr,
+ unsigned *offset)
+{
+ TESTANDRETURNPOINTER(section);
+
+ CeeSection &sec = *(reinterpret_cast<CeeSection*>(section));
+
+ *offset = sec.computeOffset(ptr);
+
+ return S_OK;
+}
+
+__success(return == S_OK)
+HRESULT ICeeFileGen::ComputeSectionPointer(HCEESECTION section, ULONG offset,
+ __out char **ptr)
+{
+ TESTANDRETURNPOINTER(section);
+
+ CeeSection &sec = *(reinterpret_cast<CeeSection*>(section));
+
+ *ptr = sec.computePointer(offset);
+
+ return S_OK;
+}
+
+HRESULT ICeeFileGen::ComputeOffset(HCEEFILE ceeFile, __in char *ptr,
+ HCEESECTION *pSection, unsigned *offset)
+{
+ TESTANDRETURNPOINTER(pSection);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+
+ CeeSection *section;
+
+ HRESULT hr = gen->computeOffset(ptr, &section, offset);
+
+ if (SUCCEEDED(hr))
+ *pSection = reinterpret_cast<HCEESECTION>(section);
+
+ return hr;
+}
+
+HRESULT ICeeFileGen::SetEnCRVABase(HCEEFILE ceeFile, ULONG dataBase, ULONG rdataBase)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setEnCRvaBase(dataBase, rdataBase);
+}
+
+HRESULT ICeeFileGen::GetCorHeader(HCEEFILE ceeFile,
+ IMAGE_COR20_HEADER **header)
+{
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->getCorHeader(header);
+}
+
+HRESULT ICeeFileGen::SetVTableEntry(HCEEFILE ceeFile, ULONG size, ULONG offset)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setVTableEntry(size, offset);
+}
+
+HRESULT ICeeFileGen::SetVTableEntry64(HCEEFILE ceeFile, ULONG size, void* ptr)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return gen->setVTableEntry64(size, ptr);
+}
+
+HRESULT ICeeFileGen::GetFileTimeStamp (HCEEFILE ceeFile, DWORD *pTimeStamp)
+{
+ TESTANDRETURNPOINTER(ceeFile);
+ TESTANDRETURNPOINTER(pTimeStamp);
+
+ CeeFileGenWriter *gen = reinterpret_cast<CeeFileGenWriter*>(ceeFile);
+ return(gen->getFileTimeStamp(pTimeStamp));
+}
+
diff --git a/src/dlls/mscorpe/mscorpe/mscorpe.def b/src/dlls/mscorpe/mscorpe/mscorpe.def
new file mode 100644
index 0000000000..875abc42a7
--- /dev/null
+++ b/src/dlls/mscorpe/mscorpe/mscorpe.def
@@ -0,0 +1,11 @@
+; 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.
+;
+; mscorpe.def for mscorpe.dll (a simple wrapper around real implementation mscorpehost.dll - see
+; file:wrapper.cpp for more details)
+; PE file generator in EE
+
+EXPORTS
+ CreateICeeFileGen
+ DestroyICeeFileGen
diff --git a/src/dlls/mscorpe/mscorpe/mscorpe.nativeproj b/src/dlls/mscorpe/mscorpe/mscorpe.nativeproj
new file mode 100644
index 0000000000..526cf6088b
--- /dev/null
+++ b/src/dlls/mscorpe/mscorpe/mscorpe.nativeproj
@@ -0,0 +1,46 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <NoCrt>true</NoCrt>
+ <LinkUseCMT>true</LinkUseCMT>
+ <UserIncludes>
+ $(UserIncludes);
+ .
+ </UserIncludes>
+ <CDefines>$(CDefines);__TODO_PORT_TO_WRAPPERS__;UNICODE</CDefines>
+ <OutputName>mscorpe</OutputName>
+ <FileToMarkForSigning>$(BinariesDirectory)\$(OutputName).dll</FileToMarkForSigning>
+ <OutputLibPath>$(IntermediateOutputDirectory)</OutputLibPath>
+ <DllDef>$(OutputName).def</DllDef>
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <PogoOptimized>true</PogoOptimized>
+ <DllEntryPoint>_DllMainCRTStartup</DllEntryPoint>
+ <Win32DllLibs>$(ClrLibPath)\utilcodestaticnohost.lib</Win32DllLibs>
+ <UseMsvcrt>false</UseMsvcrt>
+ <NoLinkGdi32>true</NoLinkGdi32>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <TargetLib Include="$(SdkLibPath)\mscoree.lib" />
+ <TargetLib Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Include="$(SdkLibPath)\uuid.lib" />
+ <TargetLib Include="$(SdkLibPath)\kernel32.lib" />
+ <TargetLib Include="$(SdkLibPath)\advapi32.lib" />
+ <TargetLib Include="$(SdkLibPath)\user32.lib" />
+ <TargetLib Include="$(SdkLibPath)\shlwapi.lib" />
+ <ProjectReference Include="$(ClrSrcDirectory)utilcode\staticnohost\staticnohost.nativeproj"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <RCResourceFile Include="..\Native.rc" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <CppCompile Include="wrapper.cpp" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+</Project>
diff --git a/src/dlls/mscorpe/mscorpe/wrapper.cpp b/src/dlls/mscorpe/mscorpe/wrapper.cpp
new file mode 100644
index 0000000000..d2f1701ec4
--- /dev/null
+++ b/src/dlls/mscorpe/mscorpe/wrapper.cpp
@@ -0,0 +1,149 @@
+// 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: wrapper.cpp
+//
+
+//
+// This file implements a simple wrapper DLL (mscorpe.dll) which calls properly into mscorpehost.dll.
+// It exists because of compatibility with 1.x/2.0 apps running on CLR 4.0+. Such older apps could pass
+// full path to LoadLibrary() Windows API and get this DLL.
+//
+// Noone in CLR should ever try to load this DLL directly (using LoadLibrary API). Note that hosting APIs
+// and PInvoke redirect mscorpe.dll to mscorpehost.dll automatically.
+//
+
+#include <MscorpeSxSWrapper.h>
+
+#include <mscoree.h>
+#include <metahost.h>
+
+// Globals
+HINSTANCE g_hThisInst; // This library.
+
+//*****************************************************************************
+// Handle lifetime of loaded library.
+//*****************************************************************************
+extern "C"
+BOOL WINAPI
+DllMain(
+ HINSTANCE hInstance,
+ DWORD dwReason,
+ LPVOID lpReserved)
+{
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ { // Save the module handle.
+ g_hThisInst = hInstance;
+ DisableThreadLibraryCalls((HMODULE)hInstance);
+ }
+ break;
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+
+ return TRUE;
+} // DllMain
+
+// Implementation for utilcode
+HINSTANCE
+GetModuleInst()
+{
+ return g_hThisInst;
+} // GetModuleInst
+
+// Load correct SxS version of mscorpe.dll and initialize it (uses shim).
+HRESULT
+LoadMscorpe(HMODULE * phModule)
+{
+ HRESULT hr = S_OK;
+ ICLRMetaHost * pMetaHost = NULL;
+ ICLRRuntimeInfo * pCLRRuntimeInfo = NULL;
+
+ // Get full DLL path
+ WCHAR wszPath[_MAX_PATH];
+ DWORD dwLength = GetModuleFileName((HMODULE)g_hThisInst, wszPath, NumItems(wszPath));
+
+ if ((dwLength == 0) ||
+ ((dwLength == NumItems(wszPath)) &&
+ (GetLastError() == ERROR_INSUFFICIENT_BUFFER)))
+ {
+ IfFailGo(CLR_E_SHIM_RUNTIMELOAD);
+ }
+
+ // Find start of '\mscorpe.dll'
+ LPWSTR wszSeparator = wcsrchr(wszPath, L'\\');
+ if (wszSeparator == NULL)
+ {
+ IfFailGo(CLR_E_SHIM_RUNTIMELOAD);
+ }
+ // Check the name of this DLL
+ _ASSERTE(_wcsicmp(wszSeparator, L"\\mscorpe.dll") == 0);
+ // Remove the DLL name
+ *wszSeparator = 0;
+
+ // Find start of last directory name (\<version>),
+ // C:\Windows\Microsoft.NET\Framework\[[v4.0.12345]]\mscorpe.dll
+ LPWSTR wszLastDirectoryName = wcsrchr(wszPath, L'\\');
+ if (wszLastDirectoryName == NULL)
+ {
+ IfFailGo(CLR_E_SHIM_RUNTIMELOAD);
+ }
+ LPWSTR wszVersion = wszLastDirectoryName + 1;
+
+ IfFailGo(CLRCreateInstance(
+ CLSID_CLRMetaHost,
+ IID_ICLRMetaHost,
+ reinterpret_cast<LPVOID *>(&pMetaHost)));
+
+ IfFailGo(pMetaHost->GetRuntime(
+ wszVersion,
+ IID_ICLRRuntimeInfo,
+ reinterpret_cast<LPVOID *>(&pCLRRuntimeInfo)));
+
+ // Shim will load correct SxS version of mscorpe.dll and will initialize it
+ IfFailGo(pCLRRuntimeInfo->LoadLibrary(
+ L"mscorpe.dll",
+ phModule));
+
+ErrExit:
+ if (pMetaHost != NULL)
+ {
+ pMetaHost->Release();
+ pMetaHost = NULL;
+ }
+ if (pCLRRuntimeInfo != NULL)
+ {
+ pCLRRuntimeInfo->Release();
+ pCLRRuntimeInfo = NULL;
+ }
+
+ if (FAILED(hr))
+ {
+ *phModule = NULL;
+ }
+
+ return hr;
+} // LoadMscorpe
+
+// SxS wrapper of mscorpe.dll entrypoints
+typedef MscorpeSxSWrapper<LoadMscorpe> MscorpeSxS;
+
+// Export of 'original' 1.x/2.0 mscorpe.dll
+EXTERN_C
+HRESULT __stdcall
+CreateICeeFileGen(
+ ICeeFileGen ** ppCeeFileGen)
+{
+ return MscorpeSxS::CreateICeeFileGen(ppCeeFileGen);
+}
+
+// Export of 'original' 1.x/2.0 mscorpe.dll
+EXTERN_C
+HRESULT __stdcall
+DestroyICeeFileGen(ICeeFileGen ** ppCeeFileGen)
+{
+ return MscorpeSxS::DestroyICeeFileGen(ppCeeFileGen);
+}
diff --git a/src/dlls/mscorpe/mscorpehost/mscorpehost.def b/src/dlls/mscorpe/mscorpehost/mscorpehost.def
new file mode 100644
index 0000000000..0cf870b17b
--- /dev/null
+++ b/src/dlls/mscorpe/mscorpehost/mscorpehost.def
@@ -0,0 +1,12 @@
+; 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.
+;
+; PeWriter.def for PeWriter.dll
+; PE file generator in EE
+
+EXPORTS
+ CreateICeeFileGen
+ DestroyICeeFileGen
+ InitializeSxS
+
diff --git a/src/dlls/mscorpe/mscorpehost/mscorpehost.nativeproj b/src/dlls/mscorpe/mscorpehost/mscorpehost.nativeproj
new file mode 100644
index 0000000000..45af39f38b
--- /dev/null
+++ b/src/dlls/mscorpe/mscorpehost/mscorpehost.nativeproj
@@ -0,0 +1,68 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <LibCLib>$(ClrCrtLib)</LibCLib>
+ <OutputName>mscorpehost</OutputName>
+ <FileToMarkForSigning>$(BinariesDirectory)\$(OutputName).dll</FileToMarkForSigning>
+ <OutputLibPath>$(IntermediateOutputDirectory)</OutputLibPath>
+ <DllDef>$(OutputName).def</DllDef>
+ <TargetType>DYNLINK</TargetType>
+ <PCHHeader>stdafx.h</PCHHeader>
+ <EnableCxxPCHHeaders>true</EnableCxxPCHHeaders>
+ <PCHCompile>..\stdafx.cpp</PCHCompile>
+ <UserIncludes>
+ $(UserIncludes);
+ .;
+ ../../vm
+ </UserIncludes>
+ <CDefines>$(CDefines);__TODO_PORT_TO_WRAPPERS__;UNICODE</CDefines>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <PogoOptimized>true</PogoOptimized>
+ <DllEntryPoint>_DllMainCRTStartup</DllEntryPoint>
+ <ExtDelayImpLib>false</ExtDelayImpLib>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <LinkDelayLoad Condition="'$(LinkDelayLoad)'!=''">$(LinkDelayLoad);</LinkDelayLoad>
+ <LinkDelayLoad>$(LinkDelayLoad)ole32.dll</LinkDelayLoad>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CppCompile Include="..\utilcodeinit.cpp" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <LinkPreCrtLibs Include="$(ClrLibPath)\utilcode.lib">
+ <ProjectReference>$(ClrSrcDirectory)utilcode\dyncrt\dyncrt.nativeproj</ProjectReference>
+ </LinkPreCrtLibs>
+
+ <TargetLib Include="$(SdkLibPath)\mscoree.lib" />
+ <TargetLib Include="$(ClrLibPath)\ceefgen.lib">
+ <ProjectReference>$(ClrSrcDirectory)md\ceefilegen\ceefgen.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(ClrLibPath)\delayimp.lib">
+ <ProjectReference>$(ClrSrcDirectory)delayimp\delayimp.nativeproj</ProjectReference>
+ </TargetLib>
+ <TargetLib Include="$(SdkLibPath)\ole32.lib" />
+ <TargetLib Include="$(SdkLibPath)\oleaut32.lib" />
+ <TargetLib Include="$(SdkLibPath)\uuid.lib" />
+ <TargetLib Include="$(SdkLibPath)\kernel32.lib" />
+ <TargetLib Include="$(SdkLibPath)\advapi32.lib" />
+ <TargetLib Include="$(SdkLibPath)\user32.lib" />
+ <TargetLib Include="$(SdkLibPath)\shlwapi.lib" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <RCResourceFile Include="..\Native.rc" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <CppCompile Include="..\ICeeFileGen.cpp" />
+ <CppCompile Include="..\CeeFileGenWriter.cpp" />
+ <CppCompile Include="..\PEWriter.cpp" />
+ <CppCompile Include="..\CeeFileGenWriterTokens.cpp" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+</Project>
diff --git a/src/dlls/mscorpe/pewriter.cpp b/src/dlls/mscorpe/pewriter.cpp
new file mode 100644
index 0000000000..f3b5fb194d
--- /dev/null
+++ b/src/dlls/mscorpe/pewriter.cpp
@@ -0,0 +1,2401 @@
+// 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.
+#include "stdafx.h"
+
+#include "blobfetcher.h"
+#include "pedecoder.h"
+
+#ifdef _DEBUG
+#define LOGGING
+#endif
+
+#ifdef LOGGING
+#include "log.h"
+
+static const char* const RelocName[] = {
+ "Absolute", "Unk1", "Unk2", "HighLow", "Unk4", "MapToken",
+ "Relative", "FilePos", "CodeRel", "Movl64", "Dir64", "PcRel25", "PcRel64",
+ "AbsTag" };
+static const char RelocSpaces[] = " ";
+
+static INT64 s_minPcRel25;
+static INT64 s_maxPcRel25;
+#endif
+
+#ifdef EnC_SUPPORTED
+#define ENC_DELTA_HACK
+#endif
+
+ /* This is the stub program that says it can't be run in DOS mode */
+ /* it is x86 specific, but so is dos so I suppose that is OK */
+static const unsigned char x86StubPgm[] = {
+ 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68,
+ 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f,
+ 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20,
+ 0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ /* number of pad bytes to make 'len' bytes align to 'align' */
+inline static unsigned roundUp(unsigned len, unsigned align) {
+ return((len + align-1) & ~(align-1));
+}
+
+inline static unsigned padLen(unsigned len, unsigned align) {
+ return(roundUp(len, align) - len);
+}
+
+inline static bool isExeOrDll(IMAGE_NT_HEADERS* ntHeaders) {
+ return ((ntHeaders->FileHeader.Characteristics & VAL16(IMAGE_FILE_EXECUTABLE_IMAGE)) != 0);
+}
+
+#ifndef IMAGE_DLLCHARACTERISTICS_NO_SEH
+#define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x400
+#endif
+
+#ifndef IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
+#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040
+#endif
+
+#ifndef IMAGE_DLLCHARACTERISTICS_NX_COMPAT
+#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
+#endif
+
+#define COPY_AND_ADVANCE(target, src, size) { \
+ ::memcpy((void *) (target), (const void *) (src), (size)); \
+ (char *&) (target) += (size); }
+
+/******************************************************************/
+int __cdecl relocCmp(const void* a_, const void* b_) {
+
+ const PESectionReloc* a = (const PESectionReloc*) a_;
+ const PESectionReloc* b = (const PESectionReloc*) b_;
+ return (a->offset > b->offset ? 1 : (a->offset == b->offset ? 0 : -1));
+}
+
+PERelocSection::PERelocSection(PEWriterSection *pBaseReloc)
+{
+ section = pBaseReloc;
+ relocPage = (unsigned) -1;
+ relocSize = 0;
+ relocSizeAddr = NULL;
+ pages = 0;
+
+#ifdef _DEBUG
+ lastRVA = 0;
+#endif
+}
+
+void PERelocSection::AddBaseReloc(unsigned rva, int type, unsigned short highAdj)
+{
+#ifdef _DEBUG
+ // Guarantee that we're adding relocs in strict increasing order.
+ _ASSERTE(rva > lastRVA);
+ lastRVA = rva;
+#endif
+
+ if (relocPage != (rva & ~0xFFF)) {
+ if (relocSizeAddr) {
+ if ((relocSize & 1) == 1) { // pad to an even number
+ short *ps = (short*) section->getBlock(2);
+ if(ps) {
+ *ps = 0;
+ relocSize++;
+ }
+ }
+ *relocSizeAddr = VAL32(relocSize*2 + sizeof(IMAGE_BASE_RELOCATION));
+ }
+ IMAGE_BASE_RELOCATION* base = (IMAGE_BASE_RELOCATION*) section->getBlock(sizeof(IMAGE_BASE_RELOCATION));
+ if(base) {
+ relocPage = (rva & ~0xFFF);
+ relocSize = 0;
+ base->VirtualAddress = VAL32(relocPage);
+ // Size needs to be fixed up when we know it - save address here
+ relocSizeAddr = &base->SizeOfBlock;
+ pages++;
+ }
+ }
+
+ relocSize++;
+ unsigned short* offset = (unsigned short*) section->getBlock(2);
+ if(offset) {
+ *offset = VAL16((rva & 0xFFF) | (type << 12));
+ }
+}
+
+void PERelocSection::Finish(bool isPE32)
+{
+ // fixup the last reloc block (if there was one)
+ if (relocSizeAddr) {
+ if ((relocSize & 1) == 1) { // pad to an even number
+ short* psh = (short*) section->getBlock(2);
+ if(psh)
+ {
+ *psh = 0;
+ relocSize++;
+ }
+ }
+ *relocSizeAddr = VAL32(relocSize*2 + sizeof(IMAGE_BASE_RELOCATION));
+ }
+}
+
+#define GET_UNALIGNED_INT32(_ptr) ((INT32) GET_UNALIGNED_VAL32(_ptr))
+
+static inline HRESULT SignedFitsIn31Bits(INT64 immediate)
+{
+ INT64 hiBits = immediate >> 31;
+ if ((hiBits == 0) || (hiBits == -1))
+ {
+ return S_OK;
+ }
+ else
+ {
+ return E_FAIL;
+ }
+}
+
+static inline HRESULT UnsignedFitsIn32Bits(UINT64 immediate)
+{
+ UINT64 hiBits = immediate >> 32;
+ if (hiBits == 0)
+ {
+ return S_OK;
+ }
+ else
+ {
+ return E_FAIL;
+ }
+}
+
+static inline HRESULT AddOvf_RVA(DWORD& a, DWORD b)
+{
+ DWORD r = a + b;
+ if (r < a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+static inline HRESULT AddOvf_S_U32(INT64 & a, unsigned int b)
+{
+ INT64 r = a + b;
+ if (r < a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+static inline HRESULT AddOvf_S_S32(INT64 & a, int b)
+{
+ INT64 r = a + b;
+ if ( ((r >= a) && (b >= 0)) ||
+ ((r < a) && (b < 0)) )
+ {
+ a = r;
+ return S_OK;
+ }
+ return E_FAIL;
+}
+
+static inline HRESULT AddOvf_U_U32(UINT64 & a, unsigned int b)
+{
+ UINT64 r = a + b;
+ if (r < a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+static inline HRESULT AddOvf_U_U(UINT64 & a, UINT64 b)
+{
+ UINT64 r = a + b;
+ if (r < a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+static inline HRESULT SubOvf_S_U32(INT64 & a, unsigned int b)
+{
+ INT64 r = a - b;
+ if (r > a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+static inline HRESULT SubOvf_S_U(INT64 & a, UINT64 b)
+{
+ INT64 r = a - b;
+ if (r > a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+static inline HRESULT SubOvf_U_U32(UINT64 & a, unsigned int b)
+{
+ UINT64 r = a - b;
+ if (r > a) // Check for overflow
+ return E_FAIL;
+ a = r;
+ return S_OK;
+}
+
+#ifndef _AMD64_
+/* subtract two unsigned pointers yeilding a signed pointer sized int */
+static inline HRESULT SubOvf_U_U(INT64 & r, UINT64 a, UINT64 b)
+{
+ r = a - b;
+ if ( ((a >= b) && (r >= 0)) ||
+ ((a < b) && (r < 0)))
+ {
+ return S_OK;
+ }
+ return E_FAIL;
+}
+#endif
+
+
+/******************************************************************/
+/* apply the relocs for this section.
+*/
+
+HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
+ PERelocSection * pBaseRelocSection,
+ CeeGenTokenMapper * pTokenMapper,
+ DWORD dataRvaBase,
+ DWORD rdataRvaBase,
+ DWORD codeRvaBase)
+{
+ HRESULT hr;
+
+ _ASSERTE(pBaseRelocSection); // need section to write relocs
+
+#ifdef LOGGING
+ // Ensure that if someone adds a value to CeeSectionRelocType in cor.h,
+ // that they also add an entry to RelocName.
+ static_assert_no_msg(NumItems(RelocName) == srRelocSentinel);
+#ifdef _DEBUG
+ for (unsigned int i = 0; i < srRelocSentinel; i++)
+ {
+ _ASSERTE(strlen(RelocName[i]) <= strlen(RelocSpaces));
+ }
+#endif // _DEBUG
+#endif // LOGGING
+
+ if (m_relocCur == m_relocStart)
+ return S_OK;
+
+ bool isPE32 = (pNtHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC));
+
+#ifdef LOGGING
+ LOG((LF_ZAP, LL_INFO100000,
+ "APPLYING section relocs for section %s start RVA = 0x%x\n",
+ m_name, m_baseRVA));
+#endif
+
+ UINT64 imageBase = isPE32 ? VAL32(((IMAGE_NT_HEADERS32 *) pNtHeaders)->OptionalHeader.ImageBase)
+ : VAL64(((IMAGE_NT_HEADERS64 *) pNtHeaders)->OptionalHeader.ImageBase);
+
+ // sort them to make the baseRelocs pretty
+ qsort(m_relocStart, (m_relocCur - m_relocStart), sizeof(PESectionReloc), relocCmp);
+
+ for (PESectionReloc * cur = m_relocStart; cur < m_relocCur; cur++)
+ {
+ _ASSERTE((cur->offset + 4) <= m_blobFetcher.GetDataLen());
+
+ int curType = cur->type;
+ DWORD curOffset = cur->offset;
+ bool isRelocPtr = ((curType & srRelocPtr) != 0);
+ bool noBaseBaseReloc = ((curType & srNoBaseReloc) != 0);
+ UINT64 targetOffset = 0;
+ int slotNum = 0;
+ INT64 oldStarPos;
+
+ // If cur->section is NULL then this is a pointer outside the module.
+ bool externalAddress = (cur->section == NULL);
+
+ curType &= ~(srRelocPtr | srNoBaseReloc);
+
+ /* If we see any srRelocHighLow's in a PE64 file we convert them into DIR64 relocs */
+ if (!isPE32 && (curType == srRelocHighLow))
+ curType = srRelocDir64;
+
+ /* If we have an IA64 instruction fixup then extract the slot number and adjust curOffset */
+ if ((curType == srRelocIA64PcRel25) || (curType == srRelocIA64Imm64) || (curType == srRelocIA64PcRel64))
+ {
+ _ASSERTE((curOffset & 0x3) == 0);
+ slotNum = (curOffset & 0xf) >> 2;
+ curOffset &= ~0xf;
+ }
+
+ DWORD curRVA = m_baseRVA; // RVA in the PE image of the reloc site
+ IfFailRet(AddOvf_RVA(curRVA, curOffset));
+ DWORD UNALIGNED * pos = (DWORD *) m_blobFetcher.ComputePointer(curOffset);
+
+ PREFIX_ASSUME(pos != NULL);
+
+#ifdef LOGGING
+ LOG((LF_ZAP, LL_INFO1000000,
+ " Reloc %s%s%s at %-7s+%04x (RVA=%08x) at" FMT_ADDR,
+ RelocName[curType], (isRelocPtr) ? "Ptr" : " ",
+ &RelocSpaces[strlen(RelocName[curType])],
+ m_name, curOffset, curRVA, DBG_ADDR(pos)));
+#endif
+ //
+ // 'pos' is the site of the reloc
+ // Compute 'targetOffset' from pointer if necessary
+ //
+
+ if (isRelocPtr)
+ {
+ // Calculate the value of ptr to pass to computeOffset
+ char * ptr = (char *) pos;
+
+ if (curType == srRelocRelative) {
+ //
+ // Here we add sizeof(int) because we need to calculate
+ // ptr as the true call target address (x86 pc-rel)
+ // We need to true call target address since pass it
+ // to computeOffset and this function would fall if
+ // the address we pass is before the start of a section
+ //
+ oldStarPos = (SSIZE_T) ptr;
+ IfFailRet(AddOvf_S_S32(oldStarPos, GET_UNALIGNED_INT32(pos)));
+ IfFailRet(AddOvf_S_U32(oldStarPos, sizeof(int)));
+ ptr = (char *) oldStarPos;
+ targetOffset = externalAddress ? (size_t) ptr
+ : cur->section->computeOffset(ptr);
+ // We subtract off the four bytes that we added previous
+ // since the code below depends upon this
+ IfFailRet(SubOvf_U_U32(targetOffset, sizeof(int)));
+ IfFailRet(UnsignedFitsIn32Bits(targetOffset)); // Check for overflow
+ SET_UNALIGNED_VAL32(pos, targetOffset);
+ }
+ else if (curType == srRelocIA64Imm64) {
+ _ASSERTE(slotNum == 1);
+ ptr = (char *) ((intptr_t) GetIA64Imm64((UINT64 *) ptr));
+ oldStarPos = (SSIZE_T) ptr;
+ targetOffset = externalAddress ? (size_t) ptr
+ : cur->section->computeOffset(ptr);
+ _ASSERTE(!isPE32);
+ PutIA64Imm64((UINT64 *)pos, targetOffset);
+ }
+ else if (curType == srRelocIA64PcRel64) {
+ _ASSERTE(slotNum == 1);
+ ptr = (char *) ((intptr_t) GetIA64Rel64((UINT64 *) ptr));
+ oldStarPos = (SSIZE_T) ptr;
+ targetOffset = externalAddress ? (size_t) ptr
+ : cur->section->computeOffset(ptr);
+ _ASSERTE(!isPE32);
+ PutIA64Rel64((UINT64 *)pos, targetOffset);
+ }
+ else {
+ _ASSERTE(curType != srRelocIA64PcRel25);
+ ptr = (char *) GET_UNALIGNED_VALPTR(ptr);
+ oldStarPos = (SSIZE_T) ptr;
+ targetOffset = externalAddress ? (size_t) ptr
+ : cur->section->computeOffset(ptr);
+ IfFailRet(UnsignedFitsIn32Bits(targetOffset)); // Check for overflow
+ SET_UNALIGNED_VAL32(pos, targetOffset);
+ /* Zero the upper 32-bits for a machine with 64-bit pointers */
+ if (!isPE32)
+ SET_UNALIGNED_VAL32(pos+1, 0);
+ }
+ }
+#ifdef LOGGING
+ else
+ {
+ if (curType == srRelocIA64PcRel25)
+ {
+ oldStarPos = GetIA64Rel25((UINT64 *) pos, slotNum);
+ }
+ else
+ {
+ if (curType == srRelocIA64PcRel64)
+ {
+ _ASSERTE(slotNum == 1);
+ oldStarPos = GetIA64Rel64((UINT64 *) pos);
+ }
+ else if (curType == srRelocIA64Imm64)
+ {
+ oldStarPos = GetIA64Imm64((UINT64 *)pos);
+ }
+ else
+ {
+ oldStarPos = GET_UNALIGNED_VAL32(pos);
+ }
+ }
+ }
+#endif
+
+ //
+ // 'targetOffset' has now been computed. Write out the appropriate value.
+ // Record base relocs as necessary.
+ //
+
+ bool fBaseReloc = false;
+ bool fNeedBrl = false;
+ INT64 newStarPos = 0; // oldStarPos gets updated to newStarPos
+
+ if (curType == srRelocAbsolute || curType == srRelocAbsoluteTagged) {
+ _ASSERTE(!externalAddress);
+
+ newStarPos = GET_UNALIGNED_INT32(pos);
+
+ if (curType == srRelocAbsoluteTagged)
+ newStarPos = (newStarPos & ~0x80000001) >> 1;
+
+ if (rdataRvaBase > 0 && ! strcmp((const char *)(cur->section->m_name), ".rdata"))
+ IfFailRet(AddOvf_S_U32(newStarPos, rdataRvaBase));
+ else if (dataRvaBase > 0 && ! strcmp((const char *)(cur->section->m_name), ".data"))
+ IfFailRet(AddOvf_S_U32(newStarPos, dataRvaBase));
+ else
+ IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
+
+ if (curType == srRelocAbsoluteTagged)
+ newStarPos = (newStarPos << 1) | 0x80000001;
+
+ SET_UNALIGNED_VAL32(pos, newStarPos);
+ }
+ else if (curType == srRelocMapToken)
+ {
+ mdToken newToken;
+ if (pTokenMapper != NULL && pTokenMapper->HasTokenMoved((mdToken)GET_UNALIGNED_VAL32(pos), newToken)) {
+ // we have a mapped token
+ SET_UNALIGNED_VAL32(pos, newToken);
+ }
+ newStarPos = GET_UNALIGNED_VAL32(pos);
+ }
+ else if (curType == srRelocFilePos)
+ {
+ _ASSERTE(!externalAddress);
+ newStarPos = GET_UNALIGNED_VAL32(pos);
+ IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_filePos));
+ SET_UNALIGNED_VAL32(pos, newStarPos);
+ }
+ else if (curType == srRelocRelative)
+ {
+ if (externalAddress) {
+#if defined(_AMD64_)
+ newStarPos = GET_UNALIGNED_INT32(pos);
+#else // x86
+ UINT64 targetAddr = GET_UNALIGNED_VAL32(pos);
+ IfFailRet(SubOvf_U_U(newStarPos, targetAddr, imageBase));
+#endif
+ }
+ else {
+ newStarPos = GET_UNALIGNED_INT32(pos);
+ IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
+ }
+ IfFailRet(SubOvf_S_U32(newStarPos, curRVA));
+ IfFailRet(SignedFitsIn31Bits(newStarPos)); // Check for overflow
+ SET_UNALIGNED_VAL32(pos, newStarPos);
+ }
+ else if (curType == srRelocCodeRelative)
+ {
+ newStarPos = GET_UNALIGNED_INT32(pos);
+ IfFailRet(SubOvf_S_U32(newStarPos, codeRvaBase));
+ if (externalAddress)
+ IfFailRet(SubOvf_S_U(newStarPos, imageBase));
+ else
+ IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
+ IfFailRet(SignedFitsIn31Bits(newStarPos)); // Check for overflow
+ SET_UNALIGNED_VAL32(pos, newStarPos);
+
+ }
+ else if (curType == srRelocIA64PcRel25)
+ {
+ _ASSERTE((m_baseRVA & 15) == 0);
+ _ASSERTE((cur->section->m_baseRVA & 15) == 0);
+
+ newStarPos = GetIA64Rel25((UINT64 *) pos, slotNum);
+ IfFailRet(SubOvf_S_U32(newStarPos, curRVA));
+ if (externalAddress)
+ IfFailRet(SubOvf_S_U(newStarPos, imageBase));
+ else
+ IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
+
+ INT64 hiBits = newStarPos >> 24;
+
+ _ASSERTE((hiBits==0) || (hiBits==-1));
+
+ IfFailRet(AddOvf_S_U32(newStarPos, GetIA64Rel25((UINT64 *) pos, slotNum)));
+
+ hiBits = newStarPos >> 24;
+
+ _ASSERTE((hiBits==0) || (hiBits==-1));
+
+ INT32 delta32 = (INT32) newStarPos;
+
+ PutIA64Rel25((UINT64 *) pos, slotNum, delta32);
+
+ _ASSERTE(GetIA64Rel25((UINT64 *) pos, slotNum) == delta32);
+
+#ifdef LOGGING
+ if (newStarPos < s_minPcRel25)
+ s_minPcRel25 = newStarPos;
+ if (newStarPos > s_maxPcRel25)
+ s_maxPcRel25 = newStarPos;
+#endif
+ }
+ else if (curType == srRelocIA64PcRel64)
+ {
+ _ASSERTE((m_baseRVA & 15) == 0);
+ _ASSERTE(slotNum == 1);
+
+ newStarPos = GetIA64Rel64((UINT64 *) pos);
+ IfFailRet(SubOvf_S_U32(newStarPos, m_baseRVA));
+
+ if (externalAddress)
+ IfFailRet(SubOvf_S_U(newStarPos, imageBase));
+ else
+ {
+ _ASSERTE((cur->section->m_baseRVA & 15) == 0);
+ IfFailRet(AddOvf_S_U32(newStarPos, cur->section->m_baseRVA));
+ }
+
+ INT64 hiBits = newStarPos >> 24;
+
+ fNeedBrl = (hiBits != 0) && (hiBits != -1);
+
+ /* Can we convert the brl.call into a br.call? */
+ if (!fNeedBrl)
+ {
+ INT32 delta32 = (INT32) newStarPos;
+
+ UINT64 temp0 = ((UINT64 *) pos)[0];
+ UINT64 temp1 = ((UINT64 *) pos)[1];
+#ifdef _DEBUG
+ //
+ // make certain we're decoding a brl opcode, with template 4 or 5
+ //
+ UINT64 templa = (temp0 >> 0) & 0x1f;
+ UINT64 opcode = (temp1 >> 60) & 0xf;
+
+ _ASSERTE(((opcode == 0xC) || (opcode == 0xD)) &&
+ ((templa == 0x4) || (templa == 0x5)));
+#endif
+ const UINT64 mask0 = UI64(0x00003FFFFFFFFFE1);
+ const UINT64 mask1 = UI64(0x7700000FFF800000);
+
+ /* Clear all bits used as part of the slot1 and slot2 */
+ temp0 &= mask0; // opcode becomes 4 or 5
+ temp1 &= mask1;
+
+ temp0 |= 0x10; // template becomes 0x10 or 0x11
+ temp1 |= 0x200; // slot 1 becomes nop.i
+
+ ((UINT64 *) pos)[0] = temp0;
+ ((UINT64 *) pos)[1] = temp1;
+
+ PutIA64Rel25((UINT64 *) pos, 2, delta32);
+ _ASSERTE(GetIA64Rel25((UINT64 *) pos, 2) == delta32);
+ }
+ else
+ {
+ PutIA64Rel64((UINT64 *) pos, newStarPos);
+ _ASSERTE(GetIA64Rel64((UINT64 *) pos) == newStarPos);
+ }
+ }
+ else if (curType == srRelocHighLow)
+ {
+ _ASSERTE(isPE32);
+
+ // we have a 32-bit value at pos
+ UINT64 value = GET_UNALIGNED_VAL32(pos);
+
+ if (!externalAddress)
+ {
+ IfFailRet(AddOvf_U_U32(value, cur->section->m_baseRVA));
+ IfFailRet(AddOvf_U_U(value, imageBase));
+ }
+
+ IfFailRet(UnsignedFitsIn32Bits(value)); // Check for overflow
+ SET_UNALIGNED_VAL32(pos, value);
+
+ newStarPos = value;
+
+ fBaseReloc = true;
+ }
+ else if (curType == srRelocDir64)
+ {
+ _ASSERTE(!isPE32);
+
+ // we have a 64-bit value at pos
+ UINT64 UNALIGNED * p_value = (UINT64 *) pos;
+ targetOffset = *p_value;
+
+ if (!externalAddress)
+ {
+ // The upper bits of targetOffset must be zero
+ IfFailRet(UnsignedFitsIn32Bits(targetOffset));
+
+ IfFailRet(AddOvf_U_U32(targetOffset, cur->section->m_baseRVA));
+ IfFailRet(AddOvf_U_U(targetOffset, imageBase));
+ }
+
+ *p_value = targetOffset;
+ newStarPos = targetOffset;
+ fBaseReloc = true;
+ }
+ else if (curType == srRelocIA64Imm64)
+ {
+ _ASSERTE(!isPE32);
+ _ASSERTE((curRVA & 15) == 0); // This reloc should be 16-byte aligned
+
+ // we have a 64-bit value encoded in the instruction at pos
+ targetOffset = GetIA64Imm64((UINT64 *)pos);
+
+ if (!externalAddress)
+ {
+ // The upper bits of targetOffset must be zero
+ IfFailRet(UnsignedFitsIn32Bits(targetOffset));
+
+ IfFailRet(AddOvf_U_U32(targetOffset, cur->section->m_baseRVA));
+ IfFailRet(AddOvf_U_U(targetOffset, imageBase));
+ }
+
+ PutIA64Imm64((UINT64 *)pos, targetOffset);
+ newStarPos = targetOffset;
+ fBaseReloc = true;
+ }
+ else
+ {
+ _ASSERTE(!"Unknown Relocation type");
+ }
+
+ if (fBaseReloc && !noBaseBaseReloc)
+ {
+ pBaseRelocSection->AddBaseReloc(curRVA, curType);
+ }
+
+#ifdef LOGGING
+ const char* sectionName;
+
+ if (externalAddress)
+ {
+ sectionName = "external";
+ }
+ else
+ {
+ sectionName = cur->section->m_name;
+ }
+
+ LOG((LF_ZAP, LL_INFO1000000,
+ "to %-7s+%04x, old =" FMT_ADDR "new =" FMT_ADDR "%s%s\n",
+ sectionName, targetOffset,
+ DBG_ADDR(oldStarPos), DBG_ADDR(newStarPos),
+ fBaseReloc ? "(BASE RELOC)" : "",
+ fNeedBrl ? "(BRL)" : "" ));
+#endif
+
+ }
+ return S_OK;
+}
+
+/******************************************************************/
+
+PESeedSection::PESeedSection(PEDecoder * peDecoder,
+ IMAGE_SECTION_HEADER * seedSection)
+ : PEWriterSection((const char *)seedSection->Name,
+ VAL32(seedSection->Characteristics),
+ VAL32(seedSection->SizeOfRawData),
+ 0),
+ m_pSeedFileDecoder(peDecoder),
+ m_pSeedSectionHeader(seedSection)
+{
+ m_baseRVA = VAL32(seedSection->VirtualAddress);
+}
+
+HRESULT PESeedSection::write(HANDLE file) {
+ ULONG sizeOfSection = VAL32(m_pSeedSectionHeader->SizeOfRawData);
+ LPCVOID sectionData = PBYTE(m_pSeedFileDecoder->GetBase()) + m_pSeedSectionHeader->PointerToRawData;
+
+ DWORD dwWritten = 0;
+ if (!WriteFile(file, sectionData, sizeOfSection, &dwWritten, NULL)) {
+ return HRESULT_FROM_GetLastError();
+ }
+ _ASSERTE(dwWritten == sizeOfSection);
+ return S_OK;
+}
+
+unsigned PESeedSection::writeMem(void ** pMem) {
+ ULONG sizeOfSection = VAL32(m_pSeedSectionHeader->SizeOfRawData);
+ LPCVOID sectionData = PBYTE(m_pSeedFileDecoder->GetBase()) + m_pSeedSectionHeader->PointerToRawData;
+
+ COPY_AND_ADVANCE(*pMem, sectionData, sizeOfSection);
+ return sizeOfSection;
+}
+
+/******************************************************************/
+HRESULT PEWriter::Init(PESectionMan *pFrom, DWORD createFlags, LPCWSTR seedFileName)
+{
+ if (pFrom)
+ *(PESectionMan*)this = *pFrom;
+ else {
+ HRESULT hr = PESectionMan::Init();
+ if (FAILED(hr))
+ return hr;
+ }
+ time_t now;
+ time(&now);
+
+#ifdef LOGGING
+ InitializeLogging();
+#endif
+
+ // Save the timestamp so that we can give it out if someone needs
+ // it.
+ m_peFileTimeStamp = (DWORD) now;
+
+ // We must be creating either a PE32 or a PE64 file
+ if (createFlags & ICEE_CREATE_FILE_PE64)
+ {
+ m_ntHeaders = (IMAGE_NT_HEADERS *) new (nothrow) IMAGE_NT_HEADERS64;
+ m_ntHeadersSize = sizeof(IMAGE_NT_HEADERS64);
+
+ if (!m_ntHeaders) return E_OUTOFMEMORY;
+ memset(m_ntHeaders, 0, m_ntHeadersSize);
+
+ m_ntHeaders->OptionalHeader.Magic = VAL16(IMAGE_NT_OPTIONAL_HDR64_MAGIC);
+ m_ntHeaders->FileHeader.SizeOfOptionalHeader = VAL16(sizeof(IMAGE_OPTIONAL_HEADER64));
+ }
+ else
+ {
+ _ASSERTE(createFlags & ICEE_CREATE_FILE_PE32);
+ m_ntHeaders = (IMAGE_NT_HEADERS *) new (nothrow) IMAGE_NT_HEADERS32;
+ m_ntHeadersSize = sizeof(IMAGE_NT_HEADERS32);
+
+ if (!m_ntHeaders) return E_OUTOFMEMORY;
+ memset(m_ntHeaders, 0, m_ntHeadersSize);
+
+ m_ntHeaders->OptionalHeader.Magic = VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC);
+ m_ntHeaders->FileHeader.SizeOfOptionalHeader = VAL16(sizeof(IMAGE_OPTIONAL_HEADER32));
+ }
+
+ // Record whether we should create the CorExeMain and CorDllMain stubs
+ m_createCorMainStub = ((createFlags & ICEE_CREATE_FILE_CORMAIN_STUB) != 0);
+
+ // We must have a valid target machine selected
+ if ((createFlags & ICEE_CREATE_MACHINE_MASK) == ICEE_CREATE_MACHINE_I386)
+ {
+ m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_I386);
+ }
+ else if ((createFlags & ICEE_CREATE_MACHINE_MASK) == ICEE_CREATE_MACHINE_IA64)
+ {
+ m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_IA64);
+ }
+ else if ((createFlags & ICEE_CREATE_MACHINE_MASK) == ICEE_CREATE_MACHINE_AMD64)
+ {
+ m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_AMD64);
+ }
+ else if ((createFlags & ICEE_CREATE_MACHINE_MASK) == ICEE_CREATE_MACHINE_ARM)
+ {
+ m_ntHeaders->FileHeader.Machine = VAL16(IMAGE_FILE_MACHINE_ARMNT);
+
+ // The OS loader already knows how to initialize pure managed assemblies and we have no legacy OS
+ // support to worry about on ARM so don't ever create the stub for ARM binaries.
+ m_createCorMainStub = false;
+ }
+ else
+ {
+ _ASSERTE(!"Invalid target machine");
+ }
+
+ cEntries = IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR + 1;
+ pEntries = new (nothrow) directoryEntry[cEntries];
+ if (pEntries == NULL) return E_OUTOFMEMORY;
+ memset(pEntries, 0, sizeof(*pEntries) * cEntries);
+
+ m_ntHeaders->Signature = VAL32(IMAGE_NT_SIGNATURE);
+ m_ntHeaders->FileHeader.TimeDateStamp = VAL32((ULONG) now);
+ m_ntHeaders->FileHeader.Characteristics = VAL16(0);
+
+ if (createFlags & ICEE_CREATE_FILE_STRIP_RELOCS)
+ {
+ m_ntHeaders->FileHeader.Characteristics |= VAL16(IMAGE_FILE_RELOCS_STRIPPED);
+ }
+
+ // Linker version should be consistent with current VC level
+ m_ntHeaders->OptionalHeader.MajorLinkerVersion = 11;
+ m_ntHeaders->OptionalHeader.MinorLinkerVersion = 0;
+
+ m_ntHeaders->OptionalHeader.SectionAlignment = VAL32(IMAGE_NT_OPTIONAL_HDR_SECTION_ALIGNMENT);
+ m_ntHeaders->OptionalHeader.FileAlignment = VAL32(0);
+ m_ntHeaders->OptionalHeader.AddressOfEntryPoint = VAL32(0);
+
+ m_ntHeaders->OptionalHeader.MajorOperatingSystemVersion = VAL16(4);
+ m_ntHeaders->OptionalHeader.MinorOperatingSystemVersion = VAL16(0);
+
+ m_ntHeaders->OptionalHeader.MajorImageVersion = VAL16(0);
+ m_ntHeaders->OptionalHeader.MinorImageVersion = VAL16(0);
+ m_ntHeaders->OptionalHeader.MajorSubsystemVersion = VAL16(4);
+ m_ntHeaders->OptionalHeader.MinorSubsystemVersion = VAL16(0);
+ m_ntHeaders->OptionalHeader.Win32VersionValue = VAL32(0);
+ m_ntHeaders->OptionalHeader.Subsystem = VAL16(0);
+ m_ntHeaders->OptionalHeader.DllCharacteristics = VAL16(0);
+ m_ntHeaders->OptionalHeader.CheckSum = VAL32(0);
+ setDllCharacteristics(IMAGE_DLLCHARACTERISTICS_NO_SEH |
+ IMAGE_DLLCHARACTERISTICS_NX_COMPAT |
+ IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE |
+ IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE);
+
+ if (isPE32())
+ {
+ IMAGE_NT_HEADERS32* p_ntHeaders32 = ntHeaders32();
+ p_ntHeaders32->OptionalHeader.ImageBase = VAL32(CEE_IMAGE_BASE_32);
+ p_ntHeaders32->OptionalHeader.SizeOfStackReserve = VAL32(0x100000);
+ p_ntHeaders32->OptionalHeader.SizeOfStackCommit = VAL32(0x1000);
+ p_ntHeaders32->OptionalHeader.SizeOfHeapReserve = VAL32(0x100000);
+ p_ntHeaders32->OptionalHeader.SizeOfHeapCommit = VAL32(0x1000);
+ p_ntHeaders32->OptionalHeader.LoaderFlags = VAL32(0);
+ p_ntHeaders32->OptionalHeader.NumberOfRvaAndSizes = VAL32(16);
+ }
+ else
+ {
+ IMAGE_NT_HEADERS64* p_ntHeaders64 = ntHeaders64();
+ // FIX what are the correct values for PE+ (64-bit) ?
+ p_ntHeaders64->OptionalHeader.ImageBase = VAL64(CEE_IMAGE_BASE_64);
+ p_ntHeaders64->OptionalHeader.SizeOfStackReserve = VAL64(0x400000);
+ p_ntHeaders64->OptionalHeader.SizeOfStackCommit = VAL64(0x4000);
+ p_ntHeaders64->OptionalHeader.SizeOfHeapReserve = VAL64(0x100000);
+ p_ntHeaders64->OptionalHeader.SizeOfHeapCommit = VAL64(0x2000);
+ p_ntHeaders64->OptionalHeader.LoaderFlags = VAL32(0);
+ p_ntHeaders64->OptionalHeader.NumberOfRvaAndSizes = VAL32(16);
+ }
+
+ m_ilRVA = (DWORD) -1;
+ m_dataRvaBase = 0;
+ m_rdataRvaBase = 0;
+ m_codeRvaBase = 0;
+ m_encMode = FALSE;
+
+ virtualPos = 0;
+ filePos = 0;
+ reloc = NULL;
+ strtab = NULL;
+ headers = NULL;
+ headersEnd = NULL;
+
+ m_file = INVALID_HANDLE_VALUE;
+
+ //
+ // Seed file
+ //
+
+ m_hSeedFile = INVALID_HANDLE_VALUE;
+ m_hSeedFileMap = INVALID_HANDLE_VALUE;
+ m_pSeedFileDecoder = NULL;
+ m_iSeedSections = 0;
+ m_pSeedSectionToAdd = NULL;
+
+ if (seedFileName)
+ {
+ HandleHolder hFile (WszCreateFile(seedFileName,
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
+ NULL));
+
+ if (hFile == INVALID_HANDLE_VALUE)
+ return HRESULT_FROM_GetLastError();
+
+ MapViewHolder hMapFile (WszCreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL));
+ DWORD dwFileLen = SafeGetFileSize(hFile, 0);
+ if (dwFileLen == 0xffffffff)
+ return HRESULT_FROM_GetLastError();
+
+ if (hMapFile == NULL)
+ return HRESULT_FROM_GetLastError();
+
+ BYTE * baseFileView = (BYTE*) MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
+
+ PEDecoder * pPEDecoder = new (nothrow) PEDecoder(baseFileView, (COUNT_T)dwFileLen);
+ if (pPEDecoder == NULL) return E_OUTOFMEMORY;
+
+ if (pPEDecoder->Has32BitNTHeaders())
+ {
+ if ((createFlags & ICEE_CREATE_FILE_PE32) == 0)
+ return E_FAIL;
+
+ setImageBase32(DWORD(size_t(pPEDecoder->GetPreferredBase())));
+ }
+ else
+ {
+ if ((createFlags & ICEE_CREATE_FILE_PE64) == 0)
+ return E_FAIL;
+
+ setImageBase64(UINT64((intptr_t) pPEDecoder->GetPreferredBase()));
+ }
+
+ setFileAlignment (VAL32(pPEDecoder->GetFileAlignment()));
+ setSectionAlignment(VAL32(pPEDecoder->GetSectionAlignment()));
+
+ hFile.SuppressRelease();
+ hMapFile.SuppressRelease();
+
+ m_hSeedFile = hFile;
+ m_hSeedFileMap = hMapFile;
+ m_pSeedFileDecoder = pPEDecoder;
+
+#ifdef _WIN64
+ m_pSeedFileNTHeaders = pPEDecoder->GetNTHeaders64();
+#else
+ m_pSeedFileNTHeaders = pPEDecoder->GetNTHeaders32();
+#endif
+
+ // Add the seed sections
+
+ m_pSeedSections = m_pSeedFileDecoder->FindFirstSection();
+
+ m_pSeedSectionToAdd = m_pSeedSections;
+ m_iSeedSections = m_pSeedFileDecoder->GetNumberOfSections();
+
+ for (unsigned i = 0; i < m_iSeedSections; m_pSeedSectionToAdd++, i++) {
+ PESection * dummy;
+ getSectionCreate((const char *)(m_pSeedSectionToAdd->Name),
+ VAL32(m_pSeedSectionToAdd->Characteristics),
+ &dummy);
+ }
+
+ m_pSeedSectionToAdd = NULL;
+ }
+
+ return S_OK;
+}
+
+/******************************************************************/
+HRESULT PEWriter::Cleanup() {
+
+ if (m_hSeedFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(m_hSeedFile);
+ CloseHandle(m_hSeedFileMap);
+ delete m_pSeedFileDecoder;
+ }
+
+ if (isPE32())
+ {
+ delete ntHeaders32();
+ }
+ else
+ {
+ delete ntHeaders64();
+ }
+
+ if (headers != NULL)
+ delete [] headers;
+
+ if (pEntries != NULL)
+ delete [] pEntries;
+
+ return PESectionMan::Cleanup();
+}
+
+PESection* PEWriter::getSection(const char* name)
+{
+ int len = (int)strlen(name);
+
+ // the section name can be at most 8 characters including the null.
+ if (len < 8)
+ len++;
+ else
+ len = 8;
+
+ // dbPrintf(("looking for section %s\n", name));
+ // Skip over the seed sections
+
+ for(PESection** cur = sectStart+m_iSeedSections; cur < sectCur; cur++) {
+ // dbPrintf(("searching section %s\n", (*cur)->m_ame));
+ if (strncmp((*cur)->m_name, name, len) == 0) {
+ // dbPrintf(("found section %s\n", (*cur)->m_name));
+ return(*cur);
+ }
+ }
+ return(0);
+}
+
+HRESULT PEWriter::newSection(const char* name, PESection **section,
+ unsigned flags, unsigned estSize,
+ unsigned estRelocs)
+{
+ if (m_pSeedSectionToAdd) {
+ _ASSERTE(strcmp((const char *)(m_pSeedSectionToAdd->Name), name) == 0 &&
+ VAL32(m_pSeedSectionToAdd->Characteristics) == flags);
+
+ PESeedSection * ret = new (nothrow) PESeedSection(m_pSeedFileDecoder, m_pSeedSectionToAdd);
+ *section = ret;
+ TESTANDRETURNMEMORY(ret);
+ return S_OK;
+ }
+
+ PEWriterSection * ret = new (nothrow) PEWriterSection(name, flags, estSize, estRelocs);
+ *section = ret;
+ TESTANDRETURNMEMORY(ret);
+ return S_OK;
+}
+
+ULONG PEWriter::getIlRva()
+{
+ // assume that pe optional header is less than size of section alignment. So this
+ // gives out the rva for the .text section, which is merged after the .text0 section
+ // This is verified in debug build when actually write out the file
+ _ASSERTE(m_ilRVA > 0);
+ return m_ilRVA;
+}
+
+void PEWriter::setIlRva(ULONG offset)
+{
+ // assume that pe optional header is less than size of section alignment. So this
+ // gives out the rva for the .text section, which is merged after the .text0 section
+ // This is verified in debug build when actually write out the file
+ m_ilRVA = roundUp(VAL32(m_ntHeaders->OptionalHeader.SectionAlignment) + offset, SUBSECTION_ALIGN);
+}
+
+HRESULT PEWriter::setDirectoryEntry(PEWriterSection *section, ULONG entry, ULONG size, ULONG offset)
+{
+ if (entry >= cEntries)
+ {
+ USHORT cNewEntries = (USHORT)max((ULONG)cEntries * 2, entry + 1);
+
+ if (cNewEntries <= cEntries) return E_OUTOFMEMORY; // Integer overflow
+ if (cNewEntries <= entry) return E_OUTOFMEMORY; // Integer overflow
+
+ directoryEntry *pNewEntries = new (nothrow) directoryEntry [ cNewEntries ];
+ if (pNewEntries == NULL) return E_OUTOFMEMORY;
+
+ CopyMemory(pNewEntries, pEntries, cEntries * sizeof(*pNewEntries));
+ ZeroMemory(pNewEntries + cEntries, (cNewEntries - cEntries) * sizeof(*pNewEntries));
+
+ delete [] pEntries;
+ pEntries = pNewEntries;
+ cEntries = cNewEntries;
+ }
+
+ pEntries[entry].section = section;
+ pEntries[entry].offset = offset;
+ pEntries[entry].size = size;
+ return S_OK;
+}
+
+void PEWriter::setEnCRvaBase(ULONG dataBase, ULONG rdataBase)
+{
+ m_dataRvaBase = dataBase;
+ m_rdataRvaBase = rdataBase;
+ m_encMode = TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// These 2 write functions must be implemented here so that they're in the same
+// .obj file as whoever creates the FILE struct. We can't pass a FILE struct
+// across a dll boundary and use it.
+//-----------------------------------------------------------------------------
+
+HRESULT PEWriterSection::write(HANDLE file)
+{
+ return m_blobFetcher.Write(file);
+}
+
+//-----------------------------------------------------------------------------
+// Write out the section to the stream
+//-----------------------------------------------------------------------------
+HRESULT CBlobFetcher::Write(HANDLE file)
+{
+// Must write out each pillar (including idx = m_nIndexUsed), one after the other
+ unsigned idx;
+ for(idx = 0; idx <= m_nIndexUsed; idx ++) {
+ if (m_pIndex[idx].GetDataLen() > 0)
+ {
+ ULONG length = m_pIndex[idx].GetDataLen();
+ DWORD dwWritten = 0;
+ if (!WriteFile(file, m_pIndex[idx].GetRawDataStart(), length, &dwWritten, NULL))
+ {
+ return HRESULT_FROM_GetLastError();
+ }
+ _ASSERTE(dwWritten == length);
+ }
+ }
+
+ return S_OK;
+}
+
+
+//-----------------------------------------------------------------------------
+// These 2 write functions must be implemented here so that they're in the same
+// .obj file as whoever creates the FILE struct. We can't pass a FILE struct
+// across a dll boundary and use it.
+//-----------------------------------------------------------------------------
+
+unsigned PEWriterSection::writeMem(void **ppMem)
+{
+ HRESULT hr;
+ hr = m_blobFetcher.WriteMem(ppMem);
+ _ASSERTE(SUCCEEDED(hr));
+
+ return m_blobFetcher.GetDataLen();
+}
+
+//-----------------------------------------------------------------------------
+// Write out the section to memory
+//-----------------------------------------------------------------------------
+HRESULT CBlobFetcher::WriteMem(void **ppMem)
+{
+ char **ppDest = (char **)ppMem;
+ // Must write out each pillar (including idx = m_nIndexUsed), one after the other
+ unsigned idx;
+ for(idx = 0; idx <= m_nIndexUsed; idx ++) {
+ if (m_pIndex[idx].GetDataLen() > 0)
+ {
+ // WARNING: macro - must enclose in curly braces
+ COPY_AND_ADVANCE(*ppDest, m_pIndex[idx].GetRawDataStart(), m_pIndex[idx].GetDataLen());
+ }
+ }
+
+ return S_OK;
+}
+
+/******************************************************************/
+
+//
+// Intermediate table to sort to help determine section order
+//
+struct entry {
+ const char * name; // full name of the section
+ unsigned char nameLength; // length of the text part of the name
+ signed char index; // numeral value at the end of the name; -1 if none
+ unsigned short arrayIndex; // index of section within sectStart[]
+};
+
+class SectionNameSorter : protected CQuickSort<entry>
+{
+ entry * m_entries;
+ PEWriterSection ** m_sections;
+ unsigned m_count;
+ unsigned m_seedCount;
+
+ public:
+ SectionNameSorter(entry *entries, PEWriterSection ** sections, int count, unsigned seedSections)
+ : CQuickSort<entry>(entries, count),
+ m_entries(entries),
+ m_sections(sections),
+ m_count(unsigned(count)),
+ m_seedCount(seedSections)
+ {}
+
+ // Sorts the entries according to alphabetical + numerical order
+
+ int Compare(entry *first, entry *second)
+ {
+ PEWriterSection * firstSection = m_sections[first->arrayIndex];
+ PEWriterSection * secondSection = m_sections[second->arrayIndex];
+
+ // Seed sections are always at the start, in the order they were
+ // added to the PEWriter
+
+ if (firstSection->isSeedSection() || secondSection->isSeedSection()) {
+ if (firstSection->isSeedSection() && secondSection->isSeedSection())
+ return first->arrayIndex - second->arrayIndex;
+
+ return firstSection->isSeedSection() ? -1 : 1;
+ }
+
+ // Sort the names
+
+ int lenDiff = first->nameLength - second->nameLength;
+ int smallerLen;
+ if (lenDiff < 0)
+ smallerLen = first->nameLength;
+ else
+ smallerLen = second->nameLength;
+
+ int result = strncmp(first->name, second->name, smallerLen);
+
+ if (result != 0)
+ return result;
+ else
+ {
+ if (lenDiff != 0)
+ return lenDiff;
+ else
+ return (int)(first->index - second->index);
+ }
+ }
+
+ int SortSections()
+ {
+ Sort();
+
+ entry * ePrev = m_entries;
+ entry * e = ePrev + 1;
+ int iSections = 1; // First section is obviously unique
+
+ for (unsigned i = 1; i < m_count; i++, ePrev = e, e++) {
+
+ // Seed sections should stay at the front
+ _ASSERTE(i >= m_seedCount || i == e->arrayIndex);
+
+ if (!m_sections[ePrev->arrayIndex]->isSeedSection() &&
+ (ePrev->nameLength == e->nameLength) &&
+ strncmp(ePrev->name, e->name, e->nameLength) == 0)
+ {
+ continue;
+ }
+
+ iSections++;
+ }
+
+ return iSections;
+ }
+};
+
+#define SectionIndex IMAGE_SECTION_HEADER::VirtualAddress
+#define FirstEntryIndex IMAGE_SECTION_HEADER::SizeOfRawData
+
+HRESULT PEWriter::linkSortSections(entry * entries,
+ unsigned * piEntries,
+ unsigned * piUniqueSections)
+{
+ //
+ // Preserve current section order as much as possible, but apply the following
+ // rules:
+ // - sections named "xxx#" are collated into a single PE section "xxx".
+ // The contents of the CeeGen sections are sorted according to numerical
+ // order & made contiguous in the PE section
+ // - "text" always comes first in the file
+ // - empty sections receive no PE section
+ //
+
+ bool ExeOrDll = isExeOrDll(m_ntHeaders);
+
+ entry *e = entries;
+ for (PEWriterSection **cur = getSectStart(); cur < getSectCur(); cur++) {
+
+ //
+ // Throw away any old headers we've used.
+ //
+
+ (*cur)->m_header = NULL;
+
+ //
+ // Don't allocate PE data for 0 length sections
+ //
+
+ if ((*cur)->dataLen() == 0)
+ continue;
+
+ //
+ // Special case: omit "text0" from obj's
+ //
+
+ if (!ExeOrDll && strcmp((*cur)->m_name, ".text0") == 0)
+ continue;
+
+ e->name = (*cur)->m_name;
+
+ //
+ // Now find the end of the text part of the section name, and
+ // calculate the numeral (if any) at the end
+ //
+
+ _ASSERTE(strlen(e->name) < UCHAR_MAX);
+ const char *p = e->name + strlen(e->name);
+ int index = 0; // numeral at the end of the section name
+ int placeValue = 1;
+ if (isdigit(p[-1]))
+ {
+ while (--p > e->name)
+ {
+ if (!isdigit(*p))
+ break;
+ index += ((*p - '0') * placeValue);
+ placeValue *= 10;
+ }
+ p++;
+
+ //
+ // Special case: put "xxx" after "xxx0" and before "xxx1"
+ //
+
+ if (index == 0)
+ index = -1;
+ }
+
+ _ASSERTE(index == -1 || index == atoi(p));
+
+ e->nameLength = (unsigned char)(p - e->name);
+ e->index = index;
+ e->arrayIndex = (unsigned short)(cur - getSectStart());
+ e++;
+ }
+
+ //
+ // Sort the entries according to alphabetical + numerical order
+ //
+
+ SectionNameSorter sorter(entries, getSectStart(), int(e - entries), m_iSeedSections);
+ *piUniqueSections = sorter.SortSections();
+
+ *piEntries = unsigned(e - entries);
+
+ return S_OK;
+}
+
+class HeaderSorter : public CQuickSort<IMAGE_SECTION_HEADER>
+{
+ public:
+ HeaderSorter(IMAGE_SECTION_HEADER *headers, int count)
+ : CQuickSort<IMAGE_SECTION_HEADER>(headers, count) {}
+
+ int Compare(IMAGE_SECTION_HEADER *first, IMAGE_SECTION_HEADER *second)
+ {
+ // IMAGE_SECTION_HEADER::VirtualAddress/SectionIndex contains the
+ // index of the section
+ return VAL32(first->SectionIndex) - VAL32(second->SectionIndex);
+ }
+};
+
+HRESULT PEWriter::linkSortHeaders(entry * entries, unsigned iEntries, unsigned iUniqueSections)
+{
+ if (headers != NULL)
+ delete [] headers;
+
+ // 1 extra for .reloc
+ S_UINT32 cUniqueSectionsAllocated = S_UINT32(iUniqueSections) + S_UINT32(1);
+ if (cUniqueSectionsAllocated.IsOverflow())
+ {
+ return COR_E_OVERFLOW;
+ }
+ headers = new (nothrow) IMAGE_SECTION_HEADER[cUniqueSectionsAllocated.Value()];
+ TESTANDRETURNMEMORY(headers);
+
+ memset(headers, 0, sizeof(*headers) * cUniqueSectionsAllocated.Value());
+
+ entry *ePrev = NULL;
+ IMAGE_SECTION_HEADER *h = headers - 1;
+
+ //
+ // Store the sorting index
+ //
+
+ entry * entriesEnd = entries + iEntries;
+
+ for (entry * e = entries ; e < entriesEnd; e++)
+ {
+ if (ePrev != NULL
+ && !getSectStart()[ePrev->arrayIndex]->isSeedSection()
+ && e->nameLength == ePrev->nameLength
+ && strncmp(e->name, ePrev->name, e->nameLength) == 0)
+ {
+ //
+ // This section has the same name as the previous section, and
+ // will be collapsed with the previous section.
+ // Just update the (common) header information
+ //
+
+ if (e->arrayIndex < ePrev->arrayIndex)
+ {
+ //
+ // Use the smaller of the indices of e and ePrev
+ //
+ h->SectionIndex = VAL32(VAL32(h->SectionIndex) - (e->arrayIndex - ePrev->arrayIndex));
+ }
+
+ // Store an approximation of the size of the section temporarily
+ h->Misc.VirtualSize = VAL32(VAL32(h->Misc.VirtualSize) + getSectStart()[e->arrayIndex]->dataLen());
+ }
+ else
+ {
+ // Grab a new header
+
+ h++;
+
+ strncpy_s((char *) h->Name, sizeof(h->Name), e->name, e->nameLength);
+
+ setSectionIndex(h, e->arrayIndex);
+
+ // Store the entry index in this field temporarily
+ h->FirstEntryIndex = VAL32((DWORD)(e - entries));
+
+ // Store an approximation of the size of the section temporarily
+ h->Misc.VirtualSize = VAL32(getSectStart()[e->arrayIndex]->dataLen());
+ }
+ ePrev = e;
+ }
+
+ headersEnd = ++h;
+
+ _ASSERTE(headers + iUniqueSections == headersEnd);
+
+ //
+ // Sort the entries according to alphabetical + numerical order
+ //
+
+ HeaderSorter headerSorter(headers, int(iUniqueSections));
+
+ headerSorter.Sort();
+
+ return S_OK;
+} // PEWriter::linkSortHeaders
+
+HRESULT PEWriter::linkPlaceSections(entry * entries, unsigned iEntries)
+{
+ entry * entriesEnd = entries + iEntries;
+
+ for (IMAGE_SECTION_HEADER * h = headers; h < headersEnd; h++)
+ {
+ // Get to the first entry corresponding to this section header
+
+ entry * e = entries + VAL32(h->FirstEntryIndex);
+ PEWriterSection *s = getSectStart()[e->arrayIndex];
+
+ if (s->isSeedSection()) {
+ virtualPos = s->getBaseRVA();
+ }
+
+ h->VirtualAddress = VAL32(virtualPos);
+ h->PointerToRawData = VAL32(filePos);
+
+ s->m_baseRVA = virtualPos;
+ s->m_filePos = filePos;
+ s->m_header = h;
+ h->Characteristics = VAL32(s->m_flags);
+
+#ifdef LOGGING
+ LOG((LF_ZAP, LL_INFO10,
+ " Section %-7s RVA=%08x, Length=%08x, FilePos=%08x\n",
+ s->m_name, s->m_baseRVA, s->dataLen(), s->m_filePos));
+#endif
+
+ unsigned dataSize = s->dataLen();
+
+ // Find all the other entries corresponding to this section header
+
+ PEWriterSection *sPrev = s;
+ entry * ePrev = e;
+ while (++e < entriesEnd)
+ {
+ if (e->nameLength != ePrev->nameLength
+ || strncmp(e->name, ePrev->name, e->nameLength) != 0)
+ break;
+
+ s = getSectStart()[e->arrayIndex];
+ _ASSERTE(s->m_flags == VAL32(h->Characteristics));
+
+ sPrev->m_filePad = padLen(dataSize, SUBSECTION_ALIGN);
+ dataSize = roundUp(dataSize, SUBSECTION_ALIGN);
+
+ s->m_baseRVA = virtualPos + dataSize;
+ s->m_filePos = filePos + dataSize;
+ s->m_header = h;
+ sPrev = s;
+
+ dataSize += s->dataLen();
+
+#ifdef LOGGING
+ LOG((LF_ZAP, LL_INFO10,
+ " Section %-7s RVA=%08x, Length=%08x, FilePos=%08x\n",
+ s->m_name, s->m_baseRVA, s->dataLen(), s->m_filePos));
+#endif
+
+ ePrev = e;
+ }
+
+ h->Misc.VirtualSize = VAL32(dataSize);
+
+ sPrev->m_filePad = padLen(dataSize, VAL32(m_ntHeaders->OptionalHeader.FileAlignment));
+ dataSize = roundUp(dataSize, VAL32(m_ntHeaders->OptionalHeader.FileAlignment));
+ h->SizeOfRawData = VAL32(dataSize);
+ filePos += dataSize;
+
+ dataSize = roundUp(dataSize, VAL32(m_ntHeaders->OptionalHeader.SectionAlignment));
+ virtualPos += dataSize;
+ }
+
+ return S_OK;
+}
+
+void PEWriter::setSectionIndex(IMAGE_SECTION_HEADER * h, unsigned sectionIndex) {
+
+ if (getSectStart()[sectionIndex]->isSeedSection()) {
+ h->SectionIndex = VAL32(sectionIndex);
+ return;
+ }
+
+ //
+ // Reserve some dummy "array index" values for special sections
+ // at the start of the image (after the seed sections)
+ //
+
+ static const char * const SpecialNames[] = { ".text", ".cormeta", NULL };
+ enum { SPECIAL_NAMES_COUNT = NumItems(SpecialNames) };
+
+ for (const char * const * s = SpecialNames; /**/; s++)
+ {
+ if (*s == 0)
+ {
+ h->SectionIndex = VAL32(sectionIndex + SPECIAL_NAMES_COUNT);
+ break;
+ }
+ else if (strcmp((char *) h->Name, *s) == 0)
+ {
+ h->SectionIndex = VAL32(m_iSeedSections + DWORD(s - SpecialNames));
+ break;
+ }
+ }
+
+}
+
+
+HRESULT PEWriter::link() {
+
+ //
+ // NOTE:
+ // link() can be called more than once! This is because at least one compiler
+ // (the prejitter) needs to know the base addresses of some segments before it
+ // builds others. It's up to the caller to insure the layout remains the same
+ // after changes are made, though.
+ //
+
+ //
+ // Assign base addresses to all sections, and layout & merge PE sections
+ //
+
+ bool ExeOrDll = isExeOrDll(m_ntHeaders);
+
+ //
+ // Collate by name & sort by index
+ //
+
+ // First collect all information into entries[]
+
+ int sectCount = getSectCount();
+ entry *entries = (entry *) _alloca(sizeof(entry) * sectCount);
+
+ unsigned iUniqueSections, iEntries;
+ HRESULT hr;
+ IfFailRet(linkSortSections(entries, &iEntries, &iUniqueSections));
+
+ //
+ // Now, allocate a header for each unique section name.
+ // Also record the minimum section index for each section
+ // so we can preserve order as much as possible.
+ //
+
+ IfFailRet(linkSortHeaders(entries, iEntries, iUniqueSections));
+
+ //
+ // If file alignment is not zero, it must have been set through
+ // setFileAlignment(), in which case we leave it untouched
+ //
+
+ if( VAL32(0) == m_ntHeaders->OptionalHeader.FileAlignment )
+ {
+ //
+ // Figure out what file alignment to use.
+ //
+
+ unsigned RoundUpVal;
+
+ if (ExeOrDll)
+ {
+ RoundUpVal = 0x0200;
+ }
+ else
+ {
+ // Don't bother padding for objs
+ RoundUpVal = 4;
+ }
+
+ m_ntHeaders->OptionalHeader.FileAlignment = VAL32(RoundUpVal);
+ }
+
+ //
+ // Now, assign a section header & location to each section
+ //
+
+ if (ExeOrDll)
+ {
+ iUniqueSections++; // One more for .reloc
+ filePos = sizeof(IMAGE_DOS_HEADER)+sizeof(x86StubPgm) + m_ntHeadersSize;
+ }
+ else
+ {
+ filePos = sizeof(IMAGE_FILE_HEADER);
+ }
+
+ m_ntHeaders->FileHeader.NumberOfSections = VAL16(iUniqueSections);
+
+ filePos += iUniqueSections * sizeof(IMAGE_SECTION_HEADER);
+ filePos = roundUp(filePos, VAL32(m_ntHeaders->OptionalHeader.FileAlignment));
+
+ m_ntHeaders->OptionalHeader.SizeOfHeaders = VAL32(filePos);
+
+ virtualPos = roundUp(filePos, VAL32(m_ntHeaders->OptionalHeader.SectionAlignment));
+
+ if (m_hSeedFile != INVALID_HANDLE_VALUE) {
+ // We do not support relocating/sliding down the seed sections
+ if (filePos > VAL32(m_pSeedSections->VirtualAddress) ||
+ virtualPos > VAL32(m_pSeedSections->VirtualAddress))
+ return E_FAIL;
+
+ if (virtualPos < VAL32(m_pSeedSections->VirtualAddress)) {
+ virtualPos = VAL32(m_pSeedSections->VirtualAddress);
+ }
+ }
+
+ // Now finally assign RVAs to the sections
+
+ IfFailRet(linkPlaceSections(entries, iEntries));
+
+ return S_OK;
+}
+
+#undef SectionIndex
+#undef FirstEntryIndex
+
+
+class SectionRVASorter : public CQuickSort<PEWriterSection*>
+{
+ public:
+ SectionRVASorter(PEWriterSection **elts, SSIZE_T count)
+ : CQuickSort<PEWriterSection*>(elts, count) {}
+
+ int Compare(PEWriterSection **e1, PEWriterSection **e2)
+ {
+ return (*e1)->getBaseRVA() - (*e2)->getBaseRVA();
+ }
+};
+
+#ifdef _PREFAST_
+#pragma warning(push)
+#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
+#endif
+HRESULT PEWriter::fixup(CeeGenTokenMapper *pMapper)
+{
+ HRESULT hr;
+
+ bool ExeOrDll = isExeOrDll(m_ntHeaders);
+ const unsigned RoundUpVal = VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
+
+ if(ExeOrDll)
+ {
+ //
+ // Apply manual relocation for entry point field
+ //
+
+ PESection *textSection;
+ IfFailRet(getSectionCreate(".text", 0, &textSection));
+
+ if (m_ntHeaders->OptionalHeader.AddressOfEntryPoint != VAL32(0))
+ m_ntHeaders->OptionalHeader.AddressOfEntryPoint = VAL32(VAL32(m_ntHeaders->OptionalHeader.AddressOfEntryPoint) + textSection->m_baseRVA);
+
+ //
+ // Apply normal relocs
+ //
+
+ IfFailRet(getSectionCreate(".reloc", sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE,
+ (PESection **) &reloc));
+ reloc->m_baseRVA = virtualPos;
+ reloc->m_filePos = filePos;
+ reloc->m_header = headersEnd++;
+ strcpy_s((char *)reloc->m_header->Name, sizeof(reloc->m_header->Name),
+ ".reloc");
+ reloc->m_header->Characteristics = VAL32(reloc->m_flags);
+ reloc->m_header->VirtualAddress = VAL32(virtualPos);
+ reloc->m_header->PointerToRawData = VAL32(filePos);
+
+#ifdef _DEBUG
+ if (m_encMode)
+ printf("Applying relocs for .rdata section with RVA %x\n", m_rdataRvaBase);
+#endif
+
+ //
+ // Sort the sections by RVA
+ //
+
+ CQuickArray<PEWriterSection *> sections;
+
+ SIZE_T count = getSectCur() - getSectStart();
+ IfFailRet(sections.ReSizeNoThrow(count));
+ UINT i = 0;
+ PEWriterSection **cur;
+ for(cur = getSectStart(); cur < getSectCur(); cur++, i++)
+ sections[i] = *cur;
+
+ SectionRVASorter sorter(sections.Ptr(), sections.Size());
+
+ sorter.Sort();
+
+ PERelocSection relocSection(reloc);
+
+ cur = sections.Ptr();
+ PEWriterSection **curEnd = cur + sections.Size();
+ while (cur < curEnd)
+ {
+ IfFailRet((*cur)->applyRelocs(m_ntHeaders,
+ &relocSection,
+ pMapper,
+ m_dataRvaBase,
+ m_rdataRvaBase,
+ m_codeRvaBase));
+ cur++;
+ }
+
+ relocSection.Finish(isPE32());
+ reloc->m_header->Misc.VirtualSize = VAL32(reloc->dataLen());
+
+ // Strip the reloc section if the flag is set
+ if (m_ntHeaders->FileHeader.Characteristics & VAL16(IMAGE_FILE_RELOCS_STRIPPED))
+ {
+ reloc->m_header->Misc.VirtualSize = VAL32(0);
+ }
+
+ reloc->m_header->SizeOfRawData = VAL32(roundUp(VAL32(reloc->m_header->Misc.VirtualSize), RoundUpVal));
+ reloc->m_filePad = padLen(VAL32(reloc->m_header->Misc.VirtualSize), RoundUpVal);
+ filePos += VAL32(reloc->m_header->SizeOfRawData);
+ virtualPos += roundUp(VAL32(reloc->m_header->Misc.VirtualSize),
+ VAL32(m_ntHeaders->OptionalHeader.SectionAlignment));
+
+ if (reloc->m_header->Misc.VirtualSize == VAL32(0))
+ {
+ //
+ // Omit reloc section from section list. (It will
+ // still be there but the loader won't see it - this
+ // only works because we've allocated it as the last
+ // section.)
+ //
+ m_ntHeaders->FileHeader.NumberOfSections = VAL16(VAL16(m_ntHeaders->FileHeader.NumberOfSections) - 1);
+ }
+ else
+ {
+ IMAGE_DATA_DIRECTORY * pRelocDataDirectory;
+ //
+ // Put reloc address in header
+ //
+ if (isPE32())
+ {
+ pRelocDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
+ }
+ else
+ {
+ pRelocDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC]);
+ }
+
+ pRelocDataDirectory->VirtualAddress = reloc->m_header->VirtualAddress;
+ pRelocDataDirectory->Size = reloc->m_header->Misc.VirtualSize;
+ }
+
+ // compute ntHeader fields that depend on the sizes of other things
+ for(IMAGE_SECTION_HEADER *h = headersEnd-1; h >= headers; h--) { // go backwards, so first entry takes precedence
+ if (h->Characteristics & VAL32(IMAGE_SCN_CNT_CODE)) {
+ m_ntHeaders->OptionalHeader.BaseOfCode = h->VirtualAddress;
+ m_ntHeaders->OptionalHeader.SizeOfCode =
+ VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfCode) + VAL32(h->SizeOfRawData));
+ }
+ if (h->Characteristics & VAL32(IMAGE_SCN_CNT_INITIALIZED_DATA)) {
+ if (isPE32())
+ {
+ ntHeaders32()->OptionalHeader.BaseOfData = h->VirtualAddress;
+ }
+ m_ntHeaders->OptionalHeader.SizeOfInitializedData =
+ VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfInitializedData) + VAL32(h->SizeOfRawData));
+ }
+ if (h->Characteristics & VAL32(IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
+ m_ntHeaders->OptionalHeader.SizeOfUninitializedData =
+ VAL32(VAL32(m_ntHeaders->OptionalHeader.SizeOfUninitializedData) + VAL32(h->SizeOfRawData));
+ }
+ }
+
+ int index;
+ IMAGE_DATA_DIRECTORY * pCurDataDirectory;
+
+ // go backwards, so first entry takes precedence
+ for(cur = getSectCur()-1; getSectStart() <= cur; --cur)
+ {
+ index = (*cur)->getDirEntry();
+
+ // Is this a valid directory entry
+ if (index > 0)
+ {
+ if (isPE32())
+ {
+ _ASSERTE((unsigned)(index) < VAL32(ntHeaders32()->OptionalHeader.NumberOfRvaAndSizes));
+
+ pCurDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[index]);
+ }
+ else
+ {
+ _ASSERTE((unsigned)(index) < VAL32(ntHeaders64()->OptionalHeader.NumberOfRvaAndSizes));
+
+ pCurDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[index]);
+ }
+
+ pCurDataDirectory->VirtualAddress = VAL32((*cur)->m_baseRVA);
+ pCurDataDirectory->Size = VAL32((*cur)->dataLen());
+ }
+ }
+
+ // handle the directory entries specified using the file.
+ for (index=0; index < cEntries; index++)
+ {
+ if (pEntries[index].section)
+ {
+ PEWriterSection *section = pEntries[index].section;
+ _ASSERTE(pEntries[index].offset < section->dataLen());
+
+ if (isPE32())
+ pCurDataDirectory = &(ntHeaders32()->OptionalHeader.DataDirectory[index]);
+ else
+ pCurDataDirectory = &(ntHeaders64()->OptionalHeader.DataDirectory[index]);
+
+ pCurDataDirectory->VirtualAddress = VAL32(section->m_baseRVA + pEntries[index].offset);
+ pCurDataDirectory->Size = VAL32(pEntries[index].size);
+ }
+ }
+
+ m_ntHeaders->OptionalHeader.SizeOfImage = VAL32(virtualPos);
+ } // end if(ExeOrDll)
+ else //i.e., if OBJ
+ {
+ //
+ // Clean up note:
+ // I've cleaned up the executable linking path, but the .obj linking
+ // is still a bit strange, what with a "extra" reloc & strtab sections
+ // which are created after the linking step and get treated specially.
+ //
+ reloc = new (nothrow) PEWriterSection(".reloc",
+ sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE, 0x4000, 0);
+ if(reloc == NULL) return E_OUTOFMEMORY;
+ strtab = new (nothrow) PEWriterSection(".strtab",
+ sdReadOnly | IMAGE_SCN_MEM_DISCARDABLE, 0x4000, 0); //string table (if any)
+ if(strtab == NULL) return E_OUTOFMEMORY;
+
+ DWORD* TokInSymbolTable = new (nothrow) DWORD[16386];
+ if (TokInSymbolTable == NULL) return E_OUTOFMEMORY;
+
+ m_ntHeaders->FileHeader.SizeOfOptionalHeader = 0;
+ //For each section set VirtualAddress to 0
+ PEWriterSection **cur;
+ for(cur = getSectStart(); cur < getSectCur(); cur++)
+ {
+ IMAGE_SECTION_HEADER* header = (*cur)->m_header;
+ header->VirtualAddress = VAL32(0);
+ }
+ // Go over section relocations and build the Symbol Table, use .reloc section as buffer:
+ DWORD tk=0, rva=0, NumberOfSymbols=0;
+ BOOL ToRelocTable = FALSE;
+ IMAGE_SYMBOL is;
+ IMAGE_RELOCATION ir;
+ ULONG StrTableLen = 4; //size itself only
+ char* szSymbolName = NULL;
+ char* pch;
+
+ PESection *textSection;
+ getSectionCreate(".text", 0, &textSection);
+
+ for(PESectionReloc* rcur = textSection->m_relocStart; rcur < textSection->m_relocCur; rcur++)
+ {
+ switch((int)rcur->type)
+ {
+ case 0x7FFA: // Ptr to symbol name
+#ifdef _WIN64
+ _ASSERTE(!"this is probably broken!!");
+#endif // _WIN64
+ szSymbolName = (char*)(UINT_PTR)(rcur->offset);
+ break;
+
+ case 0x7FFC: // Ptr to file name
+ TokInSymbolTable[NumberOfSymbols++] = 0;
+ memset(&is,0,sizeof(IMAGE_SYMBOL));
+ memcpy(is.N.ShortName,".file\0\0\0",8);
+ is.Value = 0;
+ is.SectionNumber = VAL16(IMAGE_SYM_DEBUG);
+ is.Type = VAL16(IMAGE_SYM_DTYPE_NULL);
+ is.StorageClass = IMAGE_SYM_CLASS_FILE;
+ is.NumberOfAuxSymbols = 1;
+ if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
+ memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
+ else return E_OUTOFMEMORY;
+ TokInSymbolTable[NumberOfSymbols++] = 0;
+ memset(&is,0,sizeof(IMAGE_SYMBOL));
+#ifdef _WIN64
+ _ASSERTE(!"this is probably broken!!");
+#endif // _WIN64
+ strcpy_s((char*)&is,sizeof(is),(char*)(UINT_PTR)(rcur->offset));
+ if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
+ memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
+ else return E_OUTOFMEMORY;
+#ifdef _WIN64
+ _ASSERTE(!"this is probably broken!!");
+#endif // _WIN64
+ delete (char*)(UINT_PTR)(rcur->offset);
+ ToRelocTable = FALSE;
+ tk = 0;
+ szSymbolName = NULL;
+ break;
+
+ case 0x7FFB: // compid value
+ TokInSymbolTable[NumberOfSymbols++] = 0;
+ memset(&is,0,sizeof(IMAGE_SYMBOL));
+ memcpy(is.N.ShortName,"@comp.id",8);
+ is.Value = VAL32(rcur->offset);
+ is.SectionNumber = VAL16(IMAGE_SYM_ABSOLUTE);
+ is.Type = VAL16(IMAGE_SYM_DTYPE_NULL);
+ is.StorageClass = IMAGE_SYM_CLASS_STATIC;
+ is.NumberOfAuxSymbols = 0;
+ if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
+ memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
+ else return E_OUTOFMEMORY;
+ ToRelocTable = FALSE;
+ tk = 0;
+ szSymbolName = NULL;
+ break;
+
+ case 0x7FFF: // Token value, def
+ tk = rcur->offset;
+ ToRelocTable = FALSE;
+ break;
+
+ case 0x7FFE: //Token value, ref
+ tk = rcur->offset;
+ ToRelocTable = TRUE;
+ break;
+
+ case 0x7FFD: //RVA value
+ rva = rcur->offset;
+ if(tk)
+ {
+ // Add to SymbolTable
+ DWORD i;
+ for(i = 0; (i < NumberOfSymbols)&&(tk != TokInSymbolTable[i]); i++);
+ if(i == NumberOfSymbols)
+ {
+ if(szSymbolName && *szSymbolName) // Add "extern" symbol and string table entry
+ {
+ TokInSymbolTable[NumberOfSymbols++] = 0;
+ memset(&is,0,sizeof(IMAGE_SYMBOL));
+ i++; // so reloc record (if generated) points to COM token symbol
+ is.N.Name.Long = VAL32(StrTableLen);
+ is.SectionNumber = VAL16(1); //textSection is the first one
+ is.StorageClass = IMAGE_SYM_CLASS_EXTERNAL;
+ is.NumberOfAuxSymbols = 0;
+ is.Value = VAL32(rva);
+ if(TypeFromToken(tk) == mdtMethodDef)
+ {
+ is.Type = VAL16(0x20); //IMAGE_SYM_DTYPE_FUNCTION;
+ }
+ if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
+ memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
+ else return E_OUTOFMEMORY;
+ DWORD l = (DWORD)(strlen(szSymbolName)+1); // don't forget zero terminator!
+ if((pch = reloc->getBlock(1)))
+ memcpy(pch,szSymbolName,1);
+ else return E_OUTOFMEMORY;
+ delete szSymbolName;
+ StrTableLen += l;
+ }
+ TokInSymbolTable[NumberOfSymbols++] = tk;
+ memset(&is,0,sizeof(IMAGE_SYMBOL));
+ sprintf_s((char*)is.N.ShortName,sizeof(is.N.ShortName),"%08X",tk);
+ is.SectionNumber = VAL16(1); //textSection is the first one
+ is.StorageClass = 0x6B; //IMAGE_SYM_CLASS_COM_TOKEN;
+ is.Value = VAL32(rva);
+ if(TypeFromToken(tk) == mdtMethodDef)
+ {
+ is.Type = VAL16(0x20); //IMAGE_SYM_DTYPE_FUNCTION;
+ //is.NumberOfAuxSymbols = 1;
+ }
+ if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
+ memcpy(pch,&is,sizeof(IMAGE_SYMBOL));
+ else return E_OUTOFMEMORY;
+ if(is.NumberOfAuxSymbols == 1)
+ {
+ BYTE dummy[sizeof(IMAGE_SYMBOL)];
+ memset(dummy,0,sizeof(IMAGE_SYMBOL));
+ dummy[0] = dummy[2] = 1;
+ if((pch = reloc->getBlock(sizeof(IMAGE_SYMBOL))))
+ memcpy(pch,dummy,sizeof(IMAGE_SYMBOL));
+ else return E_OUTOFMEMORY;
+ TokInSymbolTable[NumberOfSymbols++] = 0;
+ }
+ }
+ if(ToRelocTable)
+ {
+ IMAGE_SECTION_HEADER* phdr = textSection->m_header;
+ // Add to reloc table
+ ir.VirtualAddress = VAL32(rva);
+ ir.SymbolTableIndex = VAL32(i);
+ ir.Type = VAL16(IMAGE_REL_I386_SECREL);
+ if(phdr->PointerToRelocations == 0)
+ phdr->PointerToRelocations = VAL32(VAL32(phdr->PointerToRawData) + VAL32(phdr->SizeOfRawData));
+ phdr->NumberOfRelocations = VAL32(VAL32(phdr->NumberOfRelocations) + 1);
+ if((pch = reloc->getBlock(sizeof(IMAGE_RELOCATION))))
+ memcpy(pch,&is,sizeof(IMAGE_RELOCATION));
+ else return E_OUTOFMEMORY;
+ }
+ }
+ ToRelocTable = FALSE;
+ tk = 0;
+ szSymbolName = NULL;
+ break;
+
+ default:
+ break;
+ } //end switch(cur->type)
+ } // end for all relocs
+ // Add string table counter:
+ if((pch = reloc->getBlock(sizeof(ULONG))))
+ memcpy(pch,&StrTableLen,sizeof(ULONG));
+ else return E_OUTOFMEMORY;
+ reloc->m_header->Misc.VirtualSize = VAL32(reloc->dataLen());
+ if(NumberOfSymbols)
+ {
+ // recompute the actual sizes and positions of all the sections
+ filePos = roundUp(VAL16(m_ntHeaders->FileHeader.NumberOfSections) * sizeof(IMAGE_SECTION_HEADER)+
+ sizeof(IMAGE_FILE_HEADER), RoundUpVal);
+ for(cur = getSectStart(); cur < getSectCur(); cur++)
+ {
+ IMAGE_SECTION_HEADER* header = (*cur)->m_header;
+ header->Misc.VirtualSize = VAL32((*cur)->dataLen());
+ header->VirtualAddress = VAL32(0);
+ header->SizeOfRawData = VAL32(roundUp(VAL32(header->Misc.VirtualSize), RoundUpVal));
+ header->PointerToRawData = VAL32(filePos);
+
+ filePos += VAL32(header->SizeOfRawData);
+ }
+ m_ntHeaders->FileHeader.Machine = VAL16(0xC0EE); //COM+ EE
+ m_ntHeaders->FileHeader.PointerToSymbolTable = VAL32(filePos);
+ m_ntHeaders->FileHeader.NumberOfSymbols = VAL32(NumberOfSymbols);
+ filePos += roundUp(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(),RoundUpVal);
+ }
+ delete[] TokInSymbolTable;
+ } //end if OBJ
+
+ const unsigned headerOffset = (unsigned) (ExeOrDll ? sizeof(IMAGE_DOS_HEADER) + sizeof(x86StubPgm) : 0);
+
+ memset(&m_dosHeader, 0, sizeof(IMAGE_DOS_HEADER));
+ m_dosHeader.e_magic = VAL16(IMAGE_DOS_SIGNATURE);
+ m_dosHeader.e_cblp = VAL16(0x90); // bytes in last page
+ m_dosHeader.e_cp = VAL16(3); // pages in file
+ m_dosHeader.e_cparhdr = VAL16(4); // size of header in paragraphs
+ m_dosHeader.e_maxalloc = VAL16(0xFFFF); // maximum extra mem needed
+ m_dosHeader.e_sp = VAL16(0xB8); // initial SP value
+ m_dosHeader.e_lfarlc = VAL16(0x40); // file offset of relocations
+ m_dosHeader.e_lfanew = VAL32(headerOffset); // file offset of NT header!
+
+ return(S_OK); // SUCCESS
+}
+#ifdef _PREFAST_
+#pragma warning(pop)
+#endif
+
+HRESULT PEWriter::Open(__in LPCWSTR fileName)
+{
+ _ASSERTE(m_file == INVALID_HANDLE_VALUE);
+ HRESULT hr = NOERROR;
+
+ m_file = WszCreateFile(fileName,
+ GENERIC_WRITE,
+ 0, // No sharing. Was: FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+ if (m_file == INVALID_HANDLE_VALUE)
+ hr = HRESULT_FROM_GetLastErrorNA();
+
+ return hr;
+}
+
+HRESULT PEWriter::Seek(int offset)
+{
+ _ASSERTE(m_file != INVALID_HANDLE_VALUE);
+ if (SetFilePointer(m_file, offset, 0, FILE_BEGIN))
+ return S_OK;
+ else
+ return HRESULT_FROM_GetLastError();
+}
+
+HRESULT PEWriter::Write(const void *data, int size)
+{
+ _ASSERTE(m_file != INVALID_HANDLE_VALUE);
+
+ HRESULT hr = S_OK;
+ DWORD dwWritten = 0;
+ if (size)
+ {
+ CQuickBytes zero;
+ if (data == NULL)
+ {
+ hr = zero.ReSizeNoThrow(size);
+ if (SUCCEEDED(hr))
+ {
+ ZeroMemory(zero.Ptr(), size);
+ data = zero.Ptr();
+ }
+ }
+
+ if (WriteFile(m_file, data, size, &dwWritten, NULL))
+ {
+ _ASSERTE(dwWritten == (DWORD)size);
+ }
+ else
+ hr = HRESULT_FROM_GetLastError();
+ }
+
+ return hr;
+}
+
+HRESULT PEWriter::Pad(int align)
+{
+ DWORD offset = SetFilePointer(m_file, 0, NULL, FILE_CURRENT);
+ int pad = padLen(offset, align);
+ if (pad > 0)
+ return Write(NULL, pad);
+ else
+ return S_FALSE;
+}
+
+HRESULT PEWriter::Close()
+{
+ if (m_file == INVALID_HANDLE_VALUE)
+ return S_OK;
+
+ HRESULT hr;
+ if (CloseHandle(m_file))
+ hr = S_OK;
+ else
+ hr = HRESULT_FROM_GetLastError();
+
+ m_file = INVALID_HANDLE_VALUE;
+
+ return hr;
+}
+
+/******************************************************************/
+HRESULT PEWriter::write(__in LPCWSTR fileName) {
+
+ HRESULT hr;
+
+#ifdef ENC_DELTA_HACK
+ PathString szFileName;
+ DWORD len = WszGetEnvironmentVariable(L"COMP_ENC_EMIT", szFileName);
+ _ASSERTE(len < sizeof(szFileName));
+ if (len > 0)
+ {
+ _ASSERTE(!m_pSeedFileDecoder);
+ szFileName.Append(L".dil");
+
+ HANDLE pDelta = WszCreateFile(szFileName,
+ GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+ if (pDelta == INVALID_HANDLE_VALUE) {
+ hr = HRESULT_FROM_GetLastError();
+ _ASSERTE(!"failure so open .dil file");
+ goto ErrExit;
+ }
+
+ // write the actual data
+ for (PEWriterSection **cur = getSectStart(); cur < getSectCur(); cur++) {
+ if (strcmp((*cur)->m_name, ".text") == 0)
+ {
+ hr = (*cur)->write(pDelta);
+ CloseHandle(pDelta);
+ pDelta = NULL;
+ if (FAILED(hr))
+ {
+ _ASSERT(!"failure to write to .dil file");
+ goto ErrExit;
+ }
+ break;
+ }
+ }
+ PREFIX_ASSUME(!pDelta);
+ return S_OK;
+ }
+#endif
+
+ bool ExeOrDll;
+ unsigned RoundUpVal;
+ ExeOrDll = isExeOrDll(m_ntHeaders);
+ RoundUpVal = VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
+
+ IfFailGo(Open(fileName));
+
+ if(ExeOrDll)
+ {
+ // write the PE headers
+ IfFailGo(Write(&m_dosHeader, sizeof(IMAGE_DOS_HEADER)));
+ IfFailGo(Write(x86StubPgm, sizeof(x86StubPgm)));
+ IfFailGo(Write(m_ntHeaders, m_ntHeadersSize));
+ }
+ else
+ {
+ // write the object file header
+ IfFailGo(Write(&(m_ntHeaders->FileHeader),sizeof(IMAGE_FILE_HEADER)));
+ }
+
+ IfFailGo(Write(headers, (int)(sizeof(IMAGE_SECTION_HEADER)*(headersEnd-headers))));
+
+ IfFailGo(Pad(RoundUpVal));
+
+ // write the actual data
+ for (PEWriterSection **cur = getSectStart(); cur < getSectCur(); cur++) {
+ if ((*cur)->m_header != NULL) {
+ IfFailGo(Seek((*cur)->m_filePos));
+ IfFailGo((*cur)->write(m_file));
+ IfFailGo(Write(NULL, (*cur)->m_filePad));
+ }
+ }
+
+ // writes for an object file
+ if (!ExeOrDll)
+ {
+ // write the relocs section (Does nothing if relocs section is empty)
+ IfFailGo(reloc->write(m_file));
+ //write string table (obj only, empty for exe or dll)
+ IfFailGo(strtab->write(m_file));
+ int lena = padLen(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(), RoundUpVal);
+ if (lena > 0)
+ IfFailGo(Write(NULL, lena));
+ }
+
+ return Close();
+
+ ErrExit:
+ Close();
+
+ return hr;
+}
+
+HRESULT PEWriter::write(void ** ppImage)
+{
+ bool ExeOrDll = isExeOrDll(m_ntHeaders);
+ const unsigned RoundUpVal = VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
+ char *pad = (char *) _alloca(RoundUpVal);
+ memset(pad, 0, RoundUpVal);
+
+ size_t lSize = filePos;
+ if (!ExeOrDll)
+ {
+ lSize += reloc->dataLen();
+ lSize += strtab->dataLen();
+ lSize += padLen(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(),
+ RoundUpVal);
+ }
+
+ // allocate the block we are handing back to the caller
+ void * pImage = (void *) ::CoTaskMemAlloc(lSize);
+ if (NULL == pImage)
+ {
+ return E_OUTOFMEMORY;
+ }
+
+ // zero the memory
+ ::memset(pImage, 0, lSize);
+
+ char *pCur = (char *)pImage;
+
+ if(ExeOrDll)
+ {
+ // PE Header
+ COPY_AND_ADVANCE(pCur, &m_dosHeader, sizeof(IMAGE_DOS_HEADER));
+ COPY_AND_ADVANCE(pCur, x86StubPgm, sizeof(x86StubPgm));
+ COPY_AND_ADVANCE(pCur, m_ntHeaders, m_ntHeadersSize);
+ }
+ else
+ {
+ COPY_AND_ADVANCE(pCur, &(m_ntHeaders->FileHeader), sizeof(IMAGE_FILE_HEADER));
+ }
+
+ COPY_AND_ADVANCE(pCur, headers, sizeof(*headers)*(headersEnd - headers));
+
+ // now the sections
+ // write the actual data
+ for (PEWriterSection **cur = getSectStart(); cur < getSectCur(); cur++) {
+ if ((*cur)->m_header != NULL) {
+ unsigned len;
+ pCur = (char*)pImage + (*cur)->m_filePos;
+ len = (*cur)->writeMem((void**)&pCur);
+ _ASSERTE(len == (*cur)->dataLen());
+ COPY_AND_ADVANCE(pCur, pad, (*cur)->m_filePad);
+ }
+ }
+
+ // !!! Need to jump to the right place...
+
+ if (!ExeOrDll)
+ {
+ // now the relocs (exe, dll) or symbol table (obj) (if any)
+ // write the relocs section (Does nothing if relocs section is empty)
+ reloc->writeMem((void **)&pCur);
+
+ //write string table (obj only, empty for exe or dll)
+ strtab->writeMem((void **)&pCur);
+
+ // final pad
+ size_t len = padLen(VAL32(reloc->m_header->Misc.VirtualSize)+strtab->dataLen(), RoundUpVal);
+ if (len > 0)
+ {
+ // WARNING: macro - must enclose in curly braces
+ COPY_AND_ADVANCE(pCur, pad, len);
+ }
+ }
+
+ // make sure we wrote the exact numbmer of bytes expected
+ _ASSERTE(lSize == (size_t) (pCur - (char *)pImage));
+
+ // give pointer to memory image back to caller (who must free with ::CoTaskMemFree())
+ *ppImage = pImage;
+
+ // all done
+ return S_OK;
+}
+
+HRESULT PEWriter::getFileTimeStamp(DWORD *pTimeStamp)
+{
+ if (pTimeStamp)
+ *pTimeStamp = m_peFileTimeStamp;
+
+ return S_OK;
+}
+
+DWORD PEWriter::getImageBase32()
+{
+ _ASSERTE(isPE32());
+ return VAL32(ntHeaders32()->OptionalHeader.ImageBase);
+}
+
+UINT64 PEWriter::getImageBase64()
+{
+ _ASSERTE(!isPE32());
+ return VAL64(ntHeaders64()->OptionalHeader.ImageBase);
+}
+
+void PEWriter::setImageBase32(DWORD imageBase)
+{
+ _ASSERTE(m_hSeedFile == INVALID_HANDLE_VALUE);
+
+ _ASSERTE(isPE32());
+ ntHeaders32()->OptionalHeader.ImageBase = VAL32(imageBase);
+}
+
+void PEWriter::setImageBase64(UINT64 imageBase)
+{
+ _ASSERTE(!isPE32());
+ ntHeaders64()->OptionalHeader.ImageBase = VAL64(imageBase);
+}
+
+void PEWriter::getHeaderInfo(PIMAGE_NT_HEADERS *ppNtHeaders, PIMAGE_SECTION_HEADER *ppSections, ULONG *pNumSections)
+{
+ *ppNtHeaders = m_ntHeaders;
+ *ppSections = headers;
+ *pNumSections = (ULONG)(headersEnd - headers);
+}
diff --git a/src/dlls/mscorpe/pewriter.h b/src/dlls/mscorpe/pewriter.h
new file mode 100644
index 0000000000..3a4a4fd647
--- /dev/null
+++ b/src/dlls/mscorpe/pewriter.h
@@ -0,0 +1,337 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+#ifndef PEWriter_H
+#define PEWriter_H
+
+#include <crtwrap.h>
+
+#include <windows.h>
+
+#include "ceegen.h"
+
+#include "pesectionman.h"
+
+class PEWriter;
+class PEWriterSection;
+class PEDecoder;
+struct entry;
+struct _IMAGE_SECTION_HEADER;
+
+#define SUBSECTION_ALIGN 16
+
+/***************************************************************/
+// PEWriter is derived from PESectionManager. While the base class just
+// manages the sections, PEWriter can actually write them out.
+
+class PEWriter : public PESectionMan
+{
+public:
+
+ // See ICeeFileGen.h for definition of createFlags
+ HRESULT Init(PESectionMan *pFrom, DWORD createFlags, LPCWSTR seedFileName = NULL);
+ HRESULT Cleanup();
+
+ // Finds section with given name. returns 0 if not found
+ virtual PESection* getSection(const char* name);
+
+ // Create a new section
+ virtual HRESULT newSection(const char* name, PESection **section,
+ unsigned flags=sdNone, unsigned estSize=0x10000,
+ unsigned estRelocs=0x100);
+
+ HRESULT link();
+ HRESULT fixup(CeeGenTokenMapper *pMapper);
+ HRESULT write(__in LPCWSTR fileName);
+ HRESULT write(void **ppImage);
+
+ // calling these functions is optional
+ DWORD getSectionAlignment();
+ void setSectionAlignment(DWORD);
+ DWORD getFileAlignment();
+ void setFileAlignment(DWORD);
+ DWORD getImageBase32();
+ void setImageBase32(DWORD);
+ UINT64 getImageBase64();
+ void setImageBase64(UINT64);
+ void stripRelocations(bool val); // default = false
+
+ void getHeaderInfo(PIMAGE_NT_HEADERS *ppNtHeaders, PIMAGE_SECTION_HEADER *ppSections, ULONG *pNumSections);
+
+ // these affect the charactertics in the NT file header
+ void setCharacteristics(unsigned mask);
+ void clearCharacteristics(unsigned mask);
+
+ // these affect the charactertics in the NT optional header
+ void setDllCharacteristics(unsigned mask);
+ void clearDllCharacteristics(unsigned mask);
+
+ // sets the SubSystem field in the optional header
+ void setSubsystem(unsigned subsystem, unsigned major, unsigned minor);
+
+ // specify the entry point as an offset into the text section. The
+ // method will convert into an RVA from the base
+ void setEntryPointTextOffset(unsigned entryPoint);
+
+ HRESULT setDirectoryEntry(PEWriterSection *section, ULONG entry, ULONG size, ULONG offset=0);
+
+
+ // get the RVA for the IL section
+ ULONG getIlRva();
+
+ // set the RVA for the IL section by supplying offset to the IL section
+ void setIlRva(DWORD offset);
+
+ unsigned getSubsystem();
+
+ size_t getImageBase();
+
+ void setEnCRvaBase(ULONG dataBase, ULONG rdataBase);
+
+ HRESULT getFileTimeStamp(DWORD *pTimeStamp);
+
+ IMAGE_NT_HEADERS32* ntHeaders32() { return (IMAGE_NT_HEADERS32*) m_ntHeaders; }
+ IMAGE_NT_HEADERS64* ntHeaders64() { return (IMAGE_NT_HEADERS64*) m_ntHeaders; }
+
+ bool isPE32() // true -> created a PE 32-bit PE file
+ // false -> created a PE+ 64-bit PE file
+ { return (m_ntHeaders->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC)); }
+
+ bool isI386() // true -> target machine is i386
+ { return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_I386)); }
+
+ bool isIA64() // true -> target machine is ia64
+ { return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_IA64)); }
+
+ bool isAMD64() // true -> target machine is ia64
+ { return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_AMD64)); }
+
+ bool isARM() // true -> target machine is ARM
+ { return (m_ntHeaders->FileHeader.Machine == VAL16(IMAGE_FILE_MACHINE_ARMNT)); }
+
+ bool createCorMainStub() // do we need the CorExeMain/CorDllMain stubs?
+ { return m_createCorMainStub; }
+
+private:
+ DWORD m_ilRVA;
+ BOOL m_encMode;
+ ULONG m_dataRvaBase;
+ ULONG m_rdataRvaBase;
+ ULONG m_codeRvaBase;
+ DWORD m_peFileTimeStamp;
+
+ HANDLE m_file;
+
+ // "Seed" file information. The new file data will be "appended" to the seed file
+ // These are valid only if m_hSeedFile is valid
+
+ HANDLE m_hSeedFile;
+ HANDLE m_hSeedFileMap;
+ PEDecoder * m_pSeedFileDecoder;
+ IMAGE_NT_HEADERS * m_pSeedFileNTHeaders;
+ unsigned m_iSeedSections;
+ IMAGE_SECTION_HEADER*m_pSeedSections;
+ IMAGE_SECTION_HEADER*m_pSeedSectionToAdd; // used only by newSection()
+
+ PEWriterSection **getSectStart() {
+ return (PEWriterSection**)sectStart;
+ }
+
+ PEWriterSection **getSectCur() {
+ return (PEWriterSection**)sectCur;
+ }
+
+ COUNT_T getSectCount() {
+ return COUNT_T(sectCur - sectStart);
+ }
+
+
+ IMAGE_DOS_HEADER m_dosHeader;
+ IMAGE_NT_HEADERS * m_ntHeaders;
+ DWORD m_ntHeadersSize; // Size of IMAGE_NT_HEADERS (not including section headers)
+
+ unsigned virtualPos;
+ unsigned filePos;
+
+ PEWriterSection * reloc;
+ PEWriterSection * strtab;
+
+ IMAGE_SECTION_HEADER *headers, *headersEnd;
+
+ struct directoryEntry {
+ PEWriterSection *section;
+ ULONG offset;
+ ULONG size;
+ };
+
+ // Directory entries in the file header
+ directoryEntry * pEntries;
+ USHORT cEntries;
+
+ bool m_createCorMainStub;
+
+ // Helpers for link()
+ HRESULT linkSortSections(entry * entries,
+ unsigned * piEntries, // OUT
+ unsigned * piUniqueSections); // OUT
+ HRESULT linkSortHeaders(entry * entries, unsigned iEntries, unsigned iUniqueSections);
+ HRESULT linkPlaceSections(entry * entries, unsigned iEntries);
+ void setSectionIndex(IMAGE_SECTION_HEADER * h, unsigned sectionIndex);
+
+ HRESULT Open(__in LPCWSTR fileName);
+ HRESULT Write(const void *data, int size);
+ HRESULT Seek(int offset);
+ HRESULT Pad(int align);
+ HRESULT Close();
+};
+
+// This class encapsulates emitting the base relocs into the
+// .reloc section of the PE file, for the case where the image
+// does not get loaded at its preferred base address.
+
+class PERelocSection
+{
+ private:
+ PEWriterSection * section;
+ unsigned relocPage;
+ unsigned relocSize;
+ DWORD * relocSizeAddr;
+ unsigned pages;
+
+#ifdef _DEBUG
+ unsigned lastRVA;
+#endif
+
+ public:
+ PERelocSection(PEWriterSection *pBaseReloc);
+ void AddBaseReloc(unsigned rva, int type, unsigned short highAdj=0);
+ void Finish(bool isPE32);
+};
+
+class PEWriterSection : public PESection {
+
+public:
+
+ PEWriterSection(const char* name, unsigned flags,
+ unsigned estSize, unsigned estRelocs)
+ : PESection(name, flags, estSize, estRelocs) {}
+
+ virtual HRESULT applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
+ PERelocSection * relocSection,
+ CeeGenTokenMapper * pTokenMapper,
+ DWORD rdataRvaBase,
+ DWORD dataRvaBase,
+ DWORD textRvaBase);
+
+ virtual HRESULT write (HANDLE file);
+ virtual unsigned writeMem (void ** pMem);
+ virtual bool isSeedSection() { return false; }
+
+};
+
+// This is for sections from the seed file. Their order needs to be maintained and
+// they need to be written to the output file.
+
+class PESeedSection : public PEWriterSection {
+
+public:
+
+ PESeedSection(PEDecoder * peDecoder, IMAGE_SECTION_HEADER * seedSection);
+
+ // PESection methods
+
+ unsigned dataLen() { return m_pSeedSectionHeader->SizeOfRawData; }
+ HRESULT applyRelocs(CeeGenTokenMapper *pTokenMapper) { return S_OK; }
+ char* getBlock(unsigned len, unsigned align) { _ASSERTE(!"PESeedSection"); return NULL; }
+ HRESULT truncate(unsigned newLen) { _ASSERTE(!"PESeedSection"); return E_FAIL; }
+ void writeSectReloc(unsigned val, CeeSection& relativeTo,
+ CeeSectionRelocType reloc,
+ CeeSectionRelocExtra *extra) { _ASSERTE(!"PESeedSection"); return; }
+ HRESULT addSectReloc(unsigned offset, CeeSection& relativeTo,
+ CeeSectionRelocType reloc,
+ CeeSectionRelocExtra *extra) { _ASSERTE(!"PESeedSection"); return E_FAIL; }
+ HRESULT addSectReloc(unsigned offset, PESection *relativeTo,
+ CeeSectionRelocType reloc,
+ CeeSectionRelocExtra *extra) { _ASSERTE(!"PESeedSection"); return E_FAIL; }
+ HRESULT addBaseReloc(unsigned offset, CeeSectionRelocType reloc,
+ CeeSectionRelocExtra *extra) { _ASSERTE(!"PESeedSection"); return E_FAIL; }
+// unsigned char *name();
+// unsigned flags();
+// unsigned getBaseRVA();
+ int getDirEntry() { _ASSERTE(!"PESeedSection"); return 0; }
+ HRESULT directoryEntry(unsigned num) { _ASSERTE(!"PESeedSection"); return E_FAIL; }
+ char * computePointer(unsigned offset) const { _ASSERTE(!"PESeedSection"); return NULL; }
+ BOOL containsPointer(__in char *ptr) const { _ASSERTE(!"PESeedSection"); return FALSE; }
+ unsigned computeOffset(__in char *ptr) const { _ASSERTE(!"PESeedSection"); return 0; }
+ HRESULT cloneInstance(PESection *destination) { _ASSERTE(!"PESeedSection"); return E_FAIL; }
+
+ // PEWriterSection
+
+ HRESULT applyRelocs(IMAGE_NT_HEADERS * pNtHeaders,
+ PERelocSection * relocSection,
+ CeeGenTokenMapper * pTokenMapper,
+ DWORD rdataRvaBase,
+ DWORD dataRvaBase,
+ DWORD textRvaBase) { return S_OK; }
+
+ HRESULT write(HANDLE file);
+ unsigned writeMem(void ** pMem);
+ bool isSeedSection() { return true; }
+
+protected:
+
+ PEDecoder * m_pSeedFileDecoder;
+ IMAGE_SECTION_HEADER * m_pSeedSectionHeader;
+
+};
+
+inline DWORD PEWriter::getSectionAlignment() {
+ return VAL32(m_ntHeaders->OptionalHeader.FileAlignment);
+}
+
+inline void PEWriter::setSectionAlignment(DWORD SectionAlignment) {
+
+ _ASSERTE(m_hSeedFile == INVALID_HANDLE_VALUE);
+ m_ntHeaders->OptionalHeader.SectionAlignment = VAL32(SectionAlignment);
+}
+
+inline DWORD PEWriter::getFileAlignment() {
+ return m_ntHeaders->OptionalHeader.FileAlignment;
+}
+
+inline void PEWriter::setFileAlignment(DWORD fileAlignment) {
+ _ASSERTE(m_hSeedFile == INVALID_HANDLE_VALUE);
+ m_ntHeaders->OptionalHeader.FileAlignment = VAL32(fileAlignment);
+}
+
+inline unsigned PEWriter::getSubsystem() {
+ return VAL16(m_ntHeaders->OptionalHeader.Subsystem);
+}
+
+inline void PEWriter::setSubsystem(unsigned subsystem, unsigned major, unsigned minor) {
+ m_ntHeaders->OptionalHeader.Subsystem = VAL16(subsystem);
+ m_ntHeaders->OptionalHeader.MajorSubsystemVersion = VAL16(major);
+ m_ntHeaders->OptionalHeader.MinorSubsystemVersion = VAL16(minor);
+}
+
+inline void PEWriter::setCharacteristics(unsigned mask) {
+ m_ntHeaders->FileHeader.Characteristics |= VAL16(mask);
+}
+
+inline void PEWriter::clearCharacteristics(unsigned mask) {
+ m_ntHeaders->FileHeader.Characteristics &= VAL16(~mask);
+}
+
+inline void PEWriter::setDllCharacteristics(unsigned mask) {
+ m_ntHeaders->OptionalHeader.DllCharacteristics |= VAL16(mask);
+}
+
+inline void PEWriter::clearDllCharacteristics(unsigned mask) {
+ m_ntHeaders->OptionalHeader.DllCharacteristics &= VAL16(~mask);
+}
+
+inline void PEWriter::setEntryPointTextOffset(unsigned offset) {
+ m_ntHeaders->OptionalHeader.AddressOfEntryPoint = VAL32(offset);
+}
+
+#endif
diff --git a/src/dlls/mscorpe/stdafx.cpp b/src/dlls/mscorpe/stdafx.cpp
new file mode 100644
index 0000000000..6321e11d12
--- /dev/null
+++ b/src/dlls/mscorpe/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
+//
+// Host for precompiled header.
+//
+//*****************************************************************************
+#include "stdafx.h" // Precompiled header key.
diff --git a/src/dlls/mscorpe/stdafx.h b/src/dlls/mscorpe/stdafx.h
new file mode 100644
index 0000000000..c97b552cdd
--- /dev/null
+++ b/src/dlls/mscorpe/stdafx.h
@@ -0,0 +1,24 @@
+// 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
+//
+// Common include file for utility code.
+//*****************************************************************************
+#include <stdlib.h> // for qsort
+#include <windows.h>
+#include <time.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stddef.h>
+
+#define FEATURE_NO_HOST // Do not use host interface
+#include <utilcode.h>
+
+#include <corpriv.h>
+
+#include "pewriter.h"
+#include "ceegen.h"
+#include "ceefilegenwriter.h"
+#include "ceesectionstring.h"
diff --git a/src/dlls/mscorpe/stubs.h b/src/dlls/mscorpe/stubs.h
new file mode 100644
index 0000000000..70ebed4d14
--- /dev/null
+++ b/src/dlls/mscorpe/stubs.h
@@ -0,0 +1,169 @@
+// 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.
+//*****************************************************************************
+// Stubs.h
+//
+// This file contains a template for the default entry point stubs of a COM+
+// IL only program. One can emit these stubs (with some fix-ups) and make
+// the code supplied the entry point value for the image. The fix-ups will
+// in turn cause mscoree.dll to be loaded and the correct entry point to be
+// called.
+//
+// Note: Although these stubs contain x86 specific code, they are used
+// for all platforms
+//
+//*****************************************************************************
+#ifndef __STUBS_H__
+#define __STUBS_H__
+
+//*****************************************************************************
+// This stub is designed for a x86 Windows application. It will call the
+// _CorExeMain function in mscoree.dll. This entry point will in turn load
+// and run the IL program.
+//
+// jump _CorExeMain();
+//
+// The code jumps to the imported function _CorExeMain using the iat.
+// The address in the template is address of the iat entry which is
+// fixed up by the loader when the image is paged in.
+//*****************************************************************************
+
+SELECTANY const BYTE ExeMainX86Template[] =
+{
+ // Jump through IAT to _CorExeMain
+ 0xFF, 0x25, // jmp [iat:_CorDllMain entry]
+ 0x00, 0x00, 0x00, 0x00, // address to replace
+
+};
+
+#define ExeMainX86TemplateSize sizeof(ExeMainX86Template)
+#define CorExeMainX86IATOffset 2
+
+//*****************************************************************************
+// This stub is designed for a x86 Windows application. It will call the
+// _CorDllMain function in mscoree.dll with with the base entry point for
+// the loaded DLL. This entry point will in turn load and run the IL program.
+//
+// jump _CorDllMain
+//
+// The code jumps to the imported function _CorExeMain using the iat.
+// The address in the template is address of the iat entry which is
+// fixed up by the loader when the image is paged in.
+//*****************************************************************************
+
+SELECTANY const BYTE DllMainX86Template[] =
+{
+ // Jump through IAT to CorDllMain
+ 0xFF, 0x25, // jmp [iat:_CorDllMain entry]
+ 0x00, 0x00, 0x00, 0x00, // address to replace
+};
+
+#define DllMainX86TemplateSize sizeof(DllMainX86Template)
+#define CorDllMainX86IATOffset 2
+
+//*****************************************************************************
+// This stub is designed for a AMD64 Windows application. It will call the
+// _CorExeMain function in mscoree.dll. This entry point will in turn load
+// and run the IL program.
+//
+// mov rax, _CorExeMain();
+// jmp [rax]
+//
+// The code jumps to the imported function _CorExeMain using the iat.
+// The address in the template is address of the iat entry which is
+// fixed up by the loader when the image is paged in.
+//*****************************************************************************
+
+SELECTANY const BYTE ExeMainAMD64Template[] =
+{
+ // Jump through IAT to _CorExeMain
+ 0x48, 0xA1, // rex.w rex.b mov rax,[following address]
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//address of iat:_CorExeMain entry
+ 0xFF, 0xE0 // jmp [rax]
+};
+
+#define ExeMainAMD64TemplateSize sizeof(ExeMainAMD64Template)
+#define CorExeMainAMD64IATOffset 2
+
+//*****************************************************************************
+// This stub is designed for a AMD64 Windows application. It will call the
+// _CorDllMain function in mscoree.dll with with the base entry point for
+// the loaded DLL. This entry point will in turn load and run the IL program.
+//
+// mov rax, _CorDllMain();
+// jmp [rax]
+//
+// The code jumps to the imported function _CorDllMain using the iat.
+// The address in the template is address of the iat entry which is
+// fixed up by the loader when the image is paged in.
+//*****************************************************************************
+
+SELECTANY const BYTE DllMainAMD64Template[] =
+{
+ // Jump through IAT to CorDllMain
+ 0x48, 0xA1, // rex.w rex.b mov rax,[following address]
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,//address of iat:_CorDllMain entry
+ 0xFF, 0xE0 // jmp [rax]
+};
+
+#define DllMainAMD64TemplateSize sizeof(DllMainAMD64Template)
+#define CorDllMainAMD64IATOffset 2
+
+//*****************************************************************************
+// This stub is designed for an ia64 Windows application. It will call the
+// _CorExeMain function in mscoree.dll. This entry point will in turn load
+// and run the IL program.
+//
+// jump _CorExeMain();
+//
+// The code jumps to the imported function _CorExeMain using the iat.
+// We set the value of gp to point at the iat table entry for _CorExeMain
+//*****************************************************************************
+
+SELECTANY const BYTE ExeMainIA64Template[] =
+{
+ // ld8 r9 = [gp] ;;
+ // ld8 r10 = [r9],8
+ // nop.i ;;
+ // ld8 gp = [r9]
+ // mov b6 = r10
+ // br.cond.sptk.few b6
+ //
+ 0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40,
+ 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50,
+ 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
+};
+
+#define ExeMainIA64TemplateSize sizeof(ExeMainIA64Template)
+
+//*****************************************************************************
+// This stub is designed for an ia64 Windows application. It will call the
+// _CorDllMain function in mscoree.dll with with the base entry point for
+// the loaded DLL. This entry point will in turn load and run the IL program.
+//
+// jump _CorDllMain
+//
+// The code jumps to the imported function _CorExeMain using the iat.
+// We set the value of gp to point at the iat table entry for _CorExeMain
+//*****************************************************************************
+
+SELECTANY const BYTE DllMainIA64Template[] =
+{
+ // ld8 r9 = [gp] ;;
+ // ld8 r10 = [r9],8
+ // nop.i ;;
+ // ld8 gp = [r9]
+ // mov b6 = r10
+ // br.cond.sptk.few b6
+ //
+ 0x0B, 0x48, 0x00, 0x02, 0x18, 0x10, 0xA0, 0x40,
+ 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50,
+ 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
+};
+
+#define DllMainIA64TemplateSize sizeof(DllMainIA64Template)
+
+#endif // __STUBS_H__
diff --git a/src/dlls/mscorpe/utilcodeinit.cpp b/src/dlls/mscorpe/utilcodeinit.cpp
new file mode 100644
index 0000000000..0e9fab9860
--- /dev/null
+++ b/src/dlls/mscorpe/utilcodeinit.cpp
@@ -0,0 +1,11 @@
+// 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.
+
+#include "stdafx.h"
+#include <utilcode.h>
+
+EXTERN_C void __stdcall InitializeSxS(CoreClrCallbacks const & callbacks)
+{
+ InitUtilcode(callbacks);
+}
diff --git a/src/dlls/mscorrc/.gitmirror b/src/dlls/mscorrc/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/mscorrc/.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/mscorrc/CMakeLists.txt b/src/dlls/mscorrc/CMakeLists.txt
new file mode 100644
index 0000000000..8f67988a23
--- /dev/null
+++ b/src/dlls/mscorrc/CMakeLists.txt
@@ -0,0 +1,22 @@
+include_directories("../../pal/prebuilt/corerror")
+if(WIN32)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NOENTRY")
+ # remove /ltcg from resource-only libraries
+ string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
+ string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})
+
+ # remove /guard:cf from resource-only libraries
+ string(REPLACE "/guard:cf" "" CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS})
+endif(WIN32)
+
+if(CLR_CMAKE_PLATFORM_UNIX)
+ add_compile_options(-fPIC)
+endif(CLR_CMAKE_PLATFORM_UNIX)
+
+add_subdirectory(full)
+
+# Only add the small version of the resources if the platform is Windows.
+if(WIN32)
+ add_subdirectory(small)
+endif(WIN32)
+
diff --git a/src/dlls/mscorrc/dirs.proj b/src/dlls/mscorrc/dirs.proj
new file mode 100644
index 0000000000..1792a6ed67
--- /dev/null
+++ b/src/dlls/mscorrc/dirs.proj
@@ -0,0 +1,18 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildInPhase1>true</BuildInPhase1>
+ <BuildInPhaseDefault>false</BuildInPhaseDefault>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ </PropertyGroup>
+
+ <!--The following projects will build during PHASE 1-->
+ <ItemGroup Condition="'$(BuildExePhase)' == '1'">
+ <ProjectFile Include="full\mscorrc.nativeproj" />
+ <ProjectFile Condition="'$(FeatureCoreClr)' == 'true'" Include="small\mscorrc.nativeproj" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
+</Project>
diff --git a/src/dlls/mscorrc/full/.gitmirror b/src/dlls/mscorrc/full/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/mscorrc/full/.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/mscorrc/full/CMakeLists.txt b/src/dlls/mscorrc/full/CMakeLists.txt
new file mode 100644
index 0000000000..30d93385ec
--- /dev/null
+++ b/src/dlls/mscorrc/full/CMakeLists.txt
@@ -0,0 +1,19 @@
+add_definitions(-DFX_VER_INTERNALNAME_STR=mscorrc.debug.dll)
+
+if(WIN32)
+
+ add_library_clr(mscorrc.debug SHARED
+ ../include.rc
+ )
+
+ install_clr (mscorrc.debug)
+
+else()
+ build_resources(${CMAKE_CURRENT_SOURCE_DIR}/../include.rc mscorrc_debug TARGET_CPP_FILE)
+
+ add_library_clr(mscorrc_debug STATIC
+ ${TARGET_CPP_FILE}
+ )
+
+endif(WIN32)
+
diff --git a/src/dlls/mscorrc/full/mscorrc.nativeproj b/src/dlls/mscorrc/full/mscorrc.nativeproj
new file mode 100644
index 0000000000..66262603c5
--- /dev/null
+++ b/src/dlls/mscorrc/full/mscorrc.nativeproj
@@ -0,0 +1,25 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ <OutputName Condition="'$(FeatureCoreclr)'=='true'">mscorrc.debug</OutputName>
+ <OutputName Condition="'$(FeatureCoreclr)'!='true'">mscorrc</OutputName>
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <LinkResourceOnlyDll>true</LinkResourceOnlyDll>
+ <IsProjectKLibrary>true</IsProjectKLibrary>
+ <IsTestNetCoreRuntimeLibrary>true</IsTestNetCoreRuntimeLibrary>
+ <IsPhoneLibrary>true</IsPhoneLibrary>
+ <IsDesktopTool>true</IsDesktopTool>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <RCResourceFile Include="..\include.rc" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+
+</Project>
diff --git a/src/dlls/mscorrc/fuslog.rc b/src/dlls/mscorrc/fuslog.rc
new file mode 100644
index 0000000000..8a106fa084
--- /dev/null
+++ b/src/dlls/mscorrc/fuslog.rc
@@ -0,0 +1,349 @@
+// 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.
+#include "fusres.h"
+
+#ifdef FEATURE_FUSION
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_ASSEMBLY_CREATION_FAILURE L"WRN: Found match in cache, but cannot create assembly from the cache information."
+ ID_FUSLOG_ASSEMBLY_LOOKUP_FAILURE L"LOG: GAC Lookup was unsuccessful."
+ ID_FUSLOG_ISEQUAL_DIFF_NAME L"WRN: Comparing the assembly name resulted in the mismatch: NAME"
+ ID_FUSLOG_ISEQUAL_DIFF_VERSION_MAJOR L"WRN: Comparing the assembly name resulted in the mismatch: Major Version"
+ ID_FUSLOG_ISEQUAL_DIFF_VERSION_MINOR L"WRN: Comparing the assembly name resulted in the mismatch: Minor Version"
+ ID_FUSLOG_ISEQUAL_DIFF_VERSION_REVISION L"WRN: Comparing the assembly name resulted in the mismatch: Revision Number"
+ ID_FUSLOG_ISEQUAL_DIFF_VERSION_BUILD L"WRN: Comparing the assembly name resulted in the mismatch: Build Number"
+ ID_FUSLOG_ISEQUAL_DIFF_PUBLIC_KEY_TOKEN L"WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN"
+ ID_FUSLOG_ISEQUAL_DIFF_CULTURE L"WRN: Comparing the assembly name resulted in the mismatch: CULTURE"
+ ID_FUSLOG_ISEQUAL_DIFF_CUSTOM L"WRN: Comparing the assembly name resulted in the mismatch: CUSTOM"
+ ID_FUSLOG_CANONICALIZATION_ERROR L"ERR: Fatal error occurred attempting to canonicalize the codebase for this bind."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_POLICY_CACHE_FAILURE L"LOG: Unable to prepare policy cache object."
+ ID_FUSLOG_APP_CFG_PIGGYBACK L"LOG: Download of application configuration file is already in progress."
+ ID_FUSLOG_PREBIND_INFO_START L"=== Pre-bind state information ==="
+ ID_FUSLOG_PREBIND_INFO_DISPLAY_NAME L"LOG: DisplayName = %ws\n (%ws)"
+ ID_FUSLOG_PREBIND_INFO_WHERE_REF L"LOG: Where-ref bind. Location = %ws"
+ ID_FUSLOG_PREBIND_INFO_APPBASE L"LOG: Appbase = %ws"
+ ID_FUSLOG_PREBIND_INFO_PRIVATE_PATH L"LOG: Initial PrivatePath = %ws"
+ ID_FUSLOG_PREBIND_INFO_DYNAMIC_BASE L"LOG: Dynamic Base = %ws"
+ ID_FUSLOG_PREBIND_INFO_CACHE_BASE L"LOG: Cache Base = %ws"
+ ID_FUSLOG_PREBIND_INFO_APP_NAME L"LOG: AppName = %ws"
+ ID_FUSLOG_PREBIND_INFO_END L"==="
+ ID_FUSLOG_APP_CFG_DOWNLOAD L"LOG: Attempting application configuration file download."
+ ID_FUSLOG_APP_CFG_DOWNLOAD_LOCATION L"LOG: Download of application configuration file was attempted from %ws."
+ ID_FUSLOG_CFG_NOT_EXIST L"LOG: Configuration file %ws does not exist."
+ ID_FUSLOG_APP_CFG_FOUND L"LOG: Found application configuration file (%ws)."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_DEVOVERRIDE_REF_DEF_MISMATCH L"LOG: Found assembly in DEVOVERRIDE location [%ws], but the assembly reference did not match the assembly definition found."
+ ID_FUSLOG_DEVOVERRIDE_SIGNATURE_CHECK_FAILED L"LOG: Found assembly in DEVOVERRIDE location [%ws], but signature validation failed."
+ ID_FUSLOG_XML_PRIVATE_ASM_REDIRECT L"WRN: Binding redirects specified for assemblies without strong names are ignored."
+ ID_FUSLOG_XML_PARSE_ERROR_CODE L"ERR: There was an error parsing XML (hr = 0x%x)."
+ ID_FUSLOG_XML_ASSEMBLYIDENTITY_MISSING_NAME L"WRN: The assemblyIdentity was not processed because the name attribute was missing."
+ ID_FUSLOG_XML_BINDINGREDIRECT_INSUFFICIENT_DATA L"WRN: bindingRedirect tag not processed due to insufficient data."
+ ID_FUSLOG_XML_CODEBASE_HREF_MISSING L"WRN: codeBase tag not processed because href not present."
+ ID_FUSLOG_XML_MULTIPLE_IDENTITIES L"WRN: Invalid XML. Encountered more than 1 assemblyIdentity inside single dependentAssembly. Ignoring."
+ ID_FUSLOG_PRIVATE_PATH_DUPLICATE L"WRN: Private path set. Ignoring duplicate entry."
+ ID_FUSLOG_POLICY_NOT_APPLIED L"LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind)."
+ ID_FUSLOG_NO_APP_CONFIG_FILE L"LOG: No application configuration file found."
+ ID_FUSLOG_APP_CONFIG_FILE L"LOG: Using application configuration file: %ws"
+ ID_FUSLOG_HOST_CONFIG_FILE L"LOG: Using host configuration file: %ws"
+ ID_FUSLOG_HOST_CONFIG_FILE_MISSING L"LOG: Host configuration file not found."
+ ID_FUSLOG_XML_INVALID_PROCESSORARCHITECTURE L"WRN: Invalid processor architecture is specified in assemblyIdentity. Valid processor architectures are neutral/x86/IA64/AMD64."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_HOST_CFG_REDIRECT L"LOG: Redirect found in host configuration file: %ws redirected to %ws."
+ ID_FUSLOG_HOST_CFG_NO_REDIRECT L"LOG: No redirect found in host configuration file."
+ ID_FUSLOG_APP_CFG_REDIRECT L"LOG: Redirect found in application configuration file: %ws redirected to %ws."
+ ID_FUSLOG_APP_CFG_SAFE_MODE L"LOG: Safe mode is set (publisher policy disallowed)."
+ ID_FUSLOG_PUB_CFG_MISSING L"LOG: Publisher policy file is not found."
+ ID_FUSLOG_PUB_CFG_FOUND L"LOG: Publisher policy file is found at %ws."
+ ID_FUSLOG_PUB_CFG_REDIRECT L"LOG: Publisher policy file redirect is found: %ws redirected to %ws."
+ ID_FUSLOG_PUBLISHER_POLICY_CONFIG_MISSING L"ERR: Publisher policy assembly is found, but there is no config file."
+ ID_FUSLOG_MACHINE_CFG_MISSING L"LOG: Machine configuration file does not exist at %ws."
+ ID_FUSLOG_MACHINE_CFG_FOUND L"LOG: Using machine configuration file from %ws."
+ ID_FUSLOG_MACHINE_CFG_REDIRECT L"LOG: Machine configuration policy file redirect found: %ws redirected to %ws."
+ ID_FUSLOG_REDIRECT_NO_CODEBASE L"WRN: Binding redirect encountered, but could not retrieve codebase."
+ ID_FUSLOG_POLICY_CODEBASE L"LOG: Using codebase from policy file: %ws."
+ ID_FUSLOG_POST_POLICY_REFERENCE L"LOG: Post-policy reference: %ws"
+ ID_FUSLOG_APPLY_POLICY_FAILED L"ERR: Failed to apply policy (hr = 0x%x)."
+ ID_FUSLOG_CFG_PRIVATE_PATH L"LOG: Private path hint found in configuration file: %s."
+ ID_FUSLOG_CAB_ASM_NOT_FOUND L"LOG: Unable to find target assembly in CAB file."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_XML_PARSE_ERROR_FILE L"WRN: Error parsing XML file %ws. Ignoring."
+ ID_FUSLOG_CODEBASE_RETRIEVE_FAILURE L"ERR: A fatal error occurred when retrieving next codebase for download (hr = 0x%x)."
+ ID_FUSLOG_ATTEMPT_NEW_DOWNLOAD L"LOG: Attempting download of new URL %ws."
+ ID_FUSLOG_LOADER_PERMISSION_CHECK_FAILURE L"ERR: Loader location access permission check failed for URL %ws (hr = 0x%x)."
+ ID_FUSLOG_PROBE_FAIL_BUT_ASM_FOUND L"LOG: Probing in application directory failed, but assembly bind was still able to complete."
+ ID_FUSLOG_ASM_SETUP_FAILURE L"ERR: Failed to complete setup of assembly (hr = 0x%x). Probing terminated."
+ ID_FUSLOG_PREDOWNLOAD_FAILURE L"ERR: Unrecoverable error occurred during pre-download check (hr = 0x%x)."
+ ID_FUSLOG_URLMON_MISSING L"WRN: Unable to find URLMON.DLL. Assemblies cannot be downloaded."
+ ID_FUSLOG_DOWNLOAD_PIGGYBACK L"LOG: Duplicate download found. Re-using the download in progress."
+ ID_FUSLOG_DOWNLOAD_SUCCESS L"LOG: Assembly download was successful. Attempting setup of file: %ws"
+ ID_FUSLOG_LAST_MOD_FAILURE L"ERR: Unable to extract last modified time from %ws."
+ ID_FUSLOG_MSI_CODEBASE_UNSUPPORTED L"WRN: Current version does not support CODEBASEs to .MSI files. Setup is unable to complete."
+ ID_FUSLOG_FAILED_PROBING L"LOG: All probing URLs attempted and failed."
+ ID_FUSLOG_PARTIAL_GAC_UNSUPPORTED L"ERR: Partial binds to assemblies in the global assembly cache are not supported."
+ ID_FUSLOG_GAC_LOOKUP_SUCCESS L"LOG: Lookup in global assembly cache succeeded."
+ ID_FUSLOG_MSI_INSTALL_ATTEMPT L"LOG: Attempting to install assembly using Windows Installer."
+ ID_FUSLOG_PREVIOUS_FAILED L"LOG: The same bind was seen before, and was failed with hr = 0x%x."
+END
+
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_MSI_ASM_INSTALL_SUCCESS L"LOG: Successfully installed assembly using Windows Installer."
+ ID_FUSLOG_POLICY_CACHE_INSERT_FAILURE L"ERR: Error inserting entry into policy cache."
+ ID_FUSLOG_MSI_SUCCESS_FUSION_SETUP_FAIL L"WRN: Windows Installer was able to provide the requested assembly, but setup of resulting file failed."
+ ID_FUSLOG_SETUP_RUN_FROM_SOURCE L"LOG: Entering run-from-source setup phase."
+ ID_FUSLOG_SETUP_RUN_FROM_SOURCE_FAILURE L"ERR: Run-from-source setup phase failed with hr = 0x%x."
+ ID_FUSLOG_MODULE_INTEGRITY_CHECK_FAILURE L"ERR: Module integrity check failed."
+ ID_FUSLOG_SETUP_DOWNLOAD_CACHE L"LOG: Entering download cache setup phase."
+ ID_FUSLOG_REF_DEF_MISMATCH L"ERR: The assembly reference did not match the assembly definition found."
+ ID_FUSLOG_SETUP_FAILURE L"ERR: Setup failed with hr = 0x%x."
+ ID_FUSLOG_IGNORE_INVALID_PROBE L"WRN: Not probing location %ws, because the location falls outside of the appbase."
+ ID_FUSLOG_CACHE_LOOKUP_SUCCESS L"LOG: Found assembly by looking in the GAC."
+ ID_FUSLOG_PREJIT_NOT_FOUND L"ERR: Expected to find a pre-jit assembly in cache, but assembly was not found."
+ ID_FUSLOG_CODEBASE_CONSTRUCTION_FAILURE L"ERR: Error occurred constructing the probing codebase list."
+ ID_FUSLOG_CODEBASE_UNAVAILABLE L"ERR: No codebases found to download from."
+ ID_FUSLOG_DOWNLOAD_CACHE_LOOKUP_SUCCESS L"LOG: Found assembly by looking in the download cache."
+ ID_FUSLOG_SETUP_CAB L"LOG: Setting up CAB file."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_TEMP_DIR_CREATE_FAILURE L"ERR: Unable to create a temporary directory (hr = 0x%x)."
+ ID_FUSLOG_CAB_EXTRACT_FAILURE L"ERR: Unable to extract the CAB file (hr = 0x%x)."
+ ID_FUSLOG_CAB_ASM_FOUND L"LOG: Found matching assembly from CAB file: %ws."
+ ID_FUSLOG_CAB_EXTRACT_SUCCESS L"LOG: Successfully extracted assembly from CAB file."
+ ID_FUSLOG_DOWNLOAD_CACHE_CREATE_FAILURE L"ERR: Unable to create assembly in download cache (hr = 0x%x)."
+ ID_FUSLOG_CAB_ASM_NOT_FOUND_EXTRACTED L"LOG: Unable to find assembly from extracted CAB location: %ws."
+ ID_FUSLOG_TEMP_DIR_REMOVE_FAILURE L"ERR: Unable to remove temporary directory: %ws."
+ ID_FUSLOG_MANIFEST_EXTRACT_FAILURE L"ERR: Error extracting manifest import from file (hr = 0x%x)."
+ ID_FUSLOG_NAME_DEF_EXTRACT_FAILURE L"ERR: Error retrieving assembly name definition from manifest import (hr = 0x%x)."
+ ID_FUSLOG_INVALID_ASM_PLATFORM L"ERR: Invalid assembly platform or ContentType in file (hr = 0x%x)."
+ ID_FUSLOG_INVALID_PRIVATE_ASM_LOCATION L"LOG: Private assembly found in invalid location."
+ ID_FUSLOG_PARTIAL_ASM_IN_APP_DIR L"LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy."
+ ID_FUSLOG_LOADFROM_DEFAULT_MISMATCH L"LOG: Assembly in default load context is loaded from a different location than the one in LoadFrom context."
+ ID_FUSLOG_WHERE_REF_APPLY_POLICY L"LOG: Re-apply policy for where-ref bind."
+ ID_FUSLOG_WHERE_REF_GAC_MATCH L"LOG: Codebase matches assembly in GAC."
+ ID_FUSLOG_WHERE_REF_GAC_MISMATCH L"LOG: Codebase does not match assembly in GAC."
+ ID_FUSLOG_WHERE_REF_LOAD_CONTEXT_MATCH L"LOG: Where-ref bind Codebase matches what is found in default context. Keep the result in default context."
+ ID_FUSLOG_WHERE_REF_LOAD_CONTEXT_MISMATCH L"LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context."
+ ID_FUSLOG_REPROBE_REQUIRED L"LOG: The post-policy assembly reference requires probing again."
+ ID_FUSLOG_SWITCH_TO_DEFAULT_CONTEXT L"LOG: Switch from LoadFrom context to default context."
+ ID_FUSLOG_SWITCH_TO_LOADFROM_CONTEXT L"LOG: Switch from default context to LoadFrom context."
+ ID_FUSLOG_DUPLICATE_ASM_COMMIT L"WRN: A duplicate assembly was found while copying the assembly item to the cache."
+ ID_FUSLOG_COPY_FILE_FAILURE L"ERR: Unable to copy file to cache location."
+ ID_FUSLOG_INVALID_LOCATION_INFO L"ERR: The private assembly was located outside of appbase. Source Url = %ws."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_ASYNC_CFG_DOWNLOAD_SUCCESS L"LOG: The asynchronous application configuration file download successful. Download location %ws"
+ ID_FUSLOG_ASYNC_CFG_DOWNLOAD_FAILURE L"LOG: The asynchronous configuration file download unsuccessful."
+ ID_FUSLOG_CACHE_ITEM_CREATE_FAILURE L"ERR: Unable to create assembly cache item (hr = 0x%x)."
+ ID_FUSLOG_CACHE_ITEM_COMMIT_FAILURE L"ERR: Unable to commit cache item. Attempt to put assembly in cache unsuccessful (hr = 0x%x)."
+ ID_FUSLOG_LOADCTX_HIT L"LOG: Reusing an assembly instance that was previously loaded (%ws)."
+ ID_FUSLOG_BIND_SUCCESS L"LOG: Binding succeeds. Returns assembly from %ws."
+ ID_FUSLOG_ASSEMBLY_NAME_DEF L"LOG: Assembly Name is: %ws"
+END
+
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_OPERATION_SUCCESSFUL L"The operation was successful."
+ ID_FUSLOG_OPERATION_FAILED L"The operation failed."
+ ID_FUSLOG_DETAILED_LOG L"--- A detailed error log follows. \n"
+ ID_FUSLOG_HEADER_TEXT L"*** Assembly Binder Log Entry "
+ ID_FUSLOG_BIND_RESULT_TEXT L"Bind result: hr = 0x%x. %ws"
+ ID_FUSLOG_NO_DESCRIPTION L"No description available.\n"
+ ID_FUSLOG_FUSION_DLL_PATH L"Assembly manager loaded from: "
+ ID_FUSLOG_EXECUTABLE L"Running under executable "
+ ID_FUSLOG_QUALIFIED_ASSEMBLY L"LOG: Partial reference qualified from config file. New reference: %ws."
+ ID_FUSLOG_CALLING_ASSEMBLY L"Calling assembly : %ws."
+ ID_FUSLOG_CFG_ASSEMBLY_STORE L"LOG: AssemblyStore path = %ws"
+ END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_PARTIAL_BIND_DEBUG L"ERR: Partial GAC binds disallowed. [Partial Name = %ws : Calling Assembly = %ws : EXE Name = %ws]."
+ ID_FUSLOG_DISALLOW_APPLY_PUB_POLICY L"WRN: Application configuration file safe mode disallowed."
+ ID_FUSLOG_DISALLOW_APP_BINDING_REDIRECTS L"WRN: Application configuration file binding redirects disallowed."
+ ID_FUSLOG_PREBIND_INFO_DEVOVERRIDE_GLOBAL L"LOG: Global DEVOVERRIDE path = %ws"
+ ID_FUSLOG_PREBIND_INFO_DEVOVERRIDE_LOCAL L"LOG: Local DEVOVERRIDE path = %ws"
+ ID_FUSLOG_DEVOVERRIDE_FOUND L"LOG: Found assembly in DEVOVERRIDE path %ws"
+ ID_FUSLOG_DEVOVERRIDE_MISS L"LOG: Did not find assembly in DEVOVERRIDE path %ws"
+ ID_FUSLOG_PREBIND_INFO_DEVPATH L"LOG: DEVPATH = %ws"
+ ID_FUSLOG_ASSEMBLYSTORE_DUPLICATE L"WRN: assemblyStore has already been set. Ignoring duplicate entry."
+ ID_FUSLOG_DEVOVERRIDE_DUPLICATE L"WRN: devOverridePath has already been set. Ignoring duplicate entry."
+ ID_FUSLOG_DISALLOW_APP_BASE_PROBING L"WRN: App base probing is disallowed."
+ ID_FUSLOG_INSPECTION_ONLY L"LOG: This is an inspection only bind."
+ ID_FUSLOG_SHOW_START_LOAD_CONTEXT L"LOG: This bind starts in %ws load context."
+ ID_FUSLOG_SHOW_RESULT_LOAD_CONTEXT L"LOG: Assembly is loaded in %ws load context."
+ ID_FUSLOG_LOAD_CONTEXT_PA_MISMATCH L"ERR: An assembly with different processor architecture is already loaded."
+ ID_FUSLOG_INCOMPATIBLE_PROCESSOR_ARCHITECTURE L"ERR: Attempt to load an assembly with ProcessorArchitecture incompatible with the running process."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_ISEQUAL_DIFF_RETARGET L"WRN: Comparing the assembly name resulted in the mismatch: Retargetable flag"
+ ID_FUSLOG_ISEQUAL_DIFF_PROCESSOR_ARCHITECTURE L"WRN: Comparing the assembly name resulted in mismatch of Processor Architecture: Ref %ws, Def %ws."
+ ID_FUSLOG_ISEQUAL_DIFF_CONTENT_TYPE L"WRN: Comparing the assembly name resulted in the mismatch: Content Type"
+ ID_FUSLOG_RETARGET_CFG_MISSING L"LOG: Retarget policy is not found."
+ ID_FUSLOG_RETARGET_CFG_NAME_REDIRECT L"LOG: Name redirect found in retarget config: %ws redirected to %ws."
+ ID_FUSLOG_RETARGET_CFG_VER_REDIRECT L"LOG: Version redirect found in retarget config: %ws redirected to %ws."
+ ID_FUSLOG_RETARGET_CFG_PKT_REDIRECT L"LOG: PublicKeyToken redirect found in retarget config: %ws redirected to %ws."
+ ID_FUSLOG_XML_PARSE_ERROR_MEMORY L"ERR: Parse XML memory stream failed."
+ ID_FUSLOG_XML_BINDINGRETARGET_INSUFFICIENT_DATA L"ERR: bindingRetarget tag is not processed due to insufficient data."
+ ID_FUSLOG_FX_CFG_MISSING L"Log: framework config is not found."
+ ID_FUSLOG_FX_CFG_VER_REDIRECT L"LOG: Version redirect found in framework config: %ws redirected to %ws."
+ ID_FUSLOG_APPLIESTO_DUPLICATE L"WRN: appliesTo has already been set. Ignoring duplicate appliesTo."
+ ID_FUSLOG_PORTABILITY_CFG_NAME_REDIRECT L"LOG: Name redirect found in portability config: %ws redirected to %ws."
+ ID_FUSLOG_PORTABILITY_CFG_VER_REDIRECT L"LOG: Version redirect found in portability config: %ws redirected to %ws."
+ ID_FUSLOG_PORTABILITY_CFG_PKT_REDIRECT L"LOG: PublicKeyToken redirect found in portability config: %ws redirected to %ws."
+ ID_FUSLOG_WARNING_SUPPORTPORTABILITY_MISSING_PKT L"WRN: supportPortability tag is not processed due to missing PKT attribute."
+ ID_FUSLOG_WARNING_SUPPORTPORTABILITY_MISSING_ENABLE L"WRN: supportPortability tag is not processed due to missing enable attribute."
+ ID_FUSLOG_WARNING_SUPPORTPORTABILITY_INVALID_ENABLE L"WRN: supportPortability tag is not processed due to enable attribute not being 'true' or 'false'."
+
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_LOADCTX_HIT_HOST L"LOG: Reusing a host assembly instance that was previously loaded."
+ ID_FUSLOG_HOST_RESOLVED L"LOG: Assembly binding is resolved by the host."
+ ID_FUSLOG_ADMIN_CFG_POLICY_CODEBASE L"LOG: Codebase hint found in machine config file: %ws"
+ ID_FUSLOG_PROCESSOR_ARCHITECTURE_LOCKED L"LOG: ProcessorArchitecture is locked to %ws."
+ ID_FUSLOG_CHECK_HOST L"LOG: Fusion is hosted. Check host about this assembly."
+ ID_FUSLOG_NOT_IN_CLR_LOADED_LIST L"LOG: Assembly is not in CLR Loaded list. Asking host assembly store."
+ ID_FUSLOG_IN_CLR_LOADED_LIST L"LOG: Assembly is in CLR Loaded list. Proceed to normal probing."
+ ID_FUSLOG_HOST_STORE_NOT_AVAILABLE L"WRN: Host did not provide an assembly store."
+ ID_FUSLOG_HOST_STORE_RESOLVE_TRY L"LOG: Try host assembly store with assembly %ws."
+ ID_FUSLOG_HOST_STORE_RESOLVE_FAILED L"WRN: Host assembly store does not contain this assembly."
+ ID_FUSLOG_HOST_STORE_PARTIAL_NAME_SKIP L"LOG: Input is partial name. Skip host assembly store lookup."
+ ID_FUSLOG_HOST_GAC_ASM_MISMATCH L"WRN: The assembly returned from host store has different signature from the one in GAC."
+ ID_FUSLOG_HOST_RESULT L"LOG: Host store returns assembly stream with id = %I64u, context = %I64u."
+ ID_FUSLOG_HOST_NO_DEBUG_STREAM L"LOG: Host store does not provide debug stream."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_EXPLICIT_BIND_IJW L"LOG: IJW explicit bind. File path:%ws."
+ ID_FUSLOG_EXPLICIT_BIND_EXE L"LOG: EXE explicit bind. File path:%ws."
+ ID_FUSLOG_EXPLICIT_BIND_IJW_BIND_FAIL L"ERR: IJW assembly bind failure. hr = 0x%x."
+ ID_FUSLOG_EXPLICIT_BIND_IJW_PATH_DIFF L"LOG: IJW assembly bind returned a different path: %ws. Use the file provided."
+ ID_FUSLOG_EXPLICIT_BIND_IJW_PATH_MATCH L"LOG: IJW assembly bind returned the same manifest path."
+ ID_FUSLOG_EXPLICIT_BIND_IJW_NOT_FOUND L"LOG: IJW assembly bind returned file not found."
+ ID_FUSLOG_EXPLICIT_BIND_EXE_LOADCONTEXT_COLLISION L"ERR: Assembly with the same identity has already been loaded."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_LOG_TURNED_OFF L"WRN: Assembly binding logging is turned OFF."
+ ID_FUSLOG_LOG_TURN_ON_HKLM L"To enable assembly bind failure logging, set the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD) to 1."
+ ID_FUSLOG_LOG_PERF_WARNING L"Note: There is some performance penalty associated with assembly bind failure logging."
+ ID_FUSLOG_LOG_TURN_OFF_HKLM L"To turn this feature off, remove the registry value [HKLM\\Software\\Microsoft\\Fusion!EnableLog]."
+ ID_FUSLOG_UNSUPPORTED_LINKED_CONFIGURATION L"ERR: Unsupported linked configuration location: %ws"
+ ID_FUSLOG_LINKED_CONFIGURATION_PARSE_ERROR L"ERR: Error processing linked configurations (hr = 0x%x)"
+ ID_FUSLOG_LINKED_CONFIGURATION_DUPLICATE L"WRN: Ignoring duplicate linked configuration"
+ ID_FUSLOG_PROCESSING_LINKED_CONFIGURATION L"LOG: Processing linked configuration: %ws"
+ ID_FUSLOG_MISSING_CACHE_FILE L"ERR: Downloaded file was not cached. The web server may be configured to expire content immediately."
+ ID_FUSLOG_NO_PARTIAL_NAME_FOR_HOST_APPBASE_COMMON_ASM L"ERR: Partial Name Binding is not allowed when the same assembly exists in both the host assembly store and application base."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_WARNING_PARTIAL_NAME_HEADER L"WRN: Partial binding information was supplied for an assembly:"
+ ID_FUSLOG_WARNING_PARTIAL_NAME_DETAIL L"WRN: A partial bind occurs when only part of the assembly display name is provided.\r\nWRN: This might result in the binder loading an incorrect assembly.\r\nWRN: It is recommended to provide a fully specified textual identity for the assembly,\r\nWRN: that consists of the simple name, version, culture, and public key token.\r\nWRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue."
+ ID_FUSLOG_WARNING_PARTIAL_NAME_INSTANCE L"WRN: Assembly Name: %s | Domain ID: %d"
+ ID_FUSLOG_WARNING_MULTIPLE_VERSIONS_HEADER L"WRN: Multiple versions of the same assembly were loaded into one context of an application domain:"
+ ID_FUSLOG_WARNING_MULTIPLE_VERSIONS_DETAIL L"WRN: This might lead to runtime failures.\r\nWRN: It is recommended that you remove the dependency on multiple versions, and change the app.config file to point to the required version of the assembly only.\r\nWRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information."
+ ID_FUSLOG_WARNING_MULTIPLE_VERSIONS_INSTANCE L"WRN: Context: %s | Domain ID: %d | Assembly Name: %s"
+ ID_FUSLOG_WARNING_MULTIPLE_CONTEXTS_HEADER L"WRN: The same assembly was loaded into multiple contexts of an application domain:"
+ ID_FUSLOG_WARNING_MULTIPLE_CONTEXTS_DETAIL L"WRN: This might lead to runtime failures.\r\nWRN: It is recommended to inspect your application on whether this is intentional or not.\r\nWRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_BINDING_STATUS_BEGIN L"BEGIN : %s"
+ ID_FUSLOG_BINDING_STATUS_END L"END"
+ ID_FUSLOG_BINDING_STATUS_END_HR L"END : %s"
+ ID_FUSLOG_BINDING_STATUS_NATIVE_DEPENDENCY L"Native image dependency bind."
+ ID_FUSLOG_BINDING_STATUS_IMMERSIVE L"Immersive bind."
+ ID_FUSLOG_BINDING_STATUS_FRAMEWORK L"Framework bind."
+ ID_FUSLOG_BINDING_STATUS_FX_ASSEMBLY_BLOCKED L"Found .NET Framework assembly is not supported in AppX."
+ ID_FUSLOG_BINDING_STATUS_LOAD_FILE L"Assembly.LoadFile bind."
+ ID_FUSLOG_BINDING_STATUS_WINRT L"Windows Runtime Type bind."
+ ID_FUSLOG_BINDING_DEPENDENCY_NAME L"Dependency name: %s"
+ ID_FUSLOG_BINDING_STATUS_FOUND L"Found: %s"
+ ID_FUSLOG_BINDING_STATUS_IL_IMAGE L"IL image bind."
+ ID_FUSLOG_BINDING_STATUS_NATIVE_IMAGE L"Native image bind."
+END
+
+#else // FEATURE_FUSION
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_MANIFEST_FAILURE_NO_FILE L"WRN: Probed manifest path %s. No such file."
+ ID_FUSLOG_MANIFEST_FAILURE_PARSE_ERROR L"WRN: Probed manifest path %s. Ignored. Syntax error or URI encountered."
+ ID_FUSLOG_MANIFEST_FAILURE_UNKNOWN_ERROR L"WRN: Probed manifest path %s. Ignored. Unknown error occurred."
+ ID_FUSLOG_MANIFEST_FAILURE_EMPTY_DEFAULT L"WRN: Using empty default manifest."
+
+ ID_FUSLOG_MANIFEST_STATUS_STATE_CONFIGURED L"LOG: Using configured manifest from %s."
+ ID_FUSLOG_MANIFEST_STATUS_STATE_INHERITED L"LOG: Using inherited manifest from %s."
+
+ ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_ID L"LOG: Bound to assembly %s."
+ ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_LOCATION L"LOG: Assembly is picked up from %s."
+ ID_FUSLOG_ASSEMBLY_STATUS_BOUND_GAC L"LOG: Assembly is picked up from GAC."
+ ID_FUSLOG_ASSEMBLY_STATUS_BOUND_HAS L"LOG: Assembly is picked up from HAS."
+ ID_FUSLOG_ASSEMBLY_STATUS_BOUND_BYTE_ARRAY L"LOG: Assembly is picked up from byte array."
+
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_BEGIN L"=== Pre-bind state information ==="
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_BY_NAME L"LOG: By-name Bind. Display name = %s"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_BY_NAME_PARTIAL L"WRN: Unsupported partial name Bind. Display name = %s"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_WHERE_REF L"LOG: Where-ref bind. Codebase = %s"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_CALLER L"Calling assembly : %s"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_CALLER_UNKNOWN L"Calling assembly : unknown"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_USER L"LOG: User = %s"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_USER_UNKNOWN L"LOG: User = unknown"
+ ID_FUSLOG_BINDING_PRE_BIND_STATE_END L"==="
+
+ ID_FUSLOG_BINDING_LOCKED_UNLOCKED L"LOG: Display name not listed in manifest. This is a dynamic bind."
+ ID_FUSLOG_BINDING_LOCKED_ASSEMBLY_EXE_CONTEXT L"LOG: Execution context locked by already bound assembly. Display name = %s"
+ ID_FUSLOG_BINDING_LOCKED_ASSEMBLY_INS_CONTEXT L"LOG: Inspection context locked by already bound assembly. Display name = %s"
+ ID_FUSLOG_BINDING_LOCKED_MT_EXE_LOCKED_ENTRY L"LOG: Execution context locked by manifest. Display name = %s via locked entry."
+ ID_FUSLOG_BINDING_LOCKED_MT_EXE_LOCALI_ENTRY L"LOG: Execution context locked by manifest. Display name = %s via localizable entry."
+ ID_FUSLOG_BINDING_LOCKED_MT_EXE_CBASE_ENTRY L"LOG: Execution context locked by manifest. Display name = %s and Codebase = %s."
+ ID_FUSLOG_BINDING_LOCKED_MT_INS_LOCKED_ENTRY L"LOG: Inspection context locked by manifest. Display name = %s via locked entry."
+ ID_FUSLOG_BINDING_LOCKED_MT_INS_LOCALI_ENTRY L"LOG: Inspection context locked by manifest. Display name = %s via localizable entry."
+ ID_FUSLOG_BINDING_LOCKED_MT_INS_CBASE_ENTRY L"LOG: Inspection context locked by manifest. Display name = %s and Codebase = %s."
+ ID_FUSLOG_BINDING_BEHAVIOR_STATIC L"LOG: Probing GAC for highest service version."
+ ID_FUSLOG_BINDING_BEHAVIOR_ORDER_INDEPENDENT L"LOG: Probing GAC for order-independent assembly version."
+ ID_FUSLOG_BINDING_BEHAVIOR_BEST_MATCH L"LOG: Probing GAC for best-matching assembly version."
+
+ ID_FUSLOG_BINDING_LOG_WHERE_REF_NAME L"LOG: Display name in codebase = "
+ ID_FUSLOG_BINDING_LOG_NATIVE_ACTIVATION L"LOG: Mixed-mode assembly bind via native activation. No servicing is possible."
+ ID_FUSLOG_BINDING_LOG_INSPECTION_ONLY_BIND L"LOG: Inspection-only bind."
+ ID_FUSLOG_BINDING_LOG_RETARGETED L"LOG: Retarget: %s retargeted to %s"
+ ID_FUSLOG_BINDING_LOG_ERRONOUS_MANIFEST_ENTRY L"LOG: Erronous manifest entry. Declared as %s but found %s"
+ ID_FUSLOG_BINDING_LOG_PATH_ATTEMPT L"LOG: Attempting path %s"
+
+ ID_FUSLOG_BINDING_HEADER_BEGIN L"*** Assembly Binder Log Entry %s ***"
+ ID_FUSLOG_BINDING_HEADER_BIND_RESULT L"Bind result: hr = %s"
+ ID_FUSLOG_BINDING_HEADER_BIND_RESULT_SUCCESS L"The operation was successful."
+ ID_FUSLOG_BINDING_HEADER_BIND_RESULT_ERROR L"The operation failed."
+ ID_FUSLOG_BINDING_HEADER_END L"--- A detailed log follows."
+END
+
+#endif // FEATURE_FUSION
diff --git a/src/dlls/mscorrc/fusres.h b/src/dlls/mscorrc/fusres.h
new file mode 100644
index 0000000000..6d3e1b2216
--- /dev/null
+++ b/src/dlls/mscorrc/fusres.h
@@ -0,0 +1,310 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+#ifndef __FUSION_RESOURCE_H_
+#define __FUSION_RESOURCE_H_
+
+#ifdef FEATURE_FUSION
+
+#define ID_FUSLOG_ASSEMBLY_CREATION_FAILURE 10000
+#define ID_FUSLOG_ASSEMBLY_LOOKUP_FAILURE 10001
+#define ID_FUSLOG_ISEQUAL_DIFF_NAME 10005
+#define ID_FUSLOG_ISEQUAL_DIFF_VERSION_MAJOR 10006
+#define ID_FUSLOG_ISEQUAL_DIFF_VERSION_MINOR 10007
+#define ID_FUSLOG_ISEQUAL_DIFF_VERSION_REVISION 10008
+#define ID_FUSLOG_ISEQUAL_DIFF_VERSION_BUILD 10009
+#define ID_FUSLOG_ISEQUAL_DIFF_PUBLIC_KEY_TOKEN 10010
+#define ID_FUSLOG_ISEQUAL_DIFF_CULTURE 10011
+#define ID_FUSLOG_ISEQUAL_DIFF_CUSTOM 10012
+#define ID_FUSLOG_CANONICALIZATION_ERROR 10014
+#define ID_FUSLOG_POLICY_CACHE_FAILURE 10016
+#define ID_FUSLOG_APP_CFG_PIGGYBACK 10017
+#define ID_FUSLOG_PREBIND_INFO_START 10018
+#define ID_FUSLOG_PREBIND_INFO_DISPLAY_NAME 10019
+#define ID_FUSLOG_PREBIND_INFO_WHERE_REF 10020
+#define ID_FUSLOG_PREBIND_INFO_APPBASE 10021
+#define ID_FUSLOG_PREBIND_INFO_PRIVATE_PATH 10023
+#define ID_FUSLOG_PREBIND_INFO_DYNAMIC_BASE 10024
+#define ID_FUSLOG_PREBIND_INFO_CACHE_BASE 10025
+#define ID_FUSLOG_PREBIND_INFO_APP_NAME 10026
+#define ID_FUSLOG_PREBIND_INFO_END 10027
+#define ID_FUSLOG_APP_CFG_DOWNLOAD 10028
+#define ID_FUSLOG_APP_CFG_DOWNLOAD_LOCATION 10029
+#define ID_FUSLOG_LOADCTX_HIT 10030
+#define ID_FUSLOG_CFG_NOT_EXIST 10031
+#define ID_FUSLOG_APP_CFG_FOUND 10032
+#define ID_FUSLOG_DEVOVERRIDE_REF_DEF_MISMATCH 10036
+#define ID_FUSLOG_DEVOVERRIDE_SIGNATURE_CHECK_FAILED 10037
+#define ID_FUSLOG_XML_PRIVATE_ASM_REDIRECT 10039
+#define ID_FUSLOG_XML_PARSE_ERROR_CODE 10041
+#define ID_FUSLOG_XML_ASSEMBLYIDENTITY_MISSING_NAME 10042
+#define ID_FUSLOG_XML_BINDINGREDIRECT_INSUFFICIENT_DATA 10043
+#define ID_FUSLOG_XML_CODEBASE_HREF_MISSING 10044
+#define ID_FUSLOG_XML_MULTIPLE_IDENTITIES 10045
+#define ID_FUSLOG_PRIVATE_PATH_DUPLICATE 10046
+#define ID_FUSLOG_POLICY_NOT_APPLIED 10047
+#define ID_FUSLOG_HOST_CONFIG_FILE 10048
+#define ID_FUSLOG_HOST_CONFIG_FILE_MISSING 10049
+#define ID_FUSLOG_HOST_CFG_REDIRECT 10051
+#define ID_FUSLOG_HOST_CFG_NO_REDIRECT 10052
+#define ID_FUSLOG_APP_CFG_REDIRECT 10053
+#define ID_FUSLOG_APP_CFG_SAFE_MODE 10054
+#define ID_FUSLOG_PUB_CFG_MISSING 10055
+#define ID_FUSLOG_PUB_CFG_FOUND 10056
+#define ID_FUSLOG_PUB_CFG_REDIRECT 10057
+#define ID_FUSLOG_MACHINE_CFG_MISSING 10058
+#define ID_FUSLOG_MACHINE_CFG_FOUND 10059
+#define ID_FUSLOG_MACHINE_CFG_REDIRECT 10060
+#define ID_FUSLOG_REDIRECT_NO_CODEBASE 10061
+#define ID_FUSLOG_POLICY_CODEBASE 10062
+#define ID_FUSLOG_POST_POLICY_REFERENCE 10063
+#define ID_FUSLOG_APPLY_POLICY_FAILED 10064
+#define ID_FUSLOG_CFG_PRIVATE_PATH 10065
+#define ID_FUSLOG_XML_PARSE_ERROR_FILE 10066
+#define ID_FUSLOG_CODEBASE_RETRIEVE_FAILURE 10067
+#define ID_FUSLOG_ATTEMPT_NEW_DOWNLOAD 10068
+#define ID_FUSLOG_PROBE_FAIL_BUT_ASM_FOUND 10069
+#define ID_FUSLOG_ASM_SETUP_FAILURE 10070
+#define ID_FUSLOG_PREDOWNLOAD_FAILURE 10071
+#define ID_FUSLOG_URLMON_MISSING 10072
+#define ID_FUSLOG_DOWNLOAD_PIGGYBACK 10073
+#define ID_FUSLOG_DOWNLOAD_SUCCESS 10074
+#define ID_FUSLOG_LAST_MOD_FAILURE 10075
+#define ID_FUSLOG_MSI_CODEBASE_UNSUPPORTED 10076
+#define ID_FUSLOG_CAB_ASM_NOT_FOUND_EXTRACTED 10077
+#define ID_FUSLOG_FAILED_PROBING 10078
+#define ID_FUSLOG_PARTIAL_GAC_UNSUPPORTED 10079
+#define ID_FUSLOG_GAC_LOOKUP_SUCCESS 10080
+#define ID_FUSLOG_MSI_INSTALL_ATTEMPT 10081
+#define ID_FUSLOG_MSI_ASM_INSTALL_SUCCESS 10082
+#define ID_FUSLOG_POLICY_CACHE_INSERT_FAILURE 10084
+#define ID_FUSLOG_MSI_SUCCESS_FUSION_SETUP_FAIL 10085
+#define ID_FUSLOG_SETUP_RUN_FROM_SOURCE 10086
+#define ID_FUSLOG_MODULE_INTEGRITY_CHECK_FAILURE 10087
+#define ID_FUSLOG_SETUP_DOWNLOAD_CACHE 10088
+#define ID_FUSLOG_REF_DEF_MISMATCH 10089
+#define ID_FUSLOG_SETUP_FAILURE 10090
+#define ID_FUSLOG_IGNORE_INVALID_PROBE 10091
+#define ID_FUSLOG_CACHE_LOOKUP_SUCCESS 10092
+#define ID_FUSLOG_PREJIT_NOT_FOUND 10093
+#define ID_FUSLOG_CODEBASE_CONSTRUCTION_FAILURE 10094
+#define ID_FUSLOG_CODEBASE_UNAVAILABLE 10095
+#define ID_FUSLOG_DOWNLOAD_CACHE_LOOKUP_SUCCESS 10096
+#define ID_FUSLOG_SETUP_CAB 10097
+#define ID_FUSLOG_TEMP_DIR_CREATE_FAILURE 10098
+#define ID_FUSLOG_CAB_EXTRACT_FAILURE 10099
+#define ID_FUSLOG_CAB_ASM_FOUND 10100
+#define ID_FUSLOG_CAB_EXTRACT_SUCCESS 10101
+#define ID_FUSLOG_DOWNLOAD_CACHE_CREATE_FAILURE 10102
+#define ID_FUSLOG_CAB_ASM_NOT_FOUND 10103
+#define ID_FUSLOG_TEMP_DIR_REMOVE_FAILURE 10104
+#define ID_FUSLOG_MANIFEST_EXTRACT_FAILURE 10105
+#define ID_FUSLOG_NAME_DEF_EXTRACT_FAILURE 10106
+#define ID_FUSLOG_INVALID_PRIVATE_ASM_LOCATION 10107
+#define ID_FUSLOG_PARTIAL_ASM_IN_APP_DIR 10108
+#define ID_FUSLOG_REPROBE_REQUIRED 10109
+#define ID_FUSLOG_DUPLICATE_ASM_COMMIT 10110
+#define ID_FUSLOG_INVALID_ASM_PLATFORM 10111
+#define ID_FUSLOG_COPY_FILE_FAILURE 10112
+#define ID_FUSLOG_INVALID_LOCATION_INFO 10113
+#define ID_FUSLOG_ASYNC_CFG_DOWNLOAD_SUCCESS 10114
+#define ID_FUSLOG_ASYNC_CFG_DOWNLOAD_FAILURE 10115
+#define ID_FUSLOG_CACHE_ITEM_CREATE_FAILURE 10116
+#define ID_FUSLOG_CACHE_ITEM_COMMIT_FAILURE 10117
+
+
+#define ID_FUSLOG_OPERATION_SUCCESSFUL 10118
+#define ID_FUSLOG_OPERATION_FAILED 10119
+#define ID_FUSLOG_DETAILED_LOG 10120
+#define ID_FUSLOG_HEADER_TEXT 10121
+#define ID_FUSLOG_BIND_RESULT_TEXT 10122
+#define ID_FUSLOG_NO_DESCRIPTION 10123
+#define ID_FUSLOG_FUSION_DLL_PATH 10124
+#define ID_FUSLOG_EXECUTABLE 10125
+
+#define ID_FUSLOG_QUALIFIED_ASSEMBLY 10126
+#define ID_FUSLOG_CALLING_ASSEMBLY 10127
+
+#define ID_FUSLOG_CFG_ASSEMBLY_STORE 10128
+#define ID_FUSLOG_SETUP_RUN_FROM_SOURCE_FAILURE 10129
+
+#define ID_FUSLOG_ISEQUAL_DIFF_RETARGET 10130
+#define ID_FUSLOG_RETARGET_CFG_MISSING 10131
+#define ID_FUSLOG_RETARGET_CFG_NAME_REDIRECT 10132
+#define ID_FUSLOG_RETARGET_CFG_VER_REDIRECT 10133
+#define ID_FUSLOG_RETARGET_CFG_PKT_REDIRECT 10134
+#define ID_FUSLOG_XML_PARSE_ERROR_MEMORY 10135
+#define ID_FUSLOG_XML_BINDINGRETARGET_INSUFFICIENT_DATA 10136
+#define ID_FUSLOG_XML_INVALID_PROCESSORARCHITECTURE 10137
+
+#define ID_FUSLOG_BIND_SUCCESS 10139
+
+#define ID_FUSLOG_CROSS_SITE_REDIRECT 10140
+#define ID_FUSLOG_DISALLOW_APPLY_PUB_POLICY 10141
+#define ID_FUSLOG_DISALLOW_APP_BINDING_REDIRECTS 10142
+#define ID_FUSLOG_DISALLOW_APP_BASE_PROBING 10143
+#define ID_FUSLOG_INSPECTION_ONLY 10144
+#define ID_FUSLOG_SHOW_START_LOAD_CONTEXT 10145
+#define ID_FUSLOG_SHOW_RESULT_LOAD_CONTEXT 10146
+#define ID_FUSLOG_LOAD_CONTEXT_PA_MISMATCH 10147
+
+#define ID_FUSLOG_FX_CFG_MISSING 10150
+#define ID_FUSLOG_FX_CFG_VER_REDIRECT 10151
+#define ID_FUSLOG_APPLIESTO_DUPLICATE 10152
+
+#define ID_FUSLOG_PREBIND_INFO_DEVOVERRIDE_GLOBAL 10153
+#define ID_FUSLOG_PREBIND_INFO_DEVOVERRIDE_LOCAL 10154
+#define ID_FUSLOG_DEVOVERRIDE_FOUND 10155
+#define ID_FUSLOG_DEVOVERRIDE_MISS 10156
+#define ID_FUSLOG_PREBIND_INFO_DEVPATH 10157
+#define ID_FUSLOG_ASSEMBLYSTORE_DUPLICATE 10158
+#define ID_FUSLOG_DEVOVERRIDE_DUPLICATE 10159
+
+#define ID_FUSLOG_LOADCTX_HIT_HOST 10160
+#define ID_FUSLOG_HOST_RESOLVED 10161
+#define ID_FUSLOG_ADMIN_CFG_POLICY_CODEBASE 10162
+#define ID_FUSLOG_PROCESSOR_ARCHITECTURE_LOCKED 10163
+#define ID_FUSLOG_CHECK_HOST 10164
+#define ID_FUSLOG_NOT_IN_CLR_LOADED_LIST 10165
+#define ID_FUSLOG_IN_CLR_LOADED_LIST 10166
+#define ID_FUSLOG_HOST_STORE_RESOLVE_TRY 10167
+#define ID_FUSLOG_HOST_STORE_RESOLVE_FAILED 10168
+#define ID_FUSLOG_HOST_STORE_NOT_AVAILABLE 10169
+
+// 10170 - 10211 used by native binder
+
+#define ID_FUSLOG_EXPLICIT_BIND_IJW 10220
+#define ID_FUSLOG_EXPLICIT_BIND_EXE 10221
+#define ID_FUSLOG_EXPLICIT_BIND_IJW_BIND_FAIL 10222
+#define ID_FUSLOG_EXPLICIT_BIND_IJW_PATH_DIFF 10223
+#define ID_FUSLOG_EXPLICIT_BIND_IJW_PATH_MATCH 10224
+#define ID_FUSLOG_EXPLICIT_BIND_IJW_NOT_FOUND 10225
+#define ID_FUSLOG_EXPLICIT_BIND_EXE_LOADCONTEXT_COLLISION 10226
+
+#define ID_FUSLOG_PUBLISHER_POLICY_CONFIG_MISSING 10231
+
+#define ID_FUSLOG_UNSUPPORTED_LINKED_CONFIGURATION 10300
+#define ID_FUSLOG_LINKED_CONFIGURATION_PARSE_ERROR 10301
+#define ID_FUSLOG_LINKED_CONFIGURATION_DUPLICATE 10302
+#define ID_FUSLOG_PROCESSING_LINKED_CONFIGURATION 10303
+
+#define ID_FUSLOG_ISEQUAL_DIFF_PROCESSOR_ARCHITECTURE 10310
+#define ID_FUSLOG_ISEQUAL_DIFF_CONTENT_TYPE 10311
+
+#define ID_FUSLOG_WHERE_REF_APPLY_POLICY 10320
+#define ID_FUSLOG_SWITCH_TO_DEFAULT_CONTEXT 10321
+#define ID_FUSLOG_SWITCH_TO_LOADFROM_CONTEXT 10322
+#define ID_FUSLOG_WHERE_REF_GAC_MATCH 10323
+#define ID_FUSLOG_WHERE_REF_GAC_MISMATCH 10324
+#define ID_FUSLOG_WHERE_REF_LOAD_CONTEXT_MATCH 10325
+#define ID_FUSLOG_WHERE_REF_LOAD_CONTEXT_MISMATCH 10326
+#define ID_FUSLOG_HOST_STORE_PARTIAL_NAME_SKIP 10327
+#define ID_FUSLOG_MISSING_CACHE_FILE 10328
+#define ID_FUSLOG_HOST_GAC_ASM_MISMATCH 10329
+#define ID_FUSLOG_HOST_RESULT 10330
+#define ID_FUSLOG_HOST_NO_DEBUG_STREAM 10331
+#define ID_FUSLOG_APP_CONFIG_FILE 10332
+#define ID_FUSLOG_NO_APP_CONFIG_FILE 10333
+#define ID_FUSLOG_ASSEMBLY_NAME_DEF 10334
+#define ID_FUSLOG_PREVIOUS_FAILED 10335
+#define ID_FUSLOG_LOADFROM_DEFAULT_MISMATCH 10336
+#define ID_FUSLOG_LOADER_PERMISSION_CHECK_FAILURE 10337
+#define ID_FUSLOG_INCOMPATIBLE_PROCESSOR_ARCHITECTURE 10338
+#define ID_FUSLOG_NO_PARTIAL_NAME_FOR_HOST_APPBASE_COMMON_ASM 10339
+
+// 10400 - 10500 used by native binder
+
+#define ID_FUSLOG_LOG_TURNED_OFF 10990
+#define ID_FUSLOG_LOG_TURN_ON_HKLM 10991
+#define ID_FUSLOG_LOG_PERF_WARNING 10992
+#define ID_FUSLOG_LOG_TURN_OFF_HKLM 10993
+
+#define ID_FUSLOG_PARTIAL_BIND_DEBUG 11000
+
+#define ID_FUSLOG_WARNING_PARTIAL_NAME_HEADER 11001
+#define ID_FUSLOG_WARNING_PARTIAL_NAME_DETAIL 11002
+#define ID_FUSLOG_WARNING_PARTIAL_NAME_INSTANCE 11003
+#define ID_FUSLOG_WARNING_MULTIPLE_VERSIONS_HEADER 11004
+#define ID_FUSLOG_WARNING_MULTIPLE_VERSIONS_DETAIL 11005
+#define ID_FUSLOG_WARNING_MULTIPLE_VERSIONS_INSTANCE 11006
+#define ID_FUSLOG_WARNING_MULTIPLE_CONTEXTS_HEADER 11007
+#define ID_FUSLOG_WARNING_MULTIPLE_CONTEXTS_DETAIL 11008
+
+#define ID_FUSLOG_PORTABILITY_CFG_NAME_REDIRECT 11011
+#define ID_FUSLOG_PORTABILITY_CFG_VER_REDIRECT 11012
+#define ID_FUSLOG_PORTABILITY_CFG_PKT_REDIRECT 11013
+#define ID_FUSLOG_WARNING_SUPPORTPORTABILITY_MISSING_PKT 11014
+#define ID_FUSLOG_WARNING_SUPPORTPORTABILITY_MISSING_ENABLE 11015
+#define ID_FUSLOG_WARNING_SUPPORTPORTABILITY_INVALID_ENABLE 11016
+
+#define ID_FUSLOG_BINDING_STATUS_BEGIN 11020
+#define ID_FUSLOG_BINDING_STATUS_END 11021
+#define ID_FUSLOG_BINDING_STATUS_END_HR 11022
+#define ID_FUSLOG_BINDING_STATUS_NATIVE_DEPENDENCY 11023
+#define ID_FUSLOG_BINDING_STATUS_IMMERSIVE 11024
+#define ID_FUSLOG_BINDING_STATUS_FRAMEWORK 11025
+#define ID_FUSLOG_BINDING_STATUS_LOAD_FILE 11026
+#define ID_FUSLOG_BINDING_STATUS_WINRT 11027
+#define ID_FUSLOG_BINDING_DEPENDENCY_NAME 11028
+#define ID_FUSLOG_BINDING_STATUS_FOUND 11029
+#define ID_FUSLOG_BINDING_STATUS_IL_IMAGE 11030
+#define ID_FUSLOG_BINDING_STATUS_NATIVE_IMAGE 11031
+#define ID_FUSLOG_BINDING_STATUS_FX_ASSEMBLY_BLOCKED 11032
+
+#else //!FEATURE_FUSION
+
+// we have 10000 to 10125 available (and more)
+// Used are 10000 to 10042
+#define ID_FUSLOG_MANIFEST_FAILURE_NO_FILE 10001
+#define ID_FUSLOG_MANIFEST_FAILURE_PARSE_ERROR 10002
+#define ID_FUSLOG_MANIFEST_FAILURE_UNKNOWN_ERROR 10003
+#define ID_FUSLOG_MANIFEST_FAILURE_EMPTY_DEFAULT 10004
+#define ID_FUSLOG_MANIFEST_STATUS_STATE_CONFIGURED 10006
+#define ID_FUSLOG_MANIFEST_STATUS_STATE_INHERITED 10007
+
+#define ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_ID 10008
+#define ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_LOCATION 10043
+#define ID_FUSLOG_ASSEMBLY_STATUS_BOUND_GAC 10009
+#define ID_FUSLOG_ASSEMBLY_STATUS_BOUND_HAS 10010
+#define ID_FUSLOG_ASSEMBLY_STATUS_BOUND_BYTE_ARRAY 10011
+
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_BEGIN 10012
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_BY_NAME 10013
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_BY_NAME_PARTIAL 10014
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_WHERE_REF 10015
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_CALLER 10016
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_CALLER_UNKNOWN 10017
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_USER 10018
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_USER_UNKNOWN 10019
+#define ID_FUSLOG_BINDING_PRE_BIND_STATE_END 10020
+
+#define ID_FUSLOG_BINDING_LOCKED_UNLOCKED 10021
+#define ID_FUSLOG_BINDING_LOCKED_ASSEMBLY_EXE_CONTEXT 10022
+#define ID_FUSLOG_BINDING_LOCKED_ASSEMBLY_INS_CONTEXT 10023
+#define ID_FUSLOG_BINDING_LOCKED_MT_EXE_LOCKED_ENTRY 10024
+#define ID_FUSLOG_BINDING_LOCKED_MT_EXE_LOCALI_ENTRY 10025
+#define ID_FUSLOG_BINDING_LOCKED_MT_EXE_CBASE_ENTRY 10026
+#define ID_FUSLOG_BINDING_LOCKED_MT_INS_LOCKED_ENTRY 10027
+#define ID_FUSLOG_BINDING_LOCKED_MT_INS_LOCALI_ENTRY 10028
+#define ID_FUSLOG_BINDING_LOCKED_MT_INS_CBASE_ENTRY 10005
+
+#define ID_FUSLOG_BINDING_BEHAVIOR_STATIC 10029
+#define ID_FUSLOG_BINDING_BEHAVIOR_ORDER_INDEPENDENT 10030
+#define ID_FUSLOG_BINDING_BEHAVIOR_BEST_MATCH 10031
+
+#define ID_FUSLOG_BINDING_LOG_WHERE_REF_NAME 10032
+#define ID_FUSLOG_BINDING_LOG_NATIVE_ACTIVATION 10033
+#define ID_FUSLOG_BINDING_LOG_INSPECTION_ONLY_BIND 10034
+#define ID_FUSLOG_BINDING_LOG_RETARGETED 10035
+#define ID_FUSLOG_BINDING_LOG_ERRONOUS_MANIFEST_ENTRY 10036
+#define ID_FUSLOG_BINDING_LOG_PATH_ATTEMPT 10037
+
+#define ID_FUSLOG_BINDING_HEADER_BEGIN 10038
+#define ID_FUSLOG_BINDING_HEADER_BIND_RESULT 10039
+#define ID_FUSLOG_BINDING_HEADER_BIND_RESULT_SUCCESS 10040
+#define ID_FUSLOG_BINDING_HEADER_BIND_RESULT_ERROR 10041
+#define ID_FUSLOG_BINDING_HEADER_END 10042
+
+#endif //!FEATURE_FUSION
+
+#endif // __FUSION_RESOURCE_H_
diff --git a/src/dlls/mscorrc/include.rc b/src/dlls/mscorrc/include.rc
new file mode 100644
index 0000000000..ee46940871
--- /dev/null
+++ b/src/dlls/mscorrc/include.rc
@@ -0,0 +1,7 @@
+// 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.
+
+#include "mscorrc.rc"
+#include "fuslog.rc"
+#include "nativelog.rc"
diff --git a/src/dlls/mscorrc/mscorrc.common.rc b/src/dlls/mscorrc/mscorrc.common.rc
new file mode 100644
index 0000000000..602e8c84ee
--- /dev/null
+++ b/src/dlls/mscorrc/mscorrc.common.rc
@@ -0,0 +1,12 @@
+// 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.
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_EE_NAME_UNKNOWN_UNQ "<Unknown %1>"
+ IDS_EE_NAME_UNKNOWN "<Unknown>"
+ IDS_EE_NAME_INMEMORYMODULE "<In Memory Module>"
+ IDS_DEBUG_UNHANDLEDEXCEPTION "Application has generated an exception that could not be handled.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick OK to terminate the application.\nClick CANCEL to debug the application."
+ IDS_DEBUG_SERVICE_CAPTION "Application Error"
+END
diff --git a/src/dlls/mscorrc/mscorrc.rc b/src/dlls/mscorrc/mscorrc.rc
new file mode 100644
index 0000000000..be9fb1cfa6
--- /dev/null
+++ b/src/dlls/mscorrc/mscorrc.rc
@@ -0,0 +1,2173 @@
+// 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.
+
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+#include "corerror.h"
+
+#ifdef APSTUDIO_INVOKED
+ #error Do not edit this file with App Studio.
+#endif //APSTUDIO_INVOKED
+
+#include <winresrc.h>
+
+#ifndef FX_VER_FILEDESCRIPTION_STR
+#define FX_VER_FILEDESCRIPTION_STR "Microsoft .NET Runtime resources\0"
+#endif
+
+#include <fxver.h>
+#include <fxver.rc>
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+
+#undef SMAKEHR
+#undef EMAKEHR
+#define SMAKEHR(val) val
+#define EMAKEHR(val) val
+
+#include "mscorrc.common.rc"
+
+#define MDARC_PINVOKE_SIGNATURE_MISMATCH_MSG \
+ L"A call to PInvoke function '%1$s' has unbalanced the stack. This is likely because the managed PInvoke "\
+ L"signature does not match the unmanaged target signature. Check that the calling convention and " \
+ L"parameters of the PInvoke signature match the target unmanaged signature."
+
+#define MDARC_PINVOKE_LOG_MSG \
+ L"The first PInvoke call to export '%1$s' in module '%2$s' has been made."
+
+#define MDARC_LOAD_FROM_CONTEXT_MSG \
+ L"The assembly named '%1$s' was loaded from '%2$s' using the LoadFrom context. The use of this " \
+ L"context can result in unexpected behavior for serialization, casting and dependency resolution. " \
+ L"In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done " \
+ L"by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and " \
+ L"using Assembly.Load when explicitly loading assemblies."
+
+#define MDARC_BINDING_FAILURE_CODEBASE_ONLY_MSG \
+ L"The assembly loaded from code base '%1$s' failed to load in the '%2$s' binding context of the " \
+ L"AppDomain with ID %3$d. The cause of the failure was: %4$s"
+
+#define MDARC_BINDING_FAILURE_DISPLAYNAME_ONLY_MSG \
+ L"The assembly with display name '%1$s' failed to load in the '%2$s' binding context of the " \
+ L"AppDomain with ID %3$d. The cause of the failure was: %4$s"
+
+#define MDARC_BINDING_FAILURE_MSG \
+ L"The assembly with display name '%1$s' loaded from code base '%2$s' failed to load " \
+ L"in the '%3$s' binding context of the AppDomain with ID %4$d. The cause of the failure was: %5$s"
+
+#define MDARC_INVALID_CONFIG_FILE_MSG \
+ L"The '%1$s' configuration file is invalid."
+
+#define MDARC_CALLBACK_ON_COLLECTED_DELEGATE_MSG \
+ L"A callback was made on a garbage collected delegate of type '%1$s'. This may cause application " \
+ L"crashes, corruption and data loss. " \
+ L"When passing delegates to unmanaged code, they must be kept alive by the " \
+ L"managed application until it is guaranteed that they will never be called."
+
+#define MDARC_INVALID_APT_STATE_CHANGE_SET_MSG \
+ L"An attempt was made to change the apartment state of the thread to %1$s, " \
+ L"but it has already been set to %2$s. When creating a new thread the apartment state should" \
+ L"be set before the thread is started. For the main thread of the application, the apartment" \
+ L"state can be set by specifying either [STAThreadAttribute] or [MTAThreadAttribute] on the" \
+ L"main method of the application. " \
+ L"If the application really needs to attempt to set the apartment state on a running thread, " \
+ L"Thread.TrySetApartmentState should be used and the return value should be consulted to determine " \
+ L"if the operation was successful. Note that Thread.TrySetApartmentState will not fire the " \
+ L"InvalidApartmentStateChange MDA."
+
+#define MDARC_INVALID_APT_STATE_CHANGE_NOTSET_MSG \
+ L"The current thread used to have an apartment state of %1$s, but the application has CoUnitialized " \
+ L"this thread and it is now %2$s. This may cause calls on RuntimeCallableWrappers " \
+ L"representing some COM components to fail and may also cause COM component that are " \
+ L"not multi-threaded to be accessed from multiple threads at the same time which can cause " \
+ L"corruption or data loss."
+
+#define MDARC_JIT_ATTACH_MSG \
+ L"%1$s Managed Debugging Assistant"
+
+#define MDARC_LOADER_LOCK_MSG \
+ L"Attempting managed execution inside OS Loader lock. Do not " \
+ L"attempt to run managed code inside a DllMain or image initialization function since doing " \
+ L"so can cause the application to hang."
+
+#define MDARC_LOADER_LOCK_DLL_MSG \
+ L"DLL '%1$s' is attempting managed execution inside OS Loader lock. Do not " \
+ L"attempt to run managed code inside a DllMain or image initialization function since doing " \
+ L"so can cause the application to hang."
+
+#define MDARC_REENTRANCY_MSG \
+ L"Attempting to call into managed code without transitioning out first. Do not " \
+ L"attempt to run managed code inside low-level native extensibility points, such as the vectored " \
+ L"exception handler, since doing so can cause corruption and data loss."
+
+#define MDARC_REPORT_AV_ON_COM_RELEASE_MSG \
+ L"An exception was caught but handled while releasing a COM interface pointer " \
+ L"through Marshal.Release, Marshal.ReleaseComObject or implicitly after the corresponding " \
+ L"RuntimeCallableWrapper was garbage collected. This is the result of a user " \
+ L"refcount error or other problem with a COM object's Release. Make sure " \
+ L"refcounts are managed properly. While these types of exceptions are caught by the CLR, " \
+ L"they can still lead to corruption and data loss so if possible the issue causing the exception " \
+ L"should be addressed"
+
+#define MDARC_REPORT_AV_ON_COM_RELEASE_WITH_VTABLE_MSG \
+ L"An exception was caught but handled while releasing a COM interface pointer " \
+ L"through Marshal.Release or Marshal.ReleaseComObject or implicitly after the corresponding " \
+ L"RuntimeCallableWrapper was garbage collected. This is the result of a user " \
+ L"refcount error or other problem with a COM object's Release. Make sure " \
+ L"refcounts are managed properly. The COM interface pointer's original vtable " \
+ L"pointer was 0x%1$x. While these types of exceptions are caught by the CLR, " \
+ L"they can still lead to corruption and data loss so if possible the issue causing the exception " \
+ L"should be addressed"
+
+#define MDARC_INVALID_VARIANT_MSG \
+ L"An invalid VARIANT was detected during a conversion from an unmanaged VARIANT " \
+ L"to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions, " \
+ L"corruption or data loss."
+
+#define MDARC_FAILED_QI_MSG \
+ L"The call to QI for interface '%1$s' with IID '%2$s' failed with HRESULT 0x%3$s (%4$s). " \
+ L"One likely reason this failed is that the object does not have a proxy/stub dll properly registered."
+
+#define MDARC_DISCONNECTED_CONTEXT_1_MSG \
+ L"Transition into COM context 0x%1$x for this RuntimeCallableWrapper failed with the following error: " \
+ L"%2$s. " \
+ L"This is typically because the COM context 0x%1$x where this RuntimeCallableWrapper was created " \
+ L"has been disconnected or it is busy doing something else and cannot process the context transition. " \
+ L"No proxy will be used to service the request on the COM component and calls will be made to the " \
+ L"COM component directly. This may cause corruption or data loss. " \
+ L"To avoid this problem, please ensure that all COM contexts/apartments/threads stay alive and are " \
+ L"available for context transition, until the application is completely done with the " \
+ L"RuntimeCallableWrappers that represents COM components that live inside them."
+
+#define MDARC_DISCONNECTED_CONTEXT_2_MSG \
+ L"Transition into COM context 0x%1$x for this RuntimeCallableWrapper failed with the following error: " \
+ L"%2$s. " \
+ L"This is typically because the COM context 0x%1$x where this RuntimeCallableWrapper was created " \
+ L"has been disconnected or it is busy doing something else. " \
+ L"Releasing the interfaces from the current COM context (COM context 0x%3$x). " \
+ L"This may cause corruption or data loss. " \
+ L"To avoid this problem, please ensure that all COM contexts/apartments/threads stay alive and are " \
+ L"available for context transition, until the application is completely done with the " \
+ L"RuntimeCallableWrappers that represents COM components that live inside them."
+
+#define MDARC_NOTMARSHALABLE_MSG \
+ L"A non marshalable COM component is being used from a different apartment/context then the " \
+ L"one where it first entered the CLR. Since the component is non marshalable, it will be called directly " \
+ L"from the current apartment/context. This may cause corruption or data loss if the component does " \
+ L"not support being accessed from multiple threads at once. This is most likely caused by a faulty " \
+ L"IMarshal implementation on the part of the COM component."
+
+#define MDARC_INVALID_IUNKNOWN_MSG \
+ L"An invalid IUnknown* was detected during a conversion from a COM component " \
+ L"to a managed object. Passing invalid IUnknown pointers to the CLR can cause unexpected " \
+ L"exceptions, corruption or data loss."
+
+#define MDARC_CONTEXT_SWITCH_DEADLOCK_MSG \
+ L"The CLR has been unable to transition from COM context 0x%1$x to COM context 0x%2$x for 60 seconds. " \
+ L"The thread that owns the destination context/apartment is most likely either doing a non pumping wait " \
+ L"or processing a very long running operation without pumping Windows messages. " \
+ L"This situation generally has a negative performance impact and may even lead to " \
+ L"the application becoming non responsive or memory usage accumulating continually over time. " \
+ L"To avoid this problem, all single threaded apartment (STA) threads should use pumping wait " \
+ L"primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."
+
+#define MDARC_RCW_CLEANUP_RACE_MSG \
+ L"An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or " \
+ L"another thread. Attempting to free an in-use RCW can cause corruption or data loss."
+
+#define MDARC_MARSHALING_METHOD_MSG \
+ L"Marshaling parameter with index %1$i and name '%2$s' from '%3$s' to '%4$s'"
+
+#define MDARC_MARSHALING_FIELD_MSG \
+ L"Marshaling field '%1$s' from '%2$s' to '%3$s'"
+
+#define MDARC_INVALID_FUNCTION_PTR_IN_DELEGATE_MSG \
+ L"Invalid function pointer 0x%1$x was passed into the runtime to be converted to a delegate. " \
+ L"Passing in invalid function pointers to be converted to delegates can cause crashes, " \
+ L"corruption or data loss. "
+
+#define MDARC_DIRTY_CAST_AND_CALL_ON_INTERFACE_MSG \
+ L"The native component calling into the CLR through this ComCallWrapper has performed an " \
+ L"illegal cast on this IUnknown or IDispatch pointer. The caller neglected to call QueryInterface " \
+ L"for the correct interface before making this call."
+
+#define MDARC_VTABLE_CALL_ON_AUTODISP_MEMBER_MSG \
+ L"An early bound call (vtable call) was made on the following member of an auto " \
+ L"dispatch class interface: '%1$s'. Early bound calls on members of auto dispatch " \
+ L"class interfaces are not allowed. Please consider using an explicit interface " \
+ L"as the default interface for the type. If a class interface must be " \
+ L"called early bound, change it to auto dual. This can be accomplished " \
+ L"by marking the class with the following attribute, located in the " \
+ L"System.Runtime.InteropServices namespace: " \
+ L"[ClassInterface(ClassInterfaceType.AutoDual)] " \
+
+#define MDARC_INVALID_CER_CALL_MSG \
+ L"Method '%1$s', while executing within a constrained execution region, makes a call " \
+ L"at IL offset 0x%2$04X to '%3$s', which does not have a sufficiently strong reliability " \
+ L"contract and might cause non-deterministic results."
+
+#define MDARC_VIRTUAL_CER_CALL_MSG \
+ L"Method '%1$s', while executing within a constrained execution region, makes a call " \
+ L"at IL offset 0x%2$04X to '%3$s', which is virtual and cannot be prepared automatically " \
+ L"at compile time. The caller must ensure this method is prepared explicitly at " \
+ L"runtime before entering the constrained execution region."
+
+#define MDARC_OPENGENERIC_CER_CALL_MSG \
+ L"Method '%1$s', which contains at least one constrained execution region, cannot be " \
+ L"prepared automatically since it has one or more unbound generic type parameters. " \
+ L"The caller must ensure this method is prepared explicitly at runtime prior to " \
+ L"execution."
+
+#define MDARC_ILLEGAL_PCR_MSG \
+ L"Method '%1$s' calls RuntimeHelpers.PrepareConstrainedRegions() at IL offset 0x%2$04X. " \
+ L"This is invalid since it does not coincide with the beginning of a try clause."
+
+#define MDARC_MARSHALCLEANUPERROR_THREADCULTURE_MSG \
+ L"The CLR marshaler encountered an error while attempting to restore the thread culture after a call " \
+ L"from unmanaged to managed where an LCID was used to specify the culture for the call. This will " \
+ L"cause the thread's culture to remain set to the one associated with the LCID. The cause of the failure was: %1$s"
+
+#define MDARC_MARSHALCLEANUPERROR_SAFEHANDLERELEASE_MSG \
+ L"The CLR marshaler encountered an error while attempting to release the reference to a SafeHandle " \
+ L"it acquired in order to marshal the SafeHandle to an unmanaged pointer during a call from managed to unmanaged. " \
+ L"This may cause the unmanaged resource the SafeHandle represents to be leaked. The cause of the failure was: %1$s"
+
+#define MDARC_MARSHALCLEANUPERROR_SAFEHANDLEPROP_MSG \
+ L"The CLR marshaler encountered an error while attempting to associate a SafeHandle with an unmanaged resource. " \
+ L"This may cause the unmanaged resource to be leaked. The cause of the failure was: %1$s"
+
+#define MDARC_MARSHALCLEANUPERROR_CUSTOMCLEANUP_MSG \
+ L"An exception was thrown from the CleanupNativeData method of a custom marshaler of type '%1$s'. " \
+ L"This may cause an unmanaged data leak and should be corrected if possible. The cause of the failure was: %1$s"
+
+#define MDARC_SAFEHANDLE_CRITICAL_FAILURE_MSG \
+ L"A SafeHandle or CriticalHandle of type '%1$s' failed to properly release the handle " \
+ L"with value 0x%2$p. This usually indicates that the handle was released incorrectly " \
+ L"via another means (such as extracting the handle using DangerousGetHandle and " \
+ L"closing it directly or building another SafeHandle around it.)"
+
+#define MDARC_DLLMAIN_RETURNS_FALSE_MSG \
+ L"Function DllMain, called with reason DLL_PROCESS_ATTACH, returned FALSE. DLL initialization failed. " \
+ L"To ignore the DllMain return, set Registry value " \
+ L"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\.NETFramework\\IgnoreDllMainReturn to 1"
+
+#define MDARC_REFLECTION_PERFORMANCE_MEMBERINFOCACHECREATION_MSG \
+ L"Reflection has created a memberInfo cache."
+
+#define MDARC_INVALID_MEMBER_DECLARATION_MSG \
+ L"The following error occurred while determining how to marshal the parameters of member '%1$s' of type '%2$s': " \
+ L"%3$s This is most likely due to an incompatible MarshalAs attribute on one of the parameters. "
+
+#define MDARC_EXCEPTION_SWALLOWED_COM_TO_CLR_MSG \
+ L"A COM client has called managed method '%1$s' on type '%2$s'. This method does not have an HRESULT return type and " \
+ L"an exception was thrown that was not handled. The exception contains the following message: %3$s. " \
+ L"This exception will be caught and zero will be returned to the COM caller if the method's return " \
+ L"type is not void."
+
+#define MDARC_ASYNCHRONOUS_THREADABORT_MSG \
+ L"User code running on thread %1$i has attempted to abort thread %2$i. This may result in a corrupt state " \
+ L"or resource leaks if the thread being aborted was in the middle of an operation that modifies global "\
+ L"state or uses native resources. Aborting threads other than the currently running thread is strongly "\
+ L"discouraged."
+
+#define MDARC_DANGEROUS_THREADINGAPI_MSG \
+ L"User code has attempted to call the following API: '%1$s'. This may result in a deadlock in the process."
+
+#define MDARC_DATETIME_INVALID_LOCAL_FORMAT_MSG \
+ L"A UTC DateTime is being converted to text in a format that is only correct for local times. " \
+ L"This can happen when calling DateTime.ToString using the 'z' format specifier, which will " \
+ L"include a local time zone offset in the output. In that case, either use the 'Z' format specifier, " \
+ L"which designates a UTC time, or use the 'o' format string, which is the recommended way to persist " \
+ L"a DateTime in text. This can also occur when passing a DateTime to be serialized by " \
+ L"XmlConvert or DataSet. If using XmlConvert.ToString, pass in " \
+ L"XmlDateTimeSerializationMode.RoundtripKind to serialize correctly. If using DataSet, set the " \
+ L"DateTimeMode on the DataColumn object to DataSetDateTime.Utc. "
+
+#define MDARC_NON_COMVISIBLE_BASE_CLASS_CLASSITF_MSG \
+ L"A QueryInterface call was made requesting the class interface of COM visible managed class '%1$s'. " \
+ L"However since this class derives from non COM visible class '%2$s', the QueryInterface call will fail. " \
+ L"This is done to prevent the non COM visible base class from being constrained by the COM versioning " \
+ L"rules."
+
+#define MDARC_NON_COMVISIBLE_BASE_CLASS_IDISPATCH_MSG \
+ L"A QueryInterface call was made requesting the default IDispatch interface of COM visible managed " \
+ L"class '%1$s'. However since this class does not have an explicit default interface and derives from non "\
+ L"COM visible class '%2$s', the QueryInterface call will fail. This is done to prevent the non COM " \
+ L"visible base class from being constrained by the COM versioning rules."
+
+#define MDARC_INVALID_GCHANDLE_COOKIE_MSG \
+ L"An attempt was made to retrieve a GCHandle from an invalid IntPtr cookie (0x%1$x). " \
+ L"The cookie was most likely invalid because the cookie does not represent a GCHandle, " \
+ L"the GCHandle has already been freed, " \
+ L"the retrieval was attempted in the wrong AppDomain, " \
+ L"or the GCHandle was marshaled to native code as a GCHandle but passed back into " \
+ L"managed code as an IntPtr where a cast was attempted. " \
+ L"Attempting to use an invalid pointer to reclaim a GC handle can cause unexpected exceptions, crashes, " \
+ L"corruption or data loss. "
+
+#define MDARC_FATAL_EXECUTION_ENGINE_ERROR_MSG \
+ L"The runtime has encountered a fatal error. The address of the error was at 0x%1$08x, on thread 0x%2$x. "\
+ L"The error code is 0x%3$08x. This error may be a bug in the CLR or in the unsafe " \
+ L"or non-verifiable portions of user code. Common sources of this bug include user marshaling errors " \
+ L"for COM-interop or PInvoke, which may corrupt the stack." \
+
+#define MDARC_INVALID_OVERLAPPED_TO_PINVOKE_MSG \
+ L"An overlapped pointer (0x%1$p) that was not allocated on the GC heap was passed via PInvoke to " \
+ L"the Win32 function '%2$s' in module '%3$s'. " \
+ L"If the AppDomain is shut down, this can cause heap corruption when the async I/O completes. " \
+ L"The best solution is to pass a NativeOverlapped structure retrieved from a call to " \
+ L"System.Threading.Overlapped.Pack(). If the AppDomain exits, the CLR will keep this structure " \
+ L"alive and pinned until the I/O completes."
+
+#define MDARC_INVALID_OVERLAPPED_FREE_MSG \
+ L"An overlapped pointer (0x%1$p) may have been freed before the I/O operation completed. " \
+ L"Freeing an overlapped pointer before the I/O operation completes will cause GC heap corruption " \
+ L"when the I/O does complete. " \
+ L"Note that this MDA may not represent an error if the overlapped operation did not start successfully"
+
+#define MDARC_DEBUGGER_FIBER_MODE_NOT_SUPPORTED_MSG \
+ L"A thread has entered fiber mode and therefore debugging must be stopped."
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ MDARC_PINVOKE_SIGNATURE_MISMATCH MDARC_PINVOKE_SIGNATURE_MISMATCH_MSG
+ MDARC_LOAD_FROM_CONTEXT MDARC_LOAD_FROM_CONTEXT_MSG
+ MDARC_BINDING_FAILURE MDARC_BINDING_FAILURE_MSG
+ MDARC_INVALID_CONFIG_FILE MDARC_INVALID_CONFIG_FILE_MSG
+ MDARC_CALLBACK_ON_COLLECTED_DELEGATE MDARC_CALLBACK_ON_COLLECTED_DELEGATE_MSG
+ MDARC_INVALID_APT_STATE_CHANGE_SET MDARC_INVALID_APT_STATE_CHANGE_SET_MSG
+ MDARC_INVALID_APT_STATE_CHANGE_NOTSET MDARC_INVALID_APT_STATE_CHANGE_NOTSET_MSG
+ MDARC_LOADER_LOCK MDARC_LOADER_LOCK_MSG
+ MDARC_LOADER_LOCK_DLL MDARC_LOADER_LOCK_DLL_MSG
+ MDARC_JIT_ATTACH MDARC_JIT_ATTACH_MSG
+ MDARC_REENTRANCY MDARC_REENTRANCY_MSG
+ MDARC_ASYNCHRONOUS_THREADABORT MDARC_ASYNCHRONOUS_THREADABORT_MSG
+ MDARC_DANGEROUS_THREADINGAPI MDARC_DANGEROUS_THREADINGAPI_MSG
+ MDARC_REPORT_AV_ON_COM_RELEASE MDARC_REPORT_AV_ON_COM_RELEASE_MSG
+ MDARC_REPORT_AV_ON_COM_RELEASE_WITH_VTABLE MDARC_REPORT_AV_ON_COM_RELEASE_WITH_VTABLE_MSG
+ MDARC_INVALID_VARIANT MDARC_INVALID_VARIANT_MSG
+ MDARC_FAILED_QI MDARC_FAILED_QI_MSG
+ MDARC_DISCONNECTED_CONTEXT_1 MDARC_DISCONNECTED_CONTEXT_1_MSG
+ MDARC_DISCONNECTED_CONTEXT_2 MDARC_DISCONNECTED_CONTEXT_2_MSG
+ MDARC_NOTMARSHALABLE MDARC_NOTMARSHALABLE_MSG
+ MDARC_MARSHALCLEANUPERROR_THREADCULTURE MDARC_MARSHALCLEANUPERROR_THREADCULTURE_MSG
+ MDARC_MARSHALCLEANUPERROR_SAFEHANDLERELEASE MDARC_MARSHALCLEANUPERROR_SAFEHANDLERELEASE_MSG
+ MDARC_MARSHALCLEANUPERROR_SAFEHANDLEPROP MDARC_MARSHALCLEANUPERROR_SAFEHANDLEPROP_MSG
+ MDARC_MARSHALCLEANUPERROR_CUSTOMCLEANUP MDARC_MARSHALCLEANUPERROR_CUSTOMCLEANUP_MSG
+ MDARC_INVALID_IUNKNOWN MDARC_INVALID_IUNKNOWN_MSG
+ MDARC_CONTEXT_SWITCH_DEADLOCK MDARC_CONTEXT_SWITCH_DEADLOCK_MSG
+ MDARC_RCW_CLEANUP_RACE MDARC_RCW_CLEANUP_RACE_MSG
+ MDARC_INVALID_FUNCTION_PTR_IN_DELEGATE MDARC_INVALID_FUNCTION_PTR_IN_DELEGATE_MSG
+ MDARC_DIRTY_CAST_AND_CALL_ON_INTERFACE MDARC_DIRTY_CAST_AND_CALL_ON_INTERFACE_MSG
+ MDARC_VTABLE_CALL_ON_AUTODISP_MEMBER MDARC_VTABLE_CALL_ON_AUTODISP_MEMBER_MSG
+ MDARC_INVALID_CER_CALL MDARC_INVALID_CER_CALL_MSG
+ MDARC_VIRTUAL_CER_CALL MDARC_VIRTUAL_CER_CALL_MSG
+ MDARC_OPENGENERIC_CER_CALL MDARC_OPENGENERIC_CER_CALL_MSG
+ MDARC_ILLEGAL_PCR MDARC_ILLEGAL_PCR_MSG
+ MDARC_SAFEHANDLE_CRITICAL_FAILURE MDARC_SAFEHANDLE_CRITICAL_FAILURE_MSG
+ MDARC_REFLECTION_PERFORMANCE_MEMBERINFOCACHECREATION MDARC_REFLECTION_PERFORMANCE_MEMBERINFOCACHECREATION_MSG
+ MDARC_DATETIME_INVALID_LOCAL_FORMAT MDARC_DATETIME_INVALID_LOCAL_FORMAT_MSG
+ MDARC_DLLMAIN_RETURNS_FALSE MDARC_DLLMAIN_RETURNS_FALSE_MSG
+ MDARC_INVALID_MEMBER_DECLARATION MDARC_INVALID_MEMBER_DECLARATION_MSG
+ MDARC_EXCEPTION_SWALLOWED_COM_TO_CLR MDARC_EXCEPTION_SWALLOWED_COM_TO_CLR_MSG
+ MDARC_NON_COMVISIBLE_BASE_CLASS_CLASSITF MDARC_NON_COMVISIBLE_BASE_CLASS_CLASSITF_MSG
+ MDARC_NON_COMVISIBLE_BASE_CLASS_IDISPATCH MDARC_NON_COMVISIBLE_BASE_CLASS_IDISPATCH_MSG
+ MDARC_INVALID_GCHANDLE_COOKIE MDARC_INVALID_GCHANDLE_COOKIE_MSG
+ MDARC_PINVOKE_LOG MDARC_PINVOKE_LOG_MSG
+ MDARC_FATAL_EXECUTION_ENGINE_ERROR MDARC_FATAL_EXECUTION_ENGINE_ERROR_MSG
+ MDARC_INVALID_OVERLAPPED_TO_PINVOKE MDARC_INVALID_OVERLAPPED_TO_PINVOKE_MSG
+ MDARC_INVALID_OVERLAPPED_FREE MDARC_INVALID_OVERLAPPED_FREE_MSG
+ MDARC_DEBUGGER_FIBER_MODE_NOT_SUPPORTED MDARC_DEBUGGER_FIBER_MODE_NOT_SUPPORTED_MSG
+ MDARC_BINDING_FAILURE_CODEBASE_ONLY MDARC_BINDING_FAILURE_CODEBASE_ONLY_MSG
+ MDARC_BINDING_FAILURE_DISPLAYNAME_ONLY MDARC_BINDING_FAILURE_DISPLAYNAME_ONLY_MSG
+ MDARC_MARSHALING_METHOD MDARC_MARSHALING_METHOD_MSG
+ MDARC_MARSHALING_FIELD MDARC_MARSHALING_FIELD_MSG
+ MDARC_MARSHALING_RETURN_VALUE_NAME "return value"
+ MDARC_MARSHALING_UNKNOWN_PARAM_NAME "unknown"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ CLDB_E_FILE_OLDVER "Version %d.%d is not a compatible version."
+ CLDB_E_NAME_ERROR "'%s' is not a valid name."
+ CLDB_E_SMDUPLICATE "Shared memory '%hs' already exists."
+ CLDB_E_NO_DATA "No metadata was found."
+ CLDB_E_READONLY "Database is read-only."
+
+ CLDB_E_FILE_CORRUPT "Database file is corrupt and may not be usable."
+ CLDB_E_SCHEMA_VERNOTFOUND "Version %d of schema '%hs' not found."
+
+ CLDB_E_INDEX_NONULLKEYS "Null value is not allowed in unique index or primary key."
+ CLDB_E_INDEX_DUPLICATE "Duplicate record violates index %s."
+ CLDB_E_INDEX_BADTYPE "VARIANT data type is not allowed in an index."
+ CLDB_E_INDEX_NOTFOUND "Index %s not found."
+
+ CLDB_E_RECORD_NOTFOUND "No records found."
+ CLDB_E_RECORD_OVERFLOW "Record capacity has been reached."
+ CLDB_E_RECORD_DUPLICATE "Record violates the primary key constraint for the table."
+ CLDB_E_RECORD_PKREQUIRED "Primary key value is required."
+ CLDB_E_RECORD_DELETED "Access to deleted records is not allowed."
+
+ CLDB_E_COLUMN_READONLY "Attempt to update read-only column failed (column %d, table '%s')."
+ CLDB_E_COLUMN_SPECIALCOL "Only one column can be the RID or primary key column."
+ CLDB_E_COLUMN_PKNONULLS "Primary key column '%s' may not allow the null value."
+
+ CLDB_E_OBJECT_NOTFOUND "Object not found."
+ CLDB_E_OBJECT_COLNOTFOUND "Column '%s' not found."
+
+ CLDB_E_VECTOR_BADINDEX "%d out of range."
+
+ CLDB_E_INTERNALERROR "Internal error 0x%08x."
+ META_E_INVALID_TOKEN_TYPE "A token passed to a metadata function has the wrong type."
+ META_E_MERGE_COLLISION "Module information inconsistent upon merge."
+ META_E_METHD_NOT_FOUND "Inconsistent method declarations in duplicated types (types: %s; methods: %s): (0x%08x)."
+ META_E_FIELD_NOT_FOUND "Inconsistent field declarations in duplicated types (types: %s; fields: %s): (0x%08x)."
+ META_E_INTFCEIMPL_NOT_FOUND "Inconsistent implemented interfaces in duplicated types (types: %s; interfaces: %s): (0x%08x)."
+ META_E_EVENT_NOT_FOUND "Inconsistent event declarations in duplicated types (types: %s; events: %s): (0x%08x)."
+ META_E_PROP_NOT_FOUND "Inconsistent property declarations in duplicated types (types: %s; properties: %s): (0x%08x)."
+ META_E_PARAM_MISMATCH "Inconsistent parameter information in duplicated methods (methods: %s; type: %s): (0x%08x)."
+ META_E_METHDIMPL_INCONSISTENT "Inconsistent method implementation flags in duplicated methods (methods: %s; type: %s): (0x%08x)."
+ META_E_MD_INCONSISTENCY "Custom attributes are not consistent: (0x%08x)."
+ META_E_CLASS_LAYOUT_INCONSISTENT "Inconsistent layout information in duplicated types (%s): (0x%08x)."
+
+ META_E_METHOD_COUNTS "Differing number of methods in duplicated types (%s): (0x%08x)."
+ META_E_FIELD_COUNTS "Differing number of fields in duplicated types (%s): (0x%08x)."
+ META_E_PARAM_COUNTS "Differing number of parameters in duplicated method (types: %s; methods: %s): (0x%08x)."
+ META_E_GENERICPARAM_INCONSISTENT "Inconsistent Generic information in duplicated types or methods (%s): (0x%08x)."
+ META_E_EVENT_COUNTS "Differing number of events in duplicated types (%s): (0x%08x)."
+ META_E_PROPERTY_COUNTS "Differing number of properties in duplicated types (%s): (0x%08x)."
+ META_E_TYPEDEF_MISSING "A TypeRef exists which should, but does not, have a corresponding TypeDef: (%s): (0x%08x)."
+
+ META_E_CA_INVALID_TARGET "The custom attribute is not valid for the target object's type."
+ META_E_CA_INVALID_ARGTYPE "Unexpected property found in custom attribute value."
+ META_E_CA_INVALID_BLOB "Unable to process the custom attribute value - it may be corrupt or incorrect."
+ META_E_CA_UNKNOWN_ARGUMENT "Unrecognized custom attribute argument: %*s."
+ META_E_CA_REPEATED_ARG "Custom attribute argument %*s should not be repeated."
+ META_E_CA_VARIANT_NYI "Custom attribute does not yet support variants."
+ META_E_CA_ARRAY_NYI "Custom attribute does not yet support arrays."
+ META_E_CA_UNEXPECTED_TYPE "Unexpected argument type."
+ META_E_CA_INVALID_ARG_FOR_TYPE "Argument '%s' cannot be applied to objects of this type."
+ META_E_CA_INVALID_VALUE "Incorrect argument value."
+ META_E_CA_INVALID_UUID "Incorrect UUID format."
+ META_E_CA_INVALID_MARSHALAS_FIELDS "MarshalAs attribute has fields set that are not valid for the specified unmanaged type."
+ META_E_CA_NT_FIELDONLY "Specified unmanaged type is only valid on fields."
+ META_E_CA_NEGATIVE_PARAMINDEX "Parameter index cannot be negative."
+ META_E_CA_NEGATIVE_MULTIPLIER "Multiplier cannot be negative."
+ META_E_CA_NEGATIVE_CONSTSIZE "Constant size cannot be negative."
+ META_E_CA_FIXEDSTR_SIZE_REQUIRED "SizeConst is required for a fixed string."
+ META_E_CA_CUSTMARSH_TYPE_REQUIRED "A MarshalType or MarshalTypeRef setting is required for a custom marshaler."
+ META_E_CA_FILENAME_REQUIRED "A filename is required for DllImport."
+ META_E_MISMATCHED_VISIBLITY "Duplicate managed types have different visibilities."
+ META_E_CA_BAD_FRIENDS_ARGS "[%1] InternalsVisibleTo declarations cannot have a version, culture, public key token, or processor architecture specified."
+ META_E_CA_FRIENDS_SN_REQUIRED "[%1] Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations."
+
+ // These strings belong to the MetaData validator.
+ VLDTR_E_RID_OUTOFRANGE "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has rid out of range."
+ VLDTR_E_CDTKN_OUTOFRANGE "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has coded token type out of range."
+ VLDTR_E_CDRID_OUTOFRANGE "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has coded rid out of range."
+ VLDTR_E_STRING_INVALID "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has an invalid String offset."
+ VLDTR_E_GUID_INVALID "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has an invalid GUID offset."
+ VLDTR_E_BLOB_INVALID "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has an invalid BLOB offset."
+
+ VLDTR_E_MOD_MULTI "Error: Multiple module records found."
+ VLDTR_E_MOD_NULLMVID "Error: Module has no MVID."
+ VLDTR_E_MOD_NONAME "Error: Module has no name."
+ VLDTR_E_MOD_NAMEFULLQLFD "Error: Module name is fully-qualified."
+ VLDTR_E_TR_NAMENULL "Error: TypeRef has no name."
+ VLDTR_E_TR_DUP "Error: TypeRef has a duplicate, token=0x%08x."
+ VLDTR_E_TR_BADSCOPE "Error: TypeRef has invalid resolution scope."
+ VLDTR_E_TR_HASTYPEDEF "Warning: TypeDef (token=0x%08x) has same name as TypeRef."
+ VLDTR_E_TD_NAMENULL "Error: TypeDef has no name."
+ VLDTR_E_TD_DUPNAME "Error: TypeDef has a duplicate based on namespace and name, token=0x%08x."
+ VLDTR_E_TD_DUPGUID "Warning: TypeDef has a duplicate based on GUID, token=0x%08x."
+ VLDTR_E_TD_NOTIFACEOBJEXTNULL "Error: TypeDef that is not an Interface and not the Object class extends Nil token."
+ VLDTR_E_TD_OBJEXTENDSNONNULL "Error: TypeDef for Object class extends token=0x%08x which is not nil."
+ VLDTR_E_TD_EXTENDSSEALED "Error: TypeDef extends token=0x%08x which is marked Sealed."
+ VLDTR_E_TD_EXTENDSIFACE "Error: TypeDef extends an Interface (token=0x%08x)."
+ VLDTR_E_MD_CTORPINVOKE "Error: Type/instance constructor marked PInvokeImpl."
+ VLDTR_E_TD_DLTNORTSPCL "Error: TypeDef is a Deleted record but not marked RTSpecialName."
+ VLDTR_E_TD_RTSPCLNOTDLT "Error: TypeDef is marked RTSpecialName but is not a Deleted record."
+ VLDTR_E_MI_DECLPRIV "Error: MethodImpl overrides private method (token=0x%08x)."
+ VLDTR_E_AS_BADNAME "Error: Assembly name contains leading spaces or path or extension."
+ VLDTR_E_FILE_SYSNAME "Error: File has a reserved system name."
+ VLDTR_E_MI_BODYSTATIC "Error: MethodImpl has static overriding method (token=0x%08x)."
+ VLDTR_E_TD_IFACENOTABS "Error: TypeDef is marked Interface but not Abstract."
+ VLDTR_E_TD_IFACEPARNOTNIL "Error: TypeDef is marked Interface but extends non-Nil token=0x%08x."
+ VLDTR_E_TD_IFACEGUIDNULL "Warning: TypeDef is marked Interface but has no GUID."
+ VLDTR_E_MAR_BADOFFSET "Error: ManifestResource refers to non-PE file but offset is not 0."
+ VLDTR_E_MI_DECLFINAL "Error: MethodImpl overrides final method (token=0x%08x)."
+ VLDTR_E_MI_DECLNOTVIRT "Error: MethodImpl overrides non-virtual method (token=0x%08x)."
+ VLDTR_E_MI_SIGMISMATCH "Error: MethodImpl's Decl (token=0x%08x) and Body (token=0x%08x) method signatures do not match."
+ VLDTR_E_TD_VTNOTSEAL "Error: TypeDef is a Value Type, Enum or Delegate, but not marked Sealed."
+ VLDTR_E_PD_BADFLAGS "Error: Parameter has invalid flags set 0x%08x."
+ VLDTR_E_TD_NESTEDNOENCL "Error: TypeDef is marked Nested but has no enclosing type."
+ VLDTR_E_TD_ENCLNOTNESTED "Error: TypeDef is not marked Nested but has an enclosing type."
+ VLDTR_E_TD_ENUMNOVALUE "Warning: [CLS] TypeDef is Enum but has no value__ field."
+ VLDTR_E_TD_ENUMVALSTATIC "Error: Field value__ (token=0x%08x) in Enum is marked static."
+ VLDTR_E_TD_ENUMVALNOTSN "Error: Field value__ (token=0x%08x) in Enum is not marked RTSpecialName."
+ VLDTR_E_TD_ENUMFLDNOTST "Error: Field (token=0x%08x) in Enum is not marked static."
+ VLDTR_E_TD_ENUMFLDNOTLIT "Error: Field (token=0x%08x) in Enum is not marked literal."
+ VLDTR_E_TD_ENUMNOLITFLDS "Warning: [CLS] Enum has no literal fields."
+ VLDTR_E_TD_ENUMFLDSIGMISMATCH "Error: Signature of field (token=0x%08x) in Enum does not match enum type."
+ VLDTR_E_TD_ENUMVALNOT1ST "Error: Field value__ (token=0x%08x) in Enum is not the first one."
+ VLDTR_E_TD_ENUMHASMETHODS "Error: Enum has method(s)."
+ VLDTR_E_TD_ENUMIMPLIFACE "Error: Enum implements interface(s)."
+ VLDTR_E_TD_ENUMHASPROP "Error: Enum has properties."
+ VLDTR_E_TD_ENUMHASEVENT "Error: Enum has one or more events."
+ VLDTR_E_TD_SYSENUMNOTCLASS "Error: System.Enum is not marked Class."
+ VLDTR_E_TD_SYSENUMNOTEXTVTYPE "Error: System.Enum must extend System.ValueType."
+ VLDTR_E_TD_MARKEDNOSECUR "Error: TypeDef is marked HasSecurity but has no security information."
+ VLDTR_E_TD_SECURNOTMARKED "Error: TypeDef has security information but is not marked HasSecurity."
+ VLDTR_E_TD_NAMETOOLONG "Error: Full name length exceeds maximum allowed (length: %d; max: %d)."
+ VLDTR_E_TD_RTSPCLNOTSPCL "Error: TypeDef marked as RTSpecialName but not SpecialName."
+ VLDTR_E_TD_BADMETHODLST "Error: TypeDef has invalid Method List (> Nmethods+1)."
+ VLDTR_E_TD_BADFIELDLST "Error: TypeDef has invalid Field List (> Nfields+1)."
+ VLDTR_E_CN_BADTYPE "Error: Constant has illegal type (0x%02x)."
+ VLDTR_E_TD_ENUMNOINSTFLD "Error: Enum has no instance field."
+ VLDTR_E_TD_ENUMMULINSTFLD "Error: Enum has multiple instance fields."
+ VLDTR_E_TD_EXTRAFLAGS "Error: Extraneous bits in Flags (0x%08x)."
+ VLDTR_E_TD_EXTENDSITSELF "Error: TypeDef extends itself."
+ VLDTR_E_TD_SYSVTNOTEXTOBJ "Error: System.ValueType must extend System.Object."
+ VLDTR_E_TD_EXTTYPESPEC "Warning: TypeDef extends TypeSpec (0x%08x), not supported in Version 1."
+ VLDTR_E_TD_VTNOSIZE "Error: Value class has neither fields nor size parameter."
+ VLDTR_E_TD_IFACESEALED "Error: Interface is marked Sealed."
+ VLDTR_E_TD_ENUMFLDBADTYPE "Error: Invalid type of instance field(0x%08x) of an Enum."
+ VLDTR_E_IFACE_DUP "Error: InterfaceImpl has a duplicate, token=0x%08x."
+ VLDTR_E_IFACE_BADIMPL "Error: InterfaceImpl has invalid implementing type (0x%08x)."
+ VLDTR_E_IFACE_BADIFACE "Error: InterfaceImpl has invalid implemented type (0x%08x)."
+ VLDTR_E_IFACE_NOTIFACE "Error: InterfaceImpl's implemented type (0x%08x) not marked tdInterface."
+ VLDTR_E_IFACE_METHNOTIMPL "Error: Class implements interface but not method (class:0x%08x; interface:0x%08x; method:0x%08x)."
+ VLDTR_E_IFACE_METHNOTIMPLTHISMOD "Warning: Class does not implement interface method in this module (class:0x%08x; interface:0x%08x; method:0x%08x)."
+ VLDTR_E_IFACE_METHMULTIMPL "Error: Multiple implementation of interface method (class:0x%08x; interface:0x%08x; method:0x%08x)."
+ VLDTR_E_MR_NAMENULL "Error: MemberRef has no name."
+ VLDTR_E_MR_VTBLNAME "Error: MemberRef name starts with _VtblGap."
+ VLDTR_E_MR_DELNAME "Error: MemberRef name starts with _Deleted."
+ VLDTR_E_MR_PARNIL "Error: MemberRef parent is Nil but the module is a PE file."
+ VLDTR_E_MR_BADCALLINGCONV "Error: MemberRef signature has invalid calling convention=0x%08x."
+ VLDTR_E_MR_NOTVARARG "Error: MemberRef has MethodDef parent, but calling convention is not VARARG (parent:0x%08x; callconv: 0x%08x)."
+ VLDTR_E_MR_NAMEDIFF "Error: MemberRef has different name than parent MethodDef, token=0x%08x."
+ VLDTR_E_MR_SIGDIFF "Error: MemberRef has fixed part of signature different from parent MethodDef, token=0x%08x."
+ VLDTR_E_MR_DUP "Warning: MemberRef has a duplicate, token=0x%08x."
+ VLDTR_E_MR_VARARGCALLINGCONV "Warning: [CLS] MemberRef has VARARG calling convention."
+ VLDTR_E_CL_TDAUTO "Error: ClassLayout has parent TypeDef token=0x%08x marked AutoLayout."
+ VLDTR_E_CL_TDINTF "Error: ClassLayout has parent TypeDef token=0x%08x marked Interface."
+ VLDTR_E_CL_BADPCKSZ "Error: ClassLayout has invalid PackingSize; valid set of values is {1,2,4,...,128} (parent: 0x%08x; PackingSize: %ld)."
+ VLDTR_E_CL_DUP "Error: ClassLayout has a duplicate (parent: 0x%08x; duplicate rid: 0x%08x)."
+ VLDTR_E_FL_BADOFFSET "Error: FieldLayout2 record has invalid offset (field: 0x%08x; offset: 0x%08x)."
+ VLDTR_E_FL_TDNIL "Error: FieldLayout2 record for Field token=0x%08x has TypeDefNil for parent."
+ VLDTR_E_FL_NOCL "Error: FieldLayout2 record for field of type that has no ClassLayout record (field: 0x%08x; type: 0x%08x)."
+ VLDTR_E_FL_TDNOTEXPLCT "Error: Explicit offset specified for field of type marked AutoLayout (field: 0x%08x; type: 0x%08x)."
+ VLDTR_E_FL_FLDSTATIC "Error: FieldLayout2 record has Field token=0x%08x marked Static."
+ VLDTR_E_FL_DUP "Error: FieldLayout2 record has a duplicate, rid=0x%08x."
+ VLDTR_E_MODREF_NAMENULL "Error: ModuleRef has no name."
+ VLDTR_E_MODREF_DUP "Warning: ModuleRef has a duplicate, token=0x%08x."
+ VLDTR_E_TD_EXTTRRES "Warning: Type extends TypeRef which resolves to TypeDef in the same module (TypeRef: 0x%08x; TypeDef: 0x%08x)."
+ VLDTR_E_SIGNULL "Error: Signature has zero size."
+ VLDTR_E_SIGNODATA "Error: Signature does not have enough bytes left at byte=0x%08x as indicated by the compression scheme."
+ VLDTR_E_MD_BADCALLINGCONV "Error: Signature has invalid calling convention=0x%08x."
+ VLDTR_E_MD_THISSTATIC "Error: Method is marked Static but calling convention=0x%08x is marked HASTHIS."
+ VLDTR_E_MD_NOTTHISNOTSTATIC "Error: Method is not marked Static, but calling convention=0x%08x is not marked HASTHIS."
+ VLDTR_E_MD_NOARGCNT "Error: Signature has no argument count at byte=0x%08x."
+ VLDTR_E_SIG_MISSELTYPE "Error: Signature missing element type after modifier (modifier: 0x%02x; offset: 0x%08x)."
+ VLDTR_E_SIG_MISSTKN "Error: Signature missing token after element 0x%x."
+ VLDTR_E_SIG_TKNBAD "Error: Signature has an invalid token (token: 0x%08x; offset: 0x%08x)."
+ VLDTR_E_SIG_MISSFPTR "Error: Signature missing function pointer at byte=0x%08x."
+ VLDTR_E_SIG_MISSFPTRARGCNT "Error: Signature has function pointer missing argument count at byte=0x%08x."
+ VLDTR_E_SIG_MISSRANK "Error: Signature missing rank at byte=0x%08x."
+ VLDTR_E_SIG_MISSNSIZE "Error: Signature missing count of sized dimensions of array at byte=0x%08x."
+ VLDTR_E_SIG_MISSSIZE "Error: Signature missing size of dimension of array at byte=0x%08x."
+ VLDTR_E_SIG_MISSNLBND "Error: Signature missing count of lower bounds of array at byte=0x%08x."
+ VLDTR_E_SIG_MISSLBND "Error: Signature missing lower bound of array at byte=0x%08x."
+ VLDTR_E_SIG_BADELTYPE "Error: Signature has invalid ELEMENT_TYPE_* (element type: 0x%08x; offset: 0x%08x)."
+ VLDTR_E_SIG_MISSVASIZE "Error: Signature missing size for VALUEARRAY at byte=0x%08x."
+ VLDTR_E_SIG_LONGFORM "Error: Signature contains long form (such as ELEMENT_TYPE_CLASS<token of System.String>)."
+ VLDTR_E_CN_PARENTTYPE "Error: Constant has parent of invalid type (token=0x%08x)."
+ VLDTR_E_SIG_SENTINMETHODDEF "Error: ELEMENT_TYPE_SENTINEL is only allowed in MemberRef signatures."
+ VLDTR_E_SIG_SENTMUSTVARARG "Error: Signature containing ELEMENT_TYPE_SENTINEL must be VARARG."
+ VLDTR_E_SIG_MULTSENTINELS "Error: Multiple ELEMENT_TYPE_SENTINEL in signature."
+ VLDTR_E_SIG_LASTSENTINEL "Error: Trailing ELEMENT_TYPE_SENTINEL in signature."
+ VLDTR_E_SIG_MISSARG "Error: Signature is missing argument # %d."
+ VLDTR_E_SIG_BYREFINFIELD "Error: Field of ByRef type."
+ VLDTR_E_SIG_TOKTYPEMISMATCH "Error: Token 0x%08x following ELEMENT_TYPE_CLASS (_VALUETYPE) in signature is a ValueType (Class,respectively)."
+ VLDTR_E_SIG_BADVOID "Error: Illegal use of type 'void' in signature."
+ VLDTR_E_FD_BADCALLINGCONV "Error: Field signature has invalid calling convention=0x%08x."
+ VLDTR_E_MD_NAMENULL "Error: Method has no name."
+ VLDTR_E_MD_PARNIL "Error: Method parent is Nil."
+ VLDTR_E_MD_DUP "Error: Method has a duplicate, token=0x%08x."
+ VLDTR_E_MD_ABSTPARNOTABST "Error: Abstract method in non-abstract type (token=0x%08x)."
+ VLDTR_E_MD_NOTSTATABSTININTF "Error: Neither static nor abstract method in interface (token=0x%08x)."
+ VLDTR_E_MD_NOTPUBININTF "Error: Non-public method in interface (token=0x%08x)."
+ VLDTR_E_MD_CTORININTF "Error: Instance constructor in interface (token=0x%08x)."
+ VLDTR_E_MD_GLOBALCTORCCTOR "Error: Global constructor."
+ VLDTR_E_MD_CTORSTATIC "Error: Static instance constructor in type (token=0x%08x)."
+ VLDTR_E_MD_CTORNOTSNRTSN "Error: Constructor/initializer in type (token=0x%08x) is not marked SpecialName and RTSpecialName."
+ VLDTR_E_MD_CTORVIRT "Error: Virtual constructor/initializer in type (token=0x%08x)."
+ VLDTR_E_MD_CTORABST "Error: Abstract constructor/initializer in type (token=0x%08x)."
+ VLDTR_E_MD_CCTORNOTSTATIC "Error: Non-static type initializer in type (token=0x%08x)."
+ VLDTR_E_MD_ZERORVA "Error: Method marked Abstract, Runtime, InternalCall or Imported must have zero RVA, and vice versa."
+ VLDTR_E_MD_FINNOTVIRT "Error: Method marked Final or NewSlot or CheckAccessOnOverride but not Virtual."
+ VLDTR_E_MD_STATANDFINORVIRT "Error: Static method cannot be Final or NewSlot or Virtual."
+ VLDTR_E_MD_ABSTANDFINAL "Error: Method cannot be both Abstract and Final."
+ VLDTR_E_MD_ABSTANDIMPL "Error: Abstract method marked ForwardRef."
+ VLDTR_E_MD_ABSTANDPINVOKE "Error: Abstract method marked PInvokeImpl."
+ VLDTR_E_MD_ABSTNOTVIRT "Error: Abstract method not marked Virtual."
+ VLDTR_E_MD_NOTABSTNOTIMPL "Error: Non-abstract method not marked ForwardRef."
+ VLDTR_E_MD_NOTABSTBADFLAGSRVA "Error: Non-abstract method must have RVA or be PInvokeImpl or Runtime."
+ VLDTR_E_MD_PRIVSCOPENORVA "Error: PrivateScope method has zero RVA."
+ VLDTR_E_MD_GLOBALABSTORVIRT "Error: Global method marked Abstract,Virtual."
+ VLDTR_E_MD_MULTIPLESEMANTICS "Warning: Method has multiple semantics."
+ VLDTR_E_MD_INVALIDSEMANTICS "Error: Method has invalid semantic association (token=0x%08x)."
+ VLDTR_E_MD_SEMANTICSNOTEXIST "Error: Method has semantic association (token=0x%08x) that does not exist."
+ VLDTR_E_MD_MULTSEMANTICFLAGS "Error: Method has multiple semantic flags set for association (token=0x%08x)."
+ VLDTR_E_MD_NOSEMANTICFLAGS "Error: Method has no semantic flags set for association (token=0x%08x)."
+ VLDTR_E_MD_PARAMOUTOFSEQ "Warning: Parameter out of sequence (parameter: %d; seq.num: %d)."
+ VLDTR_E_MD_PARASEQTOOBIG "Error: Parameter has sequence number exceeding number of arguments (parameter: %d; seq.num: %d; num.args: %d)."
+ VLDTR_E_MD_PARMMARKEDNOMARSHAL "Error: Parameter #%d is marked HasFieldMarshal but has no marshaling information."
+ VLDTR_E_MD_PARMMARSHALNOTMARKED "Error: Parameter #%d has marshaling information but is not marked HasFieldMarshal."
+ VLDTR_E_MD_PARMMARKEDNODEFLT "Error: Parameter #%d is marked HasDefault but has no const value."
+ VLDTR_E_MD_PARMDEFLTNOTMARKED "Error: Parameter #%d has const value but is not marked HasDefault."
+ VLDTR_E_MD_CTORNOTVOID "Error: Constructor, initializer must return void."
+ VLDTR_E_MD_SYNCMETHODINVTYPE "Error: Synchronized method in ValueType (token=0x%08x)."
+ VLDTR_E_MD_RVAANDIMPLMAP "Error: Method has both non-zero RVA and Implementation Map."
+ VLDTR_E_MD_BADRVA "Error: Method has invalid RVA (0x%x)."
+ VLDTR_E_MD_BADLOCALSIGTOK "Error: Method has invalid local signature token (0x%08x)."
+ VLDTR_E_MD_BADHEADER "Error: Method has invalid header."
+ VLDTR_E_FD_NAMENULL "Error: Field has no name."
+ VLDTR_E_FD_PARNIL "Error: Field parent is Nil."
+ VLDTR_E_FD_DUP "Error: Field has a duplicate, token=0x%08x."
+ VLDTR_E_FD_NOTVALUERTSN "Error: Field (token=0x%08x) is marked RTSpecialName but not named value__."
+ VLDTR_E_FD_VALUEPARNOTENUM "Error: Field name value__ is reserved for Enums only."
+ VLDTR_E_FD_INSTINIFACE "Error: Instance field in Interface."
+ VLDTR_E_FD_NOTPUBINIFACE "Error: Non-public field in Interface."
+ VLDTR_E_FMD_GLOBALNOTPUBPRIVSC "Error: Global item (field,method) must be Public, Private, or PrivateScope."
+ VLDTR_E_FMD_GLOBALNOTSTATIC "Error: Global item (field,method) must be Static."
+ VLDTR_E_FMD_GLOBALITEM "Warning: [CLS] Global item (field,method)."
+ VLDTR_E_FD_GLOBALNORVA "Error: Global field has no RVA assigned."
+ VLDTR_E_MD_CTORZERORVA "Error: Type/instance constructor has zero RVA."
+ VLDTR_E_FD_RVAHASNORVA "Error: Field is marked HasRVA but has no RVA record."
+ VLDTR_E_FD_RVAHASZERORVA "Error: Field is assigned zero RVA."
+ VLDTR_E_FD_MARKEDNOMARSHAL "Error: Field is marked marshaled but has no marshaling information."
+ VLDTR_E_FD_MARSHALNOTMARKED "Error: Field has marshaling information but is not marked marshaled."
+ VLDTR_E_FD_MARKEDNODEFLT "Error: Field is marked HasDefault but has no const value."
+ VLDTR_E_FD_DEFLTNOTMARKED "Error: Field has const value but is not marked HasDefault."
+ VLDTR_E_FD_BADPARENT "Error: Field has invalid parent (token=0x%08x)."
+ VLDTR_E_FMD_MARKEDNOSECUR "Error: Item (field,method) is marked HasSecurity but has no security information."
+ VLDTR_E_FMD_SECURNOTMARKED "Error: Item (field,method) has security information but is not marked HasSecurity."
+ VLDTR_E_FD_INITONLYANDLITERAL "Error: Field marked both InitOnly and Literal."
+ VLDTR_E_FD_LITERALNOTSTATIC "Error: Literal field must be Static."
+ VLDTR_E_FD_LITERALNODEFAULT "Error: Literal field has no const value."
+ VLDTR_E_FD_FLDINIFACE "Warning: [CLS] Field in Interface."
+ VLDTR_E_FMD_PINVOKENOTSTATIC "Error: PInvoke item (field,method) must be Static."
+ VLDTR_E_FMD_MARKEDNOPINVOKE "Error: PInvoke item (field,method) has no Implementation Map."
+ VLDTR_E_FMD_PINVOKENOTMARKED "Error: Item (field,method) has Implementation Map but is not marked PInvoke."
+ VLDTR_E_FMD_BADIMPLMAP "Warning: Item (field,method) has invalid Implementation Map."
+ VLDTR_E_FMD_BADACCESSFLAG "Error: Item (field,method) has invalid access flag."
+ VLDTR_E_FMD_RTSNNOTSN "Error: Item (field,method) is marked RTSpecialName but not SpecialName."
+ VLDTR_E_CT_DUPTDNAME "Error: ExportedType has same namespace and name as TypeDef, token 0x%08x."
+ VLDTR_E_IMAP_BADMODREF "Error: Implementation Map has invalid Module Ref, token 0x%08x."
+ VLDTR_E_IMAP_BADMEMBER "Error: Implementation Map has invalid Member Forwarded, token 0x%08x."
+ VLDTR_E_IMAP_BADIMPORTNAME "Error: Implementation Map has no import name."
+ VLDTR_E_IMAP_BADCALLCONV "Error: Implementation Map has invalid calling convention 0x%04x."
+ VLDTR_E_AS_MULTI "Error: Multiple assembly records found."
+ VLDTR_E_AS_NAMENULL "Error: Assembly has no name."
+ VLDTR_E_AS_HASHALGID "Warning: Unrecognized Hash Algorithm ID (0x%08x)."
+ VLDTR_E_AS_PROCID "Error: Unrecognized Processor ID (0x%08x) in Assembly."
+ VLDTR_E_AS_BADFLAGS "Error: Invalid Assembly flags (0x%04x)."
+ VLDTR_E_AS_BADLOCALE "Warning: Invalid locale string."
+ VLDTR_E_AS_PROCDUP "Error: Duplicate Assembly Processor record (0x%08x)."
+ VLDTR_E_AR_PROCID "Warning: Unrecognized Processor ID (0x%08x) in AssemblyRef (token=0x%08x)."
+ VLDTR_E_AR_NAMENULL "Error: AssemblyRef has no name."
+ VLDTR_E_ASOS_OSPLTFRMIDINVAL "Error: AssemblyOS entry has invalid platform ID=0x%08x."
+ VLDTR_E_ASOS_DUP "Error: Duplicate Assembly OS record (0x%08X)."
+ VLDTR_E_AROS_OSPLTFRMIDINVAL "Error: AssemblyRefOS entry for AssemblyRef=0x%08x has invalid platform ID=0x%08x."
+ VLDTR_E_CN_PARENTRANGE "Error: Constant parent token (0x%08x) is out of range."
+ VLDTR_E_CT_NAMENULL "Error: ExportedType has no name."
+ VLDTR_E_TD_EXTENDSCHILD "Error: TypeDef extends its own child."
+ VLDTR_E_MD_CCTORHASARGS "Error: Type constructor must have no arguments."
+ VLDTR_E_CT_BADIMPL "Error: ExportedType has invalid Implementation (token=0x%08x)."
+ VLDTR_E_MD_CCTORCALLCONV "Error: Type constructor has invalid calling convention."
+ VLDTR_E_MI_ALIENBODY "Error: MethodImpl has body from another TypeDef (token=0x%08x)."
+ VLDTR_E_CT_NOTYPEDEFID "Warning: ExportedType has no TypeDefId."
+ VLDTR_E_CT_DUP "Error: ExportedType has a duplicate, token=0x%08x."
+ VLDTR_E_FILE_NAMENULL "Error: File has no name."
+ VLDTR_E_FILE_DUP "Error: File has a duplicate, token=0x%08x."
+ VLDTR_E_FILE_NAMEFULLQLFD "Error: File name is fully-qualified, but should not be."
+ VLDTR_E_FILE_BADFLAGS "Error: File has invalid flags (0x%08x)."
+ VLDTR_E_FILE_NULLHASH "Error: File has no hash BLOB."
+ VLDTR_E_MAR_NAMENULL "Error: ManifestResource has no name."
+ VLDTR_E_MAR_DUP "Error: ManifestResource has a duplicate by name, token=0x%08x."
+ VLDTR_E_MAR_NOTPUBPRIV "Error: ManifestResource is not marked Public or Private."
+ VLDTR_E_MAR_BADIMPL "Error: ManifestResource has invalid Implementation (token=0x%08x)."
+ VLDTR_E_MAR_BADFLAGS "Error: ManifestResource has invalid flags (0x%08x)."
+ VLDTR_E_MI_BADCLASS "Error: MethodImpl has invalid Type token=0x%08x."
+ VLDTR_E_MI_BADDECL "Error: MethodImpl has invalid MethodDeclaration token=0x%08x."
+ VLDTR_E_MI_BADBODY "Error: MethodImpl has invalid MethodBody token=0x%08x."
+ VLDTR_E_MI_CLASSISINTF "Error: MethodImpl declared in Interface (token=0x%08x)."
+ VLDTR_E_MI_DUP "Error: MethodImpl has a duplicate (rid=0x%08x)."
+ VLDTR_E_PR_BADSCOPE "Error: Property has invalid scope (token=0x%08x)."
+ VLDTR_E_PR_NONAME "Error: Property has no name."
+ VLDTR_E_PR_NOSIG "Error: Property has no signature."
+ VLDTR_E_PR_DUP "Error: Property has a duplicate (token=0x%08x)."
+ VLDTR_E_PR_BADCALLINGCONV "Error: Property has invalid calling convention (0x%x)."
+ VLDTR_E_PR_MARKEDNODEFLT "Error: Property is marked HasDefault but has no const value."
+ VLDTR_E_PR_DEFLTNOTMARKED "Error: Property has const value but is not marked HasDefault."
+ VLDTR_E_PR_BADSEMANTICS "Error: Property has related method with invalid semantics (method: 0x%08x; semantics: 0x%08x)."
+ VLDTR_E_PR_BADMETHOD "Error: Property has related method with invalid token (0x%08x)."
+ VLDTR_E_PR_ALIENMETHOD "Error: Property has related method belonging to another type (method: 0x%08x; type: 0x%08x)."
+ VLDTR_E_CN_BLOBNOTNULL "Error: Constant of type (0x%02x) must have null value."
+ VLDTR_E_CN_BLOBNULL "Error: Constant of type (0x%02x) must have non-null value."
+ VLDTR_E_EV_BADSCOPE "Error: Event has invalid scope (token=0x%08x)."
+ VLDTR_E_EV_NONAME "Error: Event has no name."
+ VLDTR_E_EV_DUP "Error: Event has a duplicate (token=0x%08x)."
+ VLDTR_E_EV_BADEVTYPE "Error: Event has invalid EventType (token=0x%08x)."
+ VLDTR_E_EV_EVTYPENOTCLASS "Error: Event's EventType (token=0x%08x) is not a class (flags=0x%08x)."
+ VLDTR_E_EV_BADSEMANTICS "Error: Event has related method with invalid semantics (method: 0x%08x; semantics: 0x%08x)."
+ VLDTR_E_EV_BADMETHOD "Error: Event has related method with invalid token (0x%08x)."
+ VLDTR_E_EV_ALIENMETHOD "Error: Event has related method belonging to another type (method: 0x%08x; type: 0x%08x)."
+ VLDTR_E_EV_NOADDON "Error: Event has no AddOn related method."
+ VLDTR_E_EV_NOREMOVEON "Error: Event has no RemoveOn related method."
+ VLDTR_E_EV_FIRENOTVOID "Error: Event's Fire method (0x%08x) must return void."
+ VLDTR_E_DS_BADOWNER "Error: Decl.Security is assigned to invalid item (token=0x%08x)."
+ VLDTR_E_DS_BADFLAGS "Error: Decl.Security has invalid action flag (0x%08x)."
+ VLDTR_E_DS_NOBLOB "Error: Decl.Security has no associated permission BLOB."
+ VLDTR_E_NC_BADNESTED "Error: NestedClass token (0x%08x) in NestedClass record is not a valid TypeDef."
+ VLDTR_E_NC_BADENCLOSER "Error: EnclosingClass token (0x%08x) in NestedClass record is not a valid TypeDef."
+ VLDTR_E_NC_DUP "Error: Duplicate NestedClass record (0x%08x)."
+ VLDTR_E_NC_DUPENCLOSER "Error: Nested type token (0x%08x) has multiple EnclosingClass tokens (0x%08x, 0x%08x)."
+ VLDTR_E_FRVA_ZERORVA "Error: Zero RVA of field 0x%08x in FieldRVA record."
+ VLDTR_E_FRVA_BADFIELD "Error: Invalid field token in FieldRVA record (field: 0x%08x; RVA: 0x%x)."
+ VLDTR_E_FRVA_DUPRVA "Error: Same RVA in another FieldRVA record (RVA: 0x%x; field: 0x%08x)."
+ VLDTR_E_FRVA_DUPFIELD "Error: Same field in another FieldRVA record(field: 0x%08x; record: 0x%08x)."
+ VLDTR_E_EP_BADTOKEN "Error: Invalid token specified as EntryPoint in CLR header."
+ VLDTR_E_EP_INSTANCE "Error: Instance method token specified as EntryPoint in CLR header."
+ VLDTR_E_EP_TOOMANYARGS "Error: EntryPoint method has invalid number of arguments, expecting %d."
+ VLDTR_E_EP_BADRET "Error: EntryPoint method has invalid return type."
+ VLDTR_E_EP_BADARG "Error: EntryPoint method has invalid argument number %d."
+ VLDTR_E_CA_BADPARENT "Error: CustomAttribute has invalid Parent token (0x%08x)."
+ VLDTR_E_CA_BADTYPE "Error: CustomAttribute has invalid Type token (0x%08x)."
+ VLDTR_E_CA_NOTCTOR "Error: CustomAttribute has non-constructor Type (0x%08x)."
+ VLDTR_E_CA_BADSIG "Error: CustomAttribute's Type (0x%08x) has invalid signature."
+ VLDTR_E_CA_NOSIG "Error: CustomAttribute's Type (0x%08x) has no signature."
+ VLDTR_E_CA_BADPROLOG "Error: CustomAttribute's blob has invalid prolog (0x%04x)."
+//@GENERICS
+ VLDTR_E_GP_NAMENULL "Error: GenericParam has no name."
+ VLDTR_E_GP_OWNERNIL "Warning: GenericParam has nil owner."
+ VLDTR_E_GP_DUPNAME "Error: GenericParam has a duplicate based on owner and name, token=0x%08x."
+ VLDTR_E_GP_DUPNUMBER "Error: GenericParam has a duplicate based on owner and number, token=0x%08x."
+ VLDTR_E_GP_NONSEQ_BY_OWNER "Error: GenericParam is out of sequence by owner."
+ VLDTR_E_GP_NONSEQ_BY_NUMBER "Error: GenericParam is out of sequence by number."
+ VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR "Error: GenericParam is co-or-contra variant but its owner, token (0x%08x), is not an interface or delegate."
+ VLDTR_E_GP_ILLEGAL_VARIANT_MVAR "Error: GenericParam is a method type parameter and must be non-variant, not co-or-contra variant."
+ VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS "Error: GenericParam has invalid variance value in flags (0x%08x)."
+ VLDTR_E_GP_REFANDVALUETYPE "Error: GenericParam has inconsistent special constraints ReferenceTypeConstraint and ValueTypeConstraint in flags (0x%08x)."
+ VLDTR_E_GPC_OWNERNIL "Error: GenericParamConstraint has nil owner."
+ VLDTR_E_GPC_DUP "Error: GenericParamConstraint has a duplicate based on owner and constraint, token=0x%08x."
+ VLDTR_E_GPC_NONCONTIGUOUS "Error: GenericParamConstraint is non-contiguous with preceding constraints for same owner, token=0x%08x."
+ VLDTR_E_MS_METHODNIL "Error: MethodSpec has nil method."
+ VLDTR_E_MS_DUP "Error: MethodSpec has a duplicate based on method and instantiation, token=0x%08x."
+ VLDTR_E_MS_BADCALLINGCONV "Error: MethodSpec signature has invalid calling convention=0x%08x."
+ VLDTR_E_MS_MISSARITY "Error: MethodSpec signature is missing arity at byte=0x%08x."
+ VLDTR_E_MS_MISSARG "Error: MethodSpec signature is missing type argument # %d."
+ VLDTR_E_MS_ARITYMISMATCH "Error: MethodSpec has generic method of arity %d but instantiation of different arity %d."
+ VLDTR_E_MS_METHODNOTGENERIC "Error: MethodSpec method is not generic."
+ VLDTR_E_SIG_MISSARITY "Error: Signature missing arity of instantiated generic type at byte=0x%08x."
+ VLDTR_E_SIG_ARITYMISMATCH "Error: Signature has generic type of arity %d instantiated at different arity %d at byte=0x%08x."
+ VLDTR_E_MD_GENERIC_CCTOR "Error: Method cannot be both generic and a class constructor."
+ VLDTR_E_MD_GENERIC_CTOR "Error: Method cannot be both generic and an instance constructor."
+ VLDTR_E_MD_GENERIC_IMPORT "Error: Method cannot be both generic and defined on an imported type."
+ VLDTR_E_MD_GENERIC_BADCALLCONV "Error: Method cannot be both generic and have non-default calling convention."
+ VLDTR_E_EP_GENERIC_METHOD "Error: Entry point in CLR header is the token for a generic method."
+ VLDTR_E_MD_MISSARITY "Error: Method signature is generic but is missing its arity at byte=0x%08x."
+ VLDTR_E_MD_ARITYZERO "Error: Method signature is generic but its arity is zero at byte=0x%08x."
+ VLDTR_E_SIG_ARITYZERO "Error: Signature has generic type instantiated at arity 0 at byte=0x%08x."
+ VLDTR_E_MS_ARITYZERO "Error: MethodSpec signature has arity 0 at byte=0x%08x."
+ VLDTR_E_MD_GPMISMATCH "Error: MethodDef signature has arity %d but the token owns %d GenericParams."
+ VLDTR_E_EP_GENERIC_TYPE "Error: Entry point in CLR header is the token for a method in a generic type."
+ VLDTR_E_MI_DECLNOTGENERIC "Error: MethodImpl overrides non-generic method (token=0x%08x) with generic method."
+ VLDTR_E_MI_IMPLNOTGENERIC "Error: MethodImpl overrides generic method (token=0x%08x) with non-generic method."
+ VLDTR_E_MI_ARITYMISMATCH "Error: MethodImpl overrides generic method (token=0x%08x) of arity %d with generic method of arity %d."
+ VLDTR_E_TD_EXTBADTYPESPEC "Error: TypeDef extends a TypeSpec (0x%08x) that is not an instantiated type."
+ VLDTR_E_SIG_BYREFINST "Error: Signature has type instantiated at ByRef at offset 0x%08x."
+ VLDTR_E_MS_BYREFINST "Error: MethodSpec has type instantiated at ByRef at offset 0x%08x."
+ VLDTR_E_TS_EMPTY "Error: TypeSpec has empty signature."
+ VLDTR_E_TS_HASSENTINALS "Error: TypeSpec has signature containing one or more sentinels."
+ VLDTR_E_TD_GENERICHASEXPLAYOUT "Error: TypeDef is generic but has explicit layout."
+ VLDTR_E_SIG_BADTOKTYPE "Error: Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef (token: 0x%08x; offset: 0x%08x)."
+
+ MSEE_E_LOADLIBFAILED "Failed to delay load library '%hs' (Win32 error: %d).\n\nThis program can no longer run and will now terminate."
+ MSEE_E_GETPROCFAILED "Failed to get entry point '%s' in library '%hs'. Win32 error: %d.\n\nThis program can no longer run and will now terminate."
+ COR_E_APPDOMAINUNLOADED "Error: Attempt to access unloaded AppDomain."
+ COR_E_MISSINGMETHOD "Error: Missing method '%2' from class '%1'."
+ COR_E_FIXUPSINEXE "Cannot load executable '%1' because it contains extra relocations or has relocations stripped."
+
+ COR_E_FILELOAD "Unable to load file '%1'."
+ COR_E_ASSEMBLYEXPECTED "The module '%1' was expected to contain an assembly manifest."
+ FUSION_E_REF_DEF_MISMATCH "The located assembly's manifest definition with name '%1' does not match the assembly reference."
+ FUSION_E_INVALID_PRIVATE_ASM_LOCATION "The found private assembly, '%1', was located outside the ApplicationBase."
+ FUSION_E_SIGNATURE_CHECK_FAILED "Strong name signature verification failed for assembly '%1'. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key."
+ COR_E_MODULE_HASH_CHECK_FAILED "The check of the module's hash failed for file '%1'."
+ FUSION_E_PRIVATE_ASM_DISALLOWED "Assembly '%1' is required to be strongly named."
+ FUSION_E_INVALID_NAME "The given assembly name or codebase, '%1', was invalid."
+ FUSION_E_ASM_MODULE_MISSING "A module specified in the manifest of assembly '%1' could not be found."
+ FUSION_E_CODE_DOWNLOAD_DISABLED "HTTP download of assemblies has been disabled for this appdomain."
+ FUSION_E_HOST_GAC_ASM_MISMATCH "The assembly returned from the host store has a different strong name signature than the corresponding one in GAC. Assembly: '%1'"
+ FUSION_E_LOADFROM_BLOCKED "LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host."
+ FUSION_E_CACHEFILE_FAILED "Failed to add file to AppDomain cache."
+ FUSION_E_APP_DOMAIN_LOCKED "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest."
+ FUSION_E_CONFIGURATION_ERROR "The requested assembly name was neither found in the GAC nor in the manifest or the manifest's specified location is wrong."
+ FUSION_E_MANIFEST_PARSE_ERROR "Unexpected error while parsing the specified manifest."
+ FUSION_E_INVALID_ASSEMBLY_REFERENCE "The given assembly name is invalid because a processor architecture is specified."
+ IDS_EE_HASH_VAL_FAILED "Hash validation failed for file or assembly '%1'."
+ CORSEC_E_MISSING_STRONGNAME "Assembly '%1' is missing the required strong name."
+ CORSEC_E_INVALID_PUBLICKEY "The public key for assembly '%1' was invalid."
+ CORSEC_E_INVALID_STRONGNAME "Strong name validation failed for assembly '%1'."
+ CORSEC_E_SIGNATURE_MISMATCH "The allocated signature slot for assembly '%1' does not correspond to the generated signature size."
+ CORSEC_E_CONTAINER_NOT_FOUND "Strong name key container not found."
+ CORSEC_E_NO_EXEC_PERM "Failed to grant permission to execute '%1'."
+ CORSEC_E_MIN_GRANT_FAIL "Failed to grant required minimum permissions to '%1'."
+ CORSEC_E_POLICY_EXCEPTION "Policy exception occurred while processing '%1'."
+ COR_E_EXECUTIONENGINE "An internal error happened in the Common Language Runtime's Execution Engine."
+ COR_E_REMOTING "An error relating to remoting occurred during the load of file or assembly '%1'."
+ COR_E_SERIALIZATION "An error relating to serialization occurred during the load of file or assembly '%1'."
+ COR_E_SECURITY "A security violation has occurred."
+ IDS_EE_INVALID_STRONGNAME "Strong name validation failed for assembly '%s'. The file may have been tampered with or it was delay signed, but not fully signed with the correct private key."
+ IDS_EE_INVALID_STRONGNAME_TITLE "Strong name validation failed."
+ IDS_EE_INVALID_DELEGATE_LAYOUT "Invalid delegate layout."
+ IDS_EE_PROC_NOT_FOUND "A procedure imported by '%1' could not be loaded."
+ IDS_EE_SIMD_NGEN_DISALLOWED "Target-dependent SIMD vector types may not be used with ngen."
+ IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED "SIMD intrinsics may not be used by partial trust applications."
+
+ IDS_INET_E_CANNOT_CONNECT "Cannot connect to URL for '%1'."
+ IDS_INET_E_RESOURCE_NOT_FOUND "The server or proxy was not found for '%1'."
+ IDS_INET_E_OBJECT_NOT_FOUND "The actual object was not found for '%1'."
+ IDS_INET_E_DATA_NOT_AVAILABLE "Connection was established, but data cannot be retrieved for '%1'."
+ IDS_INET_E_DOWNLOAD_FAILURE "WinInet download failed for URL '%1'."
+ IDS_INET_E_UNKNOWN_PROTOCOL "Unknown URL protocol: '%1'."
+ IDS_INET_E_CONNECTION_TIMEOUT "Connection timeout for URL '%1'."
+ IDS_INET_E_SECURITY_PROBLEM "Security problem encountered when connecting to URL for '%1'."
+
+ CORPROF_E_FUNCTION_NOT_COMPILED "Function 0x%08x had not yet been compiled."
+ CORPROF_E_DATAINCOMPLETE "The ID 0x%08x had not yet been fully loaded or defined."
+ CORPROF_E_NOT_REJITABLE_METHODS "The Module containing function ID 0x%08x is not configured for updateable methods."
+ CORPROF_E_CANNOT_UPDATE_METHOD "Method ID 0x%08x could not be updated."
+ CORPROF_E_FUNCTION_NOT_IL "Profiling error: the method has no associated IL."
+ CORPROF_E_NOT_MANAGED_THREAD "Profiling error: the thread is unmanaged and has never run managed code before."
+ CORPROF_E_CALL_ONLY_FROM_INIT "Profiling error: this function may only be called during profiler initialization."
+ CORPROF_E_INPROC_NOT_ENABLED "Profiling error: in-process debugging must be enabled during profiler initialization."
+ CORPROF_E_JITMAPS_NOT_ENABLED "Profiling error: cannot get a JIT map because the profiler did not enable JIT map tracking."
+ CORPROF_E_INPROC_ALREADY_BEGUN "Profiling error: BeginInprocDebugging cannot be called more than once."
+ CORPROF_E_INPROC_NOT_AVAILABLE "Profiling error: in-process debugging not allowed during this profiler callback."
+ CORPROF_E_NOT_YET_AVAILABLE "Profiling error: the requested information is not yet available."
+
+ // For these to be moved from the left side to the right side, they must
+ // be less than ENCERRORINFO_MAX_STRING_SIZE in length (currently, 60 characters)
+ CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE "Error: Cannot increase the maximum nesting level in Edit-and-Continue."
+ CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED "Error: Module must be loaded in Edit-and-Continue mode."
+ CORDBG_E_ENC_METHOD_SIG_CHANGED "Variable type cannot be changed."
+ CORDBG_E_ENC_METHOD_NO_LOCAL_SIG "Cannot get the local signature for the method."
+ CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS "Field cannot be added to a value or layout type."
+ CORDBG_E_ENC_CANT_CHANGE_FIELD "Field properties cannot be changed."
+ CORDBG_E_ENC_ZAPPED_WITHOUT_ENC "Edit-and-Continue impossible: Zap file was created without Edit-and-Continue flag set."
+ CORDBG_E_ENC_BAD_METHOD_INFO "Internal data structures missing method information."
+ CORDBG_E_ENC_JIT_CANT_UPDATE "JIT unable to update internal structures."
+ CORDBG_E_ENC_MISSING_CLASS "Internal type data structures are missing."
+ CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE "Not allowed to change interface inheritance."
+END
+
+// These strings belong to the type library importer and exporter.
+STRINGTABLE DISCARDABLE
+BEGIN
+ TLBX_E_CIRCULAR_EXPORT "CLR assembly '%2' was imported from a type library and cannot be re-exported to a type library. Make sure the type library from which the assembly was imported is registered."
+ TLBX_E_CIRCULAR_EXPORT2 "CLR assembly '%s' was imported from a type library and cannot be re-exported to a type library. Make sure the type library from which the assembly was imported is registered."
+ TLBX_E_CIRCULAR_IMPORT "Type library '%s' was exported from a CLR assembly and cannot be re-imported as a CLR assembly."
+ TLBX_E_BAD_VTABLE "Vtable slot number associated with member '%s' of type '%s' in type library '%s' is invalid."
+ TLBX_E_CANT_LOAD_CLASS "Type library exporter cannot load type '%hs'."
+ TLBX_E_CLASS_LOAD_EXCEPTION "Type library exporter cannot load type '%hs' (error: %s)."
+ TLBX_E_CANT_LOAD_MODULE "Type library exporter cannot load assembly '%2'."
+ TLBX_E_UNKNOWN_SIGNATURE "Type library exporter encountered an unknown signature element."
+ TLBX_E_INVALID_NAMESPACE "Type library has an invalid namespace and cannot be imported (library: '%ls'; namespace: '%ls')."
+ TLBX_E_REFERENCED_TYPELIB "Successful import of type library may require prior import (library: '%ls'; import: '%ls')."
+ TLBX_E_CRM_NON_STATIC "COM register method is invalid (not static) (method: '%hs'; type: '%hs')."
+ TLBX_E_CRM_INVALID_SIG "COM register method has an invalid signature (method: '%hs'; type: '%hs'). The COM register method must have a single string argument and a return type of void."
+ TLBX_E_LAYOUT_ERROR "Type library exporter encountered an error while attempting to lay out the TypeInfo '%2': (%1) %3"
+ TLBX_E_NOTIUNKNOWN "Type library importer has encountered an interface not derived from IUnknown: '%ls'."
+ TLBX_W_DUAL_NOT_DISPATCH "Interface '%ls' is marked as [dual], but does not derive from IDispatch. It will be converted as an IUnknown-derived interface."
+ TLBX_E_NONVISIBLEVALUECLASS "Non COM visible value type '%s' is being referenced either from the type currently being exported or from one of its base types."
+ TLBX_E_LPTSTR_NOT_ALLOWED "Type '%s' has a method or field with an unmanaged type of LPTStr which cannot be exported to COM."
+ TLBX_E_AUTO_CS_NOT_ALLOWED "Type '%s' has a char set of auto. Types with a char set of auto cannot be exported to COM."
+ TLBX_S_NOSTDINTERFACE "Type '%hs' has an IID of IID_IUnknown or IID_IDispatch, which is not allowed."
+ TLBX_S_DUPLICATE_DISPID "The method '%hs.%hs' has a duplicate dispid, %d, which will be ignored."
+ TLBX_E_ENUM_VALUE_INVALID "The enum member '%hs.%ls' has a value that cannot be expressed as a 32-bit integer. Type library enum members must be 32-bit integers."
+ TLBX_W_ENUM_VALUE_TOOBIG "The enum member '%hs.%ls' has a value that cannot be expressed as a 32-bit integer. Type library enum members must be 32-bit integers."
+ TLBX_E_DUPLICATE_IID "Type '%ls' and type '%ls' both have the same UUID."
+ TLBX_E_NO_NESTED_ARRAYS "Type '%hs' contains nested arrays, which cannot be exported to a type library."
+ TLBX_E_PARAM_ERROR_NAMED "Error while importing type: parameter referenced a type library that is not available (type: '%ls'; parameter: '%ls'; method: '%ls')."
+ TLBX_E_PARAM_ERROR_UNNAMED "Error while importing type: parameter referenced a type library that is not available (type: '%ls'; parameter: '%d'; method: '%ls')."
+ TLBX_E_INVALID_TYPEINFO "Type '%ls' is invalid and may only be partially converted."
+ TLBX_E_INVALID_TYPEINFO_UNNAMED "There was an error converting a type. The name of the type cannot be determined. It is index %d in the type library."
+ TLBX_E_BAD_NATIVETYPE "The method or field has an invalid managed/unmanaged type combination, check the MarshalAs directive."
+ TLBX_E_CTX_NESTED "%ls, while processing '%ls'."
+ TLBX_E_ERROR_MESSAGE "Type library exporter encountered an error while processing '%ls'. Error: %ls"
+ TLBX_W_WARNING_MESSAGE "Type library exporter warning processing '%ls'. Warning: %ls"
+ TLBX_E_CANT_SAVE "Type library exporter encountered an error while attempting to save the type library '%ls': Error: (%x) %ls."
+ TLBX_W_LIBNOTREGISTERED "Type library exporter warning: Referenced type is defined in managed component, which is imported from a type library that could not be loaded because it was not registered (type: '%ls'; component: '%ls')."
+ TLBX_E_CANTLOADLIBRARY "Referenced type is defined in managed component, which is imported from a type library that could not be loaded (type: '%ls'; component: '%ls')."
+ TLBX_E_AGNOST_SIGNATURE "Type library exporter encountered a size agnostic signature element."
+ TLBX_E_CONVERT_FAIL "Type library exporter failed."
+ TLBX_E_BAD_VT_TYPE "Type library importer has encountered an invalid VT type (type: 0x%x; imported member: '%ls.%ls')."
+ TLBX_E_NO_MSCOREE_TLB "Type library exporter cannot load required library MSCOREE.TLB."
+ TLBX_E_BAD_MSCOREE_TLB "Type library exporter has encountered an error reading from library MSCOREE.TLB."
+ TLBX_E_TLB_EXCEPTION "Type library importer has encountered an exception: 0x%x."
+ TLBX_E_MULTIPLE_LCIDS "Type library importer has encountered a method with multiple [lcid] parameters while importing '%ls.%ls'."
+ TLBX_I_TYPEINFO_IMPORTED "Type '%ls' imported."
+ TLBX_I_TYPE_EXPORTED "Type '%hs' exported."
+ TLBX_E_AMBIGUOUS_RETURN "Type library importer has encountered a method with an unexpected [out, retval] parameter: '%ls.%ls'."
+ TLBX_E_DUPLICATE_TYPE_NAME "Type library importer has encountered a duplicate type name: '%ls'."
+ TLBX_I_USEIUNKNOWN "Type library exporter could not find the type library for '%ls'. IUnknown was substituted for the interface."
+ TLBX_I_UNCONVERTABLE_ARGS "At least one of the arguments for '%ls.%ls' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate."
+ TLBX_I_UNCONVERTABLE_FIELD "The type library importer could not convert the signature for the member '%ls.%ls'."
+ TLBX_I_NONSEQUENTIALSTRUCT "The type has explicit layout, and has been exported as an empty record. Types with explicit layout can only be properly exported if all members have an offset of 0 (a union)."
+ TLBX_I_RESOLVEREFFAILED "Type library importer has failed to resolve a referenced type library."
+ TLBX_E_ASANY "Type contains [MarshalAs(AsAny)], which is only valid for PInvoke. The MarshalAs directive was ignored."
+ TLBX_E_INVALIDLCIDPARAM "The value of the LCID conversion attribute must not exceed the number of parameters."
+ TLBX_E_LCIDONDISPONLYITF "The LCIDConversionAttribute is not allowed on dispatch only interfaces."
+ TLBX_E_NONPUBLIC_FIELD "The public struct contains one or more non-public fields that will be exported."
+ TLBX_I_DUPLICATE_DISPID "The type had one or more duplicate DISPIDs specified. The duplicate DISPIDs were ignored."
+ TLBX_E_BAD_NAMES "The names list was not valid."
+ TLBX_I_REF_TYPE_AS_STRUCT "The reference type had sequential or explicit layout, and so was exported as a struct."
+ TLBX_E_ARRAY_NEEDS_NT_FIXED "Arrays in structs must be SafeArrays or ByValArrays."
+ TLBX_E_CLASS_NEEDS_NT_INTF "Reference types with layout in structs need [MarshalAs(UnmanagedType.Interface)]."
+ TLBX_E_GENERICINST_SIGNATURE "Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM."
+ TLBX_E_GENERICPAR_SIGNATURE "Type library exporter encountered a generic type parameter in a signature. Generic code may not be exported to COM."
+ TLBX_I_GENERIC_TYPE "Type library exporter encountered a generic type. Generic classes may not be exposed to COM."
+ TLBX_I_GENERIC_BASE_TYPE "Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute."
+ TLBX_W_NON_INTEGRAL_CA_TYPE "Ignoring IDL custom attribute '%ls' on '%ls' because it must be used with an integral value."
+ TLBX_W_IENUM_CA_ON_IUNK "Ignoring IDL custom attribute '%ls' on '%ls' because it cannot be used on an IUnknown interface."
+ TLBX_E_NO_SAFEHANDLE_ARRAYS "Type '%hs' contains arrays of SafeHandles, which cannot be exported to a type library."
+ TLBX_E_NO_CRITICALHANDLE_ARRAYS "Type '%hs' contains arrays of CriticalHandles, which cannot be exported to a type library."
+ TLBX_W_NO_PROPS_IN_EVENTS "Type library importer has encountered a source interface containing properties: '%ls'."
+ TLBX_W_EXPORTING_AUTO_LAYOUT "Type '%hs' has auto-layout but is being exported. Consider marking the type [ComVisible(false)] since the exported definition is not guaranteed to work."
+ TLBX_E_TYPED_REF "Cannot export TypedReference."
+ TLBX_W_DEFAULT_INTF_NOT_VISIBLE "Default interface is not visible to COM."
+ TLBX_W_BAD_SAFEARRAYFIELD_NO_ELEMENTVT "System.Array fields without a SafeArraySubType cannot be used from COM. For legacy reasons, they are exported as SAFEARRAYs of VARIANTs. However, at runtime, they are not marshaled as such."
+ TLBX_W_LAYOUTCLASS_AS_INTERFACE "Type library exporter encountered a reference type with layout marked as [MarshalAs(UnmanagedType.Interface)] in a signature. The reference type was instead treated as if it were marked with [MarshalAs(UnmanagedType.IUnknown)]."
+ TLBX_E_BITNESS_MISMATCH "Unable to export this assembly with the specified machine type as the assembly is marked machine specific with a different machine type."
+ TLBX_E_EVENT_WITH_NEWENUM "Type library importer encountered a source interface on coclass '%ls' with a NewEnum member. This is not supported."
+ TLBX_E_PROPGET_WITHOUT_RETURN "Type library importer encountered a property getter '%ls' on type '%ls' without a valid return type. The importer will attempt to import this property as a method instead."
+END
+
+// These strings are generated from within the EE.
+STRINGTABLE DISCARDABLE
+BEGIN
+ CEE_E_CVTRES_NOT_FOUND "Could not execute CVTRES.EXE."
+ IDS_EE_EXCEPTION_FROM_HRESULT "Exception from HRESULT: "
+ IDS_EE_NDIRECT_UNSUPPORTED_SIG "Method's type signature is not PInvoke compatible."
+ IDS_EE_COM_UNSUPPORTED_SIG "Method's type signature is not Interop compatible."
+ IDS_EE_COM_UNSUPPORTED_TYPE "The method returned a COM Variant type that is not Interop compatible."
+ IDS_EE_COM_UNSUPPORTED_VT_RECORD "The method returned a VT_RECORD Variant, which is not supported by Interop."
+ IDS_EE_NDIRECT_BADNATL "Invalid PInvoke or UnmanagedFunctionPointer metadata format."
+ IDS_EE_NDIRECT_BADNATL_CALLCONV "Invalid PInvoke or UnmanagedFunctionPointer calling convention."
+ IDS_EE_NDIRECT_BADNATL_VARARGS_CALLCONV "Invalid PInvoke calling convention. Vararg functions must use the cdecl calling convention."
+ IDS_EE_NDIRECT_BADNATL_THISCALL "Invalid PInvoke calling convention. Thiscall requires that the first parameter is present and can be enregistered."
+ IDS_EE_NDIRECT_LOADLIB "Unable to load DLL '%1': %2"
+ IDS_EE_NDIRECT_GETPROCADDRESS "Unable to find an entry point named '%2' in DLL '%1'."
+ IDS_EE_NDIRECT_GETPROCADDRESS_NONAME "A library name must be specified in a DllImport attribute applied to non-IJW methods."
+ IDS_EE_CLASS_CONSTRAINTS_VIOLATION "GenericArguments[%1], '%2', on '%3' violates the constraint of type parameter '%4'."
+ IDS_EE_METHOD_CONSTRAINTS_VIOLATION "Method %1.%2: type argument '%3' violates the constraint of type parameter '%4'."
+ IDS_EE_NOSYNCHRONIZED "Synchronized attribute cannot be used with this method type."
+ IDS_EE_LOAD_NO_MAIN "Main method not found for type '%1'."
+ IDS_EE_LOAD_BAD_MAIN_SIG "Main method for type '%1' has invalid signature."
+ IDS_EE_LOAD_CIRCULAR_DEPENDENCY "A circular dependency was detected when loading file or assembly '%1'."
+
+#ifdef FEATURE_CORECLR
+ IDS_EE_FILE_NOT_FOUND "File or assembly name '%1' was not found."
+#else
+ IDS_EE_FILE_NOT_FOUND "File or assembly name '%1', or one of its dependencies, was not found."
+#endif
+
+ IDS_EE_TOO_MANY_OPEN_FILES "The system cannot open file '%1'. There may be too many open files."
+ IDS_EE_SHARING_VIOLATION "Cannot access file '%1' because it is being used by another process."
+ IDS_EE_LOCK_VIOLATION "Cannot access file '%1' because another process has locked a portion of the file."
+ IDS_EE_OPEN_FAILED "Cannot open file '%1'."
+ IDS_EE_INVALID_NAME "The filename, directory name, or volume label syntax is incorrect: '%1'."
+ IDS_EE_UNRECOGNIZED_VOLUME "The volume does not contain a recognized file system."
+ IDS_EE_FILE_INVALID "'%1' is not a valid file."
+ IDS_EE_FILE_CORRUPT "The file or directory for '%1' is corrupt and unreadable."
+ IDS_EE_DISK_CORRUPT "The disk structure is corrupt and unreadable. Unable to load '%1'."
+ IDS_EE_DISK_FULL "There is not enough space on the disk. Unable to load '%1'."
+
+ E_ACCESSDENIED "Access is denied: '%1'."
+ COR_E_BADIMAGEFORMAT "The format of the file '%1' is invalid."
+ COR_E_NEWER_RUNTIME "The assembly is built by a runtime newer than the currently loaded runtime, and cannot be loaded."
+ IDS_EE_BAD_USER_PROFILE "The specified user does not have a valid profile. Unable to load '%1'."
+ IDS_EE_ALREADY_EXISTS "Cannot create/shadow copy '%1' when that file already exists."
+ IDS_EE_DLL_INIT_FAILED "The dll initialization routine failed for file '%1'."
+ IDS_EE_LOAD_UNEXPECTED "Unexpected error occurred loading type '%1'."
+ IDS_EE_AMBIGUOUSINVOKE "Multiple methods named Invoke."
+ IDS_EE_CALLBACK_UNSUPPORTED_SIG "Method's type signature contains a type that cannot be automatically converted."
+ IDS_EE_NOTADELEGATE "Function pointer was not created by a Delegate."
+ IDS_EE_NOTNDIRECT "Not a PInvoke method."
+ IDS_EE_METADATA_ERROR "Error loading file '%s'.\n%s."
+ IDS_EE_ERRORTITLE "Error"
+ IDS_EE_ERRORMESSAGETEMPLATE "Error 0x%08x.\n\n%s."
+ IDS_EE_ERRORMESSAGETEXTTEMPLATE "Error: %s."
+ IDS_EE_TWO_LOADED_MSCOREE_TITLE "MSCOREE.DLL load error."
+ IDS_EE_TWO_LOADED_MSCOREE_MSG "Two different copies of MSCORWKS.DLL have been loaded.\n\nFirst copy:\n%s\n\nSecond copy:\n%s\n\nThis is typically caused by having a registered MSCOREE.DLL that is different\nfrom the one that is statically linked with the application."
+ IDS_EE_CUST_MARSHALER_ON_INVALID_TYPE "Custom marshalers can only be specified for classes."
+ IDS_EE_RETHROW_NOT_ALLOWED "No exception available to rethrow."
+ IDS_EE_INVALID_OLE_VARIANT "Specified OLE variant is invalid."
+ IDS_EE_FAILED_TO_LOAD "Exception from HRESULT: 0x%1. Failed to load '%2'."
+ IDS_EE_TO_MANY_ARGUMENTS_IN_MAIN "Signature for the entry point has too many arguments."
+ IDS_EE_FAILED_TO_FIND_MAIN "Entry point not found in assembly '%1'."
+ IDS_EE_ILLEGAL_TOKEN_FOR_MAIN "Specified entry point in assembly '%1' is not a legal method."
+ IDS_EE_MAIN_METHOD_HAS_INVALID_RTN "Entry point must have a return type of void, integer, or unsigned integer."
+ IDS_EE_MAIN_METHOD_MUST_BE_STATIC "Entry point must be static."
+ IDS_EE_SAFEARRAYTYPEMISMATCH "Mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata."
+ IDS_EE_SAFEARRAYRANKMISMATCH "SafeArray of rank %1 has been passed to a method expecting an array of rank %2."
+
+ IDS_EE_SRC_OBJ_NOT_COMOBJECT "Object type must be __ComObject or derived from __ComObject."
+ IDS_EE_CANNOT_COERCE_COMOBJECT "Source object cannot be converted to the destination type since it does not support all the required interfaces."
+
+ IDS_EE_BADMARSHALFIELD_ERROR_MSG "Cannot marshal field '%2' of type '%1': %3"
+ IDS_EE_BADMARSHAL_ERROR_MSG "Cannot marshal '%1': %2"
+
+#ifdef FEATURE_COMINTEROP
+ IDS_EE_BADMARSHAL_BOOLEAN "Invalid managed/unmanaged type combination (booleans must be paired with I1, U1, Bool, or VariantBool)."
+ IDS_EE_BADMARSHAL_I4 "Invalid managed/unmanaged type combination (Int32/UInt32 must be paired with I4, U4, or Error)."
+ IDS_EE_BADMARSHAL_ARRAY "Invalid managed/unmanaged type combination (Arrays can only be marshaled as LPArray, ByValArray, or SafeArray)."
+ IDS_EE_BADMARSHALPARAM_STRING "Invalid managed/unmanaged type combination (String parameters and return types must be paired with LPStr, LPWStr, LPTStr, BStr, TBStr, VBByRefStr, or AnsiBStr)."
+ IDS_EE_BADMARSHALFIELD_ARRAY "Invalid managed/unmanaged type combination (Array fields must be paired with ByValArray or SafeArray)."
+ IDS_EE_BADMARSHALFIELD_STRING "Invalid managed/unmanaged type combination (String fields must be paired with LPStr, LPWStr, LPTStr, BStr, or ByValTStr)."
+ IDS_EE_BADMARSHALFIELD_DECIMAL "Invalid managed/unmanaged type combination (Decimal fields must be paired with Struct or Currency)."
+ IDS_EE_BADMARSHAL_STRINGARRAY "Invalid managed/unmanaged type combination (String[] must be paired with an ArraySubType of LPStr, LPWStr, BStr, or LPTStr)."
+ IDS_EE_BADMARSHAL_DECIMALARRAY "Invalid managed/unmanaged type combination (Decimal[] must be paired with an ArraySubType of Struct or Currency)."
+ IDS_EE_BADMARSHAL_WINRT_MARSHAL_AS "Invalid managed/unmanaged type combination (Windows Runtime parameters and fields must not have a MarshalAs attribute set)."
+ IDS_EE_BADMARSHAL_WINRT_MISSING_GUID "Invalid managed/unmanaged type combination (Windows Runtime interfaces, classes and delegates must have a Guid or a default interface)."
+ IDS_EE_BADMARSHAL_WINRT_DELEGATE "Invalid managed/unmanaged type combination (Delegates must be Windows Runtime delegates)."
+ IDS_EE_BADMARSHAL_WINRT_COPYCTOR "Windows Runtime marshaler does not support types with copy constructor."
+ IDS_EE_BADMARSHAL_DEFAULTIFACE_NOT_WINRT_IFACE "The default interface must refer to a Windows Runtime interface with a GUID."
+ IDS_EE_BADMARSHAL_DEFAULTIFACE_NOT_SUBTYPE "The default interface must refer to an interface that is implemented by the type."
+ IDS_EE_BADMARSHAL_DATETIMEOFFSET "Invalid managed/unmanaged type combination (the DateTimeOffset structure must be paired with Struct)."
+ IDS_EE_INVALIDARG_WINRT_INVALIDURI "The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details."
+ IDS_EE_BADMARSHAL_WINRT_ILLEGAL_TYPE "Windows Runtime marshaler does not support the type."
+#else // FEATURE_COMINTEROP
+ IDS_EE_BADMARSHAL_BOOLEAN "Invalid managed/unmanaged type combination (booleans must be paired with I1, U1, or Bool)."
+ IDS_EE_BADMARSHAL_I4 "Invalid managed/unmanaged type combination (Int32/UInt32 must be paired with I4 or U4)."
+ IDS_EE_BADMARSHAL_ARRAY "Invalid managed/unmanaged type combination (Arrays can only be marshaled as LPArray or ByValArray)."
+ IDS_EE_BADMARSHALPARAM_STRING "Invalid managed/unmanaged type combination (String parameters and return types must be paired with LPStr, LPWStr, or LPTStr)."
+ IDS_EE_BADMARSHALFIELD_ARRAY "Invalid managed/unmanaged type combination (Array fields must be paired with ByValArray)."
+ IDS_EE_BADMARSHALFIELD_STRING "Invalid managed/unmanaged type combination (String fields must be paired with LPStr, LPWStr, LPTStr, or ByValTStr)."
+ IDS_EE_BADMARSHALFIELD_DECIMAL "Invalid managed/unmanaged type combination (Decimal fields must be paired with Struct)."
+ IDS_EE_BADMARSHAL_STRINGARRAY "Invalid managed/unmanaged type combination (String[] must be paired with an ArraySubType of LPStr, LPWStr, or LPTStr)."
+ IDS_EE_BADMARSHAL_DECIMALARRAY "Invalid managed/unmanaged type combination (Decimal[] must be paired with an ArraySubType of Struct)."
+#endif // FEATURE_COMINTEROP
+
+ IDS_EE_BADMARSHAL_GENERIC "Invalid managed/unmanaged type combination."
+ IDS_EE_BADMARSHAL_CHAR "Invalid managed/unmanaged type combination (chars must be paired with I1, I2, U1, or U2)."
+ IDS_EE_BADMARSHAL_I1 "Invalid managed/unmanaged type combination (Byte/SByte must be paired with I1 or U1)."
+ IDS_EE_BADMARSHAL_I2 "Invalid managed/unmanaged type combination (Int16/UInt16 must be paired with I2 or U2)."
+ IDS_EE_BADMARSHAL_I8 "Invalid managed/unmanaged type combination (Int64/UInt64 must be paired with I8 or U8)."
+ IDS_EE_BADMARSHAL_I "Invalid managed/unmanaged type combination (Int/UInt must be paired with SysInt or SysUInt)."
+ IDS_EE_BADMARSHAL_R4 "Invalid managed/unmanaged type combination (Single must be paired with R4)."
+ IDS_EE_BADMARSHAL_R8 "Invalid managed/unmanaged type combination (Double must be paired with R8)."
+ IDS_EE_BADMARSHAL_PTR "Invalid managed/unmanaged type combination (pointers must not have a MarshalAs attribute set)."
+ IDS_EE_BADMARSHAL_NOLAYOUT "The type definition of this type has no layout information."
+ IDS_EE_BADMARSHAL_DELEGATE "Invalid managed/unmanaged type combination (Delegates must be paired with FunctionPtr or Interface)."
+ IDS_EE_BADMARSHAL_FNPTR "Invalid managed/unmanaged type combination (function pointers must be paired with FunctionPtr)."
+ IDS_EE_BADMARSHAL_INTERFACE "Invalid managed/unmanaged type combination (Interfaces must be paired with Interface)."
+ IDS_EE_BADMARSHAL_CLASS "Invalid managed/unmanaged type combination (this type must be paired with LPStruct or Interface)."
+ IDS_EE_BADMARSHAL_VALUETYPE "Invalid managed/unmanaged type combination (this value type must be paired with Struct)."
+ IDS_EE_BADMARSHAL_OBJECT "Invalid managed/unmanaged type combination (the Object class must be paired with Interface, IUnknown, IDispatch, AsAny, or Struct)."
+ IDS_EE_BADMARSHALFIELD_OBJECT "Invalid managed/unmanaged type combination (the Object class must be paired with Interface, IUnknown, IDispatch, or Struct)."
+ IDS_EE_BADMARSHALPARAM_DECIMAL "Invalid managed/unmanaged type combination (Decimal parameters and return types must be paired with Struct, LPStruct, or Currency)."
+ IDS_EE_BADMARSHAL_GUID "Invalid managed/unmanaged type combination (the Guid class must be paired with Struct or LPStruct)."
+ IDS_EE_BADMARSHAL_DATETIME "Invalid managed/unmanaged type combination (the DateTime class must be paired with Struct)."
+ IDS_EE_BADMARSHAL_SAFEHANDLE "Invalid managed/unmanaged type combination (SafeHandles must not have a MarshalAs attribute set and cannot be used in arrays)."
+ IDS_EE_BADMARSHAL_CRITICALHANDLE "Invalid managed/unmanaged type combination (CriticalHandles must not have a MarshalAs attribute set and cannot be used in arrays)."
+ IDS_EE_BADMARSHAL_BADMANAGED "There is no marshaling support for this type."
+ IDS_EE_BADMARSHAL_NESTEDARRAY "There is no marshaling support for nested arrays."
+ IDS_EE_BADMARSHAL_UNSUPPORTED_SIG "Signature is not Interop compatible."
+ IDS_EE_BADMARSHAL_OBJECTARRAY "Invalid managed/unmanaged type combination (Object[] or System.Array must be paired with an ArraySubType of Struct, Interface, IUnknown or IDispatch)."
+ IDS_EE_BADMARSHAL_DATETIMEARRAY "Invalid managed/unmanaged type combination (DateTime[] must be paired with an ArraySubType of Struct)."
+ IDS_EE_BADMARSHAL_SAFEHANDLEARRAY "Invalid managed/unmanaged type combination (Arrays of SafeHandles are not supported)."
+ IDS_EE_BADMARSHAL_CRITICALHANDLEARRAY "Invalid managed/unmanaged type combination (Arrays of CriticalHandles are not supported)."
+ IDS_EE_BADMARSHAL_SYSARRAY "Invalid managed/unmanaged type combination (System.Array must be paired with SafeArray or Interface)."
+ IDS_EE_BADMARSHAL_PTRSUBTYPE "Pointers cannot reference managed objects. Use ByRef instead."
+ IDS_EE_BADMARSHAL_PTRNONBLITTABLE "Pointers cannot reference marshaled structures. Use ByRef instead."
+ IDS_EE_BADMARSHAL_RESTRICTION "This type can only be marshaled in restricted ways."
+ IDS_EE_BADMARSHAL_CHARARRAYRESTRICTION "Ansi char arrays cannot be marshaled as ByRef or as unmanaged-to-managed parameters."
+ IDS_EE_BADMARSHAL_ASANYRESTRICTION "AsAny cannot be used on return types, ByRef parameters, ArrayWithOffset, or parameters passed from unmanaged to managed."
+ IDS_EE_BADMARSHAL_VBBYVALSTRRESTRICTION "VBByRefStr can only be used in combination with in/out, ByRef managed-to-unmanaged strings."
+ IDS_EE_BADMARSHAL_AWORESTRICTION "ArrayWithOffsets can only be marshaled as inout, non-ByRef, managed-to-unmanaged parameters."
+ IDS_EE_BADMARSHAL_BVCRESTRICTION "Internal error."
+ IDS_EE_BADMARSHAL_COPYCTORRESTRICTION "Classes with copy-ctors can only be marshaled non-ByRef."
+ IDS_EE_BADMARSHAL_VCRESTRICTION "Internal error."
+ IDS_EE_BADMARSHAL_ARGITERATORRESTRICTION "ArgIterators cannot be marshaled ByRef."
+ IDS_EE_BADMARSHAL_HANDLEREFRESTRICTION "HandleRefs cannot be marshaled ByRef or from unmanaged to managed."
+ IDS_EE_BADMARSHAL_SAFEHANDLENATIVETOCOM "SafeHandles cannot be marshaled from unmanaged to managed."
+ IDS_EE_BADMARSHAL_ABSTRACTOUTSAFEHANDLE "Ref and out SafeHandle parameters cannot be abstract."
+ IDS_EE_BADMARSHAL_ABSTRACTRETSAFEHANDLE "Returned SafeHandles cannot be abstract."
+ IDS_EE_BADMARSHAL_RETURNSHCOMTONATIVE "SafeHandles cannot be returned from managed to unmanaged."
+ IDS_EE_BADMARSHAL_CRITICALHANDLENATIVETOCOM "CriticalHandles cannot be marshaled from unmanaged to managed."
+ IDS_EE_BADMARSHAL_ABSTRACTOUTCRITICALHANDLE "Ref and out CriticalHandle parameters cannot be abstract."
+ IDS_EE_BADMARSHAL_ABSTRACTRETCRITICALHANDLE "Returned CriticalHandles cannot be abstract."
+ IDS_EE_BADMARSHAL_NOTMARSHALABLE "The type definition of this field has layout information but has an invalid managed/unmanaged type combination or is unmarshalable."
+ IDS_EE_BADMARSHAL_BADMETADATA "Invalid marshaling metadata."
+ IDS_EE_BADMARSHAL_CUSTOMMARSHALER "Custom marshalers are only allowed on classes, strings, arrays, and boxed value types."
+ IDS_EE_BADMARSHAL_BADSAFEARRAYSUBTYPE "Invalid SafeArraySubType/managed element type combination."
+ IDS_EE_BADMARSHAL_GENERICS_RESTRICTION "Generic types cannot be marshaled."
+
+ IDS_EE_BADMARSHALPARAM_STRINGBUILDER "Invalid managed/unmanaged type combination (StringBuilders must be paired with LPStr, LPWStr, or LPTStr)."
+ IDS_EE_BADMARSHALPARAM_NO_LPTSTR "Invalid managed/unmanaged type combination (Strings cannot be paired with LPTStr for parameters and return types of methods in interfaces exposed to COM)."
+
+ IDS_EE_BADMARSHALFIELD_NOCUSTOMMARSH "Custom marshalers cannot be used on fields of structures."
+ IDS_EE_BADMARSHALFIELD_FIXEDARRAY_NOSIZE "Fixed sized array fields inside structures must have the MarshalAs SizeConst field set to the size of the array."
+ IDS_EE_BADMARSHALFIELD_FIXEDARRAY_ZEROSIZE "Fixed sized array fields cannot have a SizeConst of zero."
+ IDS_EE_BADMARSHALFIELD_LAYOUTCLASS "Invalid managed/unmanaged type combination (Classes with layout fields must be paired with Struct or Interface)."
+ IDS_EE_BADMARSHALFIELD_NOSTRINGBUILDER "Struct or class fields cannot be of type StringBuilder. The same effect can usually be achieved by using a String field and preinitializing it to a string with length matching the length of the appropriate buffer."
+ IDS_EE_BADMARSHALFIELD_ZEROLENGTHFIXEDSTRING "The length for ByValTStr strings cannot be zero."
+
+#ifdef FEATURE_COMINTEROP
+ IDS_EE_BADMARSHALFIELD_NULL_HSTRING "Null strings may not be marshaled in Windows Runtime fields."
+ IDS_EE_BADMARSHALARRAY_NULL_HSTRING "Null strings may not be marshaled in Windows Runtime arrays. Null string was encountered at index %1."
+ IDS_EE_BADMARSHAL_NULLABLE_RESTRICTION "Given Windows.Foundation.IReference can not be converted to System.Nullable type. Type arguments can't be empty, string or non-value types. "
+#endif // FEATURE_COMINTEROP
+
+// For ManagedToNativeComInteropStubAttribute
+#ifdef FEATURE_COMINTEROP
+ IDS_EE_INTEROP_STUB_CA_MUST_BE_WITHIN_SAME_ASSEMBLY "The stub class '%1' specified in ManagedToNativeComInteropStubAttribute and interface '%2' must be from the same assembly."
+ IDS_EE_INTEROP_STUB_CA_STUB_CLASS_MUST_NOT_BE_GENERIC "The type '%1' specified in ManagedToNativeComInteropStubAttribute cannot be a generic type."
+ IDS_EE_INTEROP_STUB_CA_STUB_CLASS_MUST_NOT_BE_INTERFACE "The type '%1' specified in ManagedToNativeComInteropStubAttribute cannot be an interface."
+ IDS_EE_INTEROP_STUB_CA_STUB_METHOD_MISSING "Cannot find stub method '%1' in '%2' as specified in ManagedToNativeComInteropStubAttribute. Please make sure the stub method is static, non-generic, and has the expected name and signature."
+ IDS_EE_INTEROP_STUB_CA_NO_ACCESS_TO_STUB_METHOD "The interop method '%1' cannot access the stub method '%2' specified in ManagedToNativeComInteropStubAttribute. Please make sure they have compatible access modifiers and security accessibility."
+#endif // FEATURE_COMINTEROP
+
+#ifdef FEATURE_WINDOWSPHONE
+ IDS_EE_INTEROP_DLL_IMPORT_ON_USER_METHOD "DllImport cannot be used by application code. Use the Windows Runtime to call native code."
+#endif
+
+#ifdef FEATURE_COMINTEROP
+ IDS_EE_STRUCTLAYOUT_WINRT "Windows Runtime value types must have sequential layout."
+ IDS_EE_PRESERVESIG_WINRT "The PreserveSigAttribute may not be used on Windows Runtime methods."
+ IDS_EE_DELEGATEPINVOKE_WINRT "Windows Runtime delegates may not be used for PInvoke interop."
+ IDS_EE_WINRT_IENUMERABLE_BAD_CALL "There is not enough information to call IEnumerable.GetEnumerator on a Windows Runtime object, please cast the object to IEnumerable<T> first."
+ IDS_EE_WINRT_IENUMERABLE_BAD_CAST "There is not enough information to cast a Windows Runtime object to IEnumerable, please cast the object to IEnumerable<T> first."
+ IDS_EE_WINRT_INTERFACE_WITHOUT_GUID "Windows Runtime interface '%1' in assembly '%2' must have a valid GUID."
+ IDS_EE_WINRT_IID_ILLEGALTYPE "Unable to compute GUID for type '%1' because the instantiation contains types that are not supported by Windows Runtime."
+ IDS_EE_WINRT_IID_NODEFAULTINTERFACE "Unable to compute GUID because type '%1' does not have a default Windows Runtime interface."
+ IDS_EE_WINRT_ATTRIBUTES_NOT_INVOKABLE "Cannot construct type '%1'. Windows Runtime attribute types are not constructable."
+ IDS_EE_WINRT_TYPE_IN_ORDINARY_ASSEMBLY "Windows Runtime types can only be declared in Windows Runtime assemblies."
+ IDS_EE_WINRT_TYPE_NOT_REGISTERED "Requested Windows Runtime type '%1' is not registered."
+ IDS_EE_WINRT_NOT_FACTORY_FOR_TYPE "Windows Runtime factory '%1' is not a factory for Windows Runtime type '%2'."
+ IDS_EE_WINRT_INVALID_FACTORY_FOR_TYPE "Windows Runtime type '%1' has a invalid Windows Runtime factory"
+ IDS_EE_CANNOTCAST_NOMARSHAL "The Windows Runtime Object can only be used in the threading context where it was created, because it implements INoMarshal or has MarshalingBehaviorAttribute(MarshalingType.None) set."
+ IDS_EE_WINRT_WEAKREF_BAD_TYPE "The object resolved by a native IWeakReference has an incompatible type for its managed WeakReference instance.\r\nExpected WeakReference target type: '%1'\r\nNative IWeakReference returned type: '%2'"
+#endif // FEATURE_COMINTEROP
+
+ IDS_EE_INTEROP_CODE_SIZE_COMMENT "Code size"
+
+ IDS_EE_ADUNLOAD_IN_FINALIZER "AppDomain cannot be unloaded during object finalization."
+ IDS_EE_ADUNLOAD_DEFAULT "The default domain cannot be unloaded."
+ IDS_EE_ADUNLOAD_CANT_UNWIND_THREAD "AppDomain cannot be unloaded because the thread '%1' cannot be unwound out of it."
+ IDS_EE_ADUNLOAD_NOT_LOCAL "AppDomain cannot be unloaded because it is not local to the current process."
+
+ IDS_CLASSLOAD_TYPEWRONGNUMGENERICARGS "The generic type '%1' was used with the wrong number of generic arguments in assembly '%2'."
+ IDS_CLASSLOAD_METHODWRONGNUMGENERICARGS "A method in the type '%1' from assembly '%2' was used with the wrong number of generic arguments."
+ IDS_CLASSLOAD_INVALIDINSTANTIATION "The generic type '%1' was used with an invalid instantiation in assembly '%2'."
+ IDS_CLASSLOAD_VARIANCE_IN_METHOD_ARG "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in the signature for an argument in method '%3'."
+ IDS_CLASSLOAD_VARIANCE_IN_METHOD_RESULT "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in the signature for the result type in method '%3'."
+ IDS_CLASSLOAD_VARIANCE_IN_INTERFACE "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in an inherited interface."
+ IDS_CLASSLOAD_VARIANCE_IN_CONSTRAINT "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in a type parameter constraint in method '%3'."
+ IDS_CLASSLOAD_VARIANCE_CLASS "Could not load type '%1' from assembly '%2' because it declares a covariant or contravariant type parameter and is not an interface or delegate."
+ IDS_CLASSLOAD_BADVARIANCE "Could not load type '%1' from assembly '%2' because it uses an illegal variance annotation on a type parameter."
+ IDS_CLASSLOAD_GENERIC_CONTEXT_BOUND_OBJECT "Generic context-bound objects are not supported."
+ IDS_CLASSLOAD_COLLECTIBLE_CONTEXT_BOUND_OBJECT "Collectible context-bound objects are not supported."
+ IDS_CLASSLOAD_CONTEXT_BOUND_GENERIC_METHOD "Context-bound objects with generic methods are not supported."
+ IDS_CLASSLOAD_ENUM_EXTRA_GENERIC_TYPE_PARAM "Enumerated types cannot have any generic type parameters, beyond any inherited from their enclosing type (for nested enums)."
+ IDS_CLASSLOAD_GENERICTYPE_RECURSIVE "Could not load type '%1' from assembly '%2' because it has recursive generic definition."
+ IDS_CLASSLOAD_TOOMANYGENERICARGS "Could not load type '%1' from assembly '%2'. Internal limitation: Too many generic arguments."
+
+ IDS_CLASSLOAD_GENERAL "Could not load type '%1' from assembly '%2'."
+ IDS_CLASSLOAD_TYPESPEC "Could not load TypeSpec from assembly '%2'."
+ IDS_CLASSLOAD_MODULELOAD "Could not load type '%1' because the module containing it from assembly '%2' failed to load."
+ IDS_CLASSLOAD_ASSEMBLYLOAD "Could not load type '%1' because the assembly containing it failed to load."
+ IDS_CLASSLOAD_SEALEDPARENT "Could not load type '%1' from assembly '%2' because the parent type is sealed."
+ IDS_CLASSLOAD_BADFORMAT "Could not load type '%1' from assembly '%2' because the format is invalid."
+ IDS_CLASSLOAD_CANTCREATEARRAYCLASS "Could not create array type '%1' from assembly '%2'."
+ IDS_CLASSLOAD_NOCLSIDREG "No server registered or could not load class for CLSID %1."
+ IDS_CLASSLOAD_MISSINGMETHOD "Could not load type '%1' from assembly '%2' because the method '%3' could not be loaded."
+ IDS_CLASSLOAD_FIELDTOOLARGE "Size of field of type '%1' from assembly '%2' is too large."
+ IDS_CLASSLOAD_CANTEXTEND "Type '%1' from assembly '%2' cannot extend from any other type."
+ IDS_CLASSLOAD_STATICVIRTUAL "Method '%3' in type '%1' from assembly '%2' cannot be a static and a virtual."
+ IDS_CLASSLOAD_REDUCEACCESS "Derived method '%3' in type '%1' from assembly '%2' cannot reduce access."
+ IDS_CLASSLOAD_BADPINVOKE "Could not get PINVOKE information for method '%3' in type '%1' from assembly '%2'."
+ IDS_CLASSLOAD_COLLECTIBLEPINVOKE "PInvoke method not permitted on type '%1' from collectible assembly '%2'."
+ IDS_CLASSLOAD_COLLECTIBLESPECIALSTATICS "Collectible type '%1' may not have Thread or Context static members."
+ IDS_CLASSLOAD_VALUECLASSTOOLARGE "Array of type '%1' from assembly '%2' cannot be created because base value type is too large."
+ IDS_CLASSLOAD_NOTIMPLEMENTED "Method '%3' in type '%1' from assembly '%2' does not have an implementation."
+
+ IDS_CLASSLOAD_PARENTNULL "Could not load type '%1' from assembly '%2' because the parent does not exist."
+ IDS_CLASSLOAD_PARENTINTERFACE "Could not load type '%1' from assembly '%2' because the parent type is an interface."
+ IDS_CLASSLOAD_ENCLOSING "Could not load type '%1' from assembly '%2' because its enclosing type is not specified with a type definition."
+ IDS_CLASSLOAD_INTERFACEOBJECT "Could not load interface '%1' from assembly '%2' because it must extend from Object."
+ IDS_CLASSLOAD_INTERFACENULL "Could not load type '%1' from assembly '%2' because the interface does not exist."
+ IDS_CLASSLOAD_INTERFACE_NO_ACCESS "Type '%1' from assembly '%2' is attempting to implement an inaccessible interface."
+ IDS_CLASSLOAD_NOTINTERFACE "Could not load type '%1' from assembly '%2' because it attempts to implement a class as an interface."
+ IDS_CLASSLOAD_VALUEINSTANCEFIELD "Could not load the value type '%1' from assembly '%2' because it has an instance field of itself."
+
+ IDS_CLASSLOAD_BAD_NAME "Type name '%1' from assembly '%2' is invalid."
+ IDS_CLASSLOAD_RANK_TOOLARGE "'%1' from assembly '%2' has too many dimensions."
+ IDS_CLASSLOAD_BAD_MANAGED_RVA "Managed method '%3' on type '%1' from assembly '%2' is not supported."
+ IDS_CLASSLOAD_BAD_UNMANAGED_RVA "Native method '%3' on type '%1' from assembly '%2' is not supported."
+ IDS_CLASSLOAD_INHERITANCECHECK "Type '%1' from assembly '%2' does not have sufficient permission to override super type methods."
+ IDS_CLASSLOAD_NOMETHOD_NAME "Type '%1' from assembly '%2' has a method with no name."
+
+ IDS_CLASSLOAD_ZEROSIZE "Type '%1' from assembly '%2' has zero size."
+ IDS_CLASSLOAD_EXPLICIT_LAYOUT "Could not load type '%1' from assembly '%2' because it contains an object field at offset %3 that is incorrectly aligned or overlapped by a non-object field."
+ IDS_CLASSLOAD_UNVERIFIABLE_FIELD_LAYOUT "Could not load type '%1' from assembly '%2' because objects overlapped at offset %3 and the assembly must be verifiable."
+ IDS_CLASSLOAD_PRIVATEVIRTUAL "Private method '%3' on type '%1' from assembly '%2' cannot be virtual."
+ IDS_CLASSLOAD_BADSPECIALMETHOD "Constructor '%3' on type '%1' from assembly '%2' does not have the correct name or signature."
+ IDS_CLASSLOAD_MI_DECLARATIONNOTFOUND "Method override '%3' on type '%1' from assembly '%2' cannot find a method to replace."
+ IDS_CLASSLOAD_MI_MULTIPLEOVERRIDES "Method '%3' on type '%1' from assembly '%2' is overriding a method that has been overridden."
+ IDS_CLASSLOAD_MI_OVERRIDEIMPL "Method '%3' on type '%1' from assembly '%2' is overriding a method impl."
+ IDS_CLASSLOAD_MI_ACCESS_FAILURE "Method '%3' on type '%1' from assembly '%2' is overriding a method that is not visible from that assembly."
+ IDS_CLASSLOAD_MI_BADSIGNATURE "Method '%3' on type '%1' from assembly '%2' tried to override a method with a different signature."
+ IDS_CLASSLOAD_MI_NOTIMPLEMENTED "Type '%1' from assembly '%2' tried to override method '%3' but does not implement or inherit that method."
+ IDS_CLASSLOAD_MI_VIRTUALMISMATCH "Method '%3' on type '%1' from assembly '%2' tried to implement a method declaration with a different virtual state."
+ IDS_CLASSLOAD_MI_MUSTBEVIRTUAL "Method '%3' on type '%1' from assembly '%2' must be virtual to implement a method on an interface or super type."
+ IDS_CLASSLOAD_MI_BAD_SIG "Type '%1' from assembly '%2' contains an invalid method implementation signature."
+
+ IDS_CLASSLOAD_MISSINGMETHODRVA "Could not load type '%1' from assembly '%2' because the method '%3' has no implementation (no RVA)."
+ SECURITY_E_INCOMPATIBLE_EVIDENCE "Assembly '%1' already loaded without additional security evidence."
+ SECURITY_E_INCOMPATIBLE_SHARE "Assembly '%1' security permission grant set is incompatible between appdomains."
+ SECURITY_E_UNVERIFIABLE "Unverifiable assembly '%1' failed policy check."
+ IDS_CLASSLOAD_BAD_FIELD "Type '%1' from assembly '%2' has a field of an illegal type."
+ IDS_CLASSLOAD_MI_ILLEGAL_BODY "Body referenced in a method implementation must be defined in the same type. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_ILLEGAL_STATIC "Body referenced in a method implementation cannot be static. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_BODY "Body token used in a method implementation is out of range. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_DECL "Declaration token used in a method implementation is out of range. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_SEALED_DECL "Declaration referenced in a method implementation cannot be on a sealed type. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_FINAL_DECL "Declaration referenced in a method implementation cannot be a final method. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_PRIVATE_DECL "The declaration referenced in a method implementation is inaccessible. Type: '%1' Assembly: '%2'"
+ IDS_CLASSLOAD_MI_NONVIRTUAL_DECL "Declaration referenced in a method implementation must be a virtual method. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_BODY_DECL_MISMATCH "Signature of the body and declaration in a method implementation do not match. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_MISSING_SIG_BODY "Signature for the body in a method implementation cannot be found. Type: '%1'. Assembly: '%2'."
+ IDS_CLASSLOAD_MI_MISSING_SIG_DECL "Signature for the declaration in a method implementation cannot be found. Type: '%1'. Assembly: '%2'."
+
+ IDS_CLASSLOAD_EQUIVALENTSTRUCTMETHODS "Could not load the structure '%1' from assembly '%2'. The structure is marked as eligible for type equivalence, but it has a method."
+ IDS_CLASSLOAD_EQUIVALENTSTRUCTFIELDS "Could not load the structure '%1' from assembly '%2'. The structure is marked as eligible for type equivalence, but it has a static or non-public field."
+ IDS_CLASSLOAD_EQUIVALENTBADTYPE "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but either it has generic parameters, or it is not a structure, COM imported interface, enumeration, or delegate."
+ IDS_CLASSLOAD_EQUIVALENTNOTTRUSTED "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but the containing assembly is not loaded as fully trusted."
+ IDS_CLASSLOAD_EQUIVALENTTRANSPARENCY "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but either it is not marked as safe-critical or transparent, or it has a field or method that is not marked as safe-critical or transparent."
+ IDS_CLASSLOAD_EQUIVALENTNOTPUBLIC "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but it is not marked as public."
+ IDS_EE_CODEEXECUTION_CONTAINSGENERICVAR "Could not execute the method because either the method itself or the containing type is not fully instantiated."
+ IDS_CLASSLOAD_WRONGCPU "Could not load file or assembly '%1'. This assembly was compiled for a different processor."
+
+
+ IDS_SECURITY_DEMAND_DENIED "Request for permission of type '%1' failed."
+
+ IDS_CANNOT_MARSHAL "Type '%1' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed."
+ IDS_PINVOKE_STRINGBUILDEROVERFLOW "Warning: A StringBuilder buffer has been overflowed by unmanaged code. The process may become unstable. Insufficient capacity allocated to the StringBuilder before marshaling it."
+
+ IDS_INVALID_REDIM "Illegal attempt to replace or redimension a fixed or locked SafeArray."
+
+ IDS_INVALID_PINVOKE_CALLCONV "Invalid unmanaged calling convention: must be one of stdcall, cdecl, or thiscall."
+ IDS_NOLAYOUT_IN_EMBEDDED_VALUECLASS "Type could not be marshaled because an embedded valuetype has no layout information."
+ IDS_CLASSLOAD_NSTRUCT_EXPLICIT_OFFSET "Could not load type '%1' from assembly '%2' because field '%3' was not given an explicit offset."
+ IDS_UNI2ANSI_FAILURE_IN_NSTRUCT "Type could not be marshaled because an embedded string could not be converted from Unicode to ANSI."
+ IDS_WRONGSIZEARRAY_IN_NSTRUCT "Type could not be marshaled because the length of an embedded array instance does not match the declared length in the layout."
+ IDS_UNI2ANSI_FAILURE "Failure converting Unicode string to ANSI."
+ IDS_ANSI2UNI_FAILURE "Failure converting ANSI string to Unicode."
+
+ IDS_EE_INVALIDLCIDPARAM "The value of the LCID conversion attribute must not exceed the number of parameters."
+
+ IDS_ENCODEDPERMSET_DECODEFAILURE "Failure decoding embedded permission set object."
+ IDS_ENCODEDPERMSETCOLLECTION_DECODEFAILURE "Failure decoding embedded permission set collection object."
+ IDS_BAD_MSCORLIB "Mscorlib.dll is missing types required by security."
+ IDS_EE_INVALIDCOMSOURCEITF "The list of COM source interfaces for type '%1' contains non interface or generic type '%2'."
+ IDS_EE_CANNOT_COERCE_BYREF_VARIANT "Object cannot be coerced to the original type of the ByRef VARIANT it was obtained from."
+ IDS_EE_WRAPPER_MUST_HAVE_DEF_CONS "The new wrapper type must have an empty constructor."
+ IDS_EE_INVALID_STD_DISPID_NAME "Standard DISPID member name is formed incorrectly. The name must be in the following format: [DISPID=XXX]."
+ IDS_EE_NO_IDISPATCH_ON_TARGET "COM target does not implement IDispatch."
+ IDS_EE_NON_STD_NAME_WITH_STD_DISPID "All named parameters must be specified as [DISPID=XXX] when invoking on a standard members specified as [DISPID=XXX}."
+ IDS_EE_INVOKE_NEW_ENUM_INVALID_RETURN "Variant returned from an Invoke call with a DISPID of -4 does not contain a valid IUnknown pointer."
+ IDS_EE_COM_OBJECT_RELEASE_RACE "COM object that has been separated from its underlying RCW cannot be used. The COM object was released while it was still in use on another thread."
+ IDS_EE_COM_OBJECT_NO_LONGER_HAS_WRAPPER "COM object that has been separated from its underlying RCW cannot be used."
+ IDS_EE_CALLBACK_NOT_CALLED_FROM_CCTOR "Function can only be called from inside the class constructor of a class derived from a COM imported class."
+ IDS_EE_CALLBACK_ALREADY_REGISTERED "Base type has already registered a type creation callback."
+ IDS_EE_CANNOTCAST "Unable to cast object of type '%1' to type '%2'."
+ IDS_EE_CANNOTCASTPROXY "Unable to cast transparent proxy to type '%1'."
+
+ IDS_EE_CANNOTCASTSAME "[A]%1 cannot be cast to [B]%2. %3. %4."
+ IDS_EE_CANNOTCAST_HELPER_PATH "Type %s originates from '%s' in the context '%s' at location '%s'"
+ IDS_EE_CANNOTCAST_HELPER_BYTE "Type %s originates from '%s' in the context '%s' in a byte array"
+ IDS_EE_NOTISOMORPHIC "Object contains non-primitive or non-blittable data."
+ IDS_EE_INVALID_VT_FOR_CUSTOM_MARHALER "Type of the VARIANT specified for a parameter with a custom marshaler is not supported by the custom marshaler."
+ IDS_EE_BAD_COMEXTENDS_CLASS "Types extending from COM objects should override all methods of an interface implemented by the base COM class."
+ IDS_EE_INTERFACE_NOT_DISPATCH_BASED "The interface does not support late bound calls since it does not derive from IDispatch."
+ IDS_EE_MARSHAL_UNMAPPABLE_CHAR "Cannot marshal: Encountered unmappable character."
+ IDS_EE_VTRECORD_SECURITY "Structures defined in untrusted code cannot be marshaled to and from native code as either parameters or return values."
+
+ // Errors associated with parsing security custom attributes at compile time.
+ CORSECATTR_E_BAD_ATTRIBUTE "Invalid custom attribute."
+ CORSECATTR_E_MISSING_CONSTRUCTOR "The permission associated with this attribute is missing a required constructor."
+ CORSECATTR_E_FAILED_TO_CREATE_PERM "Unable to create an instance of the permission for this attribute."
+ CORSECATTR_E_BAD_ACTION_ASM "SecurityAction type invalid on assembly."
+ CORSECATTR_E_BAD_ACTION_OTHER "SecurityAction type invalid on types and methods."
+ CORSECATTR_E_BAD_PARENT "Security custom attribute attached to invalid parent."
+ CORSECATTR_E_TRUNCATED "Serialized security custom attribute is truncated or incorrectly formed."
+ CORSECATTR_E_BAD_VERSION "Serialized security custom attribute has unrecognized version."
+ CORSECATTR_E_BAD_ACTION "Security custom attribute has invalid SecurityAction."
+ CORSECATTR_E_NO_SELF_REF "Security custom attributes cannot be referenced from defining assembly."
+ CORSECATTR_E_BAD_NONCAS "Invalid SecurityAction for non-Code Access Security permission."
+ CORSECATTR_E_ASSEMBLY_LOAD_FAILED "Failed to load assembly '%s'."
+ CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX "Failed to load assembly '%s' - %s."
+ CORSECATTR_E_TYPE_LOAD_FAILED "Failed to load type '%s'."
+ CORSECATTR_E_TYPE_LOAD_FAILED_EX "Failed to load type '%s' - %s."
+ CORSECATTR_E_ABSTRACT "Security custom attribute cannot be abstract."
+ CORSECATTR_E_UNSUPPORTED_TYPE "Security custom attributes do not support array or Type fields and properties."
+ CORSECATTR_E_UNSUPPORTED_ENUM_TYPE "Unsupported enumeration base type."
+ CORSECATTR_E_NO_FIELD "Failed to locate field '%s'."
+ CORSECATTR_E_NO_PROPERTY "Failed to locate property '%s'."
+ CORSECATTR_E_EXCEPTION "Unexpected exception processing attribute - '%s'."
+ CORSECATTR_E_EXCEPTION_HR "Unexpected exception processing attribute - HRESULT 0x%08X."
+
+ IDS_EE_OFFSETOF_NOFIELDFOUND "Field passed in is not a marshaled member of the type '%1'."
+ IDS_EE_COPY_OUTOFRANGE "Requested range extends past the end of the array."
+ IDS_EE_CANNOTPIN "Object type cannot be pinned."
+ IDS_EE_ARRAYWITHOFFSETOVERFLOW "ArrayWithOffset: offset exceeds array size."
+ IDS_EE_OUTOFLOCALS "Ran out of internal resource while executing marshaling operation. Possible cause: overly complex method signature."
+ IDS_EE_NOCUSTOMMARSHALER "A call to GetInstance() for custom marshaler '%1' returned null, which is not allowed."
+ IDS_EE_SIZECONTROLOUTOFRANGE "Array size control parameter index is out of range."
+ IDS_EE_SIZECONTROLBADTYPE "Array size control parameter type not supported."
+ IDS_EE_DUPLICATE_DECLSEC "Multiple permission sets specified with the same SecurityAction."
+ IDS_EE_SAFEARRAYSZARRAYMISMATCH "SafeArray cannot be marshaled to this array type because it has either nonzero lower bounds or more than one dimension."
+
+ IDS_EE_REFLECTIONONLYGETTYPE_NOASSEMBLY "Explicit assembly name must be specified when loading a type as ReflectionOnly"
+ IDS_EE_REFLECTIONONLY_LOADFROM "API restriction: The assembly '%1' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain."
+ IDS_EE_REFLECTIONONLY_LOADFAILURE "Cannot resolve dependency to assembly '%1' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event."
+ IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE "Cannot resolve dependency to Windows Runtime type '%1'. When using the ReflectionOnly APIs, dependent Windows Runtime assemblies must be resolved on demand through the ReflectionOnlyNamespaceResolve event."
+ IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE_THIRDPARTY "To resolve a namespace from a custom Windows Runtime component, you must supply the packageGraphFilePaths argument to ResolveNamespace."
+ IDS_EE_REFLECTIONONLY_WINRT_INVALIDASSEMBLY "Returning a .NET Framework assembly to resolve a Windows Runtime reference is not supported."
+ IDS_EE_WINRT_LOADFAILURE "Could not find Windows Runtime type '%1'."
+ IDS_EE_WINRT_THIRDPARTY_NOTSUPPORTED "Types from custom Windows Runtime components are not supported in desktop applications."
+
+ IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC "Type names passed to Assembly.GetType() must not specify an assembly."
+ IDS_EE_IJWLOAD_CROSSVERSION_DISALLOWED "Mixed mode assembly is built against version '%1' of the runtime and cannot be loaded in the %2 runtime without additional configuration information."
+ IDS_EE_IJWLOAD_MULTIRUNTIME_DISALLOWED "Mixed mode assembly cannot be loaded into version '%1' of the runtime because it is already loaded into version '%2'."
+ IDS_EE_CANNOT_HAVE_ASSEMBLY_SPEC "Unexpected assembly-qualifier in a typename."
+ IDS_EE_NEEDS_ASSEMBLY_SPEC "Typename needs an assembly qualifier."
+
+#ifdef FEATURE_CORECLR
+ IDS_EE_FILELOAD_ERROR_GENERIC "Could not load file or assembly '%1'. %2"
+#else
+ IDS_EE_FILELOAD_ERROR_GENERIC "Could not load file or assembly '%1' or one of its dependencies. %2"
+#endif
+
+ IDS_EE_CRYPTO_UNKNOWN_OPERATION "Unknown import key operation specified."
+
+ IDS_EE_LOCAL_COGETCLASSOBJECT_FAILED "Retrieving the COM class factory for component with CLSID %2 failed due to the following error: %1 %3."
+ IDS_EE_REMOTE_COGETCLASSOBJECT_FAILED "Retrieving the COM class factory for remote component with CLSID %2 from machine %3 failed due to the following error: %1 %3."
+
+ IDS_EE_CREATEINSTANCE_FAILED "Creating an instance of the COM component with CLSID %2 from the IClassFactory failed due to the following error: %1 %3."
+ IDS_EE_CREATEINSTANCE_LIC_FAILED "Creating an instance of the licensed COM component with CLSID %2 from the IClassFactory failed due to the following error: %1 %3."
+ IDS_EE_CREATEINSTANCEFROMAPP_FAILED "Creating an instance of the COM component with CLSID %2 using CoCreateInstanceFromApp failed due to the following error: %1 %3. Please make sure your COM object is in the allowed list of CoCreateInstanceFromApp."
+
+ IDS_EE_RCW_INVALIDCAST_ITF "Unable to cast COM object of type '%2' to interface type '%3'. This operation failed because the QueryInterface call on the COM component for the interface with IID '%4' failed due to the following error: %1."
+ IDS_EE_RCW_INVALIDCAST_EVENTITF "Unable to cast COM object of type '%2' to event interface type '%3'. This operation failed because the QueryInterface call on the COM component for the interface with IID '%4' failed due to the following error: '%1' and the COM component does not support the source interface with IID '%5'."
+ IDS_EE_RCW_INVALIDCAST_IENUMERABLE "Unable to cast COM object of type '%2' to interface type '%3'. This operation failed because the QueryInterface call on the COM component for the interface with IID '%4' failed due to the following error: '%1' and the COM component does not support IDispatch::Invoke calls for DISPID_NEWENUM."
+ IDS_EE_RCW_INVALIDCAST_MNGSTDITF "Unable to cast COM object of type '%2' to standard managed interface type '%3'. This operation failed because the QueryInterface call on the COM component for the managed interface with IID '%4' failed due to the following error: '%1' and the QueryInterface call for the native interface with IID '%5' that corresponds to this managed interface failed due to the following error: %6."
+ IDS_EE_RCW_INVALIDCAST_COMOBJ_TO_MD "Unable to cast COM object of type '%1' to class type '%2'. COM components that enter the CLR and do not support IProvideClassInfo or that do not have any interop assembly registered will be wrapped in the __ComObject type. Instances of this type cannot be cast to any other class; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
+ IDS_EE_RCW_INVALIDCAST_TO_NON_COMOBJTYPE "Unable to cast COM object of type '%1' to class type '%2'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
+ IDS_EE_RCW_INVALIDCAST_MD_TO_MD "Unable to cast COM object of type '%1' to class type '%2'. Instances of types that represent COM components cannot be cast to different types that represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
+
+ IDS_EE_GENERIC "%1"
+
+ IDS_EE_MISSING_FIELD "Field not found: '%1'."
+ IDS_EE_MISSING_METHOD "Method not found: '%1'."
+ IDS_EE_MSCOREE_MISSING "MSCOREE is not loaded."
+ IDS_EE_MSCOREE_MISSING_ENTRYPOINT "Missing entrypoint in MSCOREE: '%1'."
+
+ IDS_EE_PINVOKE_NOREFFORSIZEIS "Cannot use SizeParamIndex for ByRef array parameters."
+ IDS_EE_NO_IDISPATCH "This object cannot be marshaled as an IDispatch."
+ IDS_EE_NO_BACKING_CLASS_FACTORY "An instance of the __ComObject type cannot be created unless the type has been obtained using GetTypeFromProgID or GetTypeFromCLSID."
+
+ IDS_EE_SIGTOOCOMPLEX "Internal limitation: method signature is too complex or too large."
+ IDS_EE_STRUCTTOOCOMPLEX "Internal limitation: structure is too complex or too large."
+ IDS_EE_STRUCTARRAYTOOLARGE "Array size exceeds addressing limitations."
+ IDS_EE_TOOMANYASSOCIATES "Internal limitation: too many property methods associated with this method."
+ IDS_EE_TOOMANYFIELDS "Internal limitation: too many fields."
+
+ IDS_EE_UNHANDLED_EXCEPTION "Unhandled Exception:"
+ IDS_EE_EXCEPTION_TOSTRING_FAILED "Cannot print exception string because Exception.ToString() failed."
+
+ IDS_EE_THREAD_ABORT "Thread was being aborted."
+ IDS_EE_THREAD_INTERRUPTED "Thread was interrupted from a waiting state."
+ IDS_EE_OUT_OF_MEMORY "Insufficient memory to continue the execution of the program."
+
+ IDS_EE_OUT_OF_MEMORY_WITHIN_RANGE "Insufficient memory within specified address space range to continue the execution of the program."
+
+ IDS_EE_ARRAY_DIMENSIONS_EXCEEDED "Array dimensions exceeded supported range."
+
+ IDS_EE_CANNOT_LOAD_JIT "Unable to load Jit Compiler: (%s): file may be missing or corrupt. Please check or rerun setup."
+ IDS_EE_PROFILING_FAILURE "Profiling failure"
+
+
+ IDS_EE_THREAD_NOTSTARTED "Thread has not been started."
+ IDS_EE_STRING_TOOLONG "Marshaler restriction: Excessively long string."
+
+ IDS_EE_VARARG_NOT_SUPPORTED "Vararg calling convention not supported."
+
+ IDS_EE_INVALID_CA "Invalid custom attribute provided."
+ IDS_EE_INVALID_CA_EX "Invalid custom attribute provided: '%1'"
+
+ IDS_EE_THREADSTART_STATE "Thread is running or terminated; it cannot restart."
+ IDS_EE_THREAD_CANNOT_GET "Unable to retrieve thread information."
+ IDS_EE_THREAD_SUSPEND_NON_RUNNING "Thread is not running; it cannot be suspended."
+ IDS_EE_THREAD_RESUME_NON_RUNNING "Thread is not running; it cannot be resumed."
+ IDS_EE_THREAD_RESUME_NON_USER_SUSPEND "Thread is not user-suspended; it cannot be resumed."
+ IDS_EE_THREAD_DEAD_PRIORITY "Thread is dead; priority cannot be accessed."
+ IDS_EE_THREAD_PRIORITY_FAIL "Unable to set thread priority."
+ IDS_EE_THREAD_DEAD_STATE "Thread is dead; state cannot be accessed."
+ IDS_EE_THREAD_BAD_STATE "Thread in invalid state."
+ IDS_EE_THREAD_ABORT_WHILE_SUSPEND "Thread is suspended; attempting to abort."
+ IDS_EE_NOVARIANTRETURN "PInvoke restriction: cannot return variants."
+ IDS_EE_THREAD_DEADLOCK_VICTIM "The current thread has been chosen as a deadlock victim."
+
+ IDS_EE_PATH_TOO_LONG "The path is too long after being fully qualified. Make sure the full path is less than 260 characters and the directory name is less than 248 characters."
+ IDS_EE_PATH_HAS_IMPROPER_CHAR "The path contains illegal characters."
+ IDS_EE_PATH_ILLEGAL "The path is not of a legal form."
+ IDS_EE_PATH_INVALID_UNCPATH "The UNC path should be of the form \\\\server\\share."
+ IDS_EE_PATH_GLOBALROOT "Paths starting with \\\\?\\GlobalRoot are internal to the kernel and should not be opened by managed applications."
+
+ IDS_CLASSLOAD_BADOVERLAP "Illegal layout for type '%1' from assembly '%2': valuetypes with non-public fields may not overlap with other fields."
+
+ IDS_EE_SID_TIMEOUT "Lookup of token information timed out."
+
+ IDS_EE_INVALID_SAFEARRAY "Specified SAFEARRAY is invalid."
+
+ IDS_EE_METHOD_NOT_FOUND_ON_EV_PROV "Method '%1' of COM event interface '%2' is not present on event provider '%3'."
+ IDS_EE_BAD_COMEVENTITF_CLASS "Methods on COM event interfaces must take a single delegate derived class as a parameter and have a void return type."
+
+ IDS_EE_COREXEMAIN_FAILED_TEXT "Could not run the given program. _CorExeMain failed."
+ IDS_EE_COREXEMAIN_FAILED_TITLE "The Common Language Runtime could not run the given program."
+
+ IDS_EE_ICUSTOMMARSHALERNOTIMPL "Custom marshaler '%1' does not implement the ICustomMarshaler interface."
+ IDS_EE_GETINSTANCENOTIMPL "Custom marshaler '%1' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler."
+
+ IDS_CLASSLOAD_COMIMPCANNOTHAVELAYOUT "COM import type '%1' from assembly '%2' cannot have layout information."
+ IDS_EE_INVALIDCOMDEFITF "Type '%1' has an invalid default COM interface: '%2'."
+ IDS_EE_COMDEFITFNOTSUPPORTED "Type '%1' does not support the specified default COM interface: '%2'"
+
+ IDS_EE_GUID_REPRESENTS_NON_VC "Type '%1' that has the requested GUID is not a value class."
+ IDS_EE_CANNOT_MAP_TO_MANAGED_VC "The specified record cannot be mapped to a managed value class."
+
+ IDS_EE_SAFEHANDLECLOSED "Safe handle has been closed"
+ IDS_EE_SAFEHANDLECANNOTSETHANDLE "Safe handle's handle field can only be set if the safe handle is not closed and has a ref count of 1."
+
+ IDS_EE_SH_FIELD_INVALID_OPERATION "Structures containing SafeHandle fields are not allowed in this operation."
+ IDS_EE_CANNOT_CREATE_SAFEHANDLE_FIELD "SafeHandle fields cannot be created from an unmanaged handle."
+ IDS_EE_SH_IN_VARIANT_NOT_SUPPORTED "SafeHandle derived types cannot be stored in Variants."
+ IDS_CLASSLOAD_SH_SUBCLASS_FINALIZER "SafeHandle subclasses may not override the finalizer. Put logic in ReleaseHandle instead."
+
+ IDS_EE_CRITICALHANDLECLOSED "Critical handle has been closed"
+
+ IDS_EE_CH_FIELD_INVALID_OPERATION "Structures containing CriticalHandle fields are not allowed in this operation."
+ IDS_EE_CANNOT_CREATE_CRITICALHANDLE_FIELD "CriticalHandle fields cannot be created from an unmanaged handle."
+ IDS_EE_CH_IN_VARIANT_NOT_SUPPORTED "CriticalHandle derived types cannot be stored in Variants."
+ IDS_CLASSLOAD_CH_SUBCLASS_FINALIZER "CriticalHandle subclasses may not override the finalizer. Put logic in ReleaseHandle instead."
+
+ IDS_EE_VAR_WRAP_IN_VAR_NOT_SUPPORTED "VariantWrappers cannot be stored in Variants."
+ IDS_EE_RECORD_NON_SUPPORTED_FIELDS "The structure contains fields that are not supported in unmanaged records."
+
+ IDS_CLASSLOAD_NSTRUCT_NEGATIVE_OFFSET "Could not load type '%1' from assembly '%2' because field '%3' was given a negative offset."
+
+ IDS_EE_CODEEXECUTION_IN_INTROSPECTIVE_ASSEMBLY "Code execution is prohibited in an assembly loaded as ReflectionOnly."
+
+ IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_INTROSPECTION "AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only."
+ IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_EXECUTION "ReflectionOnlyAssemblyResolve handlers must return Assemblies loaded for reflection only."
+
+ IDS_CLASSLOAD_MODULE_RESOLVE_INTROSPECTION_MISMATCH "ModuleResolveEvent returned an incompatible Module. ReflectionOnly assemblies cannot bind to normal Modules, nor vice-versa."
+
+ IDS_CLASSLOAD_OVERLAPPING_INTERFACES "The type '%1' in assembly '%2' has a contracting interface set for some instantiations"
+
+#ifdef FEATURE_CORECLR
+ IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY "Attempted to load a 64-bit assembly on a 32-bit platform."
+#else // !FEATURE_CORECLR
+ IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY "Attempted to load a 64-bit assembly on a 32-bit platform. Use ReflectionOnlyLoad() instead if trying to load for reflection purposes."
+#endif // FEATURE_CORECLR
+
+ IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_IMPLICIT_OVERRIDE "Method '%3' on type '%1' from assembly '%2' tried to implicitly override a method with weaker type parameter constraints."
+ IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_IMPLICIT_IMPLEMENTATION "Method '%3' on type '%1' from assembly '%2' tried to implicitly implement an interface method with weaker type parameter constraints."
+ IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_LOCAL_METHOD_IMPL "Method '%3' on type '%1' from assembly '%2' tried to explicitly implement a local method with weaker type parameter constraints."
+ IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_PARENT_METHOD_IMPL "Method '%3' on type '%1' from assembly '%2' tried to explicitly implement a parent method with weaker type parameter constraints."
+ IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_INTERFACE_METHOD_IMPL "Method '%3' on type '%1' from assembly '%2' tried to explicitly implement an interface method with weaker type parameter constraints."
+ IDS_CLASSLOAD_EXPLICIT_GENERIC "Could not load type '%1' from assembly '%2' because generic types cannot have explicit layout."
+ IDS_EE_CONFIGPARSER_ERROR_CAPTION "Configuration parser error"
+ IDS_EE_CONFIGPARSER_ERROR "Error parsing %s\nParser returned error 0x%08X."
+
+ IDS_EE_COM_INVISIBLE_PARENT "This type has a ComVisible(false) parent in its hierarchy, therefore QueryInterface calls for IDispatch or class interfaces are disallowed."
+
+ IDS_EE_COMIMPORT_METHOD_NO_INTERFACE "Method '%1' in ComImport class '%2' must implement an interface method."
+ IDS_EE_ATTEMPT_TO_CREATE_GENERIC_CCW "Generic types cannot be marshaled to COM interface pointers."
+
+ IDS_CLASSLOAD_BAD_METHOD_COUNT "Metadata method count does not match method enumeration length for type '%1' from assembly '%2'."
+ IDS_CLASSLOAD_BAD_FIELD_COUNT "Metadata field count does not match field enumeration length for type '%1' from assembly '%2'."
+ IDS_CLASSLOAD_MUST_BE_BYVAL "Type '%1' from assembly '%2' must be declared as a value type to be used as a value type."
+ IDS_CLASSLOAD_BAD_VARIANCE_SIG "Type contains improperly formed type variance signature."
+ IDS_CLASSLOAD_VARIANCE_IN_DELEGATE "Could not load type '%1' from assembly '%2' because it declares a field in a covariant type."
+ IDS_CLASSLOAD_TOO_MANY_METHODS "Type '%1' from assembly '%2' contains more methods than the current implementation allows."
+ IDS_LOADINTROSPECTION_DISALLOWED "Illegal to load assemblies for ReflectionOnly in a verification domain."
+ IDS_EE_CODEEXECUTION_ASSEMBLY_FOR_PASSIVE_DOMAIN_ONLY "File '%1' was loaded in a passive domain in a manner that makes it unable to run."
+ IDS_CLASSLOAD_MI_CANNOT_OVERRIDE "Cannot override runtime implemented method '%3' on type '%1' from assembly '%2'."
+
+ IDS_EE_WRONG_METADATA_VERSION "'%1' has an incompatible metadata format. The assembly must be compiled using metadata format '%2'."
+ IDS_CLASSLOAD_COLLECTIBLEFIXEDVTATTR "Collectible type '%1' has unsupported FixedAddressValueTypeAttribute applied to a field."
+ IDS_EE_JIT_COMPILER_ERROR "JIT Compiler encountered an internal limitation."
+ IDS_UNMARSHALABLE_DEMAND_OBJECT "The security object (Permission or PermissionSet) used for performing a Demand caused an error relating to serialization/deserialization."
+ IDS_EE_OBJECT_TO_VARIANT_NOT_SUPPORTED "Invalid managed/unmanaged type combination (Marshaling to and from COM VARIANTs isn't supported)."
+ IDS_EE_OBJECT_TO_ITF_NOT_SUPPORTED "Invalid managed/unmanaged type combination (Marshaling to and from COM interface pointers isn't supported)."
+#ifdef FEATURE_CORECLR
+ IDS_TYPE_INHERITANCE_RULES_VIOLATED "Inheritance security rules violated by type: '%1'. Derived types must either match the security accessibility of the base type or be less accessible. If the base class has a non-transparent default constructor, the derived class must also have a default constructor, and the method inheritance rules apply across those two methods."
+#else // !FEATURE_CORECLR
+ IDS_TYPE_INHERITANCE_RULES_VIOLATED "Inheritance security rules violated by type: '%1'. Derived types must either match the security accessibility of the base type or be less accessible."
+#endif // FEATURE_CORECLR
+ IDS_METHOD_INHERITANCE_RULES_VIOLATED "Inheritance security rules violated while overriding member: '%1'. Security accessibility of the overriding method must match the security accessibility of the method being overriden."
+ IDS_CRITICAL_METHOD_ACCESS_DENIED "Attempt to access method %1 in violation of security transparency rules failed."
+#ifdef FEATURE_CAS_POLICY
+ IDS_E_LOADFROM_REMOTE_SOURCE "An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information."
+ IDS_E_LOADFROM_REMOTE_SOURCE_MOTW "An attempt was made to load an assembly that was downloaded from a network location, which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this assembly is trusted, either remove the Zone marker from it or enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information."
+#endif // FEATURE_CAS_POLICY
+ IDS_CRITICAL_TYPE_ACCESS_DENIED "Attempt to access type %1 in violation of security transparency rules failed."
+ IDS_APPLICATION_ASSEMBLY_EXEC_DENIED "Application assemblies cannot be directly executed: %1"
+ IDS_REFLECTION_METHOD_ACCESS_DENIED "Application code cannot access %1 using Reflection."
+
+ IDS_E_LOAD_CRITICAL_IN_PARTIAL_TRUST "Assembly '%1' is partially trusted, however it is not entirely security transparent. If this assembly is meant to be used in partial trust, you will need to apply the SecurityTransparentAttribute to it."
+ IDS_E_TRANSPARENT_CALL_LINKDEMAND "Attempt by security transparent method '%1' to access LinkDemand protected method '%2' failed. Methods must be security critical or security safe-critical to satisfy a LinkDemand."
+ IDS_E_TRANSPARENT_CALL_NATIVE "Attempt by security transparent method '%1' to call native code through method '%2' failed. Methods must be security critical or security safe-critical to call native code."
+ IDS_E_TRANSPARENT_REFLECTION "Security transparent method %1 cannot access %2 using reflection."
+ IDS_E_TRANSPARENT_METHOD_CRITICAL_TYPE "Method '%1' is security transparent, but is a member of a security critical type."
+ IDS_E_UNKNOWN_SECURITY_RULESET "Assembly '%1' specified an unknown security rule set."
+ IDS_E_UNTRUSTED_APPDOMAIN_MANAGER "Partial trust applications may not specify an AppDomainManager for the default domain."
+
+ IDS_E_FIELDACCESS "Attempt by method '%1' to access field '%2' failed.%3"
+ IDS_E_METHODACCESS "Attempt by method '%1' to access method '%2' failed.%3"
+ IDS_E_TYPEACCESS "Attempt by method '%1' to access type '%2' failed.%3"
+ IDS_E_CRITICAL_FIELD_ACCESS_DENIED "Attempt by security transparent method '%1' to access security critical field '%2' failed.%3"
+ IDS_E_CRITICAL_METHOD_ACCESS_DENIED "Attempt by security transparent method '%1' to access security critical method '%2' failed.%3"
+ IDS_E_CRITICAL_TYPE_ACCESS_DENIED "Attempt by security transparent method '%1' to access security critical type '%2' failed.%3"
+#ifdef FEATURE_CORECLR
+ IDS_E_DELEGATE_BINDING_TRANSPARENCY "A delegate of type '%1' cannot be bound to the method '%2' due to security transparency rules. Ensure the delegate type and the method being bound have compatible security transparency."
+ IDS_E_DELEGATE_FULLTRUST_ARPIC_1 "Delegate '%1' must be bound to a method in a fully-trusted assembly and the method must have the AllowReversePinvokeCallsAttribute."
+ IDS_E_DELEGATE_FULLTRUST_ARPIC_2 "Cannot create a Delegate for marshalling out unless it is bound to a method in a fully-trusted assembly and the method has the AllowReversePinvokeCallsAttribute."
+#endif
+ IDS_E_ACCESSING_PRIVATE_FRAMEWORK_CODE "Reflection invocation to internal or private types or members in the framework is not allowed."
+
+ IDS_EE_TORNSTATE "Unexpected change made to file '%1'."
+
+END
+
+// These strings are attached to various access exceptions to provide additional context as to what may have
+// caused them, and how they might be fixed.
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_ACCESS_EXCEPTION_CONTEXT_LEVEL2_APTCA "Assembly '%1' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception."
+ IDS_ACCESS_EXCEPTION_CONTEXT_PT_TRANSPARENT "Assembly '%1' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself. In order to access security critical code, this assembly must be fully trusted."
+#ifdef FEATURE_APTCA
+ IDS_ACCESS_EXCEPTION_CONTEXT_APTCA_KILLBIT "Assembly '%1' has had an APTCA killbit set for it, which prevents it from being used by partial trust or security transparent code."
+ IDS_ACCESS_EXCEPTION_CONTEXT_CONDITIONAL_APTCA "Assembly '%1' is a conditionally APTCA assembly which is not enabled in the current AppDomain. To enable this assembly to be used by partial trust or security transparent code, please add assembly name '%2' to the the PartialTrustVisibleAssemblies list when creating the AppDomain."
+#endif // FEATURE_APTCA
+END
+
+// These strings are generated from within the EE for streams
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_STREAMS_FILE_EOF "Reached the end of the file."
+ IDS_STREAMS_FILE_OPEN "File has not been opened."
+ IDS_STREAMS_FILE_BUFFER "Buffer is shorter than requested bytes."
+ IDS_STREAMS_FILE_NAME "File name was not supplied."
+ IDS_STREAMS_SEEK_MODIFIER "Undefined seek modifier."
+END
+
+// These strings are used for Event Log Entry
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_ER_APPLICATION "Application: "
+ IDS_ER_UNKNOWN "unknown"
+#ifndef FEATURE_CORECLR
+ IDS_ER_FRAMEWORK_VERSION "Framework Version: "
+#else // FEATURE_CORECLR
+ IDS_ER_FRAMEWORK_VERSION "CoreCLR Version: "
+#endif // !FEATURE_CORECLR
+ IDS_ER_UNHANDLEDEXCEPTION "Description: The process was terminated due to an unhandled exception."
+ IDS_ER_UNHANDLEDEXCEPTIONMSG "Exception Info: "
+ IDS_ER_MANAGEDFAILFAST "Description: The application requested process termination through System.Environment.FailFast(string message)."
+ IDS_ER_MANAGEDFAILFASTMSG "Message: "
+ IDS_ER_UNMANAGEDFAILFAST "Description: The process was terminated due to an internal error in the .NET Runtime "
+ IDS_ER_STACK_OVERFLOW "Description: The process was terminated due to stack overflow."
+ IDS_ER_STACK "Stack:"
+ IDS_ER_WORDAT "at"
+ IDS_ER_UNMANAGEDFAILFASTMSG "at IP %1 (%2) with exit code %3."
+ IDS_ER_UNHANDLEDEXCEPTIONINFO "exception code %1, exception address %2"
+ IDS_ER_MESSAGE_TRUNCATE "The remainder of the message was truncated."
+ IDS_ER_CODECONTRACT_FAILED "Description: The application encountered a bug. A managed code contract (precondition, postcondition, object invariant, or assert) failed."
+ IDS_ER_CODECONTRACT_DETAILMSG "Contract details: "
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_FAIL_CAPTION "Configuration error."
+ IDS_COMPLUS_ERROR "CLR error: %lx.\n The program will now terminate."
+ IDS_FATAL_ERROR "Fatal error"
+ IDS_ERROR "Error"
+ IDS_INVALID_VARIANT_MSG "An invalid VARIANT has been passed as argument %i of method '%s' of type '%s'. If this argument is meant to be an interface pointer, add [MarshalAs(UnmanagedType.Interface)] to the managed definition of the argument.\n\nClick CANCEL to break into the debugger and OK to continue."
+ IDS_INVALID_VARIANT_CAPTION "Invalid VARIANT."
+
+ IDS_DEBUG_DIFF_BUILDS_ERR "Warning: Components of the Common Language Runtime debugging services are from different builds.\nContinuing to run will cause unpredictable results.\n\nIn-process component (mscoree.dll) is version %d.%d (%s)\nOut-of-process component (mscordbi.dll) is version %d.%d (%s).\n."
+ IDS_DEBUG_NO_DEBUGGER_FOUND "No debugger found."
+ IDS_DEBUG_UNHANDLEDEXCEPTION_IPC "INTERNAL ERROR:\n\nUnhandled exception in Debugger::HandleIPCEvent.\n\nEvent ID=0x%x.\n\nException code=0x%08x, Eip=0x%08x.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\n"
+ IDS_DEBUG_UNHANDLED_EXCEPTION_MSG "Application has generated an exception that could not be handled.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick OK to terminate the application.\nClick CANCEL to debug the application."
+ IDS_DEBUG_USER_BREAKPOINT_MSG "Application has encountered a user-defined breakpoint.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick ABORT to terminate the application.\nClick RETRY to debug the application.\nClick IGNORE to ignore the breakpoint."
+
+ IDS_DBI_ERRLOG_CATAGORY "DebuggerError"
+ IDS_DBI_EXCEPTION_ON_UNKNOWN_THREAD_MSG "Ignoring managed exception from unknown thread."
+
+ IDS_EE_NOTSUPPORTED_CATCHBEFORETRY "Catch handler cannot precede try block."
+
+ IDS_PERFORMANCEMON_WINNT_ERR "Performance Monitor Extension DLL for CLR. This can only be used on Windows NT."
+ IDS_PERFORMANCEMON_WINNT_TITLE "Could not load on non-Windows NT system."
+
+ IDS_WATSON_DEBUG_BREAK_INTRO_BOLD "%General_AppName% has encountered a user-defined breakpoint."
+ IDS_WATSON_DEBUG_BREAK_INTRO_REG "A breakpoint in an application indicates a program error. After this dialog is dismissed, the application will continue running, but it may be in an unstable state."
+END
+
+
+// IsolatedStore error messages
+STRINGTABLE DISCARDABLE
+BEGIN
+ ISS_E_ISOSTORE "IsolatedStorage operation failed."
+
+ ISS_E_OPEN_STORE_FILE "Unable to open the store."
+ ISS_E_OPEN_FILE_MAPPING "Unable to create store file mapping."
+ ISS_E_MAP_VIEW_OF_FILE "Unable to map the store file."
+ ISS_E_GET_FILE_SIZE "Unable to determine store file size."
+ ISS_E_CREATE_MUTEX "Unable to create mutex."
+ ISS_E_LOCK_FAILED "Unable to lock the store."
+ ISS_E_FILE_WRITE "File Write failed."
+ ISS_E_SET_FILE_POINTER "Cannot set file pointer."
+ ISS_E_CREATE_DIR "Unable to create the store directory."
+ ISS_E_STORE_NOT_OPEN "Store must be open for this operation."
+
+ ISS_E_CORRUPTED_STORE_FILE "Store file is corrupt."
+ ISS_E_STORE_VERSION "Store version is not supported."
+ ISS_E_FILE_NOT_MAPPED "Store file is not mapped."
+ ISS_E_BLOCK_SIZE_TOO_SMALL "Block size is too small."
+ ISS_E_ALLOC_TOO_LARGE "Allocation size is too large."
+ ISS_E_USAGE_WILL_EXCEED_QUOTA "Allowed quota is fully used."
+ ISS_E_TABLE_ROW_NOT_FOUND "Row not found."
+
+ ISS_E_DEPRECATE "Unable to deprecate old store."
+ ISS_E_CALLER "Unable to determine the caller."
+ ISS_E_PATH_LENGTH "Path length is too long."
+ ISS_E_MACHINE "Machine Store is not supported."
+ ISS_E_MACHINE_DACL "The DACL for the machine store is incorrect or could not be created."
+END
+
+// Verifier error messages
+STRINGTABLE DISCARDABLE
+BEGIN
+ VER_E_HRESULT "[HRESULT 0x%08X]"
+ VER_E_OFFSET "[offset 0x%08X]"
+ VER_E_OPCODE "[opcode %s]"
+ VER_E_OPERAND "[operand 0x%08X]"
+ VER_E_TOKEN "[token 0x%08X]"
+ VER_E_EXCEPT "[exception #0x%08X]"
+ VER_E_STACK_SLOT "[stack slot 0x%08X]"
+ VER_E_LOC "[local variable #0x%08X]"
+ VER_E_LOC_BYNAME "[local variable '%s']"
+ VER_E_ARG "[argument #0x%08x]"
+ VER_E_FOUND "[found %s]"
+ VER_E_EXPECTED "[expected %s]"
+
+ VER_E_UNKNOWN_OPCODE "Unknown opcode [0x%08X]."
+ VER_E_SIG_CALLCONV "Unknown calling convention [0x%08X]."
+ VER_E_SIG_ELEMTYPE "Unknown ELEMENT_TYPE [0x%08x]."
+
+ VER_E_RET_SIG "[return sig]"
+ VER_E_FIELD_SIG "[field sig]"
+
+ VER_E_INTERNAL "Internal error."
+ VER_E_STACK_TOO_LARGE "Stack is too large."
+ VER_E_ARRAY_NAME_LONG "Array name is too long."
+
+ VER_E_FALLTHRU "fall through end of the method without returning."
+ VER_E_TRY_GTEQ_END "try start >= try end."
+ VER_E_TRYEND_GT_CS "try end > code size."
+ VER_E_HND_GTEQ_END "handler start >= handler end."
+ VER_E_HNDEND_GT_CS "handler end > code size."
+ VER_E_TRY_START "Try starts in the middle of an instruction."
+ VER_E_HND_START "Handler starts in the middle of an instruction."
+ VER_E_TRY_OVERLAP "Try block overlap with another block."
+ VER_E_TRY_EQ_HND_FIL "Try and filter/handler blocks are equivalent."
+ VER_E_TRY_SHARE_FIN_FAL "Shared try has finally or fault handler."
+ VER_E_HND_OVERLAP "Handler block overlaps with another block."
+ VER_E_HND_EQ "Handler block is the same as another block."
+ VER_E_FIL_OVERLAP "Filter block overlaps with another block."
+ VER_E_FIL_EQ "Filter block is the same as another block."
+ VER_E_FIL_CONT_TRY "Filter contains try."
+ VER_E_FIL_CONT_HND "Filter contains handler."
+ VER_E_FIL_CONT_FIL "Nested filters."
+ VER_E_FIL_GTEQ_CS "filter >= code size."
+ VER_E_FIL_START "Filter starts in the middle of an instruction."
+ VER_E_FALLTHRU_EXCEP "fallthru the end of an exception block."
+ VER_E_FALLTHRU_INTO_HND "fallthru into an exception handler."
+ VER_E_FALLTHRU_INTO_FIL "fallthru into an exception filter."
+ VER_E_LEAVE "Leave from outside a try or catch block."
+ VER_E_RETHROW "Rethrow from outside a catch handler."
+ VER_E_ENDFINALLY "Endfinally from outside a finally handler."
+ VER_E_ENDFILTER "Endfilter from outside an exception filter block."
+ VER_E_ENDFILTER_MISSING "Missing Endfilter."
+ VER_E_BR_INTO_TRY "Branch into try block."
+ VER_E_BR_INTO_HND "Branch into exception handler block."
+ VER_E_BR_INTO_FIL "Branch into exception filter block."
+ VER_E_BR_OUTOF_TRY "Branch out of try block."
+ VER_E_BR_OUTOF_HND "Branch out of exception handler block."
+ VER_E_BR_OUTOF_FIL "Branch out of exception filter block."
+ VER_E_BR_OUTOF_FIN "Branch out of finally block."
+ VER_E_RET_FROM_TRY "Return out of try block."
+ VER_E_RET_FROM_HND "Return out of exception handler block."
+ VER_E_RET_FROM_FIL "Return out of exception filter block."
+ VER_E_BAD_JMP_TARGET "jmp / exception into the middle of an instruction."
+ VER_E_PATH_LOC "Non-compatible types depending on path."
+ VER_E_PATH_THIS "Init state for this differs depending on path."
+ VER_E_PATH_STACK "Non-compatible types on stack depending on path."
+ VER_E_PATH_STACK_DEPTH "Stack depth differs depending on path."
+ VER_E_THIS "Instance variable (this) missing."
+ VER_E_THIS_UNINIT_EXCEP "Uninitialized this on entering a try block."
+ VER_E_THIS_UNINIT_STORE "Store into this when it is uninitialized."
+ VER_E_THIS_UNINIT_RET "Return from .ctor when this is uninitialized."
+ VER_E_THIS_UNINIT_V_RET "Return from .ctor before all fields are initialized."
+ VER_E_THIS_UNINIT_BR "Branch back when this is uninitialized."
+ VER_E_LDFTN_CTOR "ldftn/ldvirtftn not allowed on .ctor."
+ VER_E_STACK_NOT_EQ "Non-compatible types on the stack."
+ VER_E_STACK_UNEXPECTED "Unexpected type on the stack."
+ VER_E_STACK_EXCEPTION "Missing stack slot for exception."
+ VER_E_STACK_OVERFLOW "Stack overflow."
+ VER_E_STACK_UNDERFLOW "Stack underflow."
+ VER_E_STACK_EMPTY "Stack empty."
+ VER_E_STACK_UNINIT "Uninitialized item on stack."
+ VER_E_STACK_I_I4_I8 "Expected I, I4, or I8 on the stack."
+ VER_E_STACK_R_R4_R8 "Expected R, R4, or R8 on the stack."
+ VER_E_STACK_NO_R_I8 "unexpected R, R4, R8, or I8 on the stack."
+ VER_E_STACK_NUMERIC "Expected numeric type on the stack."
+ VER_E_STACK_OBJREF "Expected an ObjRef on the stack."
+ VER_E_STACK_P_OBJREF "Expected address of an ObjRef on the stack."
+ VER_E_STACK_BYREF "Expected ByRef on the stack."
+ VER_E_STACK_METHOD "Expected pointer to function on the stack."
+ VER_E_STACK_ARRAY_SD "Expected single dimension array on the stack."
+ VER_E_STACK_VALCLASS "Expected value type instance on the stack."
+ VER_E_STACK_P_VALCLASS "Expected address of value type on the stack."
+ VER_E_STACK_NO_VALCLASS "Unexpected value type instance on the stack."
+ VER_E_LOC_DEAD "Local variable is unusable at this point."
+ VER_E_LOC_NUM "Unrecognized local variable number."
+ VER_E_ARG_NUM "Unrecognized argument number."
+ VER_E_TOKEN_RESOLVE "Unable to resolve token."
+ VER_E_TOKEN_TYPE "Unable to resolve type of the token."
+ VER_E_TOKEN_TYPE_MEMBER "Expected memberRef, memberDef or methodSpec token."
+ VER_E_TOKEN_TYPE_FIELD "Expected memberRef or fieldDef token."
+ VER_E_TOKEN_TYPE_SIG "Expected signature token."
+ VER_E_UNVERIFIABLE "Instruction cannot be verified."
+ VER_E_LDSTR_OPERAND "Operand does not point to a valid string ref."
+ VER_E_RET_PTR_TO_STACK "Return type is ByRef, TypedReference, ArgHandle, or ArgIterator."
+ VER_E_RET_VOID "Stack must be empty on return from a void function."
+ VER_E_RET_MISSING "Return value missing on the stack."
+ VER_E_RET_EMPTY "Stack must contain only the return value."
+ VER_E_RET_UNINIT "Return uninitialized data."
+ VER_E_ARRAY_ACCESS "Illegal array access."
+ VER_E_ARRAY_V_STORE "Store non Object type into Object array."
+ VER_E_ARRAY_SD "Expected single-dimension zero-based array."
+ VER_E_ARRAY_SD_PTR "Expected single dimension array of pointer types."
+ VER_E_ARRAY_FIELD "Array field access is denied."
+ VER_E_ARGLIST "Allowed only in vararg methods."
+ VER_E_VALCLASS "Value type expected."
+ VER_E_OPEN_DLGT_PROT_ACC "Protected method access through an open instance delegate is not verifiable."
+ VER_E_METHOD_ACCESS "Method is not visible."
+ VER_E_FIELD_ACCESS "Field is not visible."
+ VER_E_DEAD "Item is unusable at this point."
+ VER_E_FIELD_STATIC "Expected static field."
+ VER_E_FIELD_NO_STATIC "Expected non-static field."
+ VER_E_ADDR "Address of not allowed for this item."
+ VER_E_ADDR_BYREF "Address of not allowed for ByRef."
+ VER_E_ADDR_LITERAL "Address of not allowed for literal field."
+ VER_E_INITONLY "Cannot change initonly field outside its .ctor."
+ VER_E_WRITE_RVA_STATIC "Cannot modify an imaged based (RVA) static"
+ VER_E_THROW "Cannot throw this object."
+ VER_E_CALLVIRT_VALCLASS "Callvirt on a value type method."
+ VER_E_CALL_SIG "Call signature mismatch."
+ VER_E_CALL_STATIC "Static function expected."
+ VER_E_CTOR ".ctor expected."
+ VER_E_CTOR_VIRT "Cannot use callvirt on .ctor."
+ VER_E_CTOR_OR_SUPER "Only super::ctor or typeof(this)::ctor allowed here."
+ VER_E_CTOR_MUL_INIT "Possible call to .ctor more than once."
+ VER_E_SIG "Unrecognized signature."
+ VER_E_SIG_ARRAY "Cannot resolve Array type."
+ VER_E_SIG_ARRAY_PTR "Array of ELEMENT_TYPE_PTR."
+ VER_E_SIG_ARRAY_BYREF "Array of ELEMENT_TYPE_BYREF or ELEMENT_TYPE_TYPEDBYREF."
+ VER_E_SIG_ELEM_PTR "ELEMENT_TYPE_PTR cannot be verified."
+ VER_E_SIG_VARARG "Unexpected vararg."
+ VER_E_SIG_VOID "Unexpected Void."
+ VER_E_SIG_BYREF_BYREF "ByRef of ByRef"
+ VER_E_CODE_SIZE_ZERO "Code size is zero."
+ VER_E_BAD_VARARG "Unrecognized use of vararg."
+ VER_E_TAIL_CALL "Missing call/callvirt/calli."
+ VER_E_TAIL_BYREF "Cannot pass ByRef to a tail call."
+ VER_E_TAIL_RET "Missing ret."
+ VER_E_TAIL_RET_VOID "Void ret type expected for tail call."
+ VER_E_TAIL_RET_TYPE "Tail call return type not compatible."
+ VER_E_TAIL_STACK_EMPTY "Stack not empty after tail call."
+ VER_E_METHOD_END "Method ends in the middle of an instruction."
+ VER_E_BAD_BRANCH "Branch out of the method."
+ VER_E_FIN_OVERLAP "Finally handler blocks overlap."
+ VER_E_LEXICAL_NESTING "Lexical nesting."
+ VER_E_VOLATILE "Missing ldsfld, stsfld, ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk."
+ VER_E_UNALIGNED "Missing ldind, stind, ldfld, stfld, ldobj, stobj, initblk, cpblk."
+ VER_E_INNERMOST_FIRST "Innermost exception blocks should be declared first."
+ VER_E_CALLI_VIRTUAL "Calli not allowed on virtual methods."
+ VER_E_CALL_ABSTRACT "Call not allowed on abstract methods."
+ VER_E_STACK_UNEXP_ARRAY "Unexpected array type on the stack."
+ VER_E_NOT_IN_GC_HEAP "Value type with NotInGCHeap attribute being created on the GC heap."
+ VER_E_TRY_N_EMPTY_STACK "Attempt to enter a try block with nonempty stack."
+ VER_E_DLGT_CTOR "Unrecognized arguments for delegate .ctor."
+ VER_E_DLGT_BB "Delegate .ctor not allowed at the start of a basic block when the function pointer argument is a virtual method."
+ VER_E_DLGT_PATTERN "Dup, ldvirtftn, newobj delegate::.ctor() pattern expected (in the same basic block)."
+ VER_E_DLGT_LDFTN "Ldftn or ldvirtftn instruction required before call to a delegate .ctor."
+ VER_E_FTN_ABSTRACT "Attempt to load address of an abstract method."
+ VER_E_SIG_C_VC "ELEMENT_TYPE_CLASS ValueClass in signature."
+ VER_E_SIG_VC_C "ELEMENT_TYPE_VALUETYPE non-ValueClass in signature."
+ VER_E_BOX_PTR_TO_STACK "Box operation on TypedReference, ArgHandle, or ArgIterator."
+ VER_E_SIG_BYREF_TB_AH "ByRef of TypedReference, ArgHandle, or ArgIterator."
+ VER_E_SIG_ARRAY_TB_AH "Array of TypedReference, ArgHandle, or ArgIterator."
+ VER_E_ENDFILTER_STACK "Stack not empty when leaving an exception filter."
+ VER_E_DLGT_SIG_I "Unrecognized delegate .ctor signature; expected I."
+ VER_E_DLGT_SIG_O "Unrecognized delegate .ctor signature; expected Object."
+ VER_E_RA_PTR_TO_STACK "Mkrefany on TypedReference, ArgHandle, or ArgIterator."
+ VER_E_CATCH_VALUE_TYPE "Value type not allowed as catch type."
+ VER_E_CATCH_BYREF "ByRef not allowed as catch type."
+ VER_E_FIL_PRECEED_HND "filter block should immediately precede handler block"
+ VER_E_LDVIRTFTN_STATIC "ldvirtftn on static"
+ VER_E_CALLVIRT_STATIC "callvirt on static"
+ VER_E_INITLOCALS "initlocals must be set for verifiable methods with one or more local variables."
+ VER_E_BR_TO_EXCEPTION "branch/leave to the beginning of a catch/filter handler"
+ VER_E_CALL_CTOR "call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj."
+
+ //@GENERICSVER: new generics related error messages
+ VER_E_VALCLASS_OBJREF_VAR "Value type, ObjRef type or variable type expected."
+ VER_E_STACK_P_VALCLASS_OBJREF_VAR "Expected address of value type, ObjRef type or variable type on the stack."
+ VER_E_SIG_VAR_PARAM "Unrecognized type parameter of enclosing class."
+ VER_E_SIG_MVAR_PARAM "Unrecognized type parameter of enclosing method."
+ VER_E_SIG_VAR_ARG "Unrecognized type argument of referenced class instantiation."
+ VER_E_SIG_MVAR_ARG "Unrecognized type argument of referenced method instantiation."
+ VER_E_SIG_GENERICINST "Cannot resolve generic type."
+ VER_E_SIG_METHOD_INST "Method instantiation contains non boxable type arguments."
+ VER_E_SIG_METHOD_PARENT_INST "Method parent instantiation contains non boxable type arguments."
+ VER_E_SIG_FIELD_PARENT_INST "Field parent instantiation contains non boxable type arguments."
+ VER_E_CALLCONV_NOT_GENERICINST "Unrecognized calling convention for an instantiated generic method."
+ VER_E_TOKEN_BAD_METHOD_SPEC "Unrecognized generic method in method instantiation."
+ VER_E_BAD_READONLY_PREFIX "Missing ldelema or call following readonly prefix."
+ VER_E_BAD_CONSTRAINED_PREFIX "Missing callvirt following constrained prefix."
+
+ VER_E_CIRCULAR_VAR_CONSTRAINTS "Method parent has circular class type parameter constraints."
+ VER_E_CIRCULAR_MVAR_CONSTRAINTS "Method has circular method type parameter constraints."
+
+ VER_E_UNSATISFIED_METHOD_INST "Method instantiation has unsatisfied method type parameter constraints."
+ VER_E_UNSATISFIED_METHOD_PARENT_INST "Method parent instantiation has unsatisfied class type parameter constraints."
+ VER_E_UNSATISFIED_FIELD_PARENT_INST "Field parent instantiation has unsatisfied class type parameter constraints."
+ VER_E_UNSATISFIED_BOX_OPERAND "Type operand of box instruction has unsatisfied class type parameter constraints."
+ VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS "The 'this' argument to a constrained call must have ByRef type."
+ VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE "The operand to a constrained prefix instruction must be a type parameter."
+ VER_E_READONLY_UNEXPECTED_CALLEE "The readonly prefix may only be applied to calls to array methods returning ByRefs."
+ VER_E_READONLY_ILLEGAL_WRITE "Illegal write to readonly ByRef."
+ VER_E_READONLY_IN_MKREFANY "A readonly ByRef cannot be used with mkrefany."
+ VER_E_UNALIGNED_ALIGNMENT "Alignment specified for 'unaligned' prefix must be 1, 2, or 4."
+ VER_E_TAILCALL_INSIDE_EH "The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block."
+ VER_E_BACKWARD_BRANCH "Stack height at all points must be determinable in a single forward scan of IL."
+ VER_E_CALL_TO_VTYPE_BASE "Call to base type of valuetype."
+ VER_E_NEWOBJ_OF_ABSTRACT_CLASS "Cannot construct an instance of abstract class."
+ VER_E_UNMANAGED_POINTER "Unmanaged pointers are not a verifiable type."
+ VER_E_LDFTN_NON_FINAL_VIRTUAL "Cannot LDFTN a non-final virtual method for delegate creation if target object is potentially not the same type as the method class."
+ VER_E_FIELD_OVERLAP "Accessing type with overlapping fields."
+ VER_E_THIS_MISMATCH "The 'this' parameter to the call must be the calling method's 'this' parameter."
+ VER_E_STACK_I_I4 "Expected I4 on the stack."
+
+ VER_E_BAD_PE "Unverifiable PE Header/native stub."
+ VER_E_BAD_MD "Unrecognized metadata, unable to verify IL."
+ VER_E_BAD_APPDOMAIN "Unrecognized appdomain pointer."
+
+ VER_E_TYPELOAD "Type load failed."
+ VER_E_PE_LOAD "Module load failed."
+
+ IDS_VER_E_FORMATTING "Error formatting message."
+ IDS_VER_E_ILERROR "[IL]: Error: "
+ IDS_VER_E_GLOBAL "<GlobalFunction>"
+ IDS_VER_E_MDTOKEN "[mdToken=0x%x]"
+END
+
+// Security error messages
+STRINGTABLE DISCARDABLE
+BEGIN
+ SN_CRYPTOAPI_CALL_FAILED "StrongName APIs not supported on system."
+ SN_NO_SUITABLE_CSP "StrongName APIs could not locate a matching CSP."
+ SN_NO_SUITABLE_CSP_NAME "StrongName APIs could not locate a matching CSP for assembly '%1'."
+ SN_E_PUBLICKEY_MISMATCH "Key pair does not match public key from assembly '%1'."
+END
+
+// Object clone error messages. Most of these have corresponding resources in mscorlib (see mscorlib.txt)
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_SERIALIZATION_NONSERTYPE "Type '%1' in assembly '%2' is not marked as serializable."
+ IDS_SERIALIZATION_CTOR_NOT_FOUND "The constructor to deserialize an object of type '%1' was not found."
+ IDS_SERIALIZATION_WRONGFIELDTYPE "Possible version mismatch. Field '%1' in class '%2' has mismatched types."
+ IDS_SERIALIZATION_UNRESOLVED_SPECIAL_OBJECT "Not all delayed fixup objects could be resolved. Such objects could be cyclic IObjectReferences, IObjectReferences that return other IObjectReferences too many times (i.e. objects with too long an IObjectReference chain) or nested valuetypes."
+ IDS_SERIALIZATION_UNRESOLVED_TYPE "Type is not resolved for member '%1,%2'."
+ IDS_SERIALIZATION_NONFREEZABLE_TYPE "Type '%1' in assembly '%2' cannot be persisted into the native image."
+ IDS_SERIALIZATION_BAD_ISER_TYPE "ISerializable type '%1' tried to deserialize itself as type '%2' which is an invalid type."
+ IDS_REMOTING_SERVER_DISCONNECTED "Object '%1' has been disconnected or does not exist at the server."
+ IDS_REMOTING_METHODMISSING "The method '%1' was not found on type '%2'."
+ IDS_CLASSLOAD_TOO_MANY_VTS_METHODS "Type '%1' in assembly '%2' has more than one method with the following custom attribute '%3'."
+ IDS_CLASSLOAD_INVALID_VTS_SIG "Type '%1' in assembly '%2' has method '%3' with an incorrect signature for the serialization attribute that it is decorated with."
+ IDS_CLASSLOAD_INVALID_VTS_METHOD "Type '%1' in assembly '%2' has method '%3' which is either static, virtual, abstract or generic, but is marked as being a serialization callback method."
+ IDS_SERIALIZATION_MISSING_FIELD "Member '%1' in class '%2' is not present in the serialized stream and is not marked with System.Runtime.Serialization.OptionalFieldAttribute."
+END
+
+// General prompt strings.
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_GENERAL_SVC_DESCRIPTION "Notifies a subscribing client when a specified process is initializing the CLR. If this service is stopped, the client will not receive such notification. If this service is disabled, any services that explicitly depend on it will fail to start."
+ IDS_RTL "RTL_False" // change this to RTL_True on Arabic/Hebrew system
+END
+
+// BAD_FORMAT_ASSERT error messages
+STRINGTABLE DISCARDABLE
+BEGIN
+ BFA_INVALID_FILE_TOKEN "Invalid file token."
+ BFA_INVALID_TOKEN_TYPE "Invalid token type."
+ BFA_INVALID_ENTRYPOINT_TOKEN "Invalid entry point token."
+ BFA_INVALID_TOKEN "Invalid token."
+ BFA_INVALID_TOKEN_VTABLE "Invalid token in v-table fix-up table; use ildasm to find code generation error."
+ BFA_UNABLE_TO_GET_NESTED_PROPS "Unable to get nested type properties."
+ BFA_METHOD_TOKEN_OUT_OF_RANGE "Method token out of range."
+ BFA_METHOD_NAME_TOO_LONG "Method name too long."
+ BFA_METHOD_NAME_NOT_TERMINATED "Method name is not null terminated."
+ BFA_METHOD_IN_A_ENUM "Method in an Enum."
+ BFA_METHOD_WITH_NONZERO_RVA "Method with non-zero RVA in an Import."
+ BFA_ABSTRACT_METHOD_WITH_RVA "Abstract method with non-zero RVA."
+ BFA_RUNTIME_METHOD_WITH_RVA "Runtime-implemented method with non-zero RVA."
+ BFA_INTERNAL_METHOD_WITH_RVA "Internal call method with non_NULL RVA."
+ BFA_AB_METHOD_IN_AB_CLASS "Abstract method in non-abstract class."
+ BFA_NONVIRT_AB_METHOD "Non-virtual abstract method."
+ BFA_NONAB_NONCCTOR_METHOD_ON_INT "Non-abstract, non-.cctor method in an interface."
+ BFA_VIRTUAL_PINVOKE_METHOD "Virtual PInvoke implemented method."
+ BFA_VIRTUAL_STATIC_METHOD "Virtual Static Method."
+ BFA_VIRTUAL_INSTANCE_CTOR "Virtual Instance Constructor."
+ BFA_VIRTUAL_NONAB_INT_METHOD "Virtual Non-Abstract Interface Method."
+ BFA_NONVIRT_INST_INT_METHOD "Nonvirtual Instance Interface Method."
+ BFA_SYNC_METHOD_IN_VT "Synchronized Method in Value Type."
+ BFA_NONSTATIC_GLOBAL_METHOD "Non-Static Global Method."
+ BFA_GLOBAL_INST_CTOR "Global Instance Constructor."
+ BFA_BAD_PLACE_FOR_GENERIC_METHOD "Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class."
+ BFA_GENERIC_METHOD_RUNTIME_IMPL "Generic method is marked runtime-implemented."
+ BFA_BAD_RUNTIME_IMPL "Bad use of Runtime Impl attribute."
+ BFA_BAD_FLAGS_ON_DELEGATE "Bad flags on delegate constructor."
+ BFA_UNKNOWN_DELEGATE_METHOD "Unknown runtime implemented delegate method."
+ BFA_GENERIC_METHODS_INST "Generic methods should always be mcInstantiated."
+ BFA_BAD_FIELD_TOKEN "Field token out of range."
+ BFA_INVALID_FIELD_ACC_FLAGS "Invalid Field Access Flags."
+ BFA_FIELD_LITERAL_AND_INIT "Field is Literal and InitOnly."
+ BFA_NONSTATIC_GLOBAL_FIELD "Non-Static Global Field."
+ BFA_INSTANCE_FIELD_IN_INT "Instance Field in an Interface."
+ BFA_INSTANCE_FIELD_IN_ENUM "No Instance Field in an Enum."
+ BFA_NONVIRT_NO_SEARCH "Non-virtual methods should not be searched."
+ BFA_CANT_BE_INIT_METHOD "This method cannot be an Init Method."
+ BFA_MANAGED_NATIVE_NYI "Managed native not presently supported."
+ BFA_BAD_IMPL_FLAGS "Bad implementation flags."
+ BFA_BAD_UNMANAGED_ENTRY_POINT "Bad unmanaged code entry point."
+ BFA_GENCODE_NOT_BE_VARARG "Generic code may not be varargs."
+ BFA_CANNOT_INHERIT_FROM_DELEGATE "Could not load type '%1' from assembly '%2' because it cannot inherit directly from the delegate class."
+ BFA_DELEGATE_CLASS_NOTSEALED "Could not load type '%1' from assembly '%2' because delegate classes must be sealed."
+ BFA_ENCLOSING_TYPE_NOT_FOUND "Enclosing type(s) not found for type '%1' in assembly '%2'."
+ BFA_ILLEGAL_DELEGATE_METHOD "Illegal definition for runtime implemented delegate method."
+ BFA_MISSING_DELEGATE_METHOD "Missing definition for required runtime implemented delegate method."
+ BFA_MULT_TYPE_SAME_NAME "Duplicate type with name '%1' in assembly '%2'."
+ BFA_INVALID_METHOD_TOKEN "Bad method token."
+ BFA_CANT_GET_LINKREF "Cannot get LinkRef."
+ BFA_ECALLS_MUST_BE_IN_SYS_MOD "ECall methods must be packaged into a system module."
+ BFA_CANT_GET_CLASSLAYOUT "Could not get classlayout."
+ BFA_CALLCONV_NOT_LOCAL_SIG "Signature is not IMAGE_CEE_CS_CALLCONV_LOCAL_SIG."
+ BFA_BAD_CLASS_TOKEN "Bad class token."
+ BFA_BAD_IL_RANGE "Bad IL range."
+ BFA_METHODDEF_WO_TYPEDEF_PARENT "MethodDef without TypeDef as Parent."
+ BFA_METHODDEF_PARENT_NO_MEMBERS "MethodSpec or MemberRef has parent with no members."
+ BFA_MUST_USE_MEMBERREF_W_FIELD_GEN "Fields inside generic classes must be referenced using MemberRefs, even in the same module as the class."
+ BFA_INVALID_TOKEN_IN_MANIFESTRES "Invalid token saved in ManifestResource."
+ BFA_EMPTY_ASSEMDEF_NAME "Empty assembly simple name."
+ BFA_BAD_IL "Bad IL format."
+ BFA_CLASSLOAD_VALUETYPEMISMATCH "Could not load type '%1' from assembly '%2' due to value type mismatch."
+ BFA_METHODDECL_NOT_A_METHODDEF "Method declaration is not a methoddef."
+ BFA_DUPLICATE_DELEGATE_METHOD "Duplicate definition for runtime implemented delegate method."
+ BFA_ECALLS_MUST_HAVE_ZERO_RVA "Ecalls must have a 0 RVA."
+ BFA_METADATA_CORRUPT "The metadata is corrupt."
+ BFA_BAD_SIGNATURE "The signature is incorrect."
+ BFA_TYPEREG_NAME_TOO_LONG "Full Name of Typeref is too long."
+ BFA_BAD_TYPEREF_TOKEN "Invalid Typeref token."
+ BFA_BAD_CLASS_INT_CA "The ClassInterface custom attribute is invalid."
+ BFA_BAD_CLASS_INT_CA_FORMAT "ClassInterface custom attribute does not have the right format."
+ BFA_BAD_COMPLUS_SIG "Illegal or unimplemented ELEM_TYPE in signature."
+ BFA_TYPE_FWD_CHAIN_TOO_LONG "Type forwarding chain is too long or is recursive."
+ BFA_BAD_ELEM_IN_SIZEOF "Bad element type in SizeOf."
+ BFA_BAD_CA_HEADER "Malformed custom attribute header."
+ BFA_BAD_CA_STRING "Malformed custom attribute string."
+ BFA_BAD_STRING_TOKEN "Bad string token."
+ BFA_BAD_STRING_TOKEN_RANGE "No string associated with token."
+ BFA_FIXUP_WRONG_PLATFORM "Image has a platform-specific fixup type that is not compatible with this platform."
+ BFA_UNEXPECTED_GENERIC_TOKENTYPE "Token specifying generic type must be either a typeref or typedef."
+ BFA_MDARRAY_BADRANK "Array rank may not be zero."
+ BFA_SDARRAY_BADRANK "Single-dimensional array rank must be one."
+ BFA_BAD_PACKING_SIZE "ClassLayout has invalid PackingSize; valid set of values is {1,2,4,...,128}."
+ BFA_UNEXPECTED_ARRAY_TYPE "Array type not expected here."
+ BFA_BAD_VISIBILITY "Bad type visibility flag value."
+ BFA_FAMILY_ON_GLOBAL "Family flag is not allowed on global functions."
+ BFA_NOFIND_EXPORTED_TYPE "Could not find exported type in metadata."
+ BFA_NOT_AN_ARRAY "Expected array type."
+ BFA_EXPECTED_METHODDEF_OR_MEMBERREF "Generic member ref must be of type MethodDef or MemberRef."
+ BFA_EXPECTED_INTERFACE "Expected interface."
+ BFA_INVALID_CA_TYPESPEC "Custom attributes that are TypeSpecs must be of type ELEMENT_TYPE_VALUETYPE or ELEMENT_TYPE_CLASS."
+ BFA_UNEXPECTED_FIELD_SIGNATURE "An unexpected field signature was found."
+ BFA_UNEXPECTED_TOKEN_AFTER_CLASSVALTYPE "A valid typedef or typeref token is expected to follow a ELEMENT_TYPE_CLASS or ELEMENT_TYPE_VALUETYPE."
+ BFA_FNPTR_CANNOT_BE_A_FIELD "A ELEMENT_TYPE_FNPTR cannot have a field signature."
+ BFA_FNPTR_CANNOT_BE_GENERIC "A ELEMENT_TYPE_FNPTR cannot be generic."
+ BFA_UNEXPECTED_TOKEN_AFTER_GENINST "A valid typedef or typeref token is expected to follow a ELEMENT_TYPE_GENERICINST."
+ BFA_ONLY_VOID_PTR_IN_ARGS "Only pointer to void allowed in function arguments."
+ BFA_TYPEDBYREFCANNOTHAVEBYREF "An ELEMENT_TYPE_TYPEDBYREF cannot have a ELEMENT_TYPE_BYREF modifier."
+ BFA_REFERENCE_ASSEMBLY "Cannot load a reference assembly for execution."
+
+#ifdef FEATURE_PREJIT
+ BFA_MISSING_IBC_EXTERNAL_TYPE "The type specified by the IBC data is no longer present in the assembly's metadata"
+ BFA_MISSING_IBC_EXTERNAL_METHOD "The method specified by the IBC data is no longer present in the assembly's metadata"
+#endif
+
+#ifdef FEATURE_COMINTEROP
+ BFA_WINRT_INVALID_NAMESPACE_FOR_TYPE "Windows Runtime type '%1' has invalid namespace that does not begin with the file name in assembly '%2'."
+#endif
+
+END
+
+
+// Profiler messages for event log
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_E_PROF_BAD_PATH "Loading profiler failed. COR_ENABLE_PROFILING and COR_PROFILER were set properly, but COR_PROFILER_PATH was not. COR_PROFILER_PATH must be set to the full path of the profiler DLL to load with no more than 260 charaters including the null terminator."
+ IDS_E_PROF_NO_CLSID "Loading profiler failed. COR_ENABLE_PROFILING was set properly, but COR_PROFILER was not. COR_PROFILER must be set to the CLSID of the profiler to load."
+ IDS_E_PROF_INTERNAL_INIT "Loading profiler failed due to an internal profiling services initialization failure. Profiler CLSID: '%s'. HRESULT: 0x%x."
+ IDS_E_PROF_BAD_CLSID "Loading profiler failed. COR_PROFILER is set to an invalid CLSID: '%s'. HRESULT: 0x%x."
+ IDS_E_PROF_NO_CALLBACK_IFACE "Loading profiler failed. COR_PROFILER is set to a CLSID of a COM object that does not implement the interface GUID (IID) requested by the CLR. This often indicates that the profiler does not support this version of the CLR. Profiler CLSID: '%s'. Requested IID: '%s'."
+ IDS_E_PROF_CCI_FAILED "Loading profiler failed during CoCreateInstance. Profiler CLSID: '%s'. HRESULT: 0x%x."
+ IDS_E_PROF_INIT_CALLBACK_FAILED "Loading profiler failed. The profiler COM object was instantiated, but the profiler failed during its initialization callback. Profiler CLSID: '%s'. HRESULT: 0x%x."
+ IDS_PROF_SUPPLEMENTARY_INFO "Process ID (decimal): %d. Message ID: [0x%x]."
+ IDS_PROF_LOAD_COMPLETE "The profiler was loaded successfully. Profiler CLSID: '%s'."
+ IDS_E_PROF_ATTACH_INIT "There was a failure initializing profiling API attach infrastructure. This process will not allow a profiler to attach. HRESULT: 0x%x."
+ IDS_E_PROF_ATTACHTHREAD_INIT "Loading profiler failed. Failed creating interprocess communication infrastructure. HRESULT: 0x%x."
+ IDS_E_PROF_CONNECT_TO_TRIGGER "Loading profiler failed. Unable to connect to the process that is trying to request the attach. HRESULT: 0x%x."
+ IDS_E_PROF_NO_ATTACH_REQ "Loading profiler failed. The inter-process communication mechanism was initialized, but an attach request was not received. HRESULT: 0x%x."
+ IDS_E_PROF_PIPE_RCV "Loading profiler failed. Failed trying to receive from out of process a request to attach a profiler. HRESULT: 0x%x."
+ IDS_E_PROF_NOT_ATTACHABLE "Loading profiler failed. The profiler COM object was instantiated, but the profiler does not support attaching to a live process. The profiler must be loaded at application startup by using a launcher program included with the profiler (if any) or by setting the COR_ENABLE_PROFILING and COR_PROFILER environment variables before launching the application to be profiled. Profiler CLSID: '%s'"
+ IDS_E_PROF_UNHANDLED_EXCEPTION_ON_LOAD "Loading profiler failed. There was an unhandled exception while trying to instantiate the profiler COM object. Please ensure the CLSID is associated with a valid profiler designed to work with this version of the runtime. Profiler CLSID: '%s'."
+ IDS_E_PROF_INVALID_MSG "Loading profiler failed. Received an improperly formatted attach request."
+ IDS_E_PROF_PROFILER_ALREADY_ACTIVE "Loading profiler failed. A profiler is already loaded, so the request to attach another profiler was denied."
+ IDS_PROF_ATTACH_REQUEST_RECEIVED "The CLR received a request to attach a profiler. Profiler CLSID: '%s'."
+ IDS_PROF_DETACH_INITIATED "The profiler currently in use has requested to be detached from the process. The CLR has disabled communication with the profiler and will unload the profiler when it is safe to do so."
+ IDS_PROF_DETACH_COMPLETE "The CLR has fully detached and unloaded the profiler."
+ IDS_PROF_DETACH_THREAD_ERROR "There was an internal failure in the profiling API detach infrastructure. The profiler will not be able to be detached. Error code: %d."
+ IDS_PROF_CANCEL_ACTIVATION "The profiler has requested that the CLR instance not load the profiler into this process. Profiler CLSID: '%s'."
+ IDS_PROF_V2PROFILER_DISABLED "Loading profiler failed. The profiler that was configured to load was designed for an older version of the CLR. You can use the COMPlus_ProfAPI_ProfilerCompatibilitySetting environment variable to allow older profilers to be loaded by the current version of the CLR. Please consult the documentation for information on how to use this environment variable, and the risks associated with it. Profiler CLSID: '%s'."
+ IDS_PROF_V2PROFILER_ENABLED "A profiler designed for an older version of the CLR was loaded because of the environment variable setting below. Older profilers will continue to work in many cases, but if you encounter problems, please consider upgrading the profiler or changing the setting of the environment variable. Please consult the documentation for information on how to use this environment variable, and the risks associated with it. Environment variable setting: %s=%s. Profiler CLSID: '%s'."
+ IDS_PROF_V2PROFILER_ALREADY_LOADED "A profiler designed for an older version of the CLR was already loaded by an older version of the CLR in the process, and the profiler will therefore not be loaded into this process again. Please consider upgrading your profiler in order to gain better support profiling processes that load multiple instances of the CLR. Profiler CLSID: '%s'."
+ IDS_PROF_PROFILER_DISABLED "Profilers will not be loaded by the current version of the CLR because of the environment variable setting below. Please consult the documentation for information on how to use this environment variable, and the risks associated with it. Environment variable setting: %s=%s. Profiler CLSID: '%s'."
+ IDS_E_PROF_TIMEOUT_WAITING_FOR_CONCURRENT_GC "Profiler timed out on waiting for concurrent GC to finish after '%d' milliseconds. Please configure your profiler to increase its attaching time out value or consult the documentation for the COMPlus_ProfAPI_AttachProfilerMinTimeoutInMs environment variable and try again. Profiler CLSID: '%s'."
+ END
+
+// Dialog box buttons
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_DIALOG_BOX_ABORT_BUTTON "&Abort"
+ IDS_DIALOG_BOX_DEBUG_BUTTON "&Debug"
+ IDS_DIALOG_BOX_IGNORE_BUTTON "&Ignore"
+END
+
+#ifndef FEATURE_CORECLR
+// OOB servicing
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_EE_ASSEMBLY_ON_DENY_LIST "The assembly %1 that the application tried to load has a known vulnerability. Please go to %2 to find a fix for this issue."
+END
+#endif
+
+#ifdef FEATURE_CORECLR
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_EE_BADMARSHAL_TYPE_ANSIBSTR "Marshalling as AnsiBStr is not supported"
+ IDS_EE_BADMARSHAL_TYPE_VBBYVALSTR "Marshalling as VBByRefString is not supported"
+ IDS_EE_BADMARSHAL_TYPE_REFERENCECUSTOMMARSHALER "Custom marshalers are not supported"
+ IDS_EE_BADMARSHAL_TYPE_VARIANTASOBJECT "Marshalling between VARIANT and System.Object is not supported"
+ IDS_EE_BADMARSHAL_TYPE_ASANYA "Marshalling arbitrary types is not supported"
+ IDS_EE_BADMARSHAL_TYPE_IDISPATCH "Marshalling as IDispatch is not supported"
+ IDS_EE_ERROR_IDISPATCH "IDispatch and IDispatchEx are not supported"
+END
+#endif // FEATURE_CORECLR
+
+#ifdef FEATURE_HOST_ASSEMBLY_RESOLVER
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_HOST_ASSEMBLY_RESOLVER_ASSEMBLY_ALREADY_LOADED_IN_CONTEXT "Assembly with same name is already loaded"
+ IDS_HOST_ASSEMBLY_RESOLVER_DYNAMICALLY_EMITTED_ASSEMBLIES_UNSUPPORTED "Dynamically emitted assemblies are unsupported during host-based resolution."
+ IDS_HOST_ASSEMBLY_RESOLVER_INCOMPATIBLE_BINDING_CONTEXT "Assembly is already bound to an incompatible binding context."
+ IDS_HOST_ASSEMBLY_RESOLVER_INCOMPATIBLE_TPA_BINDING_CONTEXT "Default binding context is already attached to managed load context."
+END
+#endif // FEATURE_HOST_ASSEMBLY_RESOLVER
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_NATIVE_IMAGE_CANNOT_BE_LOADED_MULTIPLE_TIMES "Native image cannot be loaded multiple times"
+END
+
+//
+// Descriptions for FACILITY_URT hresults. None of these may be parameterized.
+//
+// These strings are accessed by the GetHRMsg() function in ex.cpp. Do not delete them!
+//
+// Some strings in this table may duplicate ones above. That is because the ones above were
+// added in earlier builds where we freely mixed defined hresults and internal resource ids.
+// You may wish to remove the earlier entry and redirect all references to it to the
+// one in this table.
+//
+// If you want to add resource strings to these Hresults, update the corerror.xml in inc
+// directory, and mscorurt.rc will be auto-generated to include the string.
+//
+
+#include <mscorurt.rc>
+
+#endif
diff --git a/src/dlls/mscorrc/mscorrc.rc2 b/src/dlls/mscorrc/mscorrc.rc2
new file mode 100644
index 0000000000..3e08368699
--- /dev/null
+++ b/src/dlls/mscorrc/mscorrc.rc2
@@ -0,0 +1,52 @@
+// 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.
+
+//*****************************************************************************
+// CompRC.rc2
+//
+// Holds version stamp for this program.
+//
+//*****************************************************************************
+#ifdef APSTUDIO_INVOKED
+ #error this file is not editable by App Studio
+#endif //APSTUDIO_INVOKED
+
+#include <winver.h>
+#include <__file__.ver> //file version info - variable, but same for all files
+#include <__product__.ver> //product version info - variable
+#include <corver.h> //product version info - fixed
+#include "__file__.h" // file version info - fixed per file
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VER_FILEVERSION
+ PRODUCTVERSION VER_PRODUCTVERSION
+ FILEFLAGSMASK VER_FILEFLAGSMASK
+ FILEFLAGS VER_FILEFLAGS
+ FILEOS VER_FILEOS
+ FILETYPE VER_FILETYPE
+BEGIN
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1252
+ // English language (0x409) and the Windows ANSI codepage (1252)
+ END
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
+ BEGIN
+ // Note: Non-standard value strings must be first as FileManager has a bug
+ // that leaves garbage in its name buffer otherwise.
+ VALUE "CompanyName", VER_COMPANYNAME_STR
+ VALUE "FileDescription", VER_FILEDESCRIPTION_STR
+ VALUE "FileVersion", VER_FILEVERSION_STR
+ VALUE "InternalName", VER_INTERNALNAME_STR
+ VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
+ VALUE "LegalTrademarks", VER_LEGALTRADEMARKS_STR
+ VALUE "OriginalFilename",VER_ORIGFILENAME_STR
+ VALUE "ProductName", VER_PRODUCTNAME_STR
+ VALUE "ProductVersion", VER_PRODUCTVERSION_STR
+ VALUE "Comments", VER_FILEDESCRIPTION_STR
+ END
+ END
+END
diff --git a/src/dlls/mscorrc/mscorrc.small.rc b/src/dlls/mscorrc/mscorrc.small.rc
new file mode 100644
index 0000000000..75fbb1a86f
--- /dev/null
+++ b/src/dlls/mscorrc/mscorrc.small.rc
@@ -0,0 +1,42 @@
+// 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.
+
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+#include "corerror.h"
+
+#ifdef APSTUDIO_INVOKED
+ #error Do not edit this file with App Studio.
+#endif //APSTUDIO_INVOKED
+
+#include <winresrc.h>
+
+#define FX_VER_FILEDESCRIPTION_STR "Microsoft .NET Runtime resources\0"
+
+#include <fxver.h>
+#include <fxver.rc>
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#include "mscorrc.common.rc"
+
+// These strings are generated from within the EE.
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_EE_LINK_FOR_DEBUGGING_MESSAGES "Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=%1!s!&File=mscorrc.dll&Key=0x%2!X! "
+ IDS_EE_LINK_FOR_ERROR_MESSAGES "Error 0x%3!X!. Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=%1!s!&File=mscorrc.dll&Key=0x%2!X! "
+END
+
+
+#endif
+
+
diff --git a/src/dlls/mscorrc/nativelog.rc b/src/dlls/mscorrc/nativelog.rc
new file mode 100644
index 0000000000..33e94dc129
--- /dev/null
+++ b/src/dlls/mscorrc/nativelog.rc
@@ -0,0 +1,32 @@
+// 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.
+#include "nativeres.h"
+
+#ifdef FEATURE_FUSION
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_FUSLOG_NGEN_BIND_IL_PROVIDED L"LOG: IL assembly loaded from %ws."
+ ID_FUSLOG_NGEN_BIND_LOADFROM_NOT_ALLOWED L"WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load()."
+ ID_FUSLOG_NGEN_BIND_SUCCESS L"LOG: Bind to native image succeeded."
+ ID_FUSLOG_NGEN_BIND_FAIL L"ERR: Error encountered when binding to native image assembly. (hr = 0x%x)."
+ ID_FUSLOG_NGEN_BIND_NO_MATCH L"WRN: No matching native image found."
+ ID_FUSLOG_NGEN_BIND_NGEN_REJECT_CONFIG_MASK L"WRN: Native image compile options do not match request. Looking for next native image."
+ ID_FUSLOG_NGEN_BIND_NI_DEPEND_START L"LOG: [Level %d]Start validating native image dependency %ws."
+ ID_FUSLOG_NGEN_BIND_IL_DEPEND_START L"LOG: [Level %d]Start validating IL dependency %ws."
+ ID_FUSLOG_NGEN_BIND_VALIDATE_DEPENDENCIES L"LOG: Start validating all the dependencies."
+ ID_FUSLOG_NGEN_BIND_VALIDATE_DEPENDENCIES_SUCCESS L"LOG: Validation of dependencies succeeded."
+ ID_FUSLOG_NGEN_BIND_REJECT_IL_NOT_FOUND L"WRN: Cannot load IL assembly. (hr = 0x%x)."
+ ID_FUSLOG_NGEN_BIND_MISSING_FOUND L"WRN: Dependency assembly was not found at ngen time, but is found at binding time. Disallow using this native image."
+ ID_FUSLOG_NGEN_BIND_AUXCORRUPTION_GENERAL L"ERR: Rejecting native image due to corrupted or missing .aux file (%ws)."
+ ID_FUSLOG_NGEN_BIND_AUX_REOPTIMIZED L"LOG: Successfully updated stale timestamp in .aux file (%ws)."
+ ID_FUSLOG_NGEN_BIND_REJECT_SIG L"WRN: Signature of the IL assembly does not match record in .aux file. Validation stops."
+ ID_FUSLOG_NGEN_BIND_REJECT_TP L"WRN: TPBand of the IL assembly does not match record in .aux file. Validation stops."
+ ID_FUSLOG_NGEN_BIND_REJECT_TIMESTAMP_SIGFALLBACK L"WRN: Timestamp of the IL assembly does not match record in .aux file. Loading IL to compare signature."
+ ID_FUSLOG_NGEN_BIND_REJECT_TIMESTAMP_TPFALLBACK L"WRN: Timestamp of the IL assembly does not match record in .aux file. Loading IL to compare TPBand."
+ ID_FUSLOG_NGEN_BIND_CHANGED_BINDING_POLICY L"WRN: Assembly resolved to a different version or identity than expected. Check if binding policy changed since native image built."
+ ID_FUSLOG_NGEN_BIND_REJECT_OPTOUT L"WRN: The application has opted out of using native images for this assembly."
+END
+
+#endif // FEATURE_FUSION
diff --git a/src/dlls/mscorrc/nativeres.h b/src/dlls/mscorrc/nativeres.h
new file mode 100644
index 0000000000..d1315176f8
--- /dev/null
+++ b/src/dlls/mscorrc/nativeres.h
@@ -0,0 +1,35 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+#ifndef __NATIVE_BINDER_RESOURCE_H_
+#define __NATIVE_BINDER_RESOURCE_H_
+
+#ifdef FEATURE_FUSION
+
+#define ID_FUSLOG_NGEN_BIND_IL_PROVIDED 10204
+#define ID_FUSLOG_NGEN_BIND_LOADFROM_NOT_ALLOWED 10174
+#define ID_FUSLOG_NGEN_BIND_SUCCESS 10171
+#define ID_FUSLOG_NGEN_BIND_FAIL 10172
+#define ID_FUSLOG_NGEN_BIND_NO_MATCH 10179
+#define ID_FUSLOG_NGEN_BIND_NGEN_REJECT_CONFIG_MASK 10178
+#define ID_FUSLOG_NGEN_BIND_NI_DEPEND_START 10206
+#define ID_FUSLOG_NGEN_BIND_IL_DEPEND_START 10207
+#define ID_FUSLOG_NGEN_BIND_VALIDATE_DEPENDENCIES 10197
+#define ID_FUSLOG_NGEN_BIND_VALIDATE_DEPENDENCIES_SUCCESS 10200
+#define ID_FUSLOG_NGEN_BIND_REJECT_IL_NOT_FOUND 10183
+#define ID_FUSLOG_NGEN_BIND_MISSING_FOUND 10209
+
+// Ids 10400 - 10500 reserved for new native binder messages
+// If more ids are needed, reserve them in fusres.h
+#define ID_FUSLOG_NGEN_BIND_AUXCORRUPTION_GENERAL 10400
+#define ID_FUSLOG_NGEN_BIND_AUX_REOPTIMIZED 10401
+#define ID_FUSLOG_NGEN_BIND_REJECT_SIG 10402
+#define ID_FUSLOG_NGEN_BIND_REJECT_TP 10403
+#define ID_FUSLOG_NGEN_BIND_REJECT_TIMESTAMP_SIGFALLBACK 10404
+#define ID_FUSLOG_NGEN_BIND_REJECT_TIMESTAMP_TPFALLBACK 10405
+#define ID_FUSLOG_NGEN_BIND_CHANGED_BINDING_POLICY 10406
+#define ID_FUSLOG_NGEN_BIND_REJECT_OPTOUT 10407
+
+#endif // FEATURE_FUSION
+
+#endif // __NATIVE_BINDER_RESOURCE_H_
diff --git a/src/dlls/mscorrc/resource.h b/src/dlls/mscorrc/resource.h
new file mode 100644
index 0000000000..1391a21545
--- /dev/null
+++ b/src/dlls/mscorrc/resource.h
@@ -0,0 +1,950 @@
+// 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.
+//{{NO_DEPENDENCIES}}
+// Used by mscorrc.rc
+//
+
+
+// For (failing) hresults of facility FACILITY_URT, we store
+// unparameterized description strings in the range
+// 0x6000..0x9000.
+#define MSG_FOR_URT_HR(hr) (0x6000 + (HRESULT_CODE(hr)))
+#define MAX_URT_HRESULT_CODE 0x3000
+
+#define HR_FOR_URT_MSG(code) ((code >=0x6000 && code <= 0x6000+MAX_URT_HRESULT_CODE) ? \
+ MAKE_HRESULT(SEVERITY_ERROR, FACILITY_URT, code - 0x6000) : \
+ code)
+
+#ifndef HRESULT_CODE
+#define HRESULT_CODE(hr) ((hr) & 0xFFFF)
+#endif // HRESULT_CODE
+
+
+//-----------------------------------------------------------------------------
+// Resource strings for MDA descriptions.
+//-----------------------------------------------------------------------------
+
+#define MDARC_PINVOKE_SIGNATURE_MISMATCH 0x1901
+#define MDARC_INVALID_CONFIG_FILE 0x1902
+#define MDARC_CALLBACK_ON_COLLECTED_DELEGATE 0x1903
+#define MDARC_INVALID_APT_STATE_CHANGE_SET 0x1904
+#define MDARC_INVALID_APT_STATE_CHANGE_NOTSET 0x1905
+#define MDARC_LOADER_LOCK 0x1906
+#define MDARC_REPORT_AV_ON_COM_RELEASE 0x1907
+#define MDARC_INVALID_VARIANT 0x1908
+#define MDARC_FAILED_QI 0x1909
+#define MDARC_DISCONNECTED_CONTEXT_1 0x190A
+#define MDARC_DISCONNECTED_CONTEXT_2 0x190B
+#define MDARC_NOTMARSHALABLE 0x190C
+#define MDARC_INVALID_IUNKNOWN 0x190D
+#define MDARC_MARSHALING_METHOD 0x190E
+#define MDARC_INVALID_FUNCTION_PTR_IN_DELEGATE 0x190F
+#define MDARC_VTABLE_CALL_ON_AUTODISP_MEMBER 0x1910
+#define MDARC_INVALID_CER_CALL 0x1911
+#define MDARC_VIRTUAL_CER_CALL 0x1912
+#define MDARC_OPENGENERIC_CER_CALL 0x1913
+#define MDARC_ILLEGAL_PCR 0x1914
+#define MDARC_MARSHALCLEANUPERROR_THREADCULTURE 0x1915
+#define MDARC_MARSHALCLEANUPERROR_SAFEHANDLERELEASE 0x1916
+#define MDARC_MARSHALCLEANUPERROR_SAFEHANDLEPROP 0x1917
+#define MDARC_MARSHALCLEANUPERROR_CUSTOMCLEANUP 0x1918
+#define MDARC_SAFEHANDLE_CRITICAL_FAILURE 0x1919
+#define MDARC_DLLMAIN_RETURNS_FALSE 0x191A
+#define MDARC_REFLECTION_PERFORMANCE_MEMBERINFOCACHECREATION 0x191B
+#define MDARC_DOCUMENTATION 0x191E
+#define MDARC_ASYNCHRONOUS_THREADABORT 0x191F
+#define MDARC_LOAD_FROM_CONTEXT 0x1920
+#define MDARC_CONTEXT_SWITCH_DEADLOCK 0x1921
+#define MDARC_RCW_CLEANUP_RACE 0x1923
+#define MDARC_DATETIME_INVALID_LOCAL_FORMAT 0x1924
+#define MDARC_INVALID_MEMBER_DECLARATION 0x1925
+#define MDARC_EXCEPTION_SWALLOWED_COM_TO_CLR 0x1926
+#define MDARC_REENTRANCY 0x1928
+#define MDARC_NON_COMVISIBLE_BASE_CLASS_CLASSITF 0x1929
+#define MDARC_NON_COMVISIBLE_BASE_CLASS_IDISPATCH 0x192A
+#define MDARC_BINDING_FAILURE 0x192B
+#define MDARC_INVALID_GCHANDLE_COOKIE 0x192C
+#define MDARC_REPORT_AV_ON_COM_RELEASE_WITH_VTABLE 0x192D
+#define MDARC_PINVOKE_LOG 0x192E
+#define MDARC_FATAL_EXECUTION_ENGINE_ERROR 0x192F
+#define MDARC_DANGEROUS_THREADINGAPI 0x1930
+#define MDARC_INVALID_OVERLAPPED_TO_PINVOKE 0x1931
+#define MDARC_INVALID_OVERLAPPED_FREE 0x1932
+#define MDARC_DIRTY_CAST_AND_CALL_ON_INTERFACE 0x1933
+#define MDARC_DEBUGGER_FIBER_MODE_NOT_SUPPORTED 0x1934
+#define MDARC_BINDING_FAILURE_CODEBASE_ONLY 0x1935
+#define MDARC_BINDING_FAILURE_DISPLAYNAME_ONLY 0x1936
+#define MDARC_MARSHALING_FIELD 0x1937
+#define MDARC_MARSHALING_RETURN_VALUE_NAME 0x1938
+#define MDARC_MARSHALING_UNKNOWN_PARAM_NAME 0x1939
+#define MDARC_LOADER_LOCK_DLL 0x193A
+#define MDARC_JIT_ATTACH 0x193B
+
+#define IDS_GENERAL_SVC_DESCRIPTION 0x01F4
+#define IDS_RTL 0x01F5
+
+#define IDS_DS_ACTIVESESSIONS 0x1701
+#define IDS_DS_DATASOURCENAME 0x1702
+#define IDS_DS_DATASOURCEREADONLY 0x1703
+#define IDS_DS_DBMSNAME 0x1704
+#define IDS_DS_DBMSVER 0x1705
+#define IDS_DS_IDENTIFIERCASE 0x1706
+#define IDS_DS_DSOTHREADMODEL 0x1707
+
+#define IDS_EE_NDIRECT_UNSUPPORTED_SIG 0x1708
+#define IDS_EE_EXCEPTION_FROM_HRESULT 0x1709
+#define IDS_EE_NDIRECT_BADNATL 0x170a
+#define IDS_EE_NDIRECT_LOADLIB 0x170b
+#define IDS_EE_NDIRECT_GETPROCADDRESS 0x170c
+#define IDS_EE_COM_UNSUPPORTED_SIG 0x170d
+#define IDS_EE_NOSYNCHRONIZED 0x170f
+#define IDS_EE_NDIRECT_BADNATL_THISCALL 0x1710
+
+#define IDS_EE_LOAD_NO_MAIN 0x1711
+#define IDS_EE_LOAD_BAD_MAIN_SIG 0x1712
+#define IDS_EE_COM_UNSUPPORTED_TYPE 0x1713
+#define IDS_EE_COM_UNSUPPORTED_VT_RECORD 0x1714
+
+#define IDS_EE_LOAD_UNEXPECTED 0x1715
+#define IDS_EE_AMBIGUOUSINVOKE 0x1716
+#define IDS_EE_CALLBACK_UNSUPPORTED_SIG 0x1717
+#define IDS_EE_NOTADELEGATE 0x1718
+#define IDS_EE_NOTNDIRECT 0x1719
+#define IDS_EE_TWO_LOADED_MSCOREE_TITLE 0x171a
+#define IDS_EE_TWO_LOADED_MSCOREE_MSG 0x171b
+#define IDS_EE_CUST_MARSHALER_ON_INVALID_TYPE 0x171c
+#define IDS_EE_RETHROW_NOT_ALLOWED 0x171d
+#define IDS_EE_INVALID_OLE_VARIANT 0x171e
+
+#define IDS_EE_ADUNLOAD_DEFAULT 0x171f
+
+#define IDS_EE_FILE_NOT_FOUND 0x80070002
+#define IDS_EE_TOO_MANY_OPEN_FILES 0x80070004
+#define IDS_EE_SHARING_VIOLATION 0x80070020
+#define IDS_EE_LOCK_VIOLATION 0x80070021
+#define IDS_EE_OPEN_FAILED 0x8007006D
+#define IDS_EE_PATH_TOO_LONG 0x8007006F
+#define IDS_EE_DISK_FULL 0x80070070
+#define IDS_EE_INVALID_NAME 0x8007007B
+#define IDS_EE_PROC_NOT_FOUND 0x8007007F
+#define IDS_EE_ALREADY_EXISTS 0x800700B7
+#define IDS_EE_UNRECOGNIZED_VOLUME 0x800703ED
+#define IDS_EE_FILE_INVALID 0x800703EE
+#define IDS_EE_DLL_INIT_FAILED 0x8007045A
+#define IDS_EE_BAD_USER_PROFILE 0x800704E5
+#define IDS_EE_FILE_CORRUPT 0x80070570
+#define IDS_EE_DISK_CORRUPT 0x80070571
+#define IDS_INET_E_CANNOT_CONNECT 0x1799 // 0x800C0004
+#define IDS_INET_E_RESOURCE_NOT_FOUND 0x1a60 // 0x800C0005
+#define IDS_INET_E_OBJECT_NOT_FOUND 0x800C0006
+#define IDS_INET_E_DATA_NOT_AVAILABLE 0x800C0007
+#define IDS_INET_E_DOWNLOAD_FAILURE 0x800C0008
+#define IDS_INET_E_CONNECTION_TIMEOUT 0x1a1e // 0x800C000B
+#define IDS_INET_E_UNKNOWN_PROTOCOL 0x800C000D
+#define IDS_INET_E_SECURITY_PROBLEM 0x800C000E
+
+#define IDS_EE_FAILED_TO_LOAD 0x1720
+#define IDS_EE_TO_MANY_ARGUMENTS_IN_MAIN 0x1721
+#define IDS_EE_FAILED_TO_FIND_MAIN 0x1722
+#define IDS_EE_ILLEGAL_TOKEN_FOR_MAIN 0x1723
+#define IDS_EE_MAIN_METHOD_MUST_BE_STATIC 0x1724
+#define IDS_EE_MAIN_METHOD_HAS_INVALID_RTN 0x1725
+#define IDS_EE_VTABLECALLSNOTSUPPORTED 0x1726
+
+#define IDS_EE_BADMARSHALFIELD_STRING 0x1727
+#define IDS_EE_BADMARSHALFIELD_NOCUSTOMMARSH 0x1728
+#define IDS_EE_BADMARSHALFIELD_FIXEDARRAY_NOSIZE 0x1729
+#define IDS_EE_BADMARSHALFIELD_FIXEDARRAY_ZEROSIZE 0x172a
+#define IDS_EE_BADMARSHALFIELD_LAYOUTCLASS 0x172b
+#define IDS_EE_BADMARSHALFIELD_ARRAY 0x172c
+
+#define IDS_EE_BADMARSHALPARAM_NO_LPTSTR 0x172d
+
+#define IDS_EE_BADMARSHAL_NOTMARSHALABLE 0x1730
+
+#define IDS_EE_SAFEARRAYTYPEMISMATCH 0x1738
+#define IDS_EE_SAFEARRAYRANKMISMATCH 0x1739
+#define IDS_EE_BADMARSHAL_GENERIC 0x173a
+#define IDS_EE_BADMARSHAL_CHAR 0x173b
+#define IDS_EE_BADMARSHAL_BOOLEAN 0x173c
+#define IDS_EE_BADMARSHAL_I1 0x173d
+#define IDS_EE_BADMARSHAL_I2 0x173e
+#define IDS_EE_BADMARSHAL_I4 0x173f
+#define IDS_EE_BADMARSHAL_I8 0x1740
+#define IDS_EE_BADMARSHAL_I 0x1741
+#define IDS_EE_BADMARSHAL_R4 0x1742
+#define IDS_EE_BADMARSHAL_R8 0x1743
+#define IDS_EE_BADMARSHAL_PTR 0x1745
+#define IDS_EE_BADMARSHAL_NOLAYOUT 0x1746
+#define IDS_EE_BADMARSHALPARAM_STRING 0x1747
+#define IDS_EE_BADMARSHALPARAM_STRINGBUILDER 0x1748
+#define IDS_EE_BADMARSHAL_DELEGATE 0x1749
+#define IDS_EE_BADMARSHAL_FNPTR 0x174a
+#define IDS_EE_BADMARSHAL_INTERFACE 0x174b
+#define IDS_EE_BADMARSHAL_CLASS 0x174c
+#define IDS_EE_BADMARSHAL_VALUETYPE 0x174d
+#define IDS_EE_BADMARSHAL_OBJECT 0x174e
+#define IDS_EE_BADMARSHALFIELD_OBJECT 0x174f
+#define IDS_EE_BADMARSHALPARAM_DECIMAL 0x1750
+#define IDS_EE_BADMARSHAL_GUID 0x1751
+#define IDS_EE_BADMARSHAL_DATETIME 0x1753
+#define IDS_EE_BADMARSHAL_ARRAY 0x1754
+#define IDS_EE_BADMARSHAL_BADMANAGED 0x1756
+#define IDS_EE_SRC_OBJ_NOT_COMOBJECT 0x1757
+#define IDS_EE_CANNOT_COERCE_COMOBJECT 0x1759
+#define IDS_EE_BADMARSHAL_PTRSUBTYPE 0x175b
+#define IDS_EE_BADMARSHAL_PTRNONBLITTABLE 0x175c
+
+#define IDS_EE_BADMARSHAL_RESTRICTION 0x175d
+#define IDS_EE_BADMARSHAL_CHARARRAYRESTRICTION 0x175e
+#define IDS_EE_BADMARSHAL_ASANYRESTRICTION 0x175f
+#define IDS_EE_BADMARSHAL_VBBYVALSTRRESTRICTION 0x1760
+#define IDS_EE_BADMARSHAL_AWORESTRICTION 0x1761
+#define IDS_EE_BADMARSHAL_BVCRESTRICTION 0x1762
+#define IDS_EE_BADMARSHAL_COPYCTORRESTRICTION 0x1763
+#define IDS_EE_BADMARSHAL_VCRESTRICTION 0x1764
+#define IDS_EE_BADMARSHAL_ARGITERATORRESTRICTION 0x1765
+#define IDS_EE_BADMARSHAL_HANDLEREFRESTRICTION 0x1766
+
+#define IDS_EE_ADUNLOAD_NOT_ALLOWED 0x1767
+#define IDS_EE_ADUNLOAD_IN_FINALIZER 0x1768
+#define IDS_EE_ADUNLOAD_CANT_UNWIND_THREAD 0x1769
+
+#define IDS_STREAMS_FILE_EOF 0x176a
+#define IDS_STREAMS_FILE_OPEN 0x176b
+#define IDS_STREAMS_FILE_BUFFER 0x176c
+#define IDS_STREAMS_FILE_NAME 0x176d
+#define IDS_STREAMS_SEEK_MODIFIER 0x176e
+
+#define IDS_SECURITY_DEMAND_DENIED 0x176f
+
+#define IDS_CANNOT_MARSHAL 0x1770
+#define IDS_PINVOKE_STRINGBUILDEROVERFLOW 0x1771
+#define IDS_EE_HASH_VAL_FAILED 0x1772
+
+
+#define IDS_CLASSLOAD_GENERAL 0x80131522
+#define IDS_CLASSLOAD_MODULELOAD 0x1773
+#define IDS_CLASSLOAD_BADFORMAT 0x1774
+#define IDS_CLASSLOAD_CANTCREATEARRAYCLASS 0x1775
+#define IDS_CLASSLOAD_NOCLSIDREG 0x1776
+#define IDS_CLASSLOAD_MISSINGMETHOD 0x1777
+#define IDS_CLASSLOAD_STATICVIRTUAL 0x1778
+#define IDS_CLASSLOAD_REDUCEACCESS 0x1779
+#define IDS_CLASSLOAD_BADPINVOKE 0x177a
+#define IDS_CLASSLOAD_VALUECLASSTOOLARGE 0x177b
+#define IDS_CLASSLOAD_NOTIMPLEMENTED 0x177c
+#define IDS_CLASSLOAD_PARENTNULL 0x177d
+#define IDS_CLASSLOAD_PARENTINTERFACE 0x177e
+#define IDS_CLASSLOAD_INTERFACEOBJECT 0x177f
+#define IDS_CLASSLOAD_INTERFACENULL 0x1780
+#define IDS_CLASSLOAD_NOTINTERFACE 0x1781
+#define IDS_CLASSLOAD_VALUEINSTANCEFIELD 0x1782
+#define IDS_CLASSLOAD_EXPLICIT_GENERIC 0x1783
+#define IDS_CLASSLOAD_BAD_NAME 0x1784
+#define IDS_CLASSLOAD_RANK_TOOLARGE 0x1785
+#define IDS_CLASSLOAD_BAD_MANAGED_RVA 0x1786
+#define IDS_CLASSLOAD_BAD_UNMANAGED_RVA 0x1787
+#define IDS_CLASSLOAD_INHERITANCECHECK 0x1788
+#define IDS_CLASSLOAD_ENCLOSING 0x1789
+#define IDS_CLASSLOAD_EXPLICIT_LAYOUT 0x178a
+#define IDS_CLASSLOAD_SEALEDPARENT 0x178b
+#define IDS_CLASSLOAD_NOMETHOD_NAME 0x178c
+#define IDS_CLASSLOAD_PRIVATEVIRTUAL 0x178d
+#define IDS_CLASSLOAD_BADSPECIALMETHOD 0x178e
+#define IDS_CLASSLOAD_MI_DECLARATIONNOTFOUND 0x178f
+#define IDS_CLASSLOAD_MI_MULTIPLEOVERRIDES 0x1790
+#define IDS_CLASSLOAD_MI_ACCESS_FAILURE 0x1791
+#define IDS_CLASSLOAD_MI_OVERRIDEIMPL 0x1792
+#define IDS_CLASSLOAD_MI_BADSIGNATURE 0x1793
+#define IDS_CLASSLOAD_MI_NOTIMPLEMENTED 0x1794
+#define IDS_CLASSLOAD_MI_VIRTUALMISMATCH 0x1795
+#define IDS_CLASSLOAD_MI_MUSTBEVIRTUAL 0x1796
+#define IDS_CLASSLOAD_MISSINGMETHODRVA 0x1797
+#define IDS_CLASSLOAD_FIELDTOOLARGE 0x1798
+#define IDS_CLASSLOAD_CANTEXTEND 0x179a
+#define IDS_CLASSLOAD_ZEROSIZE 0x179b
+#define IDS_CLASSLOAD_TYPESPEC 0x179c
+#define IDS_CLASSLOAD_BAD_FIELD 0x179d
+#define IDS_CLASSLOAD_MI_ILLEGAL_BODY 0x179e
+#define IDS_CLASSLOAD_MI_ILLEGAL_STATIC 0x179f
+#define IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_BODY 0x17a0
+#define IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_DECL 0x17a1
+#define IDS_CLASSLOAD_MI_SEALED_DECL 0x17a2
+#define IDS_CLASSLOAD_MI_FINAL_DECL 0x17a3
+#define IDS_CLASSLOAD_MI_NONVIRTUAL_DECL 0x17a4
+#define IDS_CLASSLOAD_MI_BODY_DECL_MISMATCH 0x17a5
+#define IDS_CLASSLOAD_MI_MISSING_SIG_BODY 0x17a6
+#define IDS_CLASSLOAD_MI_MISSING_SIG_DECL 0x17a7
+#define IDS_CLASSLOAD_ASSEMBLYLOAD 0x17a8
+#define IDS_CLASSLOAD_UNVERIFIABLE_FIELD_LAYOUT 0x17a9
+
+#define IDS_FAIL_CAPTION 0x17aa
+#define IDS_CLASSLOAD_TOOMANYGENERICARGS 0x17ab
+#define IDS_CLASSLOAD_COLLECTIBLEPINVOKE 0x17ac
+#define IDS_CLASSLOAD_COLLECTIBLESPECIALSTATICS 0x17ad
+#define IDS_COMPLUS_ERROR 0x17ae
+#define IDS_FATAL_ERROR 0x17af
+#define IDS_ERROR 0x17b0
+#define IDS_INVALID_VARIANT_MSG 0x17b1
+#define IDS_INVALID_VARIANT_CAPTION 0x17b2
+#define IDS_DEBUG_DIFF_BUILDS_ERR 0x17b3
+#define IDS_DEBUG_SERVICE_CAPTION 0x17b4
+#define IDS_DEBUG_NO_DEBUGGER_FOUND 0x17b5
+#define IDS_DEBUG_USERBREAKPOINT 0x17b6
+#define IDS_DEBUG_UNHANDLEDEXCEPTION 0x17b7
+#define IDS_DEBUG_UNHANDLEDEXCEPTION_IPC 0x17b8
+#define IDS_PERFORMANCEMON_WINNT_ERR 0x17b9
+#define IDS_PERFORMANCEMON_WINNT_TITLE 0x17ba
+#define IDS_PERFORMANCEMON_FUNCNOTFOUND 0x17bb
+#define IDS_PERFORMANCEMON_FUNCNOTFOUND_TITLE 0x17bc
+#define IDS_PERFORMANCEMON_PSAPINOTFOUND 0x17bd
+#define IDS_PERFORMANCEMON_PSAPINOTFOUND_TITLE 0x17be
+
+#define IDS_DEBUG_UNHANDLED_EXCEPTION_MSG 0x17c0
+#define IDS_DEBUG_USER_BREAKPOINT_MSG 0x17c1
+
+#define IDS_EE_ADUNLOAD_NOT_LOCAL 0x17c2
+
+#define IDS_INVALID_REDIM 0x17c3
+#define IDS_INVALID_PINVOKE_CALLCONV 0x17c4
+#define IDS_NOLAYOUT_IN_EMBEDDED_VALUECLASS 0x17c5
+#define IDS_CLASSLOAD_NSTRUCT_EXPLICIT_OFFSET 0x17c7
+#define IDS_UNI2ANSI_FAILURE_IN_NSTRUCT 0x17c8
+#define IDS_EE_BADPINVOKEFIELD_NOTMARSHALABLE 0x17c9
+#define IDS_WRONGSIZEARRAY_IN_NSTRUCT 0x17ca
+#define IDS_UNI2ANSI_FAILURE 0x17cb
+#define IDS_ANSI2UNI_FAILURE 0x17cc
+
+#define IDS_EE_INVALIDLCIDPARAM 0x17cd
+#define IDS_EE_BADMARSHAL_NESTEDARRAY 0x17ce
+#define IDS_ENCODEDPERMSET_DECODEFAILURE 0x17cf
+#define IDS_BAD_MSCORLIB 0x17d0
+#define IDS_EE_INVALIDCOMSOURCEITF 0x17d1
+#define IDS_EE_CANNOT_COERCE_BYREF_VARIANT 0x17d2
+#define IDS_EE_WRAPPER_MUST_HAVE_DEF_CONS 0x17d3
+#define IDS_EE_INVALID_STD_DISPID_NAME 0x17d4
+#define IDS_EE_NO_IDISPATCH_ON_TARGET 0x17d5
+#define IDS_EE_NON_STD_NAME_WITH_STD_DISPID 0x17d6
+#define IDS_EE_INVOKE_NEW_ENUM_INVALID_RETURN 0x17d7
+#define IDS_EE_COM_OBJECT_RELEASE_RACE 0x17d8
+#define IDS_EE_COM_OBJECT_NO_LONGER_HAS_WRAPPER 0x17d9
+#define IDS_EE_CALLBACK_NOT_CALLED_FROM_CCTOR 0x17da
+#define IDS_EE_CALLBACK_ALREADY_REGISTERED 0x17de
+#define IDS_EE_NDIRECT_BADNATL_CALLCONV 0x17df
+#define IDS_EE_CANNOTCAST 0x17e0
+#define IDS_EE_NOTISOMORPHIC 0x17e1
+
+#define IDS_EE_OFFSETOF_NOFIELDFOUND 0x17e2
+#define IDS_EE_COPY_OUTOFRANGE 0x17e3
+#define IDS_EE_CANNOTPIN 0x17e4
+#define IDS_EE_ARRAYWITHOFFSETOVERFLOW 0x17e5
+#define IDS_EE_OUTOFLOCALS 0x17e6
+#define IDS_EE_NOCUSTOMMARSHALER 0x17e7
+#define IDS_EE_SIZECONTROLOUTOFRANGE 0x17e8
+#define IDS_EE_SIZECONTROLBADTYPE 0x17e9
+#define IDS_EE_DUPLICATE_DECLSEC 0x17ea
+#define IDS_EE_SAFEARRAYSZARRAYMISMATCH 0x17eb
+#define IDS_EE_INVALID_VT_FOR_CUSTOM_MARHALER 0x17ec
+#define IDS_EE_BAD_COMEXTENDS_CLASS 0x17ed
+
+#define IDS_EE_METADATA_ERROR 0x17ee
+#define IDS_EE_ERRORTITLE 0x17f0
+#define IDS_EE_ERRORMESSAGETEMPLATE 0x17f1
+#define IDS_EE_ERRORMESSAGETEXTTEMPLATE 0x17f2
+
+#define IDS_EE_CRYPTO_UNKNOWN_OPERATION 0x17f4
+
+#define IDS_EE_LOCAL_COGETCLASSOBJECT_FAILED 0x17f5
+#define SN_NO_SUITABLE_CSP_NAME 0x17f6
+
+#define IDS_EE_MISSING_FIELD 0x17f7
+#define IDS_EE_MISSING_METHOD 0x17f8
+
+#define IDS_EE_INTERFACE_NOT_DISPATCH_BASED 0x17f9
+
+#define IDS_EE_MSCOREE_MISSING 0x17fa
+#define IDS_EE_MSCOREE_MISSING_ENTRYPOINT 0x17fb
+
+#define IDS_EE_UNHANDLED_EXCEPTION 0x17fc
+#define IDS_EE_EXCEPTION_TOSTRING_FAILED 0x17fd
+
+#define IDS_CLASSLOAD_EQUIVALENTSTRUCTMETHODS 0x17fe
+#define IDS_CLASSLOAD_EQUIVALENTSTRUCTFIELDS 0x17ff
+
+#define IDS_EE_PINVOKE_NOREFFORSIZEIS 0x1a01
+#define IDS_EE_NO_IDISPATCH 0x1a02
+
+
+#define IDS_EE_SIGTOOCOMPLEX 0x1a03
+#define IDS_EE_STRUCTTOOCOMPLEX 0x1a04
+#define IDS_EE_STRUCTARRAYTOOLARGE 0x1a05
+#define IDS_EE_BADMARSHALFIELD_NOSTRINGBUILDER 0x1a06
+#define IDS_EE_NAME_UNKNOWN 0x1a07
+#define IDS_EE_NAME_INMEMORYMODULE 0x1a08
+#define IDS_EE_THREAD_NOTSTARTED 0x1a0a
+#define IDS_EE_NO_BACKING_CLASS_FACTORY 0x1a0b
+#define IDS_EE_NAME_UNKNOWN_UNQ 0x1a0c
+#define IDS_EE_STRING_TOOLONG 0x1a0d
+#define IDS_CLASSLOAD_MI_PRIVATE_DECL 0x1a0e
+#define IDS_EE_VARARG_NOT_SUPPORTED 0x1a0f
+
+#define IDS_EE_INVALID_CA 0x1a10
+#define IDS_EE_INVALID_CA_EX 0x1a11
+
+#define IDS_EE_THREADSTART_STATE 0x1a12
+
+#define IDS_EE_CANNOTCASTPROXY 0x1a13
+#define IDS_EE_THREAD_DEADLOCK_VICTIM 0x1a14
+#define IDS_EE_THREAD_CANNOT_GET 0x1a15
+#define IDS_EE_THREAD_SUSPEND_NON_RUNNING 0x1a16
+#define IDS_EE_THREAD_RESUME_NON_RUNNING 0x1a17
+#define IDS_EE_THREAD_RESUME_NON_USER_SUSPEND 0x1a18
+#define IDS_EE_THREAD_DEAD_PRIORITY 0x1a19
+#define IDS_EE_THREAD_DEAD_STATE 0x1a1a
+#define IDS_EE_THREAD_BAD_STATE 0x1a1b
+#define IDS_EE_THREAD_ABORT_WHILE_SUSPEND 0x1a1c
+
+#define IDS_EE_NOVARIANTRETURN 0x1a1d
+
+#define IDS_EE_PATH_HAS_IMPROPER_CHAR 0x1a1f
+#define IDS_EE_PATH_ILLEGAL 0x1a20
+
+#define IDS_CLASSLOAD_BADOVERLAP 0x1a21
+
+#define IDS_EE_SID_TIMEOUT 0x1a22
+
+#define IDS_EE_INVALID_SAFEARRAY 0x1a23
+
+#define IDS_EE_METHOD_NOT_FOUND_ON_EV_PROV 0x1a24
+#define IDS_EE_BAD_COMEVENTITF_CLASS 0x1a25
+
+#define IDS_EE_INVALID_STRONGNAME 0x1a26
+#define IDS_EE_INVALID_STRONGNAME_TITLE 0x1a27
+
+#define IDS_EE_INVALID_DELEGATE_LAYOUT 0x1a28
+
+#define IDS_EE_COREXEMAIN_FAILED_TITLE 0x1a29
+#define IDS_EE_COREXEMAIN_FAILED_TEXT 0x1a2a
+#define IDS_EE_COREXEMAIN2_FAILED_TITLE 0x1a2b
+#define IDS_EE_COREXEMAIN2_FAILED_TEXT 0x1a2c
+
+#define IDS_EE_PATH_INVALID_UNCPATH 0x1a2d
+
+#define IDS_EE_ICUSTOMMARSHALERNOTIMPL 0x1a2e
+#define IDS_EE_GETINSTANCENOTIMPL 0x1a2f
+
+#define IDS_EE_BADMARSHAL_CUSTOMMARSHALER 0x1a30
+
+#define IDS_CLASSLOAD_COMIMPCANNOTHAVELAYOUT 0x1a31
+#define IDS_EE_INVALIDCOMDEFITF 0x1a32
+#define IDS_EE_COMDEFITFNOTSUPPORTED 0x1a33
+
+#define IDS_EE_GUID_REPRESENTS_NON_VC 0x1a35
+#define IDS_EE_CANNOT_MAP_TO_MANAGED_VC 0x1a36
+
+#define IDS_EE_MARSHAL_UNMAPPABLE_CHAR 0x1a37
+
+#define IDS_EE_BADMARSHAL_BADMETADATA 0x1a39
+#define IDS_EE_BADMARSHAL_SAFEHANDLENATIVETOCOM 0x1a3a
+#define IDS_EE_BADMARSHAL_ABSTRACTOUTSAFEHANDLE 0x1a3b
+#define IDS_EE_BADMARSHAL_RETURNSHCOMTONATIVE 0x1a3c
+#define IDS_EE_BADMARSHAL_SAFEHANDLE 0x1a3d
+
+#define IDS_EE_SAFEHANDLECLOSED 0x1a3f
+#define IDS_EE_SAFEHANDLECANNOTSETHANDLE 0x1a40
+#define IDS_EE_SH_FIELD_INVALID_OPERATION 0x1a41
+#define IDS_EE_CANNOT_CREATE_SAFEHANDLE_FIELD 0x1a42
+
+#define IDS_ENCODEDPERMSETCOLLECTION_DECODEFAILURE 0x1a43
+
+#define IDS_EE_BADMARSHAL_ABSTRACTRETSAFEHANDLE 0x1a44
+#define IDS_EE_SH_IN_VARIANT_NOT_SUPPORTED 0x1a47
+#define IDS_CLASSLOAD_SH_SUBCLASS_FINALIZER 0x1a45
+
+#define IDS_EE_BADMARSHAL_SYSARRAY 0x1a48
+#define IDS_EE_VAR_WRAP_IN_VAR_NOT_SUPPORTED 0x1a49
+#define IDS_EE_RECORD_NON_SUPPORTED_FIELDS 0x1a4a
+
+#define IDS_CLASSLOAD_TYPEWRONGNUMGENERICARGS 0x1a4b
+#define IDS_CLASSLOAD_METHODWRONGNUMGENERICARGS 0x1a4c
+#define IDS_CLASSLOAD_NSTRUCT_NEGATIVE_OFFSET 0x1a4d
+
+#define IDS_EE_THREAD_PRIORITY_FAIL 0x1a4e
+
+#define IDS_SERIALIZATION_NONSERTYPE 0x1a4f
+#define IDS_SERIALIZATION_CTOR_NOT_FOUND 0x1a50
+#define IDS_SERIALIZATION_MISSING_FIELD 0x1a51
+#define IDS_SERIALIZATION_WRONGFIELDTYPE 0x1a52
+#define IDS_SERIALIZATION_UNRESOLVED_SPECIAL_OBJECT 0x1a53
+#define IDS_SERIALIZATION_UNRESOLVED_TYPE 0x1a54
+
+#define IDS_REMOTING_SERVER_DISCONNECTED 0x1a55
+#define IDS_REMOTING_METHODMISSING 0x1a56
+
+#define IDS_EE_PATH_GLOBALROOT 0x1a58
+#define IDS_CLASSLOAD_INVALIDINSTANTIATION 0x1a59
+
+#define IDS_EE_CLASSLOAD_INVALIDINSTANTIATION 0x1a59
+#define IDS_EE_BADMARSHALFIELD_ZEROLENGTHFIXEDSTRING 0x1a5a
+
+#define IDS_VER_E_FORMATTING 0x1a5b
+#define IDS_VER_E_ILERROR 0x1a5c
+#define IDS_VER_E_GLOBAL 0x1a5d
+#define IDS_VER_E_MDTOKEN 0x1a5e
+
+#define IDS_EE_CODEEXECUTION_IN_INTROSPECTIVE_ASSEMBLY 0x1a61
+
+#define IDS_EE_BADMARSHAL_CRITICALHANDLENATIVETOCOM 0x1a62
+#define IDS_EE_BADMARSHAL_ABSTRACTOUTCRITICALHANDLE 0x1a63
+#define IDS_EE_BADMARSHAL_RETURNCHCOMTONATIVE 0x1a64
+#define IDS_EE_BADMARSHAL_CRITICALHANDLE 0x1a65
+
+#define IDS_EE_CRITICALHANDLECLOSED 0x1a67
+#define IDS_EE_CH_FIELD_INVALID_OPERATION 0x1a68
+#define IDS_EE_CANNOT_CREATE_CRITICALHANDLE_FIELD 0x1a69
+
+#define IDS_EE_BADMARSHAL_ABSTRACTRETCRITICALHANDLE 0x1a6a
+#define IDS_EE_CH_IN_VARIANT_NOT_SUPPORTED 0x1a6b
+#define IDS_CLASSLOAD_CH_SUBCLASS_FINALIZER 0x1a6c
+
+#define IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_INTROSPECTION 0x1a6d
+#define IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_EXECUTION 0x1a6e
+
+#define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_IMPLICIT_OVERRIDE 0x1a6f
+#define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_IMPLICIT_IMPLEMENTATION 0x1a70
+#define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_LOCAL_METHOD_IMPL 0x1a71
+#define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_PARENT_METHOD_IMPL 0x1a72
+#define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_INTERFACE_METHOD_IMPL 0x1a73
+
+#define IDS_EE_LOAD_CIRCULAR_DEPENDENCY 0x1a74
+
+#define IDS_EE_NDIRECT_BADNATL_VARARGS_CALLCONV 0x1a75
+#define IDS_SERIALIZATION_NONFREEZABLE_TYPE 0x1a76
+#define IDS_EE_REFLECTIONONLYGETTYPE_NOASSEMBLY 0x1a77
+
+#define IDS_CLASSLOAD_MODULE_RESOLVE_INTROSPECTION_MISMATCH 0x1a78
+
+#define IDS_CLASSLOAD_VARIANCE_IN_METHOD_ARG 0x1a79
+#define IDS_CLASSLOAD_VARIANCE_IN_METHOD_RESULT 0x1a7a
+#define IDS_CLASSLOAD_VARIANCE_IN_BASE 0x1a7b
+#define IDS_CLASSLOAD_VARIANCE_IN_INTERFACE 0x1a7c
+#define IDS_CLASSLOAD_VARIANCE_IN_CONSTRAINT 0x1a7d
+#define IDS_CLASSLOAD_VARIANCE_CLASS 0x1a7e
+#define IDS_CLASSLOAD_BADVARIANCE 0x1a7f
+
+#define IDS_CLASSLOAD_OVERLAPPING_INTERFACES 0x1a80
+#define IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY 0x1a81
+#define IDS_EE_CONFIGPARSER_ERROR_CAPTION 0x1a82
+#define IDS_EE_CONFIGPARSER_ERROR 0x1a83
+#define IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC 0x1a84
+
+#define IDS_EE_IJWLOAD_CROSSVERSION_DISALLOWED 0x1a85
+
+#define IDS_EE_CANNOT_HAVE_ASSEMBLY_SPEC 0x1a86
+#define IDS_EE_NEEDS_ASSEMBLY_SPEC 0x1a87
+
+#define IDS_EE_FILELOAD_ERROR_GENERIC 0x1a88
+
+#define IDS_EE_BADMARSHAL_UNSUPPORTED_SIG 0x1a89
+#define IDS_EE_BADMARSHAL_STRINGARRAY 0x1a8a
+#define IDS_EE_BADMARSHAL_OBJECTARRAY 0x1a8b
+#define IDS_EE_BADMARSHAL_DATETIMEARRAY 0x1a8c
+#define IDS_EE_BADMARSHAL_DECIMALARRAY 0x1a8d
+#define IDS_EE_BADMARSHAL_SAFEHANDLEARRAY 0x1a8f
+#define IDS_EE_BADMARSHAL_CRITICALHANDLEARRAY 0x1a90
+#define IDS_EE_BADMARSHAL_BADSAFEARRAYSUBTYPE 0x1a91
+#define IDS_EE_BADMARSHALFIELD_ERROR_MSG 0x1a92
+#define IDS_EE_BADMARSHAL_ERROR_MSG 0x1a93
+#define IDS_SERIALIZATION_BAD_ISER_TYPE 0x1a94
+#define IDS_EE_REFLECTIONONLY_LOADFROM 0x1a95
+#define IDS_EE_REFLECTIONONLY_LOADFAILURE 0x1a96
+#define IDS_EE_COM_INVISIBLE_PARENT 0x1a97
+
+#define IDS_EE_REMOTE_COGETCLASSOBJECT_FAILED 0x1a98
+#define IDS_EE_CREATEINSTANCE_FAILED 0x1a99
+#define IDS_EE_CREATEINSTANCE_LIC_FAILED 0x1a9a
+
+#define IDS_EE_RCW_INVALIDCAST_ITF 0x1a9b
+#define IDS_EE_RCW_INVALIDCAST_EVENTITF 0x1a9c
+#define IDS_EE_RCW_INVALIDCAST_IENUMERABLE 0x1a9d
+#define IDS_EE_RCW_INVALIDCAST_MNGSTDITF 0x1a9e
+#define IDS_EE_RCW_INVALIDCAST_COMOBJ_TO_MD 0x1a9f
+#define IDS_EE_RCW_INVALIDCAST_TO_NON_COMOBJTYPE 0x1aa0
+#define IDS_EE_RCW_INVALIDCAST_MD_TO_MD 0x1aa1
+
+#define IDS_EE_GENERIC 0x1aa2
+#define IDS_EE_BADMARSHAL_GENERICS_RESTRICTION 0x1aa3
+
+#define IDS_EE_THREAD_ABORT 0x1aa4
+#define IDS_EE_THREAD_INTERRUPTED 0x1aa5
+#define IDS_EE_OUT_OF_MEMORY 0x1aa6
+
+#define IDS_EE_CANNOT_LOAD_JIT 0x1aa7
+#define IDS_EE_PROFILING_FAILURE 0x1aa8
+#define IDS_EE_ATTEMPT_TO_CREATE_GENERIC_CCW 0x1aa9
+
+#define IDS_EE_IJWLOAD_MULTIRUNTIME_DISALLOWED 0x1aaa
+#define IDS_EE_COMIMPORT_METHOD_NO_INTERFACE 0x1aab
+#define IDS_EE_OUT_OF_MEMORY_WITHIN_RANGE 0x1aac
+#define IDS_EE_ARRAY_DIMENSIONS_EXCEEDED 0x1aad
+
+#define IDS_WATSON_DEBUG_BREAK_INTRO_BOLD 0x1ab0
+#define IDS_WATSON_DEBUG_BREAK_INTRO_REG 0x1ab1
+#define IDS_EE_CODEEXECUTION_ASSEMBLY_FOR_PASSIVE_DOMAIN_ONLY 0x1ab2
+#define IDS_CLASSLOAD_MI_CANNOT_OVERRIDE 0x1ab3
+#define IDS_EE_WRONG_METADATA_VERSION 0x1ab4
+#define IDS_CLASSLOAD_COLLECTIBLEFIXEDVTATTR 0x1ab6
+#define IDS_CLASSLOAD_EQUIVALENTBADTYPE 0x1ab7
+#define IDS_CLASSLOAD_EQUIVALENTNOTTRUSTED 0x1ab8
+#define IDS_CLASSLOAD_EQUIVALENTTRANSPARENCY 0x1ab9
+#define IDS_CLASSLOAD_EQUIVALENTNOTPUBLIC 0x1aba
+#define IDS_EE_CODEEXECUTION_CONTAINSGENERICVAR 0x1abb
+#define IDS_CLASSLOAD_WRONGCPU 0x1abc
+#define IDS_EE_CREATEINSTANCEFROMAPP_FAILED 0x1abd
+#define IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE 0x1abe
+#define IDS_EE_WINRT_LOADFAILURE 0x1abf
+#define IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE_THIRDPARTY 0x1ac0
+#define IDS_EE_REFLECTIONONLY_WINRT_INVALIDASSEMBLY 0x1ac1
+#define IDS_EE_WINRT_THIRDPARTY_NOTSUPPORTED 0x1ac2
+
+#define IDS_EE_SIMD_NGEN_DISALLOWED 0x1ac3
+#define IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED 0x1ac4
+
+#define BFA_INVALID_FILE_TOKEN 0x2000
+#define BFA_INVALID_TOKEN_TYPE 0x2001
+#define BFA_INVALID_ENTRYPOINT_TOKEN 0x2002
+#define BFA_INVALID_TOKEN 0x2003
+#define BFA_INVALID_TOKEN_VTABLE 0x2004
+#define BFA_UNABLE_TO_GET_NESTED_PROPS 0x2005
+#define BFA_METHOD_TOKEN_OUT_OF_RANGE 0x2006
+#define BFA_METHOD_NAME_TOO_LONG 0x2007
+#define BFA_METHOD_NAME_NOT_TERMINATED 0x2008
+#define BFA_METHOD_IN_A_ENUM 0x2009
+#define BFA_METHOD_WITH_NONZERO_RVA 0x200a
+#define BFA_ABSTRACT_METHOD_WITH_RVA 0x200b
+#define BFA_RUNTIME_METHOD_WITH_RVA 0x200c
+#define BFA_INTERNAL_METHOD_WITH_RVA 0x200d
+#define BFA_AB_METHOD_IN_AB_CLASS 0x200e
+#define BFA_NONVIRT_AB_METHOD 0x200f
+#define BFA_NONAB_NONCCTOR_METHOD_ON_INT 0x2010
+#define BFA_VIRTUAL_PINVOKE_METHOD 0x2011
+#define BFA_VIRTUAL_STATIC_METHOD 0x2012
+#define BFA_VIRTUAL_INSTANCE_CTOR 0x2013
+#define BFA_VIRTUAL_NONAB_INT_METHOD 0x2014
+#define BFA_NONVIRT_INST_INT_METHOD 0x2015
+#define BFA_SYNC_METHOD_IN_VT 0x2016
+#define BFA_NONSTATIC_GLOBAL_METHOD 0x2017
+#define BFA_GLOBAL_INST_CTOR 0x2018
+#define BFA_BAD_PLACE_FOR_GENERIC_METHOD 0x2019
+#define BFA_GENERIC_METHOD_RUNTIME_IMPL 0x201a
+#define BFA_BAD_RUNTIME_IMPL 0x201b
+#define BFA_BAD_FLAGS_ON_DELEGATE 0x201c
+#define BFA_UNKNOWN_DELEGATE_METHOD 0x201d
+#define BFA_GENERIC_METHODS_INST 0x201e
+#define BFA_BAD_FIELD_TOKEN 0x201f
+#define BFA_INVALID_FIELD_ACC_FLAGS 0x2020
+#define BFA_FIELD_LITERAL_AND_INIT 0x2021
+#define BFA_NONSTATIC_GLOBAL_FIELD 0x2022
+#define BFA_INSTANCE_FIELD_IN_INT 0x2023
+#define BFA_INSTANCE_FIELD_IN_ENUM 0x2024
+#define BFA_NONVIRT_NO_SEARCH 0x2025
+#define BFA_CANT_BE_INIT_METHOD 0x2026
+#define BFA_MANAGED_NATIVE_NYI 0x2027
+#define BFA_BAD_IMPL_FLAGS 0x2028
+#define BFA_BAD_UNMANAGED_ENTRY_POINT 0x2029
+#define BFA_GENCODE_NOT_BE_VARARG 0x202b
+#define BFA_CANNOT_INHERIT_FROM_DELEGATE 0x202c
+#define BFA_DELEGATE_CLASS_NOTSEALED 0x202d
+#define BFA_ENCLOSING_TYPE_NOT_FOUND 0x202e
+#define BFA_ILLEGAL_DELEGATE_METHOD 0x202f
+#define BFA_MISSING_DELEGATE_METHOD 0x2030
+#define BFA_MULT_TYPE_SAME_NAME 0x2031
+#define BFA_INVALID_METHOD_TOKEN 0x2032
+#define BFA_CANT_GET_LINKREF 0x2033
+#define BFA_ECALLS_MUST_BE_IN_SYS_MOD 0x2034
+#define BFA_CANT_GET_CLASSLAYOUT 0x2035
+#define BFA_CALLCONV_NOT_LOCAL_SIG 0x2036
+#define BFA_BAD_CLASS_TOKEN 0x2037
+#define BFA_BAD_IL_RANGE 0x2038
+#define BFA_METHODDEF_WO_TYPEDEF_PARENT 0x2039
+#define BFA_METHODDEF_PARENT_NO_MEMBERS 0x203a
+#define BFA_MUST_USE_MEMBERREF_W_FIELD_GEN 0x203b
+#define BFA_INVALID_TOKEN_IN_MANIFESTRES 0x203c
+#define BFA_EMPTY_ASSEMDEF_NAME 0x203d
+#define BFA_BAD_IL 0x203e
+#define BFA_CLASSLOAD_VALUETYPEMISMATCH 0x203f
+#define BFA_METHODDECL_NOT_A_METHODDEF 0x2040
+#define BFA_DUPLICATE_DELEGATE_METHOD 0x2041
+#define BFA_ECALLS_MUST_HAVE_ZERO_RVA 0x2042
+#define BFA_METADATA_CORRUPT 0x2043
+#define BFA_BAD_SIGNATURE 0x2044
+#define BFA_TYPEREG_NAME_TOO_LONG 0x2045
+#define BFA_BAD_TYPEREF_TOKEN 0x2046
+#define BFA_BAD_CLASS_INT_CA 0x2047
+#define BFA_BAD_CLASS_INT_CA_FORMAT 0x2048
+#define BFA_BAD_COMPLUS_SIG 0x2049
+#define BFA_BAD_ELEM_IN_SIZEOF 0x204b
+
+#define IDS_CLASSLOAD_TOO_MANY_VTS_METHODS 0x204c
+#define IDS_CLASSLOAD_INVALID_VTS_SIG 0x204d
+#define IDS_EE_VTRECORD_SECURITY 0x204e
+#define IDS_CLASSLOAD_INTERFACE_NO_ACCESS 0x204f
+
+#define BFA_BAD_CA_HEADER 0x2050
+#define BFA_BAD_CA_STRING 0x2051
+#define BFA_BAD_STRING_TOKEN 0x2052
+#define BFA_BAD_STRING_TOKEN_RANGE 0x2053
+#define BFA_FIXUP_WRONG_PLATFORM 0x2054
+#define BFA_UNEXPECTED_GENERIC_TOKENTYPE 0x2055
+#define BFA_MDARRAY_BADRANK 0x2056
+#define BFA_SDARRAY_BADRANK 0x2057
+#define BFA_BAD_PACKING_SIZE 0x2058
+#define BFA_UNEXPECTED_ARRAY_TYPE 0x2059
+#define BFA_BAD_VISIBILITY 0x205a
+#define BFA_FAMILY_ON_GLOBAL 0x205b
+#define BFA_NOFIND_EXPORTED_TYPE 0x205c
+#define BFA_NOT_AN_ARRAY 0x205d
+#define BFA_EXPECTED_METHODDEF_OR_MEMBERREF 0x205e
+#define BFA_EXPECTED_INTERFACE 0x205f
+
+#define IDS_CLASSLOAD_BAD_METHOD_COUNT 0x2062
+#define IDS_CLASSLOAD_BAD_FIELD_COUNT 0x2063
+#define IDS_CLASSLOAD_MUST_BE_BYVAL 0x2064
+#define IDS_CLASSLOAD_BAD_VARIANCE_SIG 0x2065
+#define IDS_CLASSLOAD_VARIANCE_IN_DELEGATE 0x2066
+
+#define BFA_INVALID_CA_TYPESPEC 0x2067
+#define BFA_UNEXPECTED_FIELD_SIGNATURE 0x2068
+#define BFA_UNEXPECTED_TOKEN_AFTER_CLASSVALTYPE 0x2069
+#define BFA_FNPTR_CANNOT_BE_A_FIELD 0x206a
+#define BFA_FNPTR_CANNOT_BE_GENERIC 0x206b
+#define BFA_UNEXPECTED_TOKEN_AFTER_GENINST 0x206c
+#define BFA_ONLY_VOID_PTR_IN_ARGS 0x206d
+#define BFA_TYPEDBYREFCANNOTHAVEBYREF 0x206e
+
+#define IDS_CLASSLOAD_INVALID_VTS_METHOD 0x206f
+#define IDS_CLASSLOAD_MI_BAD_SIG 0x2070
+
+#define IDS_EE_TOOMANYASSOCIATES 0x2071
+#define IDS_EE_TOOMANYFIELDS 0x2072
+
+#define IDS_EE_NDIRECT_GETPROCADDRESS_NONAME 0x2073
+#define IDS_CLASSLOAD_GENERIC_CONTEXT_BOUND_OBJECT 0x2074
+#define IDS_CLASSLOAD_CONTEXT_BOUND_GENERIC_METHOD 0x2075
+#define IDS_EE_CLASS_CONSTRAINTS_VIOLATION 0x2076
+#define IDS_EE_METHOD_CONSTRAINTS_VIOLATION 0x2077
+#define IDS_CLASSLOAD_TOO_MANY_METHODS 0x2078
+#define IDS_CLASSLOAD_ENUM_EXTRA_GENERIC_TYPE_PARAM 0x2079
+#define IDS_DBI_ERRLOG_CATAGORY 0x207A
+#define IDS_DBI_EXCEPTION_ON_UNKNOWN_THREAD_MSG 0x207B
+
+#define IDS_EE_NOTSUPPORTED_CATCHBEFORETRY 0x207c
+
+#define IDS_CLASSLOAD_GENERICTYPE_RECURSIVE 0x207D
+#define IDS_LOADINTROSPECTION_DISALLOWED 0x207E
+#define IDS_EE_JIT_COMPILER_ERROR 0x207F
+#define IDS_UNMARSHALABLE_DEMAND_OBJECT 0x2080
+#define BFA_TYPE_FWD_CHAIN_TOO_LONG 0x2081
+
+#define IDS_ER_APPLICATION 0x2082
+#define IDS_ER_UNKNOWN 0x2083
+#define IDS_ER_FRAMEWORK_VERSION 0x2084
+#define IDS_ER_UNHANDLEDEXCEPTION 0x2085
+#define IDS_ER_UNHANDLEDEXCEPTIONMSG 0x2086
+#define IDS_ER_MANAGEDFAILFAST 0x2087
+#define IDS_ER_MANAGEDFAILFASTMSG 0x2088
+#define IDS_ER_UNMANAGEDFAILFAST 0x2089
+#define IDS_ER_STACK_OVERFLOW 0x208a
+#define IDS_ER_STACK 0x208b
+#define IDS_ER_WORDAT 0x208c
+#define IDS_ER_UNMANAGEDFAILFASTMSG 0x208d
+#define IDS_ER_UNHANDLEDEXCEPTIONINFO 0x208e
+#define IDS_ER_MESSAGE_TRUNCATE 0x208f
+
+#define IDS_EE_OBJECT_TO_VARIANT_NOT_SUPPORTED 0x2090
+#define IDS_EE_OBJECT_TO_ITF_NOT_SUPPORTED 0x2091
+
+#define IDS_INHERITIANCE_RULES_VIOLATED 0x2092
+#define IDS_CRITICAL_METHOD_ACCESS_DENIED 0x2093
+#define IDS_CRITICAL_TYPE_ACCESS_DENIED 0x2094
+#define IDS_APPLICATION_ASSEMBLY_EXEC_DENIED 0x2095
+#define IDS_REFLECTION_METHOD_ACCESS_DENIED 0x2096
+#define IDS_METHOD_INHERITANCE_RULES_VIOLATED 0x2097
+#define IDS_TYPE_INHERITANCE_RULES_VIOLATED 0x2098
+
+#define IDS_EE_BADMARSHALFIELD_DECIMAL 0x2099
+
+#define IDS_EE_CANNOTCASTSAME 0x209a
+#define IDS_EE_CANNOTCAST_HELPER_BYTE 0x209b
+#define IDS_EE_CANNOTCAST_HELPER_PATH 0x209c
+
+#define IDS_CLASSLOAD_COLLECTIBLE_CONTEXT_BOUND_OBJECT 0x209d
+
+#define IDS_E_LOAD_CRITICAL_IN_PARTIAL_TRUST 0x2100
+#define IDS_E_TRANSPARENT_CALL_LINKDEMAND 0x2101
+#define IDS_E_TRANSPARENT_METHOD_CRITICAL_TYPE 0x2102
+#define IDS_E_UNKNOWN_SECURITY_RULESET 0x2103
+#define IDS_E_UNTRUSTED_APPDOMAIN_MANAGER 0x2104
+#define IDS_E_LOADFROM_REMOTE_SOURCE 0x2106
+
+// For ForwardInteropStubAttribute
+#ifdef FEATURE_COMINTEROP
+#define IDS_EE_INTEROP_STUB_CA_MUST_BE_WITHIN_SAME_ASSEMBLY 0x2107
+#define IDS_EE_INTEROP_STUB_CA_STUB_CLASS_MUST_NOT_BE_GENERIC 0x2108
+#define IDS_EE_INTEROP_STUB_CA_STUB_CLASS_MUST_NOT_BE_INTERFACE 0x2109
+#define IDS_EE_INTEROP_STUB_CA_STUB_METHOD_MISSING 0x2110
+#define IDS_EE_INTEROP_STUB_CA_NO_ACCESS_TO_STUB_METHOD 0x2111
+#endif
+
+#define IDS_EE_INTEROP_CODE_SIZE_COMMENT 0x2112
+
+#define BFA_REFERENCE_ASSEMBLY 0x2113
+
+#define IDS_E_FIELDACCESS 0x2114
+#define IDS_E_METHODACCESS 0x2115
+#define IDS_E_TYPEACCESS 0x2116
+#define IDS_E_CRITICAL_FIELD_ACCESS_DENIED 0x2117
+#define IDS_E_CRITICAL_METHOD_ACCESS_DENIED 0x2118
+#define IDS_E_CRITICAL_TYPE_ACCESS_DENIED 0x2119
+
+#define IDS_E_TRANSPARENT_CALL_NATIVE 0x2120
+#define IDS_E_TRANSPARENT_REFLECTION 0x2121
+
+#ifdef FEATURE_CORECLR
+#define IDS_E_DELEGATE_BINDING_TRANSPARENCY 0x2122
+#endif
+
+#define IDS_E_ACCESSING_PRIVATE_FRAMEWORK_CODE 0x2123
+
+#ifdef FEATURE_CORECLR
+#define IDS_E_DELEGATE_FULLTRUST_ARPIC_1 0x2124
+#define IDS_E_DELEGATE_FULLTRUST_ARPIC_2 0x2125
+#endif
+
+#define IDS_ACCESS_EXCEPTION_CONTEXT_LEVEL2_APTCA 0x2200
+#define IDS_ACCESS_EXCEPTION_CONTEXT_APTCA_KILLBIT 0x2201
+#define IDS_ACCESS_EXCEPTION_CONTEXT_CONDITIONAL_APTCA 0x2202
+#define IDS_ACCESS_EXCEPTION_CONTEXT_PT_TRANSPARENT 0x2203
+
+#define IDS_E_LOADFROM_REMOTE_SOURCE_MOTW 0x2204
+
+#ifdef FEATURE_PREJIT
+#define BFA_MISSING_IBC_EXTERNAL_TYPE 0x2400
+#define BFA_MISSING_IBC_EXTERNAL_METHOD 0x2401
+#endif
+
+// Profiler error messages for event log
+#define IDS_E_PROF_NO_CLSID 0x2500
+#define IDS_E_PROF_INTERNAL_INIT 0x2501
+#define IDS_E_PROF_BAD_CLSID 0x2502
+#define IDS_E_PROF_NO_CALLBACK_IFACE 0x2503
+#define IDS_E_PROF_CCI_FAILED 0x2504
+#define IDS_E_PROF_INIT_CALLBACK_FAILED 0x2505
+#define IDS_PROF_SUPPLEMENTARY_INFO 0x2506
+#define IDS_PROF_LOAD_COMPLETE 0x2507
+#define IDS_E_PROF_BAD_PATH 0x2508
+#define IDS_E_PROF_ATTACH_INIT 0x2509
+#define IDS_E_PROF_ATTACHTHREAD_INIT 0x250A
+#define IDS_E_PROF_CONNECT_TO_TRIGGER 0x250B
+#define IDS_E_PROF_NO_ATTACH_REQ 0x250C
+#define IDS_E_PROF_PIPE_RCV 0x250D
+#define IDS_E_PROF_NOT_ATTACHABLE 0x250E
+#define IDS_E_PROF_UNHANDLED_EXCEPTION_ON_LOAD 0x250F
+#define IDS_E_PROF_INVALID_MSG 0x2510
+#define IDS_E_PROF_PROFILER_ALREADY_ACTIVE 0x2511
+#define IDS_PROF_ATTACH_REQUEST_RECEIVED 0x2512
+#define IDS_PROF_DETACH_INITIATED 0x2513
+#define IDS_PROF_DETACH_COMPLETE 0x2514
+#define IDS_PROF_DETACH_THREAD_ERROR 0x2515
+#define IDS_PROF_CANCEL_ACTIVATION 0x2516
+#define IDS_PROF_V2PROFILER_DISABLED 0x2517
+#define IDS_PROF_V2PROFILER_ENABLED 0x2518
+#define IDS_PROF_V2PROFILER_ALREADY_LOADED 0x2519
+#define IDS_PROF_PROFILER_DISABLED 0x251A
+
+#define IDS_ER_CODECONTRACT_FAILED 0x251B
+#define IDS_ER_CODECONTRACT_DETAILMSG 0x251C
+
+#define IDS_E_PROF_TIMEOUT_WAITING_FOR_CONCURRENT_GC 0x251D
+
+
+#ifdef FEATURE_CORECLR
+#define IDS_EE_LINK_FOR_ERROR_MESSAGES 0x2600
+#define IDS_EE_LINK_FOR_DEBUGGING_MESSAGES 0x2601
+#endif
+
+#define IDS_DIALOG_BOX_ABORT_BUTTON 0x2602
+#define IDS_DIALOG_BOX_DEBUG_BUTTON 0x2603
+#define IDS_DIALOG_BOX_IGNORE_BUTTON 0x2604
+
+#ifdef FEATURE_COMINTEROP
+#define IDS_EE_BADMARSHALFIELD_NULL_HSTRING 0x2605
+#define IDS_EE_BADMARSHAL_WINRT_MARSHAL_AS 0x2606
+#define IDS_EE_BADMARSHALARRAY_NULL_HSTRING 0x2607
+#define IDS_EE_BADMARSHAL_WINRT_ILLEGAL_TYPE 0x2608
+#define IDS_EE_STRUCTLAYOUT_WINRT 0x260a
+#define IDS_EE_PRESERVESIG_WINRT 0x260b
+#define IDS_EE_DELEGATEPINVOKE_WINRT 0x260c
+#define IDS_EE_BADMARSHAL_WINRT_MISSING_GUID 0x260d
+#define IDS_EE_BADMARSHAL_DEFAULTIFACE_NOT_WINRT_IFACE 0x260f
+
+#define IDS_EE_BADMARSHAL_DEFAULTIFACE_NOT_SUBTYPE 0x2610
+#define IDS_EE_BADMARSHAL_WINRT_DELEGATE 0x2611
+#define IDS_EE_BADMARSHAL_DATETIMEOFFSET 0x2614
+#define IDS_EE_WINRT_IENUMERABLE_BAD_CALL 0x2615
+#define IDS_EE_WINRT_IENUMERABLE_BAD_CAST 0x2616
+#define IDS_EE_WINRT_INTERFACE_WITHOUT_GUID 0x2617
+#define IDS_EE_WINRT_IID_ILLEGALTYPE 0x2619
+#define IDS_EE_WINRT_IID_NODEFAULTINTERFACE 0x261A
+#define IDS_EE_WINRT_ATTRIBUTES_NOT_INVOKABLE 0x261B
+#define IDS_EE_WINRT_TYPE_IN_ORDINARY_ASSEMBLY 0x261C
+
+#define IDS_EE_WINRT_TYPE_NOT_REGISTERED 0x261F
+#define IDS_EE_WINRT_NOT_FACTORY_FOR_TYPE 0x2620
+#define IDS_EE_INVALIDARG_WINRT_INVALIDURI 0x2624
+#define IDS_EE_BADMARSHAL_WINRT_COPYCTOR 0x2625
+
+#define IDS_EE_WINRT_INVALID_FACTORY_FOR_TYPE 0x2628
+#define IDS_EE_CANNOTCAST_NOMARSHAL 0x2629
+
+#define BFA_WINRT_INVALID_NAMESPACE_FOR_TYPE 0x262a
+#define IDS_EE_BADMARSHAL_NULLABLE_RESTRICTION 0x262d
+#endif // FEATURE_COMINTEROP
+
+
+#define IDS_EE_TORNSTATE 0x2613
+
+#ifdef FEATURE_WINDOWSPHONE
+#define IDS_EE_INTEROP_DLL_IMPORT_ON_USER_METHOD 0x262b
+#endif
+
+#ifndef FEATURE_CORECLR
+#define IDS_EE_ASSEMBLY_ON_DENY_LIST 0x262c
+#endif
+
+#ifdef FEATURE_COMINTEROP
+#define IDS_EE_WINRT_WEAKREF_BAD_TYPE 0x262e
+#endif // FEATURE_COMINTEROP
+
+#ifdef FEATURE_CORECLR
+#define IDS_EE_BADMARSHAL_TYPE_ANSIBSTR 0x262f
+#define IDS_EE_BADMARSHAL_TYPE_VBBYVALSTR 0x2630
+#define IDS_EE_BADMARSHAL_TYPE_REFERENCECUSTOMMARSHALER 0x2631
+#define IDS_EE_BADMARSHAL_TYPE_VARIANTASOBJECT 0x2632
+#define IDS_EE_BADMARSHAL_TYPE_ASANYA 0x2633
+#define IDS_EE_BADMARSHAL_TYPE_IDISPATCH 0x2634
+#define IDS_EE_ERROR_IDISPATCH 0x2635
+#endif // FEATURE_CORECLR
+
+#ifdef FEATURE_HOST_ASSEMBLY_RESOLVER
+#define IDS_HOST_ASSEMBLY_RESOLVER_ASSEMBLY_ALREADY_LOADED_IN_CONTEXT 0x2636
+#define IDS_HOST_ASSEMBLY_RESOLVER_DYNAMICALLY_EMITTED_ASSEMBLIES_UNSUPPORTED 0x2637
+#define IDS_HOST_ASSEMBLY_RESOLVER_INCOMPATIBLE_BINDING_CONTEXT 0x2638
+#define IDS_HOST_ASSEMBLY_RESOLVER_INCOMPATIBLE_TPA_BINDING_CONTEXT 0x2639
+#endif // FEATURE_HOST_ASSEMBLY_RESOLVER
+
+#define IDS_NATIVE_IMAGE_CANNOT_BE_LOADED_MULTIPLE_TIMES 0x263a
+
+
diff --git a/src/dlls/mscorrc/small/.gitmirror b/src/dlls/mscorrc/small/.gitmirror
new file mode 100644
index 0000000000..f507630f94
--- /dev/null
+++ b/src/dlls/mscorrc/small/.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/mscorrc/small/CMakeLists.txt b/src/dlls/mscorrc/small/CMakeLists.txt
new file mode 100644
index 0000000000..7c359e075e
--- /dev/null
+++ b/src/dlls/mscorrc/small/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_definitions(-DFX_VER_INTERNALNAME_STR=mscorrc.dll)
+
+add_library_clr(mscorrc SHARED
+ ../mscorrc.small.rc
+)
+
+# add the install targets
+install_clr (mscorrc) \ No newline at end of file
diff --git a/src/dlls/mscorrc/small/mscorrc.nativeproj b/src/dlls/mscorrc/small/mscorrc.nativeproj
new file mode 100644
index 0000000000..994589aa91
--- /dev/null
+++ b/src/dlls/mscorrc/small/mscorrc.nativeproj
@@ -0,0 +1,22 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="dogfood">
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
+
+ <PropertyGroup>
+ <BuildCoreBinaries>true</BuildCoreBinaries>
+ <BuildSysBinaries>true</BuildSysBinaries>
+ <OutputName>mscorrc</OutputName>
+ <TargetType>DYNLINK</TargetType>
+ <LinkSubsystem>windows</LinkSubsystem>
+ <LinkResourceOnlyDll>true</LinkResourceOnlyDll>
+ <IsProjectKLibrary>true</IsProjectKLibrary>
+ <IsTestNetCoreRuntimeLibrary>true</IsTestNetCoreRuntimeLibrary>
+ <IsPhoneLibrary>true</IsPhoneLibrary>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <RCResourceFile Include="..\mscorrc.small.rc" />
+ </ItemGroup>
+
+ <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.targets" />
+
+</Project>