/* 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 dnSpy.Contracts.Debugger.Breakpoints.Code; using dnSpy.Contracts.Debugger.CallStack; using dnSpy.Contracts.Debugger.Code; using dnSpy.Contracts.Disassembly; namespace dnSpy.Contracts.Debugger.Disassembly { /// /// Returns a method's native code /// public abstract class DbgNativeCodeProvider { /// /// 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); } /// /// Native code result /// public readonly struct GetNativeCodeResult { /// /// Native code /// public NativeCode Code { get; } /// /// Symbol resolver or null /// public ISymbolResolver? SymbolResolver { get; } /// /// Header or null /// public string? Header { get; } /// /// Constructor /// /// Native code /// Symbol resolver or null /// Header or null public GetNativeCodeResult(NativeCode code, ISymbolResolver? symbolResolver, string? header) { Code = code; SymbolResolver = symbolResolver; Header = header; } } /// /// Native code options /// [Flags] public enum DbgNativeCodeOptions : uint { /// /// No option is enabled /// None = 0, /// /// Show IL code, if available /// ShowILCode = 0x00000001, /// /// Show source code or decompiled code, if available /// ShowCode = 0x00000002, } }