Exemple #1
0
        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);
        }