public static AttachableProcessInfo Create(ProcessProvider processProvider, AttachProgramOptions options) { if (processProvider == null) { throw new ArgumentNullException(nameof(processProvider)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var name = options.Name; var title = options.Title; var filename = options.Filename; var commandLine = options.CommandLine; var architecture = options.Architecture; if (name == null || title == null || filename == null || commandLine == null || architecture == null) { var info = GetDefaultProperties(processProvider, options); name = name ?? info.name ?? string.Empty; title = title ?? info.title ?? string.Empty; filename = filename ?? info.filename ?? string.Empty; commandLine = commandLine ?? info.commandLine ?? string.Empty; architecture = architecture ?? info.arch ?? string.Empty; } return(new AttachableProcessInfo(options.ProcessId, options.RuntimeId, options.RuntimeGuid, options.RuntimeKindGuid, options.RuntimeName, name, title, filename, commandLine, architecture)); }
public ProgramVM(ProcessProvider processProvider, AttachProgramOptions attachProgramOptions, IAttachToProcessContext context) { if (processProvider == null) { throw new ArgumentNullException(nameof(processProvider)); } AttachProgramOptions = attachProgramOptions ?? throw new ArgumentNullException(nameof(attachProgramOptions)); attachableProcessInfo = AttachableProcessInfo.Create(processProvider, attachProgramOptions); Context = context ?? throw new ArgumentNullException(nameof(context)); }
void AddOptions(AttachProgramOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } lock (lockObj) { var info = AttachableProcessInfo.Create(processProvider, options); if (IsMatch(info)) { result.Add(new AttachableProcessImpl(dbgManager.Value, options, info)); } } }
public static ProgramVM?Create(ProcessProvider processProvider, AttachProgramOptions attachProgramOptions, IAttachToProcessContext context) { if (processProvider is null) { throw new ArgumentNullException(nameof(processProvider)); } var attachableProcessInfo = AttachableProcessInfo.Create(processProvider, attachProgramOptions); if (attachableProcessInfo is null) { return(null); } return(new ProgramVM(attachableProcessInfo, attachProgramOptions, context)); }
void AddOptions(AttachProgramOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } bool start; lock (lockObj) { if (disposed) { return; } pendingOptions.Add(options); start = !emptyQueueCalled && pendingOptions.Count == 1; emptyQueueCalled |= start; } if (start) { uiDispatcher.UIBackground(EmptyQueue); } }
public static AttachableProcessInfo?Create(ProcessProvider processProvider, AttachProgramOptions options) { if (processProvider is null) { throw new ArgumentNullException(nameof(processProvider)); } if (options is null) { throw new ArgumentNullException(nameof(options)); } var name = options.Name; var title = options.Title; var filename = options.Filename; var commandLine = options.CommandLine; var architecture = options.Architecture; var operatingSystem = options.OperatingSystem; if (name is null || title is null || filename is null || commandLine is null || architecture is null || operatingSystem is null) { var info = GetDefaultProperties(processProvider, options); name = name ?? info.name ?? string.Empty; title = title ?? info.title ?? string.Empty; filename = filename ?? info.filename ?? string.Empty; commandLine = commandLine ?? info.commandLine ?? string.Empty; architecture = architecture ?? info.arch; operatingSystem = operatingSystem ?? info.operatingSystem; } if (architecture is null) { return(null); } if (operatingSystem is null) { return(null); } return(new AttachableProcessInfo(options.ProcessId, options.RuntimeId, options.RuntimeGuid, options.RuntimeKindGuid, options.RuntimeName, name, title, filename, commandLine, architecture ?? DbgArchitecture.X86, operatingSystem ?? DbgOperatingSystem.Windows)); }
static (string name, string title, string filename, string commandLine, string arch) GetDefaultPropertiesCore(ProcessProvider processProvider, AttachProgramOptions attachProgramOptions) { string name = null, title = null, filename = null, commandLine = null, arch = null; var process = processProvider.GetProcess(attachProgramOptions.ProcessId); if (process != null) { if (attachProgramOptions.Name == null) { name = Path.GetFileName(attachProgramOptions.Filename ?? process.MainModule.FileName); } if (attachProgramOptions.Filename == null) { filename = process.MainModule.FileName; } if (attachProgramOptions.CommandLine == null) { commandLine = Win32CommandLineProvider.TryGetCommandLine(process.Handle); } if (attachProgramOptions.Title == null) { title = process.MainWindowTitle; } if (attachProgramOptions.Architecture == null) { switch (ProcessUtilities.GetBitness(process.Handle)) { case 32: arch = PredefinedArchitectureNames.X86; break; case 64: arch = PredefinedArchitectureNames.X64; break; default: arch = "???"; break; } } } return(name, title, filename, commandLine, arch); }
static (string name, string title, string filename, string commandLine, string arch) GetDefaultProperties(ProcessProvider processProvider, AttachProgramOptions attachProgramOptions) { try { return(GetDefaultPropertiesCore(processProvider, attachProgramOptions)); } catch { } return(null, null, null, null, null); }
static (string?name, string?title, string?filename, string?commandLine, DbgArchitecture?arch, DbgOperatingSystem?operatingSystem) GetDefaultProperties(ProcessProvider processProvider, AttachProgramOptions attachProgramOptions) { try { return(GetDefaultPropertiesCore(processProvider, attachProgramOptions)); } catch { } return(default);
public AttachableProcessImpl(DbgManager dbgManager, AttachProgramOptions attachProgramOptions, AttachableProcessInfo attachableProcessInfo) { this.dbgManager = dbgManager ?? throw new ArgumentNullException(nameof(dbgManager)); this.attachProgramOptions = attachProgramOptions ?? throw new ArgumentNullException(nameof(attachProgramOptions)); this.attachableProcessInfo = attachableProcessInfo ?? throw new ArgumentNullException(nameof(attachableProcessInfo)); }
ProgramVM(AttachableProcessInfo attachableProcessInfo, AttachProgramOptions attachProgramOptions, IAttachToProcessContext context) { AttachProgramOptions = attachProgramOptions ?? throw new ArgumentNullException(nameof(attachProgramOptions)); this.attachableProcessInfo = attachableProcessInfo ?? throw new ArgumentNullException(nameof(attachableProcessInfo)); Context = context ?? throw new ArgumentNullException(nameof(context)); }