/*
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 System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace dnSpy.Contracts.Debugger.StartDebugging {
///
/// Process starter result flags
///
[Flags]
public enum ProcessStarterResult {
///
/// No bit is set
///
None = 0,
///
/// The file extension is not the normal extension
///
WrongExtension = 0x00000001,
}
///
/// Starts a process without debugging
///
public abstract class DbgProcessStarter {
///
/// Checks if this instance supports starting the executable
///
/// Filename
/// Contains extra information if it's a supported file
///
public abstract bool IsSupported(string filename, out ProcessStarterResult result);
///
/// Starts the executable. Returns false and an error message if it failed or throws an exception
///
/// Filename
/// Updated with an error message
///
public abstract bool TryStart(string filename, [NotNullWhen(false)] out string? error);
}
/// Metadata
public interface IDbgProcessStarterMetadata {
/// See
double Order { get; }
}
///
/// Exports a instance
///
[MetadataAttribute, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class ExportDbgProcessStarterAttribute : ExportAttribute, IDbgProcessStarterMetadata {
///
/// Constructor
///
/// Order, see
public ExportDbgProcessStarterAttribute(double order)
: base(typeof(DbgProcessStarter)) => Order = order;
///
/// Order
///
public double Order { get; }
}
///
/// Predefined order constants
///
public static class PredefinedDbgProcessStarterOrders {
///
/// .NET
///
public const double DotNet = 1000000;
///
/// Default process starter that calls
///
public const double DefaultExe = double.MaxValue;
}
}