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
20 changes: 0 additions & 20 deletions src/coreclr/src/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ extern bool TryGetSymbol(ICorDebugDataTarget* dataTarget, uint64_t baseAddress,

CRITICAL_SECTION g_dacCritSec;
ClrDataAccess* g_dacImpl;
HINSTANCE g_thisModule;

EXTERN_C
#ifdef TARGET_UNIX
Expand Down Expand Up @@ -75,9 +74,6 @@ BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
#endif
InitializeCriticalSection(&g_dacCritSec);

// Save the module handle.
g_thisModule = (HINSTANCE)instance;

g_procInitialized = true;
break;
}
Expand All @@ -95,12 +91,6 @@ BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
return TRUE;
}

HINSTANCE
GetModuleInst(void)
{
return g_thisModule;
}

HRESULT
ConvertUtf8(__in LPCUTF8 utf8,
ULONG32 bufLen,
Expand Down Expand Up @@ -5622,16 +5612,6 @@ 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_hmodCoreCLR = (HINSTANCE)m_globalBase; // Base address of the runtime in the target process

return S_OK;
}

Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/src/debug/daccess/dacimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ enum DAC_USAGE_TYPE
DAC_PAL,
};

// mscordacwks's module handle
extern HINSTANCE g_thisModule;

class ReflectionModule;

struct DAC_MD_IMPORT
Expand Down
12 changes: 11 additions & 1 deletion src/coreclr/src/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3889,12 +3889,22 @@ HRESULT ClrDataAccess::GetTLSIndex(ULONG *pIndex)
return hr;
}

#ifndef TARGET_UNIX
extern "C" IMAGE_DOS_HEADER __ImageBase;
#endif

HRESULT ClrDataAccess::GetDacModuleHandle(HMODULE *phModule)
{
if(phModule == NULL)
return E_INVALIDARG;
*phModule = GetModuleInst();

#ifndef TARGET_UNIX
*phModule = (HMODULE)&__ImageBase;
return S_OK;
#else
// hModule is not available under TARGET_UNIX
return E_FAIL;
#endif
}

HRESULT ClrDataAccess::GetRCWData(CLRDATA_ADDRESS addr, struct DacpRCWData *rcwData)
Expand Down
20 changes: 1 addition & 19 deletions src/coreclr/src/debug/di/cordb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
#define SUPPORT_LOCAL_DEBUGGING 1
#endif

//********** Globals. *********************************************************
#ifndef HOST_UNIX
HINSTANCE g_hInst; // Instance handle to this piece of code.
#endif

//-----------------------------------------------------------------------------
// SxS Versioning story for Mscordbi (ICorDebug + friends)
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -200,9 +195,7 @@ BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)

case DLL_PROCESS_ATTACH:
{
#ifndef HOST_UNIX
g_hInst = hInstance;
#else
#ifdef HOST_UNIX
int err = PAL_InitializeDLL();
if(err != 0)
{
Expand Down Expand Up @@ -438,17 +431,6 @@ HRESULT STDMETHODCALLTYPE CClassFactory::LockServer(
}


//*****************************************************************************
// This helper provides access to the instance handle of the loaded image.
//*****************************************************************************
#ifndef TARGET_UNIX
HINSTANCE GetModuleInst()
{
return g_hInst;
}
#endif


//-----------------------------------------------------------------------------
// Substitute for mscoree
//
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,7 @@ HRESULT CordbModule::CreateReaderForInMemorySymbols(REFIID riid, void** ppObj)
#ifndef TARGET_UNIX
// PDB format - use diasymreader.dll with COM activation
InlineSString<_MAX_PATH> ssBuf;
IfFailThrow(GetHModuleDirectory(GetModuleInst(), ssBuf));
IfFailThrow(GetClrModuleDirectory(ssBuf));
IfFailThrow(FakeCoCreateInstanceEx(CLSID_CorSymBinder_SxS,
ssBuf.GetUnicode(),
IID_ISymUnmanagedBinder,
Expand Down
14 changes: 2 additions & 12 deletions src/coreclr/src/debug/di/rsmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ void LeftSideResourceCleanupList::SweepNeuterLeftSideResources(CordbProcess * pP
/* ------------------------------------------------------------------------- *
* CordbBase class
* ------------------------------------------------------------------------- */
extern void* GetClrModuleBase();

// Do any initialization necessary for both CorPublish and CorDebug
// This includes enabling logging and adding the SEDebug priv.
Expand Down Expand Up @@ -488,11 +489,7 @@ void CordbCommonBase::InitializeCommon()
unsigned level = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::EXTERNAL_LogLevel, LL_INFO1000);
unsigned bytesPerThread = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_StressLogSize, STRESSLOG_CHUNK_SIZE * 2);
unsigned totalBytes = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::UNSUPPORTED_TotalStressLogSize, STRESSLOG_CHUNK_SIZE * 1024);
#ifndef TARGET_UNIX
StressLog::Initialize(facilities, level, bytesPerThread, totalBytes, GetModuleInst());
#else
StressLog::Initialize(facilities, level, bytesPerThread, totalBytes, NULL);
#endif
StressLog::Initialize(facilities, level, bytesPerThread, totalBytes, GetClrModuleBase());
}
}

Expand Down Expand Up @@ -1427,13 +1424,6 @@ HRESULT Cordb::SetTargetCLR(HMODULE hmodTargetCLR)
m_targetCLR = hmodTargetCLR;
#endif

// @REVIEW: are we happy with this workaround? It allows us to use the existing
// infrastructure for instance name decoration, but it really doesn't fit
// the same model because coreclr.dll isn't in this process and hmodTargetCLR
// is the debuggee target, not the coreclr.dll to bind utilcode to..

g_hmodCoreCLR = hmodTargetCLR;

return S_OK;
}

Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/src/debug/di/rspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@ class DbgTransportSession;
// These hooks must be removed before shipping.
class ShimProcess;


#ifndef TARGET_UNIX
extern HINSTANCE GetModuleInst();
#endif


template <class T>
class CordbSafeHashTable;

Expand Down
19 changes: 2 additions & 17 deletions src/coreclr/src/debug/di/shimprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,34 +1824,19 @@ HMODULE ShimProcess::GetDacModule()
HModuleHolder hDacDll;
PathString wszAccessDllPath;

#ifdef TARGET_UNIX
if (!PAL_GetPALDirectoryWrapper(wszAccessDllPath))
{
ThrowLastError();
}
PCWSTR eeFlavor = MAKEDLLNAME_W(W("mscordaccore"));
#else
//
// Load the access DLL from the same directory as the the current CLR Debugging Services DLL.
//

if (!WszGetModuleFileName(GetModuleInst(), wszAccessDllPath))
if (GetClrModuleDirectory(wszAccessDllPath) != S_OK)
{
ThrowLastError();
}

if (!SUCCEEDED(CopySystemDirectory(wszAccessDllPath, wszAccessDllPath)))
{
ThrowHR(E_INVALIDARG);
}

// Dac Dll is named:
// mscordaccore.dll <-- coreclr
// mscordacwks.dll <-- desktop
PCWSTR eeFlavor =
W("mscordaccore.dll");
PCWSTR eeFlavor = MAKEDLLNAME_W(W("mscordaccore"));

#endif // TARGET_UNIX
wszAccessDllPath.Append(eeFlavor);

hDacDll.Assign(WszLoadLibrary(wszAccessDllPath));
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/src/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ void Debugger::SendRawEvent(const DebuggerIPCEvent * pManagedEvent)
// The debugger can then use ReadProcessMemory to read through this array.
ULONG_PTR rgData [] = {
CLRDBG_EXCEPTION_DATA_CHECKSUM,
(ULONG_PTR) g_hThisInst,
(ULONG_PTR)GetClrModuleBase(),
(ULONG_PTR) pManagedEvent
};

Expand Down Expand Up @@ -5668,7 +5668,7 @@ bool Debugger::FirstChanceNativeException(EXCEPTION_RECORD *exception,
// Ignore any notification exceptions sent from code:Debugger.SendRawEvent.
// This is not a common case, but could happen in some cases described
// in SendRawEvent. Either way, Left-Side and VM should just ignore these.
if (IsEventDebuggerNotification(exception, PTR_TO_CORDB_ADDRESS(g_hThisInst)))
if (IsEventDebuggerNotification(exception, PTR_TO_CORDB_ADDRESS(GetClrModuleBase())))
{
return true;
}
Expand Down Expand Up @@ -12363,7 +12363,7 @@ void Debugger::GetAndSendTransitionStubInfo(CORDB_ADDRESS_TYPE *stubAddress)
// If its not a stub, then maybe its an address in mscoree?
if (result == false)
{
result = (IsIPInModule(g_hThisInst, (PCODE)stubAddress) == TRUE);
result = (IsIPInModule(GetClrModuleBase(), (PCODE)stubAddress) == TRUE);
}

// This is a synchronous event (reply required)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ nativeStringResourceTable_mscorrc
#PAL_fwprintf
#PAL_GetLogicalCpuCountFromOS
#PAL_GetNumaProcessorNode
#PAL_GetPALDirectoryW
#PAL_get_stdout
#PAL_get_stderr
#PAL_GetApplicationGroupId
#PAL_GetTransportName
#PAL_GetCurrentThread
#PAL_GetCpuLimit
#PAL_GetNativeExceptionHolderHead
#PAL_GetPalHostModule
#PAL_GetSymbolModuleBase
#PAL_GetTransportPipeName
#PAL_InitializeDLL
Expand Down
45 changes: 2 additions & 43 deletions src/coreclr/src/dlls/mscoree/mscoree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)

#endif // !defined(CROSSGEN_COMPILE) && !defined(CORECLR_EMBEDDED)

// Globals
extern HINSTANCE g_hThisInst;

HINSTANCE GetModuleInst()
{
LIMITED_METHOD_CONTRACT;
return (g_hThisInst);
}
extern void* GetClrModuleBase();

// ---------------------------------------------------------------------------
// %%Function: MetaDataGetDispenser
Expand Down Expand Up @@ -222,39 +215,6 @@ STDAPI ReOpenMetaDataWithMemoryEx(
return hr;
}

STDAPI GetCORSystemDirectoryInternaL(SString& pBuffer)
{
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;
}

static DWORD g_dwSystemDirectory = 0;
static WCHAR * g_pSystemDirectory = NULL;

Expand Down Expand Up @@ -326,8 +286,7 @@ HRESULT SetInternalSystemDirectory()

// use local buffer for thread safety
PathString wzSystemDirectory;

hr = GetCORSystemDirectoryInternaL(wzSystemDirectory);
hr = GetClrModuleDirectory(wzSystemDirectory);

if (FAILED(hr)) {
wzSystemDirectory.Set(W('\0'));
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/src/dlls/mscoree/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@

#include "intrinsic.h" // Functions to make intrinsic.


// Helper function returns the instance handle of this module.
HINSTANCE GetModuleInst();

#endif // __STDAFX_H__
2 changes: 1 addition & 1 deletion src/coreclr/src/inc/clrhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ typedef Holder<CRITSEC_COOKIE, ClrEnterCriticalSection, ClrLeaveCriticalSection,
FORCEINLINE void VoidClrDeleteCriticalSection(CRITSEC_COOKIE cs) { if (cs != NULL) ClrDeleteCriticalSection(cs); }
typedef Wrapper<CRITSEC_COOKIE, DoNothing<CRITSEC_COOKIE>, VoidClrDeleteCriticalSection, NULL> CRITSEC_AllocationHolder;

HMODULE GetCLRModule ();
DWORD GetClrModulePathName(SString& buffer);

extern thread_local int t_CantAllocCount;

Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/src/inc/corcompile.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,6 @@ typedef enum

extern LPCWSTR CorCompileGetRuntimeDllName(CorCompileRuntimeDlls id);

// Will always return a valid HMODULE for CLR_INFO, but will return NULL for NGEN_COMPILER_INFO
// if the DLL has not yet been loaded (it does not try to cause a load).
extern HMODULE CorCompileGetRuntimeDll(CorCompileRuntimeDlls id);

struct CORCOMPILE_RUNTIME_DLL_INFO
{
// This structure can only contain information not updated by authenticode signing. It is required
Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/src/inc/corpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,6 @@ struct CORCOMPILE_VERSION_INFO;
struct CORCOMPILE_DEPENDENCY;
typedef GUID CORCOMPILE_NGEN_SIGNATURE;


//**********************************************************************
// Internal versions of shim functions for use by the CLR.

STDAPI GetCORSystemDirectoryInternaL(
SString& pBuffer
);

//LONGPATH:TODO: Remove this once Desktop usage has been removed
STDAPI GetCORSystemDirectoryInternal(
__out_ecount_part_opt(cchBuffer, *pdwLength) LPWSTR pBuffer,
DWORD cchBuffer,
__out_opt DWORD* pdwLength
);

#endif // _CORPRIV_H_
// EOF =======================================================================

2 changes: 0 additions & 2 deletions src/coreclr/src/inc/longfilepathwrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,5 @@ DWORD WINAPI GetEnvironmentVariableWrapper(
_Out_opt_ SString& lpBuffer
);

BOOL PAL_GetPALDirectoryWrapper(SString& pbuffer);

#endif //_WIN_PATH_APIS_WRAPPER_

2 changes: 1 addition & 1 deletion src/coreclr/src/inc/stresslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class ThreadStressLog;
class StressLog {
public:
static void Initialize(unsigned facilities, unsigned level, unsigned maxBytesPerThread,
unsigned maxBytesTotal, HMODULE hMod);
unsigned maxBytesTotal, void* moduleBase);
static void Terminate(BOOL fProcessDetach=FALSE);
static void ThreadDetach(); // call at DllMain THREAD_DETACH if you want to recycle thread logs
static int NewChunk ()
Expand Down
Loading