Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern "C" bool TryGetSymbol(ICorDebugDataTarget* dataTarget, uint64_t baseAddre
#define CAN_USE_CDAC
#endif

extern TADDR g_ClrModuleBase;

#include "dwbucketmanager.hpp"
#include "gcinterface.dac.h"

Expand Down Expand Up @@ -5531,6 +5533,15 @@ ClrDataAccess::Initialize(void)
// Do some validation
IfFailRet(VerifyDlls());

// To support EH SxS, utilcode requires the base address of the runtime as part of its initialization
// so that functions like "WasThrownByUs" work correctly since they use the CLR base address to check
// if an exception was raised by a given instance of the runtime or not.
//
// Thus, when DAC is initialized, initialize utilcode with the base address of the runtime loaded in the
// target process. This is similar to work done in CorDB::SetTargetCLR for mscordbi.

g_ClrModuleBase = m_globalBase; // Base address of the runtime in the target process

return S_OK;
}

Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/utilcode/clrhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
static void* pImageBase = NULL;
#endif

#ifdef DACCESS_COMPILE

TADDR g_ClrModuleBase;

void* GetClrModuleBase()
{
return (void*)g_ClrModuleBase;
}

#else // DACCESS_COMPILE

void* GetClrModuleBase()
{
LIMITED_METHOD_CONTRACT;
Expand All @@ -37,6 +48,8 @@ void* GetClrModuleBase()
#endif // HOST_WINDOWS
}

#endif // DACCESS_COMPILE

thread_local int t_CantAllocCount;

DWORD GetClrModulePathName(SString& buffer)
Expand Down