コード例 #1
0
        private static void AddProcess(StringBuilder builder)
        {
            var maxHeaderLength = ProcessHeaders.Max(h => h.Length);
            var formatter       = "{0,-" + (maxHeaderLength + 1) + "}";

            var sectionIndex = builder.Length;

            using (var p = Process.GetCurrentProcess())
            {
                var pVerInfo = p.MainModule.FileVersionInfo;
                Format(ProcessHeaders[0], p.Id);
                Format(ProcessHeaders[1], p.ProcessName);
                Format(ProcessHeaders[2], p.StartTime.ToString("dd-MM-yyyy HH:mm:ss.fff"));
                Format(ProcessHeaders[3], ApplicationHelper.GetProcessStartupDuration());
                Format(ProcessHeaders[17], Environment.UserInteractive);
                Format(ProcessHeaders[4], IsOptimized());
                Format(ProcessHeaders[5], Environment.Is64BitProcess);
                Format(ProcessHeaders[6], ApplicationHelper.IsProcessLargeAddressAware());
                Format(ProcessHeaders[16], Environment.WorkingSet.Bytes().Humanize());
                Format(ProcessHeaders[12], pVerInfo.FileVersion);
                Format(ProcessHeaders[13], pVerInfo.ProductVersion);
                Format(ProcessHeaders[14], pVerInfo.Language);
                Format(ProcessHeaders[15], pVerInfo.LegalCopyright);
                Format(ProcessHeaders[10], pVerInfo.OriginalFilename);
                Format(ProcessHeaders[11], pVerInfo.FileName);
                Format(ProcessHeaders[7], p.MainModule.ModuleName);
                Format(ProcessHeaders[8], p.MainModule.FileName);
                Format(ProcessHeaders[9], pVerInfo.ProductName);

                var cmdArgs = Environment.GetCommandLineArgs();
                Format(ProcessHeaders[18], cmdArgs[0]);

                for (var i = 1; i < cmdArgs.Length; i++)
                {
                    builder
                    .Append(LinePrefix)
                    .Append(Space).Append(Space)
                    .AppendFormat(formatter, string.Empty)
                    .Append(Space).Append(Space)
                    .AppendLine(cmdArgs[i]);
                }

                var maxLineLength = GetMaximumLineLength(builder, sectionIndex);
                builder.Insert(sectionIndex, GetSeperator("Process", maxLineLength));

                void Format(string key, object value)
                {
                    builder
                    .Append(LinePrefix)
                    .Append(Dot)
                    .Append(Space)
                    .AppendFormat(formatter, key)
                    .Append(Colon)
                    .Append(Space)
                    .AppendLine(value.ToString());
                }

                string IsOptimized()
                {
                    var executingAssembly = Assembly.GetEntryAssembly();

                    return(executingAssembly == null
                        ? "N/A - Assembly was called from Unmanaged code."
                        : executingAssembly.IsOptimized().ToString());
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Queries the assembly's headers to find if it is <c>LARGEADDRESSAWARE</c>.
 /// <remarks>The method is equivalent to running <c>DumpBin</c> on the assembly.</remarks>
 /// </summary>
 public static bool IsAssemblyLargeAddressAware(Assembly assembly)
 {
     return(ApplicationHelper.IsLargeAddressAware(assembly.Location));
 }