public V45Runtime(ClrInfo info, DataTarget dt, DacLibrary lib) : base(info, dt, lib) { if (!GetCommonMethodTables(ref _commonMTs)) { throw new ClrDiagnosticsException("Could not request common MethodTable list.", ClrDiagnosticsException.HR.DacError); } if (!_commonMTs.Validate()) { CanWalkHeap = false; } // Ensure the version of the dac API matches the one we expect. (Same for both // v2 and v4 rtm.) byte[] tmp = new byte[sizeof(int)]; if (!Request(DacRequests.VERSION, null, tmp)) { throw new ClrDiagnosticsException("Failed to request dac version.", ClrDiagnosticsException.HR.DacError); } int v = BitConverter.ToInt32(tmp, 0); if (v != 9) { throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsException.HR.DacError); } }
public SOSHandleEnum(DacLibrary library, IntPtr pUnk) : base(library.OwningLibrary, ref IID_ISOSHandleEnum, pUnk) { ISOSHandleEnumVTable *vtable = (ISOSHandleEnumVTable *)_vtable; InitDelegate(ref _next, vtable->Next); }
protected override void InitApi() { if (_sos == null) { _sos = DacLibrary.GetSOSInterfaceNoAddRef(); } Debug.Assert(_sos != null); }
internal DesktopRuntimeBase(ClrInfo info, DataTarget dt, DacLibrary lib) : base(info, dt, lib) { _heap = new Lazy <DesktopGCHeap>(CreateHeap); _threads = new Lazy <List <ClrThread> >(CreateThreadList); _appDomains = new Lazy <DomainContainer>(CreateAppDomainList); _threadpool = new Lazy <DesktopThreadPool>(CreateThreadPoolData); _moduleSizes = new Lazy <Dictionary <ulong, uint> >(() => _dataReader.EnumerateModules().ToDictionary(module => module.ImageBase, module => module.FileSize)); _mscorlib = new Lazy <ClrModule>(GetMscorlib); }
public ClrDataProcess(DacLibrary library, IntPtr pUnknown) : base(library?.OwningLibrary, IID_IXCLRDataProcess, pUnknown) { if (library is null) { throw new ArgumentNullException(nameof(library)); } _library = library; }
public ClrStackWalk?CreateStackWalk(DacLibrary library, uint flags) { CreateStackWalkDelegate create = Marshal.GetDelegateForFunctionPointer <CreateStackWalkDelegate>(VTable.CreateStackWalk); if (!create(Self, flags, out IntPtr pUnk)) { return(null); } GC.KeepAlive(create); return(new ClrStackWalk(library, pUnk)); }
public ClrStackWalk CreateStackWalk(DacLibrary library, uint flags) { CreateStackWalkDelegate create = (CreateStackWalkDelegate)Marshal.GetDelegateForFunctionPointer(VTable->CreateStackWalk, typeof(CreateStackWalkDelegate)); int hr = create(Self, flags, out IntPtr pUnk); if (hr != S_OK) { return(null); } return(new ClrStackWalk(library, pUnk)); }
public RhRuntime(DataTargetImpl dt, DacLibrary lib) : base(dt, lib) { byte[] tmp = new byte[sizeof(int)]; if (!Request(DacRequests.VERSION, null, tmp)) throw new ClrDiagnosticsException("Failed to request dac version.", ClrDiagnosticsException.HR.DacError); m_dacRawVersion = BitConverter.ToInt32(tmp, 0); if (m_dacRawVersion != 10 && m_dacRawVersion != 11) throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsException.HR.DacError); }
public NativeRuntime(ModuleInfo module, DataTarget dt, DacLibrary lib) { Module = module; DataTarget = dt; SOSNative = lib.GetInterface <SOSNative>(ref SOSNative.IID_ISOSNative); _dataReader = dt.DataReader; _modules = dt.EnumerateModules().ToArray(); if (SOSNative == null) { throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsException.HR.DacError); } }
/// <summary> /// Flushes the DAC cache. This function <b>must</b> be called any time you expect to call the same function /// but expect different results. For example, after walking the heap, you need to call Flush before /// attempting to walk the heap again. /// </summary> public override void FlushCachedData() { if (_disposed) { throw new ObjectDisposedException(nameof(ClrRuntime)); } _domains = null; _systemDomain = null; _sharedDomain = null; _helpers.DataReader.FlushCachedData(); _helpers.FlushCachedData(); DacLibrary.Flush(); }
public NativeRuntime(ClrInfo info, DataTargetImpl dt, DacLibrary lib) : base(info, dt, lib) { byte[] tmp = new byte[sizeof(int)]; if (!Request(DacRequests.VERSION, null, tmp)) { throw new ClrDiagnosticsException("Failed to request dac version.", ClrDiagnosticsException.HR.DacError); } _dacRawVersion = BitConverter.ToInt32(tmp, 0); if (_dacRawVersion != 10 && _dacRawVersion != 11) { throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsException.HR.DacError); } }
public V45Runtime(ClrInfo info, DataTargetImpl dt, DacLibrary lib) : base(info, dt, lib) { if (!GetCommonMethodTables(ref _commonMTs)) throw new ClrDiagnosticsException("Could not request common MethodTable list.", ClrDiagnosticsException.HR.DacError); // Ensure the version of the dac API matches the one we expect. (Same for both // v2 and v4 rtm.) byte[] tmp = new byte[sizeof(int)]; if (!Request(DacRequests.VERSION, null, tmp)) throw new ClrDiagnosticsException("Failed to request dac version.", ClrDiagnosticsException.HR.DacError); int v = BitConverter.ToInt32(tmp, 0); if (v != 9) throw new ClrDiagnosticsException("Unsupported dac version.", ClrDiagnosticsException.HR.DacError); }
internal CallableCOMWrapper(DacLibrary library, ref Guid desiredInterface, IntPtr pUnknown) { Interlocked.Increment(ref _totalInstances); IUnknownVTable *tbl = *(IUnknownVTable **)pUnknown; var queryInterface = (QueryInterfaceDelegate)Marshal.GetDelegateForFunctionPointer(tbl->QueryInterface, typeof(QueryInterfaceDelegate)); int hr = queryInterface(pUnknown, ref desiredInterface, out IntPtr pCorrectUnknown); if (hr != 0) { GC.SuppressFinalize(this); throw new InvalidOperationException(); } var release = (ReleaseDelegate)Marshal.GetDelegateForFunctionPointer(tbl->Release, typeof(ReleaseDelegate)); release(pUnknown); Self = pCorrectUnknown; _unknownVTable = *(IUnknownVTable **)pCorrectUnknown; _library = GCHandle.Alloc(library); }
static void Main(string[] args) { // needs to run in docker: AttachToProcess is not supported on Darwin 19.4.0 int.TryParse(args[0], out var processId); Console.WriteLine("Attaching for PID: " + processId.ToString()); var suspendOnStart = false; Console.WriteLine("Hello World!"); DataTarget dataTarget = DataTarget.AttachToProcess(processId, suspendOnStart); if (dataTarget != null) { Console.WriteLine("Attached."); Console.WriteLine("Name: " + dataTarget.DataReader.DisplayName); Console.WriteLine("Arch: " + dataTarget.DataReader.Architecture.ToString()); var modules = dataTarget.DataReader.EnumerateModules(); foreach (var module in modules) { Console.WriteLine("file: " + module.FileName); } var clrVersions = dataTarget.ClrVersions; foreach (var version in clrVersions) { Console.WriteLine("dacPath: " + version.DacInfo.LocalDacPath); } // we have a live dac! (i think). var dac = new DacLibrary(dataTarget, clrVersions[0].DacInfo.LocalDacPath); var dacDebug = dac.DacPrivateInterface.QueryInterface(Guid.NewGuid()); } else { Console.WriteLine("Not attached."); } }
public ClrStackWalk(DacLibrary library, IntPtr pUnk) : base(library?.OwningLibrary, IID_IXCLRDataStackWalk, pUnk) { }
public ClrDataMethod(DacLibrary library, IntPtr pUnk) : base(library.OwningLibrary, ref IID_IXCLRDataMethodInstance, pUnk) { }
public SOSHandleEnum(DacLibrary library, IntPtr pUnk) : base(library?.OwningLibrary, IID_ISOSHandleEnum, pUnk) { ref readonly ISOSHandleEnumVTable vtable = ref Unsafe.AsRef <ISOSHandleEnumVTable>(_vtable);
public SOSNative(DacLibrary library, IntPtr pUnk) : base(library.OwningLibrary, ref IID_ISOSNative, pUnk) { }
public ClrDataProcess(DacLibrary library, IntPtr pUnknown) : base(library.OwningLibrary, ref IID_IXCLRDataProcess, pUnknown) { _library = library; }
public ClrmdRuntime(ClrInfo info, DacLibrary dac, IRuntimeHelpers helpers) { ClrInfo = info; DacLibrary = dac; _helpers = helpers ?? throw new ArgumentNullException(nameof(helpers)); }
public SOSDac(DacLibrary lib, CallableCOMWrapper toClone) : base(toClone) { _library = lib; }
public ClrDataModule(DacLibrary library, IntPtr pUnknown) : base(library?.OwningLibrary, IID_IXCLRDataModule, pUnknown) { }
public ClrDataTask(DacLibrary library, IntPtr pUnk) : base(library.OwningLibrary, ref IID_IXCLRDataTask, pUnk) { }
public ClrDataProcess(DacLibrary library, CallableCOMWrapper toClone) : base(toClone) { _library = library; }
internal DesktopRuntimeBase(ClrInfo info, DataTargetImpl dt, DacLibrary lib) : base(info, dt, lib) { }
public MetadataImport(DacLibrary library, IntPtr pUnknown) : base(library?.OwningLibrary, IID_IMetaDataImport, pUnknown) { }
public SOSDac6(DacLibrary library, IntPtr ptr) : base(library?.OwningLibrary, IID_ISOSDac6, ptr) { }
public MetaDataImport(DacLibrary library, IntPtr pUnknown) : base(library, ref IID_IMetaDataImport, pUnknown) { }
public SOSDac(DacLibrary library, IntPtr ptr) : base(library.OwningLibrary, ref IID_ISOSDac, ptr) { _library = library; }
public SOSDac(DacLibrary?library, IntPtr ptr) : base(library?.OwningLibrary, IID_ISOSDac, ptr) { _library = library ?? throw new ArgumentNullException(nameof(library)); }
internal DesktopRuntimeBase(DataTargetImpl dt, DacLibrary lib) : base(dt, lib) { }