Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int GetRuntimeNameByAddress(
int GetModuleByAddress(ClrDataAddress address, /*IXCLRDataModule*/ void** mod);

[PreserveSig]
int StartEnumMethodInstancesByAddress(ulong address, /*IXCLRDataAppDomain*/ void* appDomain, ulong* handle);
int StartEnumMethodInstancesByAddress(ClrDataAddress address, /*IXCLRDataAppDomain*/ void* appDomain, ulong* handle);
[PreserveSig]
int EnumMethodInstanceByAddress(ulong* handle, out IXCLRDataMethodInstance? method);
[PreserveSig]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private bool HasMethodInstantiation(MethodDescHandle md)
}
}

int IXCLRDataProcess.StartEnumMethodInstancesByAddress(ulong address, /*IXCLRDataAppDomain*/ void* appDomain, ulong* handle)
int IXCLRDataProcess.StartEnumMethodInstancesByAddress(ClrDataAddress address, /*IXCLRDataAppDomain*/ void* appDomain, ulong* handle)
{
int hr = HResults.S_OK;

Expand All @@ -347,14 +347,16 @@ int IXCLRDataProcess.StartEnumMethodInstancesByAddress(ulong address, /*IXCLRDat

try
{
TargetCodePointer methodAddr = address.ToTargetCodePointer(_target);

// ClrDataAccess::IsPossibleCodeAddress
// Does a trivial check on the readability of the address
bool isTriviallyReadable = _target.TryRead(address, out byte _);
bool isTriviallyReadable = _target.TryRead(methodAddr, out byte _);
if (!isTriviallyReadable)
throw new ArgumentException();

IExecutionManager eman = _target.Contracts.ExecutionManager;
if (eman.GetCodeBlockHandle(address) is CodeBlockHandle cbh &&
if (eman.GetCodeBlockHandle(methodAddr) is CodeBlockHandle cbh &&
eman.GetMethodDesc(cbh) is TargetPointer methodDesc)
{
EnumMethodInstances emi = new(_target, methodDesc, TargetPointer.Null);
Expand All @@ -365,6 +367,11 @@ int IXCLRDataProcess.StartEnumMethodInstancesByAddress(ulong address, /*IXCLRDat
hr = emi.Start();
}
}
catch (InvalidOperationException)
{
// If the target read fails, expect HResult to be CORDBG_E_READVIRTUAL_FAILURE
hr = CorDbgHResults.CORDBG_E_READVIRTUAL_FAILURE;
}
catch (System.Exception ex)
{
hr = ex.HResult;
Expand Down
Loading