public Device() { com = ComFactory.MakeDefault(); com.setOnRead(onComRead); EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { onClose(); }); }
/// <summary> /// Decodes managed debug events that have been encapsulated in the /// payload of specially crafted native exception debug events. /// </summary> /// <param name="record"> /// A pointer to a byte array from a native exception debug event that /// includes information about a managed debug event. /// </param> /// <param name="countBytes"> /// The number of elements in the <c>pRecord</c> byte array. /// </param> /// <param name="format"> /// A <c>CorDebugRecordFormat</c> enumeration member that specifies the format /// of the unmanaged debug event. /// </param> /// <param name="dwFlags"> /// A bit field that depends on the target architecture and that specifies additional /// information about the debug event. For Windows systems, it can be a member of the /// <c>CorDebugDecodeEventFlagsWindows</c> enumeration. /// </param> /// <param name="dwThreadId"> /// The operating system identifier of the thread on which the exception was thrown. /// </param> /// <param name="ppEvent"> /// A pointer to the address of an <c>ICorDebugDebugEvent</c> object that represents /// a decoded managed debug event. /// </param> /// <remarks> /// NOTE: /// /// This method is available with .NET Native only. /// </remarks> public int DecodeEvent( Span <byte> record, CorDebugRecordFormat format, uint dwFlags, uint dwThreadId, out CorDebugDebugEvent @event) { void **pEvent = default; fixed(void *pRecord = record) { int hResult = Calli( _this, This[0]->DecodeEvent, pRecord, record.Length, (int)format, dwFlags, dwThreadId, &pEvent); ComFactory.Create(pEvent, hResult, out @event); return(hResult); } }
// Use this for initialization void Start() { GameDirector gameDirector = GameDirector.getInstance(); gameDirector.currentSceneController = this; comFactory = ComFactory.GetInstance(); }
/// <summary> /// Gets the value of the specified global variable. /// </summary> /// <param name="fieldDef"> /// An <c>mdFieldDef</c> token that references the metadata /// describing the global variable. /// </param> /// <param name="value">The value of the specified global variable.</param> public int GetGlobalVariableValue(uint fieldDef, out CorDebugValue value) { void **pValue = default; int result = Calli(_this, This[0]->GetGlobalVariableValue, fieldDef, &pValue); ComFactory.Create(pValue, out value); return(result); }
/// <summary> /// Gets a metadata interface object that can be used to examine the /// metadata for the module. /// </summary> /// <param name="riid"> /// The reference ID that specifies the metadata interface. /// </param> /// <param name="obj"> /// An object that is one of the metadata interfaces /// (see https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/metadata/metadata-interfaces). /// </param> /// <remarks> /// The debugger can use this method to make a copy of the original /// metadata for a module, which it must do in order to edit that /// module. The debugger calls this to get an <c>IMetaDataEmit</c> /// interface object for the module, then calls <c>IMetaDataEmit::SaveToMemory</c> /// to save a copy of the module's metadata to memory. /// </remarks> public int GetMetaDataInterface(Guid riid, out Unknown obj) { void **pObj = default; int result = Calli(_this, This[0]->GetMetaDataInterface, &riid, &pObj); ComFactory.Create(pObj, out obj); return(result); }
/// <summary> /// Gets the class specified by the metadata token. /// </summary> public int GetClassFromToken(uint methodDef, out CorDebugClass @class) { void **pClass = default; int result = Calli(_this, This[0]->GetClassFromToken, methodDef, &pClass); ComFactory.Create(pClass, out @class); return(result); }
public int GetFunctionFromRVA(ulong rva, out CorDebugFunction function) { void **pFunction = default; int result = Calli(_this, This[0]->GetFunctionFromRVA, rva, &pFunction); ComFactory.Create(pFunction, out function); return(result); }
/// <summary> /// Gets the function that is specified by the metadata token. /// </summary> /// <param name="methodDef"> /// A <c>mdMethodDef</c> metadata token that references the /// function's metadata. /// </param> /// <param name="function"> /// The <see cref="CorDebugFunction" /> that represents the function. /// </param> /// <remarks> /// This method returns a <c>CORDBG_E_FUNCTION_NOT_IL</c>(0x8013130A) HRESULT /// if the value passed in <c>methodDef</c> does not refer to a Microsoft /// intermediate language (MSIL) method. /// </remarks> public int GetFunctionFromToken(uint methodDef, out CorDebugFunction function) { void **pFunction = default; int result = Calli(_this, This[0]->GetFunctionFromToken, methodDef, &pFunction); ComFactory.Create(pFunction, out function); return(result); }
public int GetVirtualMethod(uint memberRef, out CorDebugFunction function) { void **pFunction = default; int result = Calli(_this, This[0]->GetVirtualMethod, memberRef, &pFunction); ComFactory.Create(pFunction, out function); return(result); }
/// <summary> /// Gets this process's thread that has the specified operating system (OS) thread ID. /// </summary> /// <param name="dwThreadId">The OS thread ID of the thread to be retrieved.</param> /// <param name="thread">The specified thread.</param> public int GetThread(uint dwThreadId, out CorDebugThread thread) { void **pThread = default; int result = Calli(_this, This[0]->GetThread, dwThreadId, &pThread); ComFactory.Create(pThread, result, out thread); return(result); }
public int ThreadForFiberCookie(uint fiberCookie, out CorDebugThread thread) { void **pThread = default; int result = Calli(_this, This[0]->ThreadForFiberCookie, fiberCookie, &pThread); ComFactory.Create(pThread, result, out thread); return(result); }
/// <summary> /// Creates a handle of the specified type for the heap value represented /// by this <c>ICorDebugHeapValue2</c> object. /// </summary> /// <param name="type"> /// A value of the <c>CorDebugHandleType</c> enumeration that specifies the /// type of handle to be created. /// </param> /// <param name="handle"> /// A pointer to the address of an <c>ICorDebugHandleValue</c> object that /// represents the new handle for this heap value. /// </param> /// <remarks> /// The handle will be created in the application domain that is associated /// with the heap value, and will become invalid if the application domain /// gets unloaded. /// /// Multiple calls to this function for the same heap value will create /// multiple handles. Because handles affect the performance of the garbage /// collector, the debugger should limit itself to a relatively small number /// of handles (about 256) that are active at a time. /// </remarks> public int CreateHandle(CorDebugHandleType type, out CorDebugHandleValue handle) { void **pHandle = default; int hResult = Calli(_this, This[0]->CreateHandle, (int)type, &pHandle); ComFactory.Create(pHandle, hResult, out handle); return(hResult); }
public static ComFactory GetInstance() { if (instance == null) { instance = new ComFactory(); } return(instance); }
/// <inheritdoc /> public override unsafe int Clone(out CorDebugEnum <TUnknown> ppEnum) { void **clonedEnum = default; int hResult = Calli(_this, This[0]->Clone, &clonedEnum); ppEnum = ComFactory.Create <CorDebugComEnum <TUnknown> >(clonedEnum, hResult); return(hResult); }
/// <summary> /// Gets an enumerator for all objects that are to be garbage-collected /// in a process. /// </summary> /// <param name="enumerateWeakReferences"> /// A <c>Boolean</c> value that indicates whether weak references are also /// to be enumerated. If <c>enumerateWeakReferences</c> is <c>true</c>, the /// <c>ppEnum</c> enumerator includes both strong references and weak references. /// If <c>enumerateWeakReferences</c> is <c>false</c>, the enumerator includes /// only strong references. /// </param> /// <param name="ppEnum"> /// A pointer to the address of an <c>ICorDebugGCReferenceEnum</c> that is an /// enumerator for the objects to be garbage-collected. /// </param> /// <remarks> /// This method provides a way to determine the full rooting chain /// for any managed object in a process and can be used to determine /// why an object is still alive. /// </remarks> public int EnumerateGCReferences(bool enumerateWeakReferences, out CorDebugStructEnum <COR_GC_REFERENCE> ppEnum) { void **pppEnum = default; int hResult = Calli(_this, This[0]->EnumerateGCReferences, enumerateWeakReferences.ToNativeInt(), &pppEnum); ppEnum = ComFactory.Create <CorDebugStructEnum <COR_GC_REFERENCE> >(pppEnum, hResult); return(hResult); }
/// <summary> /// Converts a type identifier to an <c>ICorDebugType</c> value. /// </summary> /// <param name="id"> /// The type identifier. /// </param> /// <param name="ppType"> /// A pointer to the address of an <c>ICorDebugType</c> object. /// </param> /// <remarks> /// In some cases, methods that return a type identifier may return a /// null <c>COR_TYPEID</c> value. If this value is passed as the <c>id</c> /// argument, the <c>GetTypeForTypeID</c> method will fail and return <c>E_FAIL</c>. /// </remarks> public int GetTypeForTypeID(COR_TYPEID id, out CorDebugType ppType) { void **ptr = default; int hResult = Calli(_this, This[0]->GetTypeForTypeID, id.ToCalliArg(), &ptr); ComFactory.Create(ptr, hResult, out ppType); return(hResult); }
/// <summary> /// Gets a managed object from a COM callable wrapper (CCW) pointer. /// </summary> /// <param name="ccwPointer"> /// A COM callable wrapper (CCW) pointer. /// </param> /// <param name="managedObject"> /// A pointer to the address of an <c>ICorDebugValue</c> object that /// represents the managed object that corresponds to the given CCW pointer. /// </param> public int GetObjectForCCW(long ccwPointer, out CorDebugValue managedObject) { void **pManagedObject = default; int hResult = Calli(_this, This[0]->GetObjectForCCW, ccwPointer, &pManagedObject); ComFactory.Create(pManagedObject, hResult, out managedObject); return(hResult); }
/// <summary> /// Gets an enumerator for the memory ranges of the managed heap. /// </summary> /// <param name="ppRegions"> /// A pointer to the address of an <c>ICorDebugHeapSegmentEnum</c> /// interface object that is an enumerator for the ranges of memory /// in which objects reside in the managed heap. /// </param> /// <remarks> /// Before calling the <c>ICorDebugProcess5::EnumerateHeapRegions</c> /// method, you should call the <c>ICorDebugProcess5::GetGCHeapInformation</c> /// method and examine the value of the <c>areGCStructuresValid</c> /// field of the returned <c>COR_HEAPINFO</c> object to ensure that /// the garbage collection heap in its current state is enumerable. /// In addition, the <c>ICorDebugProcess5::EnumerateHeapRegions</c> /// method returns <c>E_FAIL</c> if you attach too early in the lifetime /// of the process, before memory regions are created. /// /// This method is guaranteed to enumerate all memory regions that may /// contain managed objects, but it does not guarantee that managed objects /// actually reside in those regions. The <c>ICorDebugHeapSegmentEnum</c> /// collection object may include empty or reserved memory regions. /// /// The <c>ICorDebugHeapSegmentEnum</c> interface object is a standard /// enumerator derived from the <c>ICorDebugEnum</c> interface that allows /// you to enumerate <c>COR_SEGMENT</c> objects. Each <c>COR_SEGMENT</c> /// object provides information about the memory range of a particular /// segment, along with the generation of the objects in that segment. /// </remarks> public int EnumerateHeapRegions(out CorDebugStructEnum <COR_SEGMENT> ppRegions) { void **ptr = default; int hResult = Calli(_this, This[0]->EnumerateHeapRegions, &ptr); ppRegions = ComFactory.Create <CorDebugStructEnum <COR_SEGMENT> >(ptr, hResult); return(hResult); }
/// <summary> /// Converts an object address to an <c>ICorDebugObjectValue</c> object. /// </summary> /// <param name="addr"> /// The object address. /// </param> /// <param name="ppObject"> /// A pointer to the address of an <c>ICorDebugObjectValue</c> object. /// </param> /// <remarks> /// If <c>addr</c> does not point to a valid managed object, /// the <c>GetObject</c> method returns <c>E_FAIL</c>. /// </remarks> public int GetObject(ulong addr, out CorDebugObjectValue ppObject) { void **ptr = default; int hResult = Calli(_this, This[0]->GetObject, addr, &ptr); ComFactory.Create(ptr, hResult, out ppObject); return(hResult); }
/// <summary> /// Gets an enumerator for object handles in a process. /// </summary> /// <param name="types"> /// A bitwise combination of <c>CorGCReferenceType</c> values that /// specifies the type of handles to include in the collection. /// </param> /// <param name="ppENum"> /// A pointer to the address of an <c>ICorDebugGCReferenceEnum</c> that /// is an enumerator for the objects to be garbage-collected. /// </param> /// <remarks> /// <c>EnumerateHandles</c> is a helper function that supports inspection /// of the handle table. It is similar to the <c>ICorDebugProcess5::EnumerateGCReferences</c> /// method, except that rather than populating an <c>ICorDebugGCReferenceEnum</c> /// collection with all objects to be garbage-collected, it includes only /// objects that have handles from the handle table. /// /// The <c>types</c> parameter specifies the handle types to include /// in the collection. <c>types</c> can be any of the following three /// members of the <c>CorGCReferenceType</c> enumeration: /// /// - <c>CorHandleStrongOnly</c> (handles to strong references only). /// - <c>CorHandleWeakOnly</c> (handles to weak references only). /// - <c>CorHandleAll</c> (all handles). /// </remarks> public int EnumerateHandles(CorGCReferenceType types, out CorDebugStructEnum <COR_GC_REFERENCE> ppEnum) { void **pointer = default; int hResult = Calli(_this, This[0]->EnumerateHandles, (uint)types, &pointer); ppEnum = ComFactory.Create <CorDebugStructEnum <COR_GC_REFERENCE> >(pointer, hResult); return(hResult); }
/// <summary> /// Gets an enumerator for the objects on the managed heap. /// </summary> /// <param name="ppObject"> /// A pointer to the address of an <c>ICorDebugHeapEnum</c> interface object /// that is an enumerator for the objects that reside on the managed heap. /// </param> /// <remarks> /// Before calling the <c>ICorDebugProcess5::EnumerateHeap</c> method, /// you should call the <c>ICorDebugProcess5::GetGCHeapInformation</c> method and /// examine the value of the <c>areGCStructuresValid</c> field of the returned /// <c>COR_HEAPINFO</c> object to ensure that the garbage collection heap in its /// current state is enumerable. In addition, the <c>ICorDebugProcess5::EnumerateHeap</c> /// returns <c>E_FAIL</c> if you attach too early in the lifetime of the process, /// before memory for the managed heap is allocated. /// /// The <c>ICorDebugHeapEnum</c> interface object is a standard enumerator /// derived from the <c>ICorDebugEnum</c> interface that allows you to enumerate /// <c>COR_HEAPOBJECT</c> objects. This method populates the <c>ICorDebugHeapEnum</c> /// collection object with <c>COR_HEAPOBJECT</c> instances that provide information /// about all objects. The collection may also include <c>COR_HEAPOBJECT</c> instances /// that provide information about objects that are not rooted by any object but /// have not yet been collected by the garbage collector. /// </remarks> public int EnumerateHeap(out CorDebugStructEnum <COR_HEAPOBJECT> ppObjects) { void **pointer = default; int hResult = Calli(_this, This[0]->EnumerateHeap, &pointer); ppObjects = ComFactory.Create <CorDebugStructEnum <COR_HEAPOBJECT> >(pointer, hResult); return(hResult); }
/// <summary> /// Gets a reference pointer to the specified managed object that has a /// garbage collection handle. /// </summary> /// <param name="handle"> /// A pointer to a managed object that has a garbage collection handle. /// This value is a <see cref="IntPtr" /> object and can be retrieved /// from the <see cref="GCHandle" /> for the managed object. /// </param> /// <param name="outValue"> /// The reference to the specified managed object. /// </param> /// <remarks> /// Do not confuse the returned reference value with a garbage collection /// reference value. /// /// The returned reference behaves like a normal reference. It is disabled /// when code execution continues after a breakpoint. The lifetime of the /// target object is not affected by the lifetime of the reference value. /// /// This method does not validate the handle. Therefore, this method can /// potentially corrupt both the debugger and the code being debugged if /// an invalid handle is passed. /// </remarks> public unsafe int GetReferenceValueFromGCHandle(UIntPtr handle, out CorDebugReferenceValue outValue) { void **pOutValue = default; int hResult = Calli(_this, This[0]->GetReferenceValueFromGCHandle, handle, &pOutValue); ComFactory.Create(pOutValue, hResult, out outValue); return(hResult); }
/// <summary> /// Gets the thread on which the task with the specified identifier /// is executing. /// </summary> /// <param name="taskid">The identifier for the task.</param> /// <param name="thread">The requested thread.</param> /// <remarks> /// The host can set the task identifier by using the <c>ICLRTask::SetTaskIdentifier</c> /// method. /// </remarks> public unsafe int GetThreadForTaskID(ulong taskid, out CorDebugThread2 thread) { void **pThread = default; int hResult = Calli(_this, This[0]->GetThreadForTaskID, taskid, &pThread); ComFactory.Create(pThread, hResult, out thread); return(hResult); }
/// <summary> /// Gets the element at the given position, treating the array as /// a zero-based, single-dimensional array. /// </summary> /// <param name="position"> /// The position of the element to be retrieved. /// </param> /// <param name="value"> /// A pointer to the address of an <c>ICorDebugValue</c> object that /// represents the value of the element. /// </param> /// <remarks> /// The layout of a multi-dimension array follows the C++ style of /// array layout. /// </remarks> public int GetElementAtPosition(uint position, out CorDebugValue value) { void **pValue = default; int hResult = Calli(_this, This[0]->GetElementAtPosition, position, &pValue); ComFactory.Create(pValue, hResult, out value); return(hResult); }
/// <summary> /// Gets the value of the specified argument in this Microsoft intermediate /// language (MSIL) stack frame. /// </summary> /// <param name="dwIndex"> /// The index of the argument in this MSIL stack frame. /// </param> /// <param name="value"> /// A pointer to the address of an <c>ICorDebugValue</c> object that /// represents the retrieved value. /// </param> /// <remarks> /// The <c>GetArgument</c> method can be used either in an MSIL stack frame /// or in a just-in-time (JIT) compiled frame. /// </remarks> public int GetArgument(uint dwIndex, out CorDebugValue value) { void **pValue = default; int hResult = Calli(_this, This[0]->GetArgument, dwIndex, &pValue); ComFactory.Create(pValue, hResult, out value); return(hResult); }
/// <summary> /// Gets information about the managed code at a particular code address. /// </summary> /// <param name="codeAddress"> /// [in] A CORDB_ADDRESS value that specifies the starting address of the managed code segment. /// </param> /// <param name="ppCode"> /// [out] A pointer to the address of an "ICorDebugCode" object that represents a segment of managed code. /// </param> /// <remarks> /// NOTE: /// /// This method is available with .NET Native only. /// </remarks> public int GetCode(long codeAddress, out CorDebugCode code) { void **pCode = default; int hResult = Calli(_this, This[0]->GetCode, codeAddress, &pCode); ComFactory.Create(pCode, hResult, out code); return(hResult); }
/// <summary> /// Creates a breakpoint in this code segment at the specified offset. /// </summary> /// <param name="offset">The offset at which to create the breakpoint.</param> /// <param name="breakpoint">The created breakpoint.</param> /// <remarks> /// Before the breakpoint is active, it must be added to the process object. /// /// If this code is Microsoft intermediate language (MSIL) code, and there is /// a just-in-time (JIT)-compiled, native version of the code, the breakpoint /// will be applied in the JIT-compiled code as well. (The same is true if the /// code is JIT-compiled later.) /// </remarks> public int CreateBreakpoint(uint offset, out CorDebugFunctionBreakpoint breakpoint) { void **pBreakpoint = default; int result = Calli(_this, This[0]->CreateBreakpoint, offset, &pBreakpoint); ComFactory.Create(pBreakpoint, out breakpoint); return(result); }
public int CreateValue(CorElementType elementType, CorDebugClass elementClass, out CorDebugValue value) { using var pElementClass = elementClass.AcquirePointer(); void *pValue = default; int result = Calli(_this, This[0]->CreateValue, (int)elementType, pElementClass, &pValue); ComFactory.Create(pValue, out value); return(result); }
/// <summary> /// Gets the value of the specified field of the specified class for this object value. /// </summary> /// <remarks> /// The class, specified in <see paramref="class" />, must be in /// the hierarchy of the object value's class, and the field must /// be a field of that class. /// /// This method will still succeed for generic objects and generic /// classes. For example, if <c>MyDictionary{V}</c> inherits from /// <c>Dictionary{string,V}</c>, and the object value is of type /// <c>MyDictionary{int32}</c>, passing the <see cref="CorDebugClass" /> /// object for <c>Dictionary{K,V}</c> will successfully get a /// field of <c>Dictionary{string,int32}</c>. /// </remarks> public int GetFieldValue(CorDebugClass @class, uint fieldDef, out CorDebugValue value) { using var pClass = @class.AcquirePointer(); void **pValue = default; int result = Calli(_this, This[0]->GetFieldValue, pClass, fieldDef, &pValue); ComFactory.Create(pValue, out value); return(result); }
/// <summary> /// Gets the value of the specified static field. /// </summary> /// <param name="fieldDef"> /// A FieldDef token that references the field to be retrieved. /// </param> /// <param name="frame"> /// The frame to be used to disambiguate among thread, context, or application /// domain statics. /// /// If the static field is relative to a thread, a context, or an application domain, /// the frame will determine the proper value. /// </param> /// <param name="value">The value of the static field.</param> /// <remarks> /// For parameterized types, the value of a static field is relative to the particular /// instantiation. Therefore, if the class constructor takes parameters of type /// <see cref="Type" />, call <see cref="CorDebugType.GetStaticFieldValue" /> instead. /// </remarks> public int GetStaticFieldValue(uint fieldDef, CorDebugFrame frame, out CorDebugValue value) { using var pFrame = frame.AcquirePointer(); void *pValue = default; int result = Calli(_this, This[0]->GetStaticFieldValue, fieldDef, pFrame, &pValue); ComFactory.Create(pValue, out value); return(result); }