Ejemplo n.º 1
0
        public void AttachAndLaunch(ProcessEntry processEntry, SolutionTypeEntry solutionTypeEntry)
        {
            if (solutionTypeEntry == null)
            {
                MessageBox.Show("Select solution to run.");
                return;
            }

            if (mainSolution != null)
            {
                TerminateRunningSolution();
                return;
            }

            if (processEntry == null)
            {
                MessageBox.Show("No WoW process selected.");
                return;
            }

            mainForm.PostInfo("Launching...", Color.Gold);

            Client clientToRun = AttachToProcess(processEntry.GetProcess(), null);

            RunSolution(solutionTypeEntry.GetSolutionType(), clientToRun);
        }
        private void RefreshProcessList(string filter, bool hideUnrestricted)
        {
            List <ProcessEntry> processes = ProcessEntry.GetProcesses();

            processes.Sort((a, b) => a.Pid - b.Pid);

            IEnumerable <ProcessEntry> filtered = processes.Where(p => p.Token != null);

            if (!String.IsNullOrWhiteSpace(filter))
            {
                filter   = filter.ToLower();
                filtered = filtered.Where(p => p.Name.ToLower().Contains(filter));
            }

            if (hideUnrestricted)
            {
                filtered = filtered.Where(p => p.Token.IsRestricted() || p.Token.IsAppContainer() || p.Token.GetTokenIntegrityLevel() < TokenIntegrityLevel.Medium);
            }

            treeViewProcesses.Nodes.Clear();
            listViewThreads.Items.Clear();
            foreach (ProcessEntry entry in filtered)
            {
                AddProcessNode(entry);
                AddThreads(entry);
            }
            listViewThreads.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listViewThreads.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Ejemplo n.º 3
0
        public bool Restart(int index)
        {
            ProcessEntry entry = m_processList[index];

            if (entry.process == null || entry.process.HasExited)
            {
                Console.WriteLine("Error: process already exited");
                return(true);
            }

            try
            {
                entry.restartOnExit = true;
                entry.process.Kill();
                OnProcessStopped(entry);
                return(true);
            }
            catch (System.Exception)
            {
                //TODO: Display error dialog
                m_onEvent?.Invoke("StopFailure");
            }

            return(false);
        }
Ejemplo n.º 4
0
        private bool StartInternal(ProcessEntry entry)
        {
            try
            {
                entry.process = Process.Start(entry.pinfo);
                entry.process.EnableRaisingEvents = true;
                entry.process.Exited += OnProcessExit;
                entry.restartOnExit   = true;

                if (entry.name.Length > 0)
                {
                    //entry.process.WaitForInputIdle(500);
                    Thread.Sleep(500);
                    SetWindowText(entry.process.MainWindowHandle, entry.name);
                }

                OnProcessStarted(entry);

                m_onEvent?.Invoke("StatusUpdated");
                return(true);
            } catch (System.Exception)
            {
                m_onEvent?.Invoke("StartFailure");
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static void Entry <TStartup, TConfig>()
            where TStartup : class
            where TConfig : class, IDocumentsWebConfiguration, new()
        {
            ProcessEntry.Entry();

            var config = new TConfig();

            Configuration <TConfig> .Load(config.SectionName, instance : config);


            ThreadPool.SetMinThreads(50, 50);
            var host = new WebHostBuilder()
                       .UseKestrel(options => {
                options.Limits.MaxRequestBodySize               = 250 * 1024 * 1024;
                options.Limits.MinResponseDataRate              = null;
                options.Limits.MaxConcurrentConnections         = null;
                options.Limits.MaxConcurrentUpgradedConnections = null;
            })
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .ConfigureServices((services) =>
            {
                services.AddSingleton(config);
            })
                       .UseStartup <TStartup>()
                       .UseUrls(config.HostingURL)
                       .Build();

            host.Run();
        }
        private void openTokenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeViewProcesses.SelectedNode;

            if (selectedNode != null)
            {
                ProcessEntry process = selectedNode.Tag as ProcessEntry;
                HandleEntry  handle  = selectedNode.Tag as HandleEntry;
                if (process != null)
                {
                    TokenForm.OpenForm(process.Token, true);
                }
                else if (handle != null)
                {
                    try
                    {
                        TokenForm.OpenForm(new UserToken(NativeBridge.DuplicateHandleFromProcess(handle,
                                                                                                 (uint)(TokenAccessRights.Query | TokenAccessRights.QuerySource), 0)), false);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static IList <ProcessInfo> EnumProcesses()
        {
            var hSnapshot = Win32.CreateToolhelp32Snapshot(CreateToolhelpSnapshotFlags.SnapProcess, 0);
            var processes = new List <ProcessInfo>(256);
            var pe        = new ProcessEntry();

            pe.Init();

            if (!Win32.Process32First(hSnapshot, ref pe))
            {
                return(processes);
            }

            do
            {
                // skip idle process
                if (pe.th32ProcessID == 0)
                {
                    continue;
                }

                processes.Add(new ProcessInfo {
                    Id = pe.th32ProcessID, Name = pe.szExeFile
                });
            } while(Win32.Process32Next(hSnapshot, ref pe));

            //Win32.CloseHandle(hSnapshot);
            return(processes);
        }
Ejemplo n.º 8
0
        public async static Task <int> StartAsync(params Task[] tasks)
        {
            ProcessEntry.Entry();
            await Task.WhenAny(tasks);

            return(0);
        }
Ejemplo n.º 9
0
 public ProcessTransited(IReadOnlyCollection <ICommand> producedCommands,
                         IMessageMetadata metadata,
                         ProcessEntry procesTransitEntry,
                         IProcessState newProcessState) : base(producedCommands, metadata)
 {
     ProcessTransitEntry = procesTransitEntry;
     NewProcessState     = newProcessState;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// See <see cref="IReducible.Reduce(double, ProcessEntry, ProcessZeros, Reduction.Finalize)"/>.
        /// </summary>
        public double Reduce(double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
        {
            double accumulator = identityValue; // no zeros implied

            accumulator = processEntry(data[0], accumulator);
            accumulator = processEntry(data[1], accumulator);
            return(finalize(accumulator));
        }
Ejemplo n.º 11
0
 private void PushFileEntryEvent(ProcessEntry whichProcess, List <FileEntry> fileEntry)
 {
     fileEntry.ForEach((entry) => this.ListViewLog.Items.Add(new ListViewItem(new[]
     {
         whichProcess.ImageName,
         entry.Timestamp.ToLongTimeString(),
         entry.FullPath
     })));
 }
Ejemplo n.º 12
0
        public FutureEventsSchedulingMessageHandler(IActorRef schedulingActor, ILogger log)
        {
            _logger            = log;
            _schedulerActorRef = schedulingActor;

            _schedulingFutureEventProcessEntry = new ProcessEntry(GetType()
                                                                  .Name,
                                                                  "Scheduling raise future event command",
                                                                  "FutureEventScheduled event occured");
        }
Ejemplo n.º 13
0
 public MeminfoViewData(ProcessMeminfo meminfo, ProcessEntry process)
 {
     this.Pid           = meminfo.Pid;
     this.processName   = process?.Name ?? "-";
     this.PssTotal      = meminfo.Total.PssTotal;
     this.PssNativeHeap = meminfo.NativeHeap.PssTotal;
     this.PssDalvikHeap = meminfo.DalvikHeap.PssTotal;
     this.UssTotal      = meminfo.Total.PrivateDirty + meminfo.Total.PrivateClean;
     this.UssEGL        = meminfo.EglMtrack.PrivateDirty + meminfo.EglMtrack.PrivateClean;
     this.UssGL         = meminfo.GlMtrack.PrivateDirty + meminfo.GlMtrack.PrivateClean;
 }
Ejemplo n.º 14
0
 public ProcessViewData(ProcessEntry pi, int cpuPeakRange)
 {
     this.Pid      = pi.Pid;
     this.Priority = pi.Priority;
     this.Cpu      = 0.0f;
     //this.Vss = pi.Vss;
     //this.Rss = pi.Rss;
     this.User         = pi.User;
     this.ThreadCount  = pi.Threads.Count();
     this.Name         = pi.Name;
     this.cpuPeakRange = cpuPeakRange;
 }
        static void DumpProcessEntry(ProcessEntry entry, HashSet<string> mitigation_filter, bool all_mitigations)
        {
            ProcessMitigations mitigations = entry.Mitigations;

            Console.WriteLine("Process Mitigations: {0,8} - {1}", entry.Pid, entry.Name);
            IEnumerable<PropertyInfo> props = _props.Values.Where(p => all_mitigations || mitigation_filter.Contains(p.Name));
            foreach (PropertyInfo prop in props.OrderBy(p => p.Name))
            {
                FormatEntry(prop.Name, prop.GetValue(mitigations));
            }
            Console.WriteLine();
        }
Ejemplo n.º 16
0
        public ProcessEntry Find(ProcessEntry proc, ObservableCollection <ProcessEntry> list)
        {
            if (proc != null)
            {
                if (list.FirstOrDefault(p => p.Pid == proc.Pid) != null)
                {
                    return(list.First(p => p.Pid == proc.Pid));
                }
            }

            return(system);
        }
Ejemplo n.º 17
0
        public int AddProcess(string name, string exec, string args)
        {
            ProcessEntry entry = new ProcessEntry();

            entry.name = name;
            entry.exec = exec;
            entry.args = args;

            m_processList.Add(entry);

            return(m_processList.Count - 1);            //this is the index now assigned to the process.
        }
Ejemplo n.º 18
0
        /// <summary>
        /// See <see cref="IReducible.Reduce(double, ProcessEntry, ProcessZeros, Reduction.Finalize)"/>.
        /// </summary>
        public double Reduce(double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
        {
            double aggregator = identityValue;
            int    nnz        = values.Length;

            for (int i = 0; i < nnz; ++i)
            {
                aggregator = processEntry(values[i], aggregator);
            }
            aggregator = processZeros(NumRows * NumColumns - nnz, aggregator);
            return(finalize(aggregator));
        }
Ejemplo n.º 19
0
 public static void KillProcess(string processName)
 {
     ProcessEntry[] processes = ProcessEntry.GetProcesses();
     foreach (var process in processes)
     {
         if (process.ExeFile.ToLower().CompareTo(processName.ToLower()) == 0)
         {
             process.Kill();
             return;
         }
     }
 }
        static void DumpProcessEntry(ProcessEntry entry, HashSet <string> mitigation_filter, bool all_mitigations)
        {
            ProcessMitigations mitigations = entry.Mitigations;

            Console.WriteLine("Process Mitigations: {0,8} - {1}", entry.Pid, entry.Name);
            IEnumerable <PropertyInfo> props = _props.Values.Where(p => all_mitigations || mitigation_filter.Contains(p.Name));

            foreach (PropertyInfo prop in props.OrderBy(p => p.Name))
            {
                FormatEntry(prop.Name, prop.GetValue(mitigations));
            }
            Console.WriteLine();
        }
Ejemplo n.º 21
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ProcessEntry selected = (ProcessEntry)comboBox1.SelectedItem;

            if (selected != null)
            {
                liveGraph.ProcessPid = selected.Pid;
            }
            else
            {
                liveGraph.ProcessPid = -1;
            }
        }
Ejemplo n.º 22
0
        public static bool ProcessExists(string processName)
        {
            ProcessEntry[] processes = ProcessEntry.GetProcesses();
            foreach (var process in processes)
            {
                if (process.ExeFile.ToLower().CompareTo(processName.ToLower()) == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 23
0
 public AggregateActor(IAggregateCommandsHandler <TAggregate> handler,
                       ISnapshotsPersistencePolicy snapshotsPersistencePolicy,
                       IConstructAggregates aggregateConstructor,
                       IConstructSnapshots snapshotsConstructor,
                       IActorRef customHandlersActor) : base(aggregateConstructor, snapshotsConstructor, snapshotsPersistencePolicy)
 {
     _aggregateCommandsHandler = handler;
     _publisher                    = Context.System.GetTransport();
     _customHandlersActor          = customHandlersActor;
     _domainEventProcessEntry      = new ProcessEntry(Self.Path.Name, AggregateActorConstants.PublishingEvent, AggregateActorConstants.CommandExecutionCreatedAnEvent);
     _domainEventProcessFailEntry  = new ProcessEntry(Self.Path.Name, AggregateActorConstants.CommandExecutionFinished, AggregateActorConstants.CommandRaisedAnError);
     _commandCompletedProcessEntry = new ProcessEntry(Self.Path.Name, AggregateActorConstants.CommandExecutionFinished, AggregateActorConstants.ExecutedCommand);
     Behavior.Become(AwaitingCommandBehavior, nameof(AwaitingCommandBehavior));
 }
Ejemplo n.º 24
0
        internal void AttachPreset(Preset preset)
        {
            if (!preset.Clients.Any())
            {
                MessageBox.Show("No clients specified in preset.");
                return;
            }

            var notInjectedWowProcessess =
                ProcessEntry.GetRunningWoWProcessess()
                .Where(procEntry => !injectedClients.Any(injectedClient => injectedClient.Process == procEntry.GetProcess()))
                .Select(procEntry => procEntry.GetProcess());

            var clientsToRun = new List <Client>();

            foreach (var process in notInjectedWowProcessess)
            {
                var client = AttachToProcess(process, null);

                /* match process to preset config by character name */
                if (client.IsInWorld() && client.GetObjectMgrAndPlayer())
                {
                    string name = client.ControlInterface.remoteControl.GetUnitName(client.Player.GetAddress());

                    client.LaunchSettings = preset.Clients.FirstOrDefault(settings => settings.Character == name);


                    clientsToRun.Add(client);
                }
            }


            Console.WriteLine($"Matched {clientsToRun.Count} clients.");
            if (!clientsToRun.Any())
            {
                return;
            }

            var orderedClientsToRun = clientsToRun.OrderBy(client => Array.IndexOf(preset.Clients, client.LaunchSettings));

            string solutionName = preset.Clients[0].Solution;

            if (!String.IsNullOrEmpty(solutionName))
            {
                RunSolution(Type.GetType(solutionName),
                            orderedClientsToRun.Count() == 1 ? (object)orderedClientsToRun.First() : orderedClientsToRun);
            }
        }
        // https://www.rhyous.com/2010/04/30/how-to-get-the-parent-process-that-launched-a-c-application/
        public static int GetParentProcessId(int processId, string exeName)
        {
            int parentProcessId = 0;

            if (processId > 0)
            {
                IntPtr oHnd = UnsafeNativeMethods.CreateToolhelp32Snapshot(Enumerations.Snapshots.Process, 0);

                if (oHnd == IntPtr.Zero)
                {
                    return(0);
                }

                ProcessEntry oProcInfo = new ProcessEntry();

                oProcInfo.Size = (uint)Marshal.SizeOf(typeof(ProcessEntry));

                if (UnsafeNativeMethods.Process32First(oHnd, ref oProcInfo) == false)
                {
                    return(0);
                }

                do
                {
                    if (processId == oProcInfo.ProcessId)
                    {
                        Process parentProcess = Process.GetProcessById((int)oProcInfo.ParentProcessId);

                        if (parentProcess.ProcessName.Equals(exeName, StringComparison.OrdinalIgnoreCase))
                        {
                            parentProcessId = (int)oProcInfo.ParentProcessId;
                        }
                    }
                }while (parentProcessId == 0 && UnsafeNativeMethods.Process32Next(oHnd, ref oProcInfo));

                if (parentProcessId > 0)
                {
                    return(parentProcessId);
                }
                else
                {
                    return(0);
                }
            }

            return(0);
        }
        private void UpdateValues(ComputerObj comp)
        {
            this.Dispatcher.Invoke(() =>
            {
                Applications         = new ObservableCollection <ProcessEntry>(comp.ProcessList.Where(p => p.IsApplication == true));
                listView.ItemsSource = Applications;

                ProcessEntry selected = SelectedApplication;

                if (SelectedApplication != null)
                {
                    SelectedApplication = Applications.FirstOrDefault(p => p.Pid == selected.Pid);
                }

                listView.SelectedItem = SelectedApplication;
            });
        }
        private void AddProcessNode(ProcessEntry entry)
        {
            try
            {
                UserToken token = entry.Token;
                TreeNode  node  = new TreeNode(String.Format("Pid: {0} - Name: {1} (User:{2}, IL: {3}, R: {4}, AC: {5})",
                                                             entry.Pid, entry.Name, token.GetUser().GetName(), token.GetTokenIntegrityLevel(),
                                                             token.IsRestricted(), token.IsAppContainer()));
                node.Tag = entry;

                treeViewProcesses.Nodes.Add(node);
            }
            catch (Win32Exception)
            {
                // Do nothing
            }
        }
        private void AddProcessNode(ProcessEntry entry)
        {
            try
            {
                UserToken token = entry.Token;
                TreeNode node = new TreeNode(String.Format("Pid: {0} - Name: {1} (User:{2}, IL: {3}, R: {4}, AC: {5})",
                   entry.Pid, entry.Name, token.GetUser().GetName(), token.GetTokenIntegrityLevel(),
                   token.IsRestricted(), token.IsAppContainer()));
                node.Tag = entry;

                treeViewProcesses.Nodes.Add(node);
            }
            catch (Win32Exception)
            {
                // Do nothing
            }
        }
Ejemplo n.º 29
0
        public ProcessTreeBuilder()
        {
            int snapshot = NativeMethods.CreateSnapshot(SnapshotFlag.TH32CS_SNAPPROCESS, 0);

            ProcessEntry entry = new ProcessEntry()
            {
                Size = Marshal.SizeOf <ProcessEntry>()
            };

            if (NativeMethods.GetFirstProcess(snapshot, ref entry))
            {
                do
                {
                    unorderedNodes.Add(new ExtendProcess(entry));
                } while (NativeMethods.GetNextProcess(snapshot, ref entry));
            }
            NativeMethods.CloseHandle(snapshot);
        }
        public ActionResult OpenIncident(string DocumentID)
        {
            StaffADProfile staffADProfile = new StaffADProfile();

            // staffADProfile.user_logon_name = Environment.UserName;
            staffADProfile.user_logon_name = User.Identity.Name;

            //AD
            ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile);

            staffADProfile = activeDirectoryQuery.GetStaffProfile();
            Profile profile = new Profile();

            profile = new LinqCalls().getProfile(staffADProfile.employee_number);
            bool checkICA = new IC_A_Users().ValidateCheckApproverUser(staffADProfile.employee_number);

            ViewData["ICA"] = checkICA;
            bool checkAdmin = new IC_A_Users().ValidateAdminUser(staffADProfile.employee_number);

            ViewData["Admin"] = checkAdmin;

            if (profile.JobTitle == "HEAD OF OPERATIONS" || profile.JobTitle == "ACTING HEAD OF OPERATIONS" || checkAdmin == true || checkICA == true)
            {
                if (profile.JobTitle == "HEAD OF OPERATIONS" || profile.JobTitle == "ACTING HEAD OF OPERATIONS" || checkAdmin == true)
                {
                    ViewData["HopUser"] = true;
                }
                else
                {
                    ViewData["HopUser"] = false;
                }
                InputClass Entry = new InputClass();
                Entry        = new ProcessEntry().GetEntry(DocumentID).First();
                ViewBag.date = Entry.DateSubmitted;
                return(View(Entry));
            }
            else
            {
                ViewData["HopUser"] = false;

                TempData["ErrorMessage"] = "You are not Authorized to view this page";
                return(RedirectToAction("ErrorPage"));
            }
        }
Ejemplo n.º 31
0
        public void UpdateList(ComputerObj comp)
        {
            this.Dispatcher.Invoke(() =>
            {
                ProcessEntry selectedListView = selectedProcessListView;
                ProcessEntry selectedComboBox = selectedProcessComboBox;

                procListListView = new ObservableCollection <ProcessEntry>(comp.ProcessList.OrderByDescending(p => p.Cpu)); // TEMPORARY - sorting to make it easier since most processes use 0%
                procListComboBox = new ObservableCollection <ProcessEntry>(comp.ProcessList.OrderByDescending(p => p.Cpu)); // TEMPORARY - sorting to make it easier since most processes use 0%
                //procListTreeView = new ObservableCollection<ProcessEntry>(comp.ProcessTree.OrderByDescending(p => p.Cpu));
                procListComboBox.Insert(0, system);

                selectedProcessListView = Find(selectedListView, procListListView);
                selectedProcessComboBox = Find(selectedComboBox, procListComboBox);

                UpdateColumnHeaders(comp);
                UpdateProcessTreeView();
            });
        }
        private void AddThreads(ProcessEntry entry)
        {
            List<ThreadEntry> threads = entry.GetThreadsWithTokens();

            foreach (ThreadEntry thread in threads)
            {
                try
                {
                    ListViewItem item = new ListViewItem(String.Format("{0} - {1}", entry.Pid, entry.Name));
                    item.SubItems.Add(thread.Tid.ToString());
                    UserToken token = thread.Token;
                    item.SubItems.Add(token.GetUser().GetName());
                    item.SubItems.Add(token.GetImpersonationLevel().ToString());
                    item.Tag = thread;
                    listViewThreads.Items.Add(item);
                }
                catch (Win32Exception)
                { 
                }
            }
        }
        static void Main(string[] args)
        {
            bool show_help = false;                        

            _pid = Process.GetCurrentProcess().Id;

            try
            {
                OptionSet opts = new OptionSet() {                        
                        { "p|pid=", "Specify a PID of a process to impersonate when checking", v => _pid = int.Parse(v.Trim()) },    
                        { "n", "Specifes the list of arguments represents names instead of pids", v => _named_process = v != null },        
                        { "i", "Use an indentify level token when impersonating", v => _identify_only = v != null },                        
                        { "t", "Dump accessible threads for process", v => _dump_threads = v != null },                        
                        { "k", "Dump tokens for accessible objects", v => _dump_token = v != null },
                        { "sddl", "Dump SDDL strings for objects", v => _print_sddl = v != null },
                        { "h|help",  "show this message and exit", 
                           v => show_help = v != null },
                    };

                List<string> pids = opts.Parse(args).Select(s => s.ToLower()).ToList();
                
                if (show_help)
                {
                    ShowHelp(opts);
                }
                else
                {
                    IEnumerable<ProcessEntry> processes = new ProcessEntry[0];

                    if (pids.Count > 0 && !_named_process)
                    {
                        List<ProcessEntry> procs = new List<ProcessEntry>();
                        using (ImpersonateProcess imp = NativeBridge.Impersonate(_pid,
                            _identify_only ? TokenSecurityLevel.Identification : TokenSecurityLevel.Impersonate))
                        {
                            foreach (string pid_name in pids)
                            {
                                try
                                {
                                    procs.Add(new ProcessEntry(NativeBridge.OpenProcess(int.Parse(pid_name))));
                                }
                                catch (Win32Exception ex)
                                {
                                    Console.WriteLine("Error opening pid {0} - {1}", pid_name, ex.Message);
                                }
                            }
                        }

                        processes = procs;                        
                    }
                    else
                    {
                        try
                        {
                            using (ImpersonateProcess imp = NativeBridge.Impersonate(_pid,
                                _identify_only ? TokenSecurityLevel.Identification : TokenSecurityLevel.Impersonate))
                            {
                                processes = NativeBridge.GetProcesses().Select(h => new ProcessEntry(h));
                            }

                            if (_named_process && pids.Count > 0)
                            {
                                processes = processes.Where(p => pids.Contains(p.Name.ToLower()));
                            }
                        }
                        catch (Win32Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }

                    List<ProcessEntry> ps = processes.ToList();

                    ps.Sort((a, b) => a.Pid - b.Pid);

                    processes = ps;

                    foreach (ProcessEntry process in processes)
                    {
                        Console.WriteLine("{0}: {1} {2}", process.Pid, process.Name, process.GetGrantedAccess());
                        if (_print_sddl && process.StringSecurityDescriptor.Length > 0)
                        {
                            Console.WriteLine("SDDL: {0}", process.StringSecurityDescriptor);
                        }

                        if (_dump_token && process.Token != null)
                        {
                            Console.WriteLine("User: {0}", process.Token.UserName);
                            if (_print_sddl && process.Token.StringSecurityDescriptor.Length > 0)
                            {
                                Console.WriteLine("Token SDDL: {0}", process.Token.StringSecurityDescriptor);
                            }
                        }

                        if (_dump_threads)
                        {
                            foreach (ThreadEntry thread in process.Threads)
                            {
                                Console.WriteLine("-- Thread {0}: {1}", thread.Tid, thread.GetGrantedAccess());
                                if (_print_sddl && thread.StringSecurityDescriptor.Length > 0)
                                {
                                    Console.WriteLine("---- SDDL: {0}", thread.StringSecurityDescriptor);
                                }

                                if (_dump_token && thread.Token != null)
                                {                                    
                                    Console.WriteLine("---- Impersonating {0}", thread.Token.UserName);
                                    if (_print_sddl && thread.Token.StringSecurityDescriptor.Length > 0)
                                    {
                                        Console.WriteLine("---- Token SDDL: {0}", thread.Token.StringSecurityDescriptor);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }