/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; using System.ComponentModel.Composition; using dnSpy.Contracts.Debugger.Breakpoints.Code; using dnSpy.Contracts.Debugger.CallStack; using dnSpy.Contracts.Debugger.Code; namespace dnSpy.Contracts.Debugger.Disassembly { /// /// Returns native method bodies. Use to /// export an instance. /// public abstract class DbgRuntimeNativeCodeProvider { /// /// Checks if it's possible to get native code /// /// Stack frame /// public abstract bool CanGetNativeCode(DbgStackFrame frame); /// /// Tries to get the native code /// /// Stack frame /// Options /// Native code if successful /// public abstract bool TryGetNativeCode(DbgStackFrame frame, DbgNativeCodeOptions options, out GetNativeCodeResult result); /// /// Checks if it's possible to get native code /// /// A bound breakpoint /// public abstract bool CanGetNativeCode(DbgBoundCodeBreakpoint boundBreakpoint); /// /// Tries to get the native code /// /// A bound breakpoint /// Options /// Native code if successful /// public abstract bool TryGetNativeCode(DbgBoundCodeBreakpoint boundBreakpoint, DbgNativeCodeOptions options, out GetNativeCodeResult result); /// /// Checks if it's possible to get native code /// /// Runtime /// Code location /// public abstract bool CanGetNativeCode(DbgRuntime runtime, DbgCodeLocation location); /// /// Tries to get the native code /// /// Runtime /// Code location /// Options /// Native code if successful /// public abstract bool TryGetNativeCode(DbgRuntime runtime, DbgCodeLocation location, DbgNativeCodeOptions options, out GetNativeCodeResult result); } /// Metadata public interface IDbgRuntimeNativeCodeProviderMetadata { /// See string? Guid { get; } /// See string? RuntimeKindGuid { get; } /// See double Order { get; } } /// /// Exports a instance /// [MetadataAttribute, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public sealed class ExportDbgRuntimeNativeCodeProviderAttribute : ExportAttribute, IDbgRuntimeNativeCodeProviderMetadata { /// /// Constructor /// /// Runtime GUID or null, see /// Runtime kind GUID or null, see /// Order public ExportDbgRuntimeNativeCodeProviderAttribute(string? guid, string? runtimeKindGuid, double order = double.MaxValue) : base(typeof(DbgRuntimeNativeCodeProvider)) { Guid = guid; RuntimeKindGuid = runtimeKindGuid; Order = order; } /// /// Gets the runtime GUID or null, see /// public string? Guid { get; } /// /// Gets the runtime kind GUID or null, see /// public string? RuntimeKindGuid { get; } /// /// Order /// public double Order { get; } } }