add_definitions(-DFEATURE_MANUALLY_MANAGED_CARD_BUNDLES)
endif(CLR_CMAKE_PLATFORM_ARCH_AMD64 OR CLR_CMAKE_PLATFORM_ARCH_ARM64)
-if(WIN32)
- add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_VERSIONING_LOG>)
-endif(WIN32)
if(NOT CLR_CMAKE_PLATFORM_UNIX)
add_definitions(-DFEATURE_WIN32_REGISTRY)
endif(NOT CLR_CMAKE_PLATFORM_UNIX)
assemblybinder.cpp
assemblyidentitycache.cpp
assemblyname.cpp
- bindinglog.cpp
bindertracing.cpp
- cdebuglog.cpp
clrprivbindercoreclr.cpp
coreclrbindercommon.cpp
failurecache.cpp
inc/assemblyversion.inl
inc/bindertypes.hpp
inc/bindertracing.h
- inc/bindinglog.hpp
- inc/bindinglog.inl
inc/bindresult.hpp
inc/bindresult.inl
- inc/cdebuglog.hpp
inc/clrprivbindercoreclr.h
inc/coreclrbindercommon.h
inc/failurecache.hpp
inc/failurecachehashtraits.hpp
inc/fusionassemblyname.hpp
inc/fusionhelpers.hpp
- inc/list.hpp
inc/loadcontext.hpp
inc/loadcontext.inl
inc/stringlexer.hpp
#include "loadcontext.hpp"
#include "bindresult.inl"
#include "failurecache.hpp"
-#ifdef FEATURE_VERSIONING_LOG
-#include "bindinglog.hpp"
-#endif // FEATURE_VERSIONING_LOG
#include "utils.hpp"
#include "variables.hpp"
#include "stringarraylist.h"
#include "strongname.h"
-#ifdef FEATURE_VERSIONING_LOG
-#include "../dlls/mscorrc/fusres.h"
-#endif // FEATURE_VERSIONING_LOG
#define APP_DOMAIN_LOCKED_UNLOCKED 0x02
#define APP_DOMAIN_LOCKED_CONTEXT 0x04
return hr;
}
-
-#ifdef FEATURE_VERSIONING_LOG
- //
- // This function outputs the current binding result
- // and flushes the bind log.
- //
- HRESULT LogBindResult(ApplicationContext *pApplicationContext,
- HRESULT hrLog,
- BindResult *pBindResult)
- {
- HRESULT hr = S_OK;
- BindingLog *pBindingLog = pApplicationContext->GetBindingLog();
-
- if (!pBindingLog->CanLog())
- {
- // For non-logging, return the bind result
- hr = hrLog;
- goto Exit;
- }
-
- IF_FAIL_GO(pBindingLog->LogHR(hrLog));
-
- if ((hrLog == S_OK) && pBindResult->HaveResult())
- {
- IF_FAIL_GO(pBindingLog->LogResult(pBindResult));
- }
-
- IF_FAIL_GO(pBindingLog->Flush());
-
- // For failure-free logging, return the bind result
- hr = hrLog;
-
- Exit:
- // SilverLight does not propagate binding log; therefore kill the information here.
- pApplicationContext->ClearBindingLog();
- return hr;
- }
-
- HRESULT LogAppDomainLocked(ApplicationContext *pApplicationContext,
- DWORD dwLockedReason,
- AssemblyName *pAssemblyName = NULL)
- {
- HRESULT hr = S_OK;
- BindingLog *pBindingLog = pApplicationContext->GetBindingLog();
-
- if (pBindingLog->CanLog())
- {
- PathString info;
- PathString format;
-
- switch (dwLockedReason)
- {
- case APP_DOMAIN_LOCKED_UNLOCKED:
- {
- IF_FAIL_GO(info.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_LOCKED_UNLOCKED));
- }
- break;
- case APP_DOMAIN_LOCKED_CONTEXT:
- {
- PathString displayName;
-
- _ASSERTE(pAssemblyName != NULL);
-
- IF_FAIL_GO(format.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_LOCKED_ASSEMBLY_EXE_CONTEXT));
-
- pAssemblyName->GetDisplayName(displayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE);
-
- info.Printf(format.GetUnicode(), displayName.GetUnicode());
- }
- break;
- default:
- _ASSERTE(0);
- IF_FAIL_GO(E_INVALIDARG);
- break;
- }
-
- IF_FAIL_GO(pBindingLog->Log(info));
- }
-
- Exit:
- return hr;
- }
-
- HRESULT LogAssemblyNameWhereRef(ApplicationContext *pApplicationContext,
- Assembly *pAssembly)
- {
- HRESULT hr = S_OK;
- BindingLog *pBindingLog = pApplicationContext->GetBindingLog();
-
- if (pBindingLog->CanLog())
- {
- PathString info;
-
- IF_FAIL_GO(info.
- LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_LOG_WHERE_REF_NAME));
- IF_FAIL_GO(pBindingLog->LogAssemblyName(info.GetUnicode(),
- pAssembly->GetAssemblyName()));
- }
-
- Exit:
- return hr;
- }
-
- HRESULT LogConfigurationError(ApplicationContext *pApplicationContext,
- AssemblyName *pCulturedManifestName,
- AssemblyName *pLocalPathAssemblyName)
- {
- HRESULT hr = S_OK;
- BindingLog *pBindingLog = pApplicationContext->GetBindingLog();
-
- if (pBindingLog->CanLog())
- {
- PathString tmp;
- PathString culturedManifestDisplayName;
- PathString localPathDisplayName;
- PathString info;
-
- IF_FAIL_GO(tmp.
- LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_LOG_ERRONOUS_MANIFEST_ENTRY));
-
- pCulturedManifestName->GetDisplayName(culturedManifestDisplayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE);
- pLocalPathAssemblyName->GetDisplayName(localPathDisplayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE);
-
- info.Printf(tmp.GetUnicode(),
- culturedManifestDisplayName.GetUnicode(),
- localPathDisplayName.GetUnicode());
- IF_FAIL_GO(pBindingLog->Log(info.GetUnicode()));
- }
-
- Exit:
- return hr;
- }
-#endif // FEATURE_VERSIONING_LOG
-
#ifndef CROSSGEN_COMPILE
HRESULT CreateImageAssembly(IMDInternalImport *pIMetaDataAssemblyImport,
PEKIND PeKind,
if (szCodeBase == NULL)
{
-#ifdef FEATURE_VERSIONING_LOG
- // Log bind
- IF_FAIL_GO(BindingLog::CreateInContext(pApplicationContext,
- pAssemblyName,
- pParentAssembly));
-#endif // FEATURE_VERSIONING_LOG
-
-
IF_FAIL_GO(BindByName(pApplicationContext,
pAssemblyName,
false, // skipFailureCaching
{
PathString assemblyPath(szCodeBase);
-#ifdef FEATURE_VERSIONING_LOG
- // Log bind
- IF_FAIL_GO(BindingLog::CreateInContext(pApplicationContext,
- assemblyPath,
- pParentAssembly));
-#endif // FEATURE_VERSIONING_LOG
-
// Convert URL to full path and block HTTP downloads
IF_FAIL_GO(URLToFullPath(assemblyPath));
BOOL fDoNgenExplicitBind = fNgenExplicitBind;
// Remember the post-bind version
kContextVersion = pApplicationContext->GetVersion();
- Exit:
-#ifdef FEATURE_VERSIONING_LOG
- hr = LogBindResult(pApplicationContext, hr, &bindResult);
-#else // FEATURE_VERSIONING_LOG
- ;
-#endif // FEATURE_VERSIONING_LOG
-
#ifndef CROSSGEN_COMPILE
} // lock(pApplicationContext)
#endif
+ Exit:
if (bindResult.HaveResult())
{
// this TRUE.
fExplicitBindToNativeImage,
&pAssembly));
-#ifdef FEATURE_VERSIONING_LOG
- IF_FAIL_GO(LogAssemblyNameWhereRef(pApplicationContext, pAssembly));
-#endif // FEATURE_VERSIONING_LOG
AssemblyName *pAssemblyName;
pAssemblyName = pAssembly->GetAssemblyName();
if (pContextEntry != NULL)
{
AssemblyName *pContextName = pContextEntry->GetAssemblyName();
-
-#ifdef FEATURE_VERSIONING_LOG
- // First-time requests are considered unlocked, everything else is locked
- DWORD dwLockedReason = (pContextEntry->GetIsFirstRequest() ?
- APP_DOMAIN_LOCKED_UNLOCKED : APP_DOMAIN_LOCKED_CONTEXT);
-
- IF_FAIL_GO(LogAppDomainLocked(pApplicationContext, dwLockedReason, pContextName));
- pContextEntry->SetIsFirstRequest(FALSE);
-#endif // FEATURE_VERSIONING_LOG
-
if (pAssemblyName->GetIsDefinition() &&
(pContextName->GetArchitecture() != pAssemblyName->GetArchitecture()))
{
GO_WITH_HRESULT(S_OK);
}
-#ifdef FEATURE_VERSIONING_LOG
- // Log the candidates we throw out for diagnostics
- IF_FAIL_GO(LogConfigurationError(pApplicationContext,
- pRequestedAssemblyName,
- pBoundAssemblyName));
-#endif // FEATURE_VERSIONING_LOG
-
IF_FAIL_GO(FUSION_E_REF_DEF_MISMATCH);
}
}
}
-#ifdef FEATURE_VERSIONING_LOG
- // Log the candidates we throw out for diagnostics
- IF_FAIL_GO(LogConfigurationError(pApplicationContext,
- pRequestedAssemblyName,
- pAssembly->GetAssemblyName()));
-#endif // FEATURE_VERSIONING_LOG
-
IF_FAIL_GO(FUSION_E_REF_DEF_MISMATCH);
}
+++ /dev/null
-// 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.
-// ============================================================
-//
-// BindingLog.cpp
-//
-
-
-//
-// Implements the fusion-like BindingLog class
-//
-// ============================================================
-
-#ifdef FEATURE_VERSIONING_LOG
-
-#include "bindinglog.hpp"
-#include "assemblyname.hpp"
-#include "assembly.hpp"
-#include "applicationcontext.hpp"
-#include "bindresult.hpp"
-#include "cdebuglog.hpp"
-#include "variables.hpp"
-#include "bindresult.inl"
-
-#include "strsafe.h"
-
-#define SIZE_OF_TOKEN_INFORMATION \
- (sizeof( TOKEN_USER ) \
- + sizeof( SID ) \
- + sizeof( ULONG ) * SID_MAX_SUB_AUTHORITIES)
-
-#include "../dlls/mscorrc/fusres.h"
-
-STDAPI BinderGetDisplayName(PEAssembly *pAssembly,
- SString &displayName);
-
-namespace BINDER_SPACE
-{
- namespace
- {
- inline UINT GetPreBindStateName(AssemblyName *pAssemblyName)
- {
- if (pAssemblyName->HaveAssemblyVersion())
- {
- return ID_FUSLOG_BINDING_PRE_BIND_STATE_BY_NAME;
- }
- else
- {
- return ID_FUSLOG_BINDING_PRE_BIND_STATE_BY_NAME_PARTIAL;
- }
- }
- };
-
- BindingLog::BindingLog()
- {
- m_pCDebugLog = NULL;
- }
-
- BindingLog::~BindingLog()
- {
- SAFE_RELEASE(m_pCDebugLog);
- }
-
- /* static */
- HRESULT BindingLog::CreateInContext(ApplicationContext *pApplicationContext,
- SString &assemblyPath,
- PEAssembly *pParentAssembly)
- {
- if (!IsLoggingNeeded())
- return S_OK;
-
- return CreateInContext(pApplicationContext, NULL, assemblyPath, pParentAssembly);
- }
-
- /* static */
- BOOL BindingLog::IsLoggingNeeded()
- {
-#ifdef FEATURE_VERSIONING_LOG
- return g_BinderVariables->fLoggingNeeded;
-#else // FEATURE_VERSIONING_LOG
- return FALSE;
-#endif // FEATURE_VERSIONING_LOG
- }
-
- /* static */
- HRESULT BindingLog::CreateInContext(ApplicationContext *pApplicationContext,
- AssemblyName *pAssemblyName,
- PEAssembly *pParentAssembly)
- {
- HRESULT hr = S_OK;
-
- if (IsLoggingNeeded())
- {
- SmallStackSString emptyString;
-
- IF_FALSE_GO(pAssemblyName != NULL);
- IF_FAIL_GO(CreateInContext(pApplicationContext,
- pAssemblyName,
- emptyString,
- pParentAssembly));
- }
-
- Exit:
- return hr;
- }
-
- HRESULT BindingLog::Log(SString &info)
- {
- return GetDebugLog()->LogMessage(0, FUSION_BIND_LOG_CATEGORY_DEFAULT, info);
- }
-
- HRESULT BindingLog::LogAssemblyName(LPCWSTR pwzPrefix,
- AssemblyName *pAssemblyName)
- {
- HRESULT hr = S_OK;
- PathString assemblyDisplayName;
-
- // Verify input arguments
- IF_FALSE_GO(pwzPrefix != NULL);
- IF_FALSE_GO(pAssemblyName != NULL);
-
- pAssemblyName->GetDisplayName(assemblyDisplayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE);
- IF_FAIL_GO(Log(pwzPrefix, assemblyDisplayName));
-
- Exit:
- return hr;
- }
-
- HRESULT BindingLog::LogHR(HRESULT logHR)
- {
- return GetDebugLog()->SetResultCode(0, logHR);
- }
-
- HRESULT BindingLog::LogResult(BindResult *pBindResult)
- {
- HRESULT hr = S_OK;
- PathString assemblyDisplayName;
- PathString format;
- PathString info;
-
- pBindResult->GetAssemblyName()->GetDisplayName(assemblyDisplayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE);
-
- IF_FAIL_GO(format.LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_ID));
- info.Printf(format.GetUnicode(), assemblyDisplayName.GetUnicode());
- IF_FAIL_GO(Log(info));
-
- IUnknown *pIUnknownAssembly;
- pIUnknownAssembly = pBindResult->GetAssembly(FALSE /* fAddRef */);
- Assembly *pAssembly;
- pAssembly = static_cast<Assembly *>(static_cast<void *>(pIUnknownAssembly));
- _ASSERTE(pAssembly != NULL);
-
- if (pAssembly->GetIsInGAC())
- {
- IF_FAIL_GO(info.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_ASSEMBLY_STATUS_BOUND_GAC));
- }
- else if (pAssembly->GetIsByteArray())
- {
- IF_FAIL_GO(info.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_ASSEMBLY_STATUS_BOUND_BYTE_ARRAY));
- }
- else
- {
- PathString assemblyPath;
-
- BinderGetImagePath(pAssembly->GetPEImage(), assemblyPath);
- IF_FAIL_GO(format.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_LOCATION));
- info.Printf(format.GetUnicode(), assemblyPath.GetUnicode());
- }
- IF_FAIL_GO(Log(info));
-
- Exit:
- return hr;
- }
-
- HRESULT BindingLog::Flush()
- {
- HRESULT hr = S_OK;
-
- hr = GetDebugLog()->Flush(0, FUSION_BIND_LOG_CATEGORY_DEFAULT);
- if (hr == E_ACCESSDENIED)
- {
- // We've been impersonated differently and have a old log entry
- hr = S_OK;
- }
-
- return hr;
- }
-
- /* static */
- HRESULT BindingLog::CreateInContext(ApplicationContext *pApplicationContext,
- AssemblyName *pAssemblyName,
- SString &assemblyPath,
- PEAssembly *pParentAssembly)
- {
- HRESULT hr = S_OK;
-
- BindingLog *pBindingLog = pApplicationContext->GetBindingLog();
-
- // Invalidate existing debug log
- pBindingLog->SetDebugLog(NULL);
-
- IF_FAIL_GO(CDebugLog::Create(pApplicationContext,
- pAssemblyName,
- assemblyPath,
- &pBindingLog->m_pCDebugLog));
-
- IF_FAIL_GO(pBindingLog->LogPreBindState(pApplicationContext,
- pAssemblyName,
- assemblyPath,
- pParentAssembly));
- Exit:
- return hr;
- }
-
- HRESULT BindingLog::LogPreBindState(ApplicationContext *pApplicationContext,
- AssemblyName *pAssemblyName,
- SString &assemblyPath,
- PEAssembly *pParentAssembly)
- {
- HRESULT hr = S_OK;
- PathString format;
- PathString info;
-
- IF_FAIL_GO(info.LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_PRE_BIND_STATE_BEGIN));
- IF_FAIL_GO(Log(info));
-
- if (pAssemblyName != NULL)
- {
- PathString assemblyDisplayName;
-
- pAssemblyName->GetDisplayName(assemblyDisplayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE |
- AssemblyName::INCLUDE_RETARGETABLE);
-
- IF_FAIL_GO(format.LoadResourceAndReturnHR(CCompRC::Debugging,
- GetPreBindStateName(pAssemblyName)));
- info.Printf(format.GetUnicode(), assemblyDisplayName.GetUnicode());
- }
- else
- {
- IF_FAIL_GO(format.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_PRE_BIND_STATE_WHERE_REF));
- info.Printf(format.GetUnicode(), assemblyPath.GetUnicode());
- }
- IF_FAIL_GO(Log(info));
-
- if (pParentAssembly != NULL)
- {
- PathString parentAssemblyDisplayName;
-
- IF_FAIL_GO(BinderGetDisplayName(pParentAssembly, parentAssemblyDisplayName));
- IF_FAIL_GO(format.LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_PRE_BIND_STATE_CALLER));
- info.Printf(format.GetUnicode(), parentAssemblyDisplayName.GetUnicode());
- }
- else
- {
- IF_FAIL_GO(info.
- LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_PRE_BIND_STATE_CALLER_UNKNOWN));
- }
- IF_FAIL_GO(Log(info));
-
- IF_FAIL_GO(info.LoadResourceAndReturnHR(CCompRC::Debugging,
- ID_FUSLOG_BINDING_PRE_BIND_STATE_END));
- IF_FAIL_GO(Log(info));
-
- Exit:
- return hr;
- }
-
- void BindingLog::SetDebugLog(CDebugLog *pCDebugLog)
- {
- SAFE_RELEASE(m_pCDebugLog);
- m_pCDebugLog = pCDebugLog;
- }
-};
-
-#endif // FEATURE_VERSIONING_LOG
+++ /dev/null
-// 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.
-// ============================================================
-//
-// CDebugLog.cpp
-//
-
-
-//
-// Implements the fusion-derived CDebugLog class
-//
-// ============================================================
-
-#ifdef FEATURE_VERSIONING_LOG
-
-#include "cdebuglog.hpp"
-#include "applicationcontext.hpp"
-#include "assemblyname.hpp"
-#include "variables.hpp"
-#include "utils.hpp"
-
-#include "shlwapi.h"
-#include "strsafe.h"
-
-#include "../dlls/mscorrc/fusres.h"
-
-#define MAX_DBG_STR_LEN 1024
-#define MAX_DATE_LEN 128
-
-#define DEBUG_LOG_HTML_START L"<html><pre>\r\n"
-#define DEBUG_LOG_HTML_META_LANGUAGE L"<meta http-equiv=\"Content-Type\" content=\"charset=unicode-1-1-utf-8\">"
-#define DEBUG_LOG_MARK_OF_THE_WEB L"<!-- saved from url=(0015)assemblybinder: -->"
-#define DEBUG_LOG_HTML_END L"\r\n</pre></html>"
-#define DEBUG_LOG_NEW_LINE L"\r\n"
-
-namespace BINDER_SPACE
-{
- namespace
- {
- inline LPCWSTR LogCategoryToString(DWORD dwLogCategory)
- {
- switch (dwLogCategory)
- {
- case FUSION_BIND_LOG_CATEGORY_DEFAULT:
- return L"default";
- case FUSION_BIND_LOG_CATEGORY_NGEN:
- return L"Native";
- default:
- return L"Unknown";
- }
- }
-
- HRESULT CreateFilePathHierarchy(LPCOLESTR pszName)
- {
- HRESULT hr=S_OK;
- LPTSTR pszFileName;
- PathString szPathString;
- DWORD dw = 0;
-
- size_t pszNameLen = wcslen(pszName);
- WCHAR * szPath = szPathString.OpenUnicodeBuffer(static_cast<COUNT_T>(pszNameLen));
- size_t cbSzPath = (sizeof(WCHAR)) * (pszNameLen + 1); // SString allocates extra byte for null
- IF_FAIL_GO(StringCbCopy(szPath, cbSzPath, pszName));
- szPathString.CloseBuffer(static_cast<COUNT_T>(pszNameLen));
-
- pszFileName = PathFindFileName(szPath);
-
- if (pszFileName <= szPath)
- {
- IF_FAIL_GO(E_INVALIDARG);
- }
-
- *(pszFileName-1) = 0;
-
- dw = WszGetFileAttributes(szPath);
- if (dw != INVALID_FILE_ATTRIBUTES)
- {
- return S_OK;
- }
-
- hr = HRESULT_FROM_GetLastError();
-
- switch (hr)
- {
- case __HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND):
- {
- hr = CreateFilePathHierarchy(szPath);
- if (hr != S_OK)
- return hr;
- }
-
- case __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND):
- {
- if (WszCreateDirectory(szPath, NULL))
- return S_OK;
- else
- {
- hr = HRESULT_FROM_WIN32(GetLastError());
- if(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
- hr = S_OK;
- else
- return hr;
- }
- }
-
- default:
- break;
- }
-
- Exit:
- return hr;
- }
-
- HRESULT WriteLog(HANDLE hLogFile,
- LPCWSTR pwzInfo)
- {
- HRESULT hr = S_OK;
- DWORD dwLen = 0;
- DWORD dwWritten = 0;
- CHAR szBuf[MAX_DBG_STR_LEN];
-
- dwLen = WszWideCharToMultiByte(CP_UTF8,
- 0,
- pwzInfo,
- -1,
- szBuf,
- MAX_DBG_STR_LEN,
- NULL,
- NULL);
-
- if (!dwLen)
- {
- IF_FAIL_GO(HRESULT_FROM_GetLastError());
- }
-
- // dwLen includes NULL terminator. We don't want to write this out.
- if (dwLen > 1) {
- dwLen--;
-
- if (!WriteFile(hLogFile, szBuf, dwLen, &dwWritten, NULL)) {
- IF_FAIL_GO(HRESULT_FROM_GetLastError());
- }
- }
-
- Exit:
- return hr;
- }
-
- HRESULT GetBindTimeInfo(PathString &info)
- {
- HRESULT hr = S_OK;
- SYSTEMTIME systime;
-
- {
- WCHAR wzDateBuffer[MAX_DATE_LEN];
- WCHAR wzTimeBuffer[MAX_DATE_LEN];
-
- GetLocalTime(&systime);
-
- if (!WszGetDateFormat(LOCALE_USER_DEFAULT,
- 0,
- &systime,
- NULL,
- wzDateBuffer,
- MAX_DATE_LEN))
- {
- return HRESULT_FROM_GetLastError();
- }
-
- if (!WszGetTimeFormat(LOCALE_USER_DEFAULT,
- 0,
- &systime,
- NULL,
- wzTimeBuffer,
- MAX_DATE_LEN))
- {
- return HRESULT_FROM_GetLastError();
- }
-
- info.Printf(L"(%s @ %s)", wzDateBuffer, wzTimeBuffer);
- }
- return hr;
- }
-
- HRESULT GetHrResultInfo(PathString &info, HRESULT hrResult)
- {
- HRESULT hr = S_OK;
-
- // TODO: Get the result information in here.
- info.Printf(L"%p.", hrResult);
-
- return hr;
- }
-
- inline BOOL IsInvalidCharacter(WCHAR wcChar)
- {
- switch (wcChar)
- {
- case L':':
- case L'/':
- case L'\\':
- case L'*':
- case L'<':
- case L'>':
- case L'?':
- case L'|':
- case L'"':
- return TRUE;
- default:
- return FALSE;
- }
- }
-
- inline void ReplaceInvalidFileCharacters(SString &assemblyName)
- {
- SString::Iterator pos = assemblyName.Begin();
- SString::Iterator end = assemblyName.End();
-
- while (pos < end)
- {
- if (IsInvalidCharacter(pos[0]))
- {
- assemblyName.Replace(pos, L'_');
- }
-
- pos++;
- }
- }
- };
-
- CDebugLog::CDebugLog()
- {
- m_cRef = 1;
- }
-
- CDebugLog::~CDebugLog()
- {
- // Nothing to do here
- }
-
- /* static */
- HRESULT CDebugLog::Create(ApplicationContext *pApplicationContext,
- AssemblyName *pAssemblyName,
- SString &sCodeBase,
- CDebugLog **ppCDebugLog)
- {
- HRESULT hr = S_OK;
- ReleaseHolder<CDebugLog> pDebugLog;
-
- // Validate input arguments
- IF_FALSE_GO(pApplicationContext != NULL);
- IF_FALSE_GO(ppCDebugLog != NULL);
-
- SAFE_NEW(pDebugLog, CDebugLog);
- IF_FAIL_GO(pDebugLog->Init(pApplicationContext, pAssemblyName, sCodeBase));
-
- *ppCDebugLog = pDebugLog.Extract();
-
- Exit:
- return hr;
- }
-
- ULONG CDebugLog::AddRef()
- {
- return InterlockedIncrement(&m_cRef);
- }
-
- ULONG CDebugLog::Release()
- {
- ULONG ulRef;
-
- ulRef = InterlockedDecrement(&m_cRef);
-
- if (ulRef == 0)
- {
- delete this;
- }
-
- return ulRef;
- }
-
- HRESULT CDebugLog::SetResultCode(DWORD dwLogCategory,
- HRESULT hrResult)
- {
- HRESULT hr = S_OK;
-
- IF_FALSE_GO(dwLogCategory < FUSION_BIND_LOG_CATEGORY_MAX);
-
- m_HrResult[dwLogCategory] = hrResult;
-
- Exit:
- return hr;
- }
-
- HRESULT CDebugLog::LogMessage(DWORD,
- DWORD dwLogCategory,
- SString &sDebugString)
- {
- HRESULT hr = S_OK;
-
- IF_FALSE_GO(dwLogCategory < FUSION_BIND_LOG_CATEGORY_MAX);
-
- m_content[dwLogCategory].AddTail(const_cast<const SString &>(sDebugString));
-
- Exit:
- return hr;
- }
-
- HRESULT CDebugLog::Flush(DWORD,
- DWORD dwLogCategory)
- {
- HRESULT hr = S_OK;
- SmallStackSString sCategory(LogCategoryToString(dwLogCategory));
- PathString logFilePath;
- ListNode<SString> *pListNode = NULL;
-
- IF_FALSE_GO(dwLogCategory < FUSION_BIND_LOG_CATEGORY_MAX);
-
- CombinePath(g_BinderVariables->logPath, sCategory, logFilePath);
- CombinePath(logFilePath, m_applicationName, logFilePath);
- CombinePath(logFilePath, m_logFileName, logFilePath);
-
- IF_FAIL_GO(CreateFilePathHierarchy(logFilePath.GetUnicode()));
-
- m_hLogFile = WszCreateFile(logFilePath.GetUnicode(),
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (m_hLogFile == INVALID_HANDLE_VALUE)
- {
- // Silently ignore unability to log.
- GO_WITH_HRESULT(S_OK);
- }
-
- LogHeader(dwLogCategory);
-
- pListNode = static_cast<ListNode<SString> *>(m_content[dwLogCategory].GetHeadPosition());
- while (pListNode != NULL)
- {
- SString item = pListNode->GetItem();
-
- IF_FAIL_GO(WriteLog(m_hLogFile, item.GetUnicode()));
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_NEW_LINE));
-
- pListNode = pListNode->GetNext();
- }
-
- LogFooter(dwLogCategory);
-
- // Ignore failure
- CloseHandle(m_hLogFile.Extract());
-
- Exit:
- return hr;
- }
-
- HRESULT CDebugLog::Init(ApplicationContext *pApplicationContext,
- AssemblyName *pAssemblyName,
- SString &sCodeBase)
- {
- HRESULT hr = S_OK;
-
- m_applicationName.Set(pApplicationContext->GetApplicationName());
- ReplaceInvalidFileCharacters(m_applicationName);
-
- if (m_applicationName.IsEmpty())
- {
- m_applicationName.Set(L"unknown");
- }
-
- if (pAssemblyName == NULL)
- {
- m_logFileName.Set(L"WhereRefBind!Host=(LocalMachine)!FileName=(");
-
- LPCWSTR pwzFileName = PathFindFileNameW(sCodeBase.GetUnicode());
- if (pwzFileName != NULL)
- {
- m_logFileName.Append(pwzFileName);
- }
- m_logFileName.Append(L").HTM");
- }
- else
- {
- PathString assemblyDisplayName;
-
- pAssemblyName->GetDisplayName(assemblyDisplayName,
- AssemblyName::INCLUDE_VERSION |
- AssemblyName::INCLUDE_ARCHITECTURE |
- AssemblyName::INCLUDE_RETARGETABLE);
-
- ReplaceInvalidFileCharacters(assemblyDisplayName);
-
- m_logFileName.Set(assemblyDisplayName);
- m_logFileName.Append(L".HTM");
- }
-
- return hr;
- }
-
- HRESULT CDebugLog::LogHeader(DWORD dwLogCategory)
- {
- HRESULT hr = S_OK;
- PathString info;
- PathString temp;
- PathString format;
-
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_HTML_META_LANGUAGE));
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_MARK_OF_THE_WEB));
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_HTML_START));
-
- IF_FAIL_GO(GetBindTimeInfo(temp));
- IF_FAIL_GO(format.LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_HEADER_BEGIN));
- info.Printf(format.GetUnicode(), temp.GetUnicode());
- IF_FAIL_GO(WriteLog(m_hLogFile, info.GetUnicode()));
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_NEW_LINE DEBUG_LOG_NEW_LINE));
-
- if (SUCCEEDED(m_HrResult[dwLogCategory]))
- {
- IF_FAIL_GO(temp.
- LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_HEADER_BIND_RESULT_SUCCESS));
- IF_FAIL_GO(WriteLog(m_hLogFile, temp.GetUnicode()));
- }
- else
- {
- IF_FAIL_GO(temp.
- LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_HEADER_BIND_RESULT_ERROR));
- IF_FAIL_GO(WriteLog(m_hLogFile, temp.GetUnicode()));
- }
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_NEW_LINE));
-
- GetHrResultInfo(temp, m_HrResult[dwLogCategory]);
-
- IF_FAIL_GO(format.LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_HEADER_BIND_RESULT));
- info.Printf(format.GetUnicode(), temp.GetUnicode());
- IF_FAIL_GO(WriteLog(m_hLogFile, info.GetUnicode()));
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_NEW_LINE DEBUG_LOG_NEW_LINE));
-
- // TODO: Assembly Manager info + Executable info.
-
- IF_FAIL_GO(info.LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_BINDING_HEADER_END));
- IF_FAIL_GO(WriteLog(m_hLogFile, info.GetUnicode()));
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_NEW_LINE DEBUG_LOG_NEW_LINE));
-
- Exit:
- return hr;
- }
-
- HRESULT CDebugLog::LogFooter(DWORD)
- {
- HRESULT hr = S_OK;
-
- IF_FAIL_GO(WriteLog(m_hLogFile, DEBUG_LOG_HTML_END));
-
- Exit:
- return hr;
- }
-};
-
-#endif // FEATURE_VERSIONING_LOG
#include "bindertypes.hpp"
#include "failurecache.hpp"
#include "assemblyidentitycache.hpp"
-#ifdef FEATURE_VERSIONING_LOG
-#include "bindinglog.hpp"
-#endif // FEATURE_VERSIONING_LOG
#include "stringarraylist.h"
namespace BINDER_SPACE
inline LONG GetVersion();
inline void IncrementVersion();
-#ifdef FEATURE_VERSIONING_LOG
- inline BindingLog *GetBindingLog();
- inline void ClearBindingLog();
-#endif // FEATURE_VERSIONING_LOG
-
protected:
LONG m_cRef;
Volatile<LONG> m_cVersion;
ExecutionContext *m_pExecutionContext;
FailureCache *m_pFailureCache;
CRITSEC_COOKIE m_contextCS;
-#ifdef FEATURE_VERSIONING_LOG
- BindingLog m_bindingLog;
-#endif // FEATURE_VERSIONING_LOG
AssemblyIdentityCache m_assemblyIdentityCache;
return m_contextCS;
}
-#ifdef FEATURE_VERSIONING_LOG
-BindingLog *ApplicationContext::GetBindingLog()
-{
- return &m_bindingLog;
-}
-
-void ApplicationContext::ClearBindingLog()
-{
- m_bindingLog.SetDebugLog(NULL);
-}
-#endif // FEATURE_VERSIONING_LOG
-
-
#endif
STDAPI BinderHasNativeHeader(PEImage *pPEImage,
BOOL *result);
-STDAPI BinderGetImagePath(PEImage *pPEImage,
- SString &imagePath);
-
STDAPI BinderReleasePEImage(PEImage *pPEImage);
STDAPI BinderAddRefPEImage(PEImage *pPEImage);
inline AssemblyName *GetAssemblyName(BOOL fAddRef = FALSE);
inline BOOL GetIsInGAC();
- inline BOOL GetIsByteArray();
- inline void SetIsByteArray(BOOL fIsByteArray);
+
inline SString &GetPath();
inline PEImage *GetPEImage(BOOL fAddRef = FALSE);
}
}
-BOOL Assembly::GetIsByteArray()
-{
- return ((m_dwAssemblyFlags & FLAG_IS_BYTE_ARRAY) != 0);
-}
-
-void Assembly::SetIsByteArray(BOOL fIsByteArray)
-{
- if (fIsByteArray)
- {
- m_dwAssemblyFlags |= FLAG_IS_BYTE_ARRAY;
- }
- else
- {
- m_dwAssemblyFlags &= ~FLAG_IS_BYTE_ARRAY;
- }
-}
-
SString &Assembly::GetPath()
{
return m_assemblyPath;
inline void SetHave(DWORD dwIdentityFlags);
- inline BOOL HaveAssemblyVersion();
-
BOOL IsMscorlib();
ULONG Hash(/* in */ DWORD dwIncludeFlags);
AssemblyIdentity::SetHave(dwIdentityFlags);
}
-BOOL AssemblyName::HaveAssemblyVersion()
-{
- return m_version.HasMajor();
-}
-
#endif
class BindResult;
class FailureCache;
class AssemblyBinder;
-
-#if defined(FEATURE_VERSIONING_LOG)
- class BindingLog;
- class CDebugLog;
-#endif // FEATURE_VERSIONING_LOG
};
#define IF_FAIL_GO(expr) \
+++ /dev/null
-// 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.
-// ============================================================
-//
-// BindingLog.hpp
-//
-
-
-//
-// Defines the BindingLog class
-//
-// ============================================================
-
-#ifndef __BINDER__BINDING_LOG_HPP__
-#define __BINDER__BINDING_LOG_HPP__
-
-#include "bindertypes.hpp"
-
-namespace BINDER_SPACE
-{
- class BindingLog
- {
- public:
- BindingLog();
- ~BindingLog();
-
- //
- // These functions will create a new log together with pre-bind state
- // information if needed and store it into the application context.
- // This is to avoid endlessly passing around the debug log.
- //
- static HRESULT CreateInContext(/* in */ ApplicationContext *pApplicationContext,
- /* in */ SString &assemblyPath,
- /* in */ PEAssembly *pParentAssembly);
- static HRESULT CreateInContext(/* in */ ApplicationContext *pApplicationContext,
- /* in */ AssemblyName *pAssemblyName,
- /* in */ PEAssembly *pParentAssembly);
-
- HRESULT Log(SString &info);
-
- inline HRESULT Log(LPCWSTR pwzInfo);
- inline HRESULT Log(/* in */ LPCWSTR pwzPrefix,
- /* in */ SString &info);
-
- HRESULT LogAssemblyName(/* in */ LPCWSTR pwzPrefix,
- /* in */ AssemblyName *pAssemblyName);
-
- HRESULT LogHR(/* in */ HRESULT logHR);
- HRESULT LogResult(/* in */ BindResult *pBindResult);
-
- HRESULT Flush();
-
- inline BOOL CanLog();
-
- void SetDebugLog(CDebugLog *pCDebugLog);
-
- protected:
- static BOOL IsLoggingNeeded();
-
- static HRESULT CreateInContext(/* in */ ApplicationContext *pApplicationContext,
- /* in */ AssemblyName *pAssemblyName,
- /* in */ SString &assemblyPath,
- /* in */ PEAssembly *pParentAssembly);
-
- HRESULT LogPreBindState(/* in */ ApplicationContext *pApplicationContext,
- /* in */ AssemblyName *pAssemblyName,
- /* in */ SString &assemblyPath,
- /* in */ PEAssembly *pParentAssembly);
-
-
- inline CDebugLog *GetDebugLog();
-
- HRESULT LogUser();
-
- CDebugLog *m_pCDebugLog;
- };
-
-#include "bindinglog.inl"
-};
-
-#endif
+++ /dev/null
-// 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.
-// ============================================================
-//
-// BindingLog.inl
-//
-
-
-//
-// Implements inlined methods of BindingLog
-//
-// ============================================================
-
-#ifndef __BINDER__BINDING_LOG_INL__
-#define __BINDER__BINDING_LOG_INL__
-
-BOOL BindingLog::CanLog()
-{
- return (m_pCDebugLog != NULL);
-}
-
-CDebugLog *BindingLog::GetDebugLog()
-{
- _ASSERTE(m_pCDebugLog != NULL);
- return m_pCDebugLog;
-}
-
-HRESULT BindingLog::Log(LPCWSTR pwzInfo)
-{
- PathString info(pwzInfo);
- return BindingLog::Log(info);
-}
-
-HRESULT BindingLog::Log(LPCWSTR pwzPrefix,
- SString &info)
-{
- PathString message;
-
- message.Append(pwzPrefix);
- message.Append(info);
-
- return Log(message);
-}
-
-#endif
inline void SetNoResult();
inline BOOL HaveResult();
- inline IUnknown *ExtractAssembly();
inline void Reset();
protected:
return (GetAssemblyName() != NULL);
}
-IUnknown *BindResult::ExtractAssembly()
-{
- return m_pIUnknownAssembly.Extract();
-}
-
void BindResult::Reset()
{
SAFE_RELEASE(m_pAssemblyName);
+++ /dev/null
-// 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.
-// ============================================================
-//
-// CDebugLog.hpp
-//
-
-
-//
-// Defines the CDebugLog class
-//
-// ============================================================
-
-#ifndef __BINDER__C_DEBUG_LOG_HPP__
-#define __BINDER__C_DEBUG_LOG_HPP__
-
-#include "bindertypes.hpp"
-#include "list.hpp"
-
-#define FUSION_BIND_LOG_CATEGORY_DEFAULT 0
-#define FUSION_BIND_LOG_CATEGORY_NGEN 1
-#define FUSION_BIND_LOG_CATEGORY_MAX 2
-
-namespace BINDER_SPACE
-{
- class CDebugLog
- {
- public:
- CDebugLog();
- ~CDebugLog();
-
- static HRESULT Create(/* in */ ApplicationContext *pApplicationContext,
- /* in */ AssemblyName *pAssemblyName,
- /* in */ SString &sCodeBase,
- /* out */ CDebugLog **ppCDebugLog);
-
- ULONG AddRef();
- ULONG Release();
-
- HRESULT SetResultCode(/* in */ DWORD dwLogCategory,
- /* in */ HRESULT hrResult);
-
- HRESULT LogMessage(/* in */ DWORD dwDetailLevel,
- /* in */ DWORD dwLogCategory,
- /* in */ SString &sDebugString);
-
- HRESULT Flush(/* in */ DWORD dwDetailLevel,
- /* in */ DWORD dwLogCategory);
- protected:
- HRESULT Init(/* in */ ApplicationContext *pApplicationContext,
- /* in */ AssemblyName *pAssemblyName,
- /* in */ SString &sCodeBase);
-
- HRESULT LogHeader(/* in */ DWORD dwLogCategory);
- HRESULT LogFooter(/* in */ DWORD dwLogCategory);
-
- LONG m_cRef;
- FileHandleHolder m_hLogFile;
- List<SString> m_content[FUSION_BIND_LOG_CATEGORY_MAX];
- SString m_applicationName;
- SString m_logFileName;
- HRESULT m_HrResult[FUSION_BIND_LOG_CATEGORY_MAX];
- };
-};
-
-#endif
+++ /dev/null
-// 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.
-// ============================================================
-//
-// List.hpp
-//
-
-
-//
-// Defines the List class
-//
-// ============================================================
-
-#ifndef __BINDER__LIST_HPP__
-#define __BINDER__LIST_HPP__
-
-#include "bindertypes.hpp"
-#include "ex.h"
-
-namespace BINDER_SPACE
-{
- //
- // ListNode
- //
-
- typedef void *LISTNODE;
-
- template <class Type> class ListNode
- {
- public:
- ListNode(Type item);
- virtual ~ListNode();
-
- void SetNext(ListNode *pNode);
- void SetPrev(ListNode *pNode);
- Type GetItem();
- ListNode *GetNext();
- ListNode *GetPrev();
-
- private:
- Type _type;
- ListNode *_pNext;
- ListNode *_pPrev;
- };
-
- //
- // List
- //
-
- template <class Type> class List
- {
- public:
- List();
- ~List();
-
- LISTNODE AddHead(const Type &item);
- LISTNODE AddTail(const Type &item);
-
- LISTNODE GetHeadPosition();
- LISTNODE GetTailPosition();
- void RemoveAt(LISTNODE pNode);
- void RemoveAll();
- LISTNODE Find(const Type &item);
- int GetCount();
- Type GetNext(LISTNODE &pNode);
- Type GetAt(LISTNODE pNode);
- LISTNODE AddSorted(const Type &item, LPVOID pfn);
-
- public:
- DWORD _dwSig;
-
- private:
- ListNode<Type> *_pHead;
- ListNode<Type> *_pTail;
- int _iCount;
- };
-
- //
- // ListNode Implementation
- //
-
- template <class Type> ListNode<Type>::ListNode(Type item)
- : _type(item)
- , _pNext(NULL)
- , _pPrev(NULL)
- {
- }
-
- template <class Type> ListNode<Type>::~ListNode()
- {
- }
-
- template <class Type> void ListNode<Type>::SetNext(ListNode *pNode)
- {
- _pNext = pNode;
- }
-
- template <class Type> void ListNode<Type>::SetPrev(ListNode *pNode)
- {
- _pPrev = pNode;
- }
-
- template <class Type> Type ListNode<Type>::GetItem()
- {
- return _type;
- }
-
- template <class Type> ListNode<Type> *ListNode<Type>::GetNext()
- {
- return _pNext;
- }
-
- template <class Type> ListNode<Type> *ListNode<Type>::GetPrev()
- {
- return _pPrev;
- }
-
-
- //
- // List Implementation
- //
-
- template <class Type> List<Type>::List()
- : _pHead(NULL)
- , _pTail(NULL)
- , _iCount(0)
- {
- _dwSig = 0x5453494c; /* 'TSIL' */
- }
-
- template <class Type> List<Type>::~List()
- {
- HRESULT hr = S_OK;
-
- EX_TRY
- {
- RemoveAll();
- }
- EX_CATCH_HRESULT(hr);
- }
-
- template <class Type> LISTNODE List<Type>::AddHead(const Type &item)
- {
- ListNode<Type> *pNode = NULL;
-
- NEW_CONSTR(pNode, ListNode<Type>(item));
- if (pNode) {
- _iCount++;
- pNode->SetNext(_pHead);
- pNode->SetPrev(NULL);
- if (_pHead == NULL) {
- _pTail = pNode;
- }
- else {
- _pHead->SetPrev(pNode);
- }
- _pHead = pNode;
- }
-
- return (LISTNODE)pNode;
- }
-
- template <class Type> LISTNODE List<Type>::AddSorted(const Type &item,
- LPVOID pfn)
- {
- ListNode<Type> *pNode = NULL;
- LISTNODE pCurrNode = NULL;
- LISTNODE pPrevNode = NULL;
- int i;
- Type curItem;
-
- LONG (*pFN) (const Type item1, const Type item2);
-
- pFN = (LONG (*) (const Type item1, const Type item2))pfn;
-
- if(_pHead == NULL) {
- return AddHead(item);
- }
- else {
- pCurrNode = GetHeadPosition();
- curItem = ((ListNode<Type> *) pCurrNode)->GetItem();
- for (i = 0; i < _iCount; i++) {
- if (pFN(item, curItem) < 1) {
- NEW_CONSTR(pNode, ListNode<Type>(item));
- if (pNode) {
- pNode->SetPrev((ListNode<Type> *)pPrevNode);
- pNode->SetNext((ListNode<Type> *)pCurrNode);
- // update pPrevNode
- if(pPrevNode) {
- ((ListNode<Type> *)pPrevNode)->SetNext(pNode);
- }
- else {
- _pHead = pNode;
- }
- // update pCurrNode
- ((ListNode<Type> *)pCurrNode)->SetPrev(pNode);
- _iCount++;
- }
- break;
- }
- pPrevNode = pCurrNode;
- GetNext(pCurrNode);
- if(i+1 == _iCount) {
- return AddTail(item);
- }
- else {
- _ASSERTE(pCurrNode);
- curItem = GetAt(pCurrNode);
- }
- }
- }
-
- return (LISTNODE)pNode;
- }
-
- template <class Type> LISTNODE List<Type>::AddTail(const Type &item)
- {
- ListNode<Type> *pNode = NULL;
-
- NEW_CONSTR(pNode, ListNode<Type>(item));
- if (pNode) {
- _iCount++;
- if (_pTail) {
- pNode->SetPrev(_pTail);
- _pTail->SetNext(pNode);
- _pTail = pNode;
- }
- else {
- _pHead = _pTail = pNode;
- }
- }
-
- return (LISTNODE)pNode;
- }
-
- template <class Type> int List<Type>::GetCount()
- {
- return _iCount;
- }
-
- template <class Type> LISTNODE List<Type>::GetHeadPosition()
- {
- return (LISTNODE)_pHead;
- }
-
- template <class Type> LISTNODE List<Type>::GetTailPosition()
- {
- return (LISTNODE)_pTail;
- }
-
- template <class Type> Type List<Type>::GetNext(LISTNODE &pNode)
- {
- ListNode<Type> *pListNode = (ListNode<Type> *)pNode;
-
- // Faults if you pass NULL
- _ASSERTE(pNode);
-
- Type item = pListNode->GetItem();
- pNode = (LISTNODE)(pListNode->GetNext());
-
- return item;
- }
-
- template <class Type> void List<Type>::RemoveAll()
- {
- int i;
- LISTNODE listNode = NULL;
- ListNode<Type> *pDelNode = NULL;
-
- listNode = GetHeadPosition();
-
- for (i = 0; i < _iCount; i++) {
- pDelNode = (ListNode<Type> *)listNode;
- GetNext(listNode);
- SAFE_DELETE(pDelNode);
- }
-
- _iCount = 0;
- _pHead = NULL;
- _pTail = NULL;
- }
-
- template <class Type> void List<Type>::RemoveAt(LISTNODE pNode)
- {
- ListNode<Type> *pListNode = (ListNode<Type> *)pNode;
- ListNode<Type> *pPrevNode = NULL;
- ListNode<Type> *pNextNode = NULL;
-
- if (pNode) {
- pPrevNode = pListNode->GetPrev();
- pNextNode = pListNode->GetNext();
-
- if (pPrevNode) {
- pPrevNode->SetNext(pNextNode);
- if (pNextNode) {
- pNextNode->SetPrev(pPrevNode);
- }
- else {
- // We're removing the last node, so we have a new tail
- _pTail = pPrevNode;
- }
- SAFE_DELETE(pListNode);
- }
- else {
- // No previous, so we are the head of the list
- _pHead = pNextNode;
- if (pNextNode) {
- pNextNode->SetPrev(NULL);
- }
- else {
- // No previous, or next. There was only one node.
- _pHead = NULL;
- _pTail = NULL;
- }
- SAFE_DELETE(pListNode);
- }
-
- _iCount--;
- }
- }
-
-
- template <class Type> LISTNODE List<Type>::Find(const Type &item)
- {
- int i;
- Type curItem;
- LISTNODE pNode = NULL;
- LISTNODE pMatchNode = NULL;
- ListNode<Type> * pListNode = NULL;
-
- pNode = GetHeadPosition();
- for (i = 0; i < _iCount; i++) {
- pListNode = (ListNode<Type> *)pNode;
- curItem = GetNext(pNode);
- if (curItem == item) {
- pMatchNode = (LISTNODE)pListNode;
- break;
- }
- }
-
- return pMatchNode;
- }
-
- template <class Type> Type List<Type>::GetAt(LISTNODE pNode)
- {
- ListNode<Type> *pListNode = (ListNode<Type> *)pNode;
-
- // Faults if you pass NULL
- _ASSERTE(pNode);
-
- return pListNode->GetItem();
- }
-};
-
-#endif
HRESULT Init();
- // ApplicationContext string constants
- SString AppBaseURL;
- SString DynamicDirectory;
- SString DynamicBaseDirectory;
- SString AppName;
- SString AppConfigFile;
- SString AppDomainId;
-
// AssemblyBinder string constants
SString httpURLPrefix;
// AssemblyName string constants
SString cultureNeutral;
- SString emptyString;
SString mscorlib;
-
-#ifdef FEATURE_VERSIONING_LOG
- BOOL fLoggingNeeded;
- SString logPath;
-#endif // FEATURE_VERSIONING_LOG
};
extern Variables *g_BinderVariables;
namespace BINDER_SPACE
{
-#ifdef FEATURE_VERSIONING_LOG
- namespace
- {
- HRESULT CheckFileExistence(LPCWSTR pwzFile, LPDWORD pdwAttrib)
- {
- HRESULT hr = S_FALSE;
- DWORD dwRet = 0;
-
- _ASSERTE(pwzFile && pdwAttrib);
-
- *pdwAttrib = 0;
-
- dwRet = WszGetFileAttributes(pwzFile);
- if (dwRet == INVALID_FILE_ATTRIBUTES)
- {
- hr = HRESULT_FROM_GetLastError();
-
- if ((hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) ||
- (hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)))
- {
- GO_WITH_HRESULT(S_FALSE);
- }
- }
- else
- {
- *pdwAttrib = dwRet;
- GO_WITH_HRESULT(S_OK);
- }
-
- Exit:
- return hr;
- }
- };
-#endif // FEATURE_VERSIONING_LOG
-
Variables *g_BinderVariables = NULL;
Variables::Variables()
EX_TRY
{
- // ApplicationContext string constants
-
// AssemblyBinder string constants
httpURLPrefix.SetLiteral(W("http://"));
// AssemblyName string constants
cultureNeutral.SetLiteral(W("neutral"));
mscorlib.SetLiteral(CoreLibName_W);
-
- emptyString.Clear();
-
-#ifdef FEATURE_VERSIONING_LOG
- REGUTIL::CORConfigLevel kCorConfigLevel =
- static_cast<REGUTIL::CORConfigLevel>(REGUTIL::COR_CONFIG_ENV |
- REGUTIL::COR_CONFIG_FUSION);
-
- DWORD dwLoggingNeeded = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::EXTERNAL_ForceLog,
- 0,
- kCorConfigLevel,
- TRUE);
- fLoggingNeeded = (dwLoggingNeeded ? TRUE : FALSE);
-
- NewArrayHolder<WCHAR> pwzLogDirectory = REGUTIL::GetConfigString_DontUse_(CLRConfig::INTERNAL_LogPath,
- TRUE,
- kCorConfigLevel,
- FALSE /* fUsePerfCache */);
-
- // When no directory is specified, we can't log.
- if (pwzLogDirectory == NULL)
- {
- fLoggingNeeded = FALSE;
- }
- else
- {
- DWORD dwAttr = 0;
-
- // If we do not get a regular directory, then we can't log either
- hr = CheckFileExistence(pwzLogDirectory, &dwAttr);
- if ((hr == S_OK) && ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0))
- {
- logPath.Set(pwzLogDirectory);
- }
- else
- {
- // Any failure here simply yields no logging.
- hr = S_OK;
- fLoggingNeeded = FALSE;
- }
- }
-#endif // FEATURE_VERSIONING_LOG
}
EX_CATCH_HRESULT(hr);
+++ /dev/null
-// 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"
-
-
-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
-
+++ /dev/null
-// 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_
-
-
-// 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 // __FUSION_RESOURCE_H_
// See the LICENSE file in the project root for more information.
#include "mscorrc.rc"
-#include "fuslog.rc"
/// Loader
///
CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_APIThreadStress, W("APIThreadStress"), "Used to test Loader for race conditions")
-RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_ForceLog, W("ForceLog"), "Fusion flag to enforce assembly binding log. Heavily used and documented in MSDN and BLOGS.")
RETAIL_CONFIG_STRING_INFO(INTERNAL_WinMDPath, W("WinMDPath"), "Path for Windows WinMD files")
///
CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogFileAppend, W("LogFileAppend"), "Specifies whether to append to or replace the CLR log file.")
CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogFlushFile, W("LogFlushFile"), "Specifies whether to flush the CLR log file on each write.")
RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_LogLevel, W("LogLevel"), "4=10 msgs, 9=1000000, 10=everything")
-RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(INTERNAL_LogPath, W("LogPath"), "?Fusion debug log path.")
RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogToConsole, W("LogToConsole"), "Writes the CLR log to console.")
CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogToDebugger, W("LogToDebugger"), "Writes the CLR log to debugger (OutputDebugStringA).")
CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogToFile, W("LogToFile"), "Writes the CLR log to a file.")
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbCopy(LPTSTR pszDest,
- size_t cbDest,
- LPCTSTR pszSrc);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'strcpy'.
- The size of the destination buffer (in bytes) is a parameter and this
- function will not write past the end of this buffer and it will ALWAYS
- null terminate the destination buffer (unless it is zero length).
-
- This routine is not a replacement for strncpy. That function will pad the
- destination string with extra null termination characters if the count is
- greater than the length of the source string, and it will fail to null
- terminate the destination string if the source string length is greater
- than or equal to the count. You can not blindly use this instead of strncpy:
- it is common for code to use it to "patch" strings and you would introduce
- errors if the code started null terminating in the middle of the string.
-
- This function returns a hresult, and not a pointer. It returns a S_OK
- if the string was copied without truncation and null terminated, otherwise
- it will return a failure code. In failure cases as much of pszSrc will be
- copied to pszDest as possible, and pszDest will be null terminated.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes.
- length must be = ((_tcslen(src) + 1) * sizeof(TCHAR)) to
- hold all of the source including the null terminator
-
- pszSrc - source string which must be null terminated
-
-Notes:
- Behavior is undefined if source and destination strings overlap.
-
- pszDest and pszSrc should not be NULL. See StringCbCopyEx if you require
- the handling of NULL values.
-
-Return Value:
-
- S_OK - if there was source data and it was all copied and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all hresult falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the copy operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function.
-
---*/
-
-STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc);
-STRSAFEAPI StringCbCopyW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc);
-#ifdef UNICODE
-#define StringCbCopy StringCbCopyW
-#else
-#define StringCbCopy StringCbCopyA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc)
-{
- HRESULT hr;
- size_t cchDest;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyWorkerA(pszDest, cchDest, pszSrc);
- }
-
- return hr;
-}
-
-STRSAFEAPI StringCbCopyW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
-{
- HRESULT hr;
- size_t cchDest;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyWorkerW(pszDest, cchDest, pszSrc);
- }
-
- return hr;
-}
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbCopyEx(TCHAR pszDest,
- size_t cbDest,
- LPCTSTR pszSrc,
- LPTSTR* ppszDestEnd,
- size_t* pcbRemaining,
- DWORD dwFlags);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'strcpy' with
- some additional parameters. In addition to functionality provided by
- StringCbCopy, this routine also returns a pointer to the end of the
- destination string and the number of bytes left in the destination string
- including the null terminator. The flags parameter allows additional controls.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes.
- length must be ((_tcslen(pszSrc) + 1) * sizeof(TCHAR)) to
- hold all of the source including the null terminator
-
- pszSrc - source string which must be null terminated
-
- ppszDestEnd - if ppszDestEnd is non-null, the function will return a
- pointer to the end of the destination string. If the
- function copied any data, the result will point to the
- null termination character
-
- pcbRemaining - pcbRemaining is non-null,the function will return the
- number of bytes left in the destination string,
- including the null terminator
-
- dwFlags - controls some details of the string copy:
-
- STRSAFE_FILL_BEHIND_NULL
- if the function succeeds, the low byte of dwFlags will be
- used to fill the uninitialize part of destination buffer
- behind the null terminator
-
- STRSAFE_IGNORE_NULLS
- treat NULL string pointers like empty strings (TEXT("")).
- this flag is useful for emulating functions like lstrcpy
-
- STRSAFE_FILL_ON_FAILURE
- if the function fails, the low byte of dwFlags will be
- used to fill all of the destination buffer, and it will
- be null terminated. This will overwrite any truncated
- string returned when the failure is
- STRSAFE_E_INSUFFICIENT_BUFFER
-
- STRSAFE_NO_TRUNCATION /
- STRSAFE_NULL_ON_FAILURE
- if the function fails, the destination buffer will be set
- to the empty string. This will overwrite any truncated string
- returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER.
-
-Notes:
- Behavior is undefined if source and destination strings overlap.
-
- pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag
- is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc
- may be NULL. An error may still be returned even though NULLS are ignored
- due to insufficient space.
-
-Return Value:
-
- S_OK - if there was source data and it was all copied and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the copy operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags);
-STRSAFEAPI StringCbCopyExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags);
-#ifdef UNICODE
-#define StringCbCopyEx StringCbCopyExW
-#else
-#define StringCbCopyEx StringCbCopyExA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyExWorkerA(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char));
- }
- }
-
- return hr;
-}
-
-STRSAFEAPI StringCbCopyExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyExWorkerW(pszDest, cchDest, cbDest, pszSrc, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(WCHAR) since cchRemaining < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcbRemaining = (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR));
- }
- }
-
- return hr;
-}
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbCopyN(LPTSTR pszDest,
- size_t cbDest,
- LPCTSTR pszSrc,
- size_t cbSrc);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'strncpy'.
- The size of the destination buffer (in bytes) is a parameter and this
- function will not write past the end of this buffer and it will ALWAYS
- null terminate the destination buffer (unless it is zero length).
-
- This routine is meant as a replacement for strncpy, but it does behave
- differently. This function will not pad the destination buffer with extra
- null termination characters if cbSrc is greater than the size of pszSrc.
-
- This function returns a hresult, and not a pointer. It returns a S_OK
- if the entire string or the first cbSrc characters were copied without
- truncation and the resultant destination string was null terminated, otherwise
- it will return a failure code. In failure cases as much of pszSrc will be
- copied to pszDest as possible, and pszDest will be null terminated.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes.
- length must be = ((_tcslen(src) + 1) * sizeof(TCHAR)) to
- hold all of the source including the null terminator
-
- pszSrc - source string
-
- cbSrc - maximum number of bytes to copy from source string
-
-Notes:
- Behavior is undefined if source and destination strings overlap.
-
- pszDest and pszSrc should not be NULL. See StringCbCopyEx if you require
- the handling of NULL values.
-
-Return Value:
-
- S_OK - if there was source data and it was all copied and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all hresult falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the copy operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function.
-
---*/
-
-STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc);
-STRSAFEAPI StringCbCopyNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc);
-#ifdef UNICODE
-#define StringCbCopyN StringCbCopyNW
-#else
-#define StringCbCopyN StringCbCopyNA
-#endif // !UNICODE
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchSrc;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(char);
- cchSrc = cbSrc / sizeof(char);
-
- if ((cchDest > STRSAFE_MAX_CCH) ||
- (cchSrc > STRSAFE_MAX_CCH))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyNWorkerA(pszDest, cchDest, pszSrc, cchSrc);
- }
-
- return hr;
-}
-
-STRSAFEAPI StringCbCopyNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchSrc;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(WCHAR);
- cchSrc = cbSrc / sizeof(WCHAR);
-
- if ((cchDest > STRSAFE_MAX_CCH) ||
- (cchSrc > STRSAFE_MAX_CCH))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyNWorkerW(pszDest, cchDest, pszSrc, cchSrc);
- }
-
- return hr;
-}
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-#ifndef STRSAFE_NO_CB_FUNCTIONS
-/*++
-
-STDAPI StringCbCopyNEx(TCHAR pszDest,
- size_t cbDest,
- LPCTSTR pszSrc,
- size_t cbSrc,
- LPTSTR* ppszDestEnd,
- size_t* pcbRemaining,
- DWORD dwFlags);
-
-Routine Description:
-
- This routine is a safer version of the C built-in function 'strncpy' with
- some additional parameters. In addition to functionality provided by
- StringCbCopyN, this routine also returns a pointer to the end of the
- destination string and the number of bytes left in the destination string
- including the null terminator. The flags parameter allows additional controls.
-
- This routine is meant as a replacement for strncpy, but it does behave
- differently. This function will not pad the destination buffer with extra
- null termination characters if cbSrc is greater than the size of pszSrc.
-
-Arguments:
-
- pszDest - destination string
-
- cbDest - size of destination buffer in bytes.
- length must be ((_tcslen(pszSrc) + 1) * sizeof(TCHAR)) to
- hold all of the source including the null terminator
-
- pszSrc - source string
-
- cbSrc - maximum number of bytes to copy from source string
-
- ppszDestEnd - if ppszDestEnd is non-null, the function will return a
- pointer to the end of the destination string. If the
- function copied any data, the result will point to the
- null termination character
-
- pcbRemaining - pcbRemaining is non-null,the function will return the
- number of bytes left in the destination string,
- including the null terminator
-
- dwFlags - controls some details of the string copy:
-
- STRSAFE_FILL_BEHIND_NULL
- if the function succeeds, the low byte of dwFlags will be
- used to fill the uninitialize part of destination buffer
- behind the null terminator
-
- STRSAFE_IGNORE_NULLS
- treat NULL string pointers like empty strings (TEXT("")).
- this flag is useful for emulating functions like lstrcpy
-
- STRSAFE_FILL_ON_FAILURE
- if the function fails, the low byte of dwFlags will be
- used to fill all of the destination buffer, and it will
- be null terminated. This will overwrite any truncated
- string returned when the failure is
- STRSAFE_E_INSUFFICIENT_BUFFER
-
- STRSAFE_NO_TRUNCATION /
- STRSAFE_NULL_ON_FAILURE
- if the function fails, the destination buffer will be set
- to the empty string. This will overwrite any truncated string
- returned when the failure is STRSAFE_E_INSUFFICIENT_BUFFER.
-
-Notes:
- Behavior is undefined if source and destination strings overlap.
-
- pszDest and pszSrc should not be NULL unless the STRSAFE_IGNORE_NULLS flag
- is specified. If STRSAFE_IGNORE_NULLS is passed, both pszDest and pszSrc
- may be NULL. An error may still be returned even though NULLS are ignored
- due to insufficient space.
-
-Return Value:
-
- S_OK - if there was source data and it was all copied and the
- resultant dest string was null terminated
-
- failure - you can use the macro HRESULT_CODE() to get a win32 error
- code for all falure cases
-
- STRSAFE_E_INSUFFICIENT_BUFFER /
- HRESULT_CODE(hr) == ERROR_INSUFFICIENT_BUFFER
- - this return value is an indication that the copy operation
- failed due to insufficient space. When this error occurs,
- the destination buffer is modified to contain a truncated
- version of the ideal result and is null terminated. This
- is useful for situations where truncation is ok.
-
- It is strongly recommended to use the SUCCEEDED() / FAILED() macros to test the
- return value of this function
-
---*/
-
-STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags);
-STRSAFEAPI StringCbCopyNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags);
-#ifdef UNICODE
-#define StringCbCopyNEx StringCbCopyNExW
-#else
-#define StringCbCopyNEx StringCbCopyNExA
-#endif // !UNICODE
-
-
-#ifdef STRSAFE_INLINE
-STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, size_t cbSrc, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchSrc;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(char);
- cchSrc = cbSrc / sizeof(char);
-
- if ((cchDest > STRSAFE_MAX_CCH) ||
- (cchSrc > STRSAFE_MAX_CCH))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyNExWorkerA(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char));
- }
- }
-
- return hr;
-}
-
-STRSAFEAPI StringCbCopyNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchSrc;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(WCHAR);
- cchSrc = cbSrc / sizeof(WCHAR);
-
- if ((cchDest > STRSAFE_MAX_CCH) ||
- (cchSrc > STRSAFE_MAX_CCH))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringCopyNExWorkerW(pszDest, cchDest, cbDest, pszSrc, cchSrc, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) || (hr == STRSAFE_E_INSUFFICIENT_BUFFER))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(WCHAR) since cchRemaining < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcbRemaining = (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR));
- }
- }
-
- return hr;
-}
-#endif // STRSAFE_INLINE
-#endif // !STRSAFE_NO_CB_FUNCTIONS
-
-
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
"FEATURE_USE_ASM_GC_WRITE_BARRIERS",
"FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP",
"FEATURE_UTF8STRING=1",
- "FEATURE_VERSIONING_LOG",
"FEATURE_WIN32_REGISTRY",
"FEATURE_WINMD_RESILIENT",
"PLATFORM_WINDOWS=1",
#include "../binder/inc/applicationcontext.hpp"
#ifndef DACCESS_COMPILE
-STDAPI BinderGetImagePath(PEImage *pPEImage,
- SString &imagePath)
-{
- HRESULT hr = S_OK;
-
- _ASSERTE(pPEImage != NULL);
-
- imagePath.Set(pPEImage->GetPath());
- return hr;
-}
-
STDAPI BinderAddRefPEImage(PEImage *pPEImage)
{
HRESULT hr = S_OK;
return hr;
}
-STDAPI BinderGetDisplayName(PEAssembly *pAssembly,
- SString &displayName)
-{
- HRESULT hr = S_OK;
-
- if (pAssembly != NULL)
- {
- pAssembly->GetDisplayName(displayName, ASM_DISPLAYF_FULL);
- }
-
- return hr;
-}
-
-
-
static VOID ThrowLoadError(AssemblySpec * pSpec, HRESULT hr)
{
CONTRACTL
EnC_SUPPORTED
FEATURE_EVENT_TRACE
FEATURE_MULTICOREJIT
- FEATURE_VERSIONING_LOG
CROSSGEN_MSCORLIB)
set_target_properties(mscorlib_crossgen PROPERTIES CROSSGEN_COMPONENT TRUE)