コード例 #1
0
        private void buttonLinkedToken_Click(object sender, EventArgs e)
        {
            using (var thandle = _object.GetToken(TokenAccess.Query))
            {
                var         token  = new TokenWithLinkedToken(thandle);
                TokenWindow window = new TokenWindow(token);

                window.ShowDialog();
            }
        }
コード例 #2
0
        private JsonGoalList GetFromYa(string token = "")
        {
            string fullName = jsonPath + "/" + "Data2.json";

            if (String.IsNullOrEmpty(token))
            {
                string url = "https://oauth.yandex.ru/authorize?response_type=token&client_id=" + secret;
                try
                {
                    Process.Start(url);
                }
                catch (Win32Exception)
                {
                    var startInfo = new ProcessStartInfo(@"C:\Program Files\Internet Explorer\iexplore.exe", url);
                    Process.Start(startInfo);
                }
                finally
                {
                }
                tokenWindow = new TokenWindow();
                //tokenWindow.Owner = (Application.Current as App).MainWindow;
                tokenWindow.Closing += GetToken;
                tokenWindow.Show();
            }
            else
            {
                Task t = Task.Run(() => DownloadJson());
                //t.Wait();
                if (t.IsCompletedSuccessfully)
                {
                    MessageBox.Show("Succes");
                    return(GetJson(fullName));
                }
                else
                {
                    MessageBox.Show("NotExist");
                }
            }
            return(null);
        }
コード例 #3
0
        public static void ShowHandleProperties(SystemHandleEntry handleInfo)
        {
            try
            {
                IntPtr        handle    = new IntPtr(handleInfo.Handle);
                ProcessHandle phandle   = new ProcessHandle(handleInfo.ProcessId, ProcessAccess.DupHandle);
                GenericHandle dupHandle = null;

                // Try to get a handle, since we need one for security editing.
                try
                {
                    dupHandle = new GenericHandle(phandle, handle, 0);
                }
                catch
                { }

                PropSheetHeader64 header = new PropSheetHeader64
                {
                    dwSize     = (uint)PropSheetHeader64.SizeOf,
                    nPages     = 2,
                    dwFlags    = (uint)PropSheetFlags.PSH_DEFAULT,
                    pszCaption = "Handle Properties"
                };

                using (HandleDetails hw = new HandleDetails())
                {
                    hw.ObjectHandle              = handleInfo;
                    hw.HandlePropertiesCallback += (control, name, typeName) =>
                    {
                        switch (typeName.ToLowerInvariant())
                        {
                        // Objects with separate property windows:
                        case "file":
                        case "job":
                        case "key":
                        case "token":
                        case "process":
                        {
                            Button b = new Button
                            {
                                FlatStyle = FlatStyle.System,
                                Text      = "Properties"
                            };

                            b.Click += (sender, e) =>
                            {
                                try
                                {
                                    switch (typeName.ToLowerInvariant())
                                    {
                                    case "file":
                                    {
                                        FileUtils.ShowProperties(name);
                                    }
                                    break;

                                    case "job":
                                    {
                                        dupHandle = new GenericHandle(phandle, handle, (int)JobObjectAccess.Query);

                                        (new JobWindow(JobObjectHandle.FromHandle(dupHandle))).ShowDialog();
                                    }
                                    break;

                                    case "key":
                                    {
                                        try
                                        {
                                            PhUtils.OpenKeyInRegedit(PhUtils.GetForegroundWindow(), name);
                                        }
                                        catch (Exception ex)
                                        {
                                            PhUtils.ShowException("Unable to open the Registry Editor", ex);
                                        }
                                    }
                                    break;

                                    case "token":
                                    {
                                        using (TokenWindow twindow = new TokenWindow(new RemoteTokenHandle(phandle, handle)))
                                        {
                                            twindow.ShowDialog();
                                        }
                                    }
                                    break;

                                    case "process":
                                    {
                                        dupHandle = new GenericHandle(phandle, handle, (int)OSVersion.MinProcessQueryInfoAccess);
                                        int pid = ProcessHandle.FromHandle(dupHandle).ProcessId;

                                        Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], Program.FocusWindow);
                                    }
                                    break;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    PhUtils.ShowException("Unable to show object properties", ex);
                                }
                            };

                            control.Controls.Add(b);
                        }
                        break;

                        case "event":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)EventAccess.QueryState);
                            var eventProps = new EventProperties(EventHandle.FromHandle(dupHandle));
                            control.Controls.Add(eventProps);
                        }
                        break;

                        case "eventpair":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)EventPairAccess.All);
                            var eventPairProps = new EventPairProperties(EventPairHandle.FromHandle(dupHandle));
                            control.Controls.Add(eventPairProps);
                        }
                        break;

                        case "mutant":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)MutantAccess.QueryState);
                            var mutantProps = new MutantProperties(MutantHandle.FromHandle(dupHandle));
                            control.Controls.Add(mutantProps);
                        }
                        break;

                        case "section":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)SectionAccess.Query);
                            var sectionProps = new SectionProperties(SectionHandle.FromHandle(dupHandle));
                            control.Controls.Add(sectionProps);
                        }
                        break;

                        case "semaphore":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)SemaphoreAccess.QueryState);
                            var semaphoreProps = new SemaphoreProperties(SemaphoreHandle.FromHandle(dupHandle));
                            control.Controls.Add(semaphoreProps);
                        }
                        break;

                        case "timer":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)TimerAccess.QueryState);
                            var timerProps = new TimerProperties(TimerHandle.FromHandle(dupHandle));
                            control.Controls.Add(timerProps);
                        }
                        break;

                        case "tmrm":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)ResourceManagerAccess.QueryInformation);
                            var tmRmProps = new TmRmProperties(ResourceManagerHandle.FromHandle(dupHandle));
                            control.Controls.Add(tmRmProps);
                        }
                        break;

                        case "tmtm":
                        {
                            dupHandle = new GenericHandle(phandle, handle, (int)TmAccess.QueryInformation);
                            var tmTmProps = new TmTmProperties(TmHandle.FromHandle(dupHandle));
                            control.Controls.Add(tmTmProps);
                        }
                        break;
                        }
                    };

                    hw.Init();

                    IntPtr[] pages = new IntPtr[2];
                    pages[0] = hw.CreatePageHandle();
                    pages[1] = CreateSecurityPage(SecurityEditor.EditSecurity2(
                                                      null,
                                                      SecurityEditor.GetSecurableWrapper(dupHandle),
                                                      hw._name,
                                                      NativeTypeFactory.GetAccessEntries(NativeTypeFactory.GetObjectType(hw._typeName))
                                                      ));

                    GCHandle gch = GCHandle.Alloc(pages, GCHandleType.Pinned);
                    header.phpage = gch.AddrOfPinnedObject();

                    PropertySheetW(ref header);

                    if (dupHandle != null)
                    {
                        dupHandle.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                PhUtils.ShowException("Unable to show handle properties", ex);
            }
        }
コード例 #4
0
ファイル: ThreadList.cs プロジェクト: andyvand/ProcessHacker
        private void tokenThreadMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                using (ThreadHandle thandle = new ThreadHandle(
                    int.Parse(listThreads.SelectedItems[0].Text), Program.MinThreadQueryRights
                    ))
                {
                    TokenWindow tokForm = new TokenWindow(thandle);

                    tokForm.Text = "Thread Token";
                    tokForm.ShowDialog();
                }
            }
            catch (ObjectDisposedException)
            { }
            catch (Exception ex)
            {
                PhUtils.ShowException("Unable to view the thread token", ex);
            }
        }
コード例 #5
0
        private void buttonLinkedToken_Click(object sender, EventArgs e)
        {
            using (var thandle = _object.GetToken(TokenAccess.Query))
            {
                var token = new TokenWithLinkedToken(thandle);
                TokenWindow window = new TokenWindow(token);

                window.ShowDialog();
            }
        }
コード例 #6
0
        public static void ShowHandleProperties(SystemHandleEntry handleInfo)
        {
            try
            {
                IntPtr handle = new IntPtr(handleInfo.Handle);
                ProcessHandle phandle = new ProcessHandle(handleInfo.ProcessId, ProcessAccess.DupHandle);
                GenericHandle dupHandle = null;

                // Try to get a handle, since we need one for security editing.
                try
                {
                    dupHandle = new GenericHandle(phandle, handle, 0);
                }
                catch
                { }

                PropSheetHeader64 header = new PropSheetHeader64
                {
                    dwSize = (uint)PropSheetHeader64.SizeOf, 
                    nPages = 2, 
                    dwFlags = (uint)PropSheetFlags.PSH_DEFAULT, 
                    pszCaption = "Handle Properties"
                };

                using (HandleDetails hw = new HandleDetails())
                {
                    hw.ObjectHandle = handleInfo;
                    hw.HandlePropertiesCallback += (control, name, typeName) =>
                    {
                        switch (typeName.ToLowerInvariant())
                        {
                            // Objects with separate property windows:
                            case "file":
                            case "job":
                            case "key":
                            case "token":
                            case "process":
                                {
                                    Button b = new Button
                                    {
                                        FlatStyle = FlatStyle.System,
                                        Text = "Properties"
                                    };

                                    b.Click += (sender, e) =>
                                    {
                                        try
                                        {
                                            switch (typeName.ToLowerInvariant())
                                            {
                                                case "file":
                                                    {
                                                        FileUtils.ShowProperties(name);
                                                    }
                                                    break;
                                                case "job":
                                                    {
                                                        dupHandle = new GenericHandle(phandle, handle, (int)JobObjectAccess.Query);

                                                        (new JobWindow(JobObjectHandle.FromHandle(dupHandle))).ShowDialog();
                                                    }
                                                    break;
                                                case "key":
                                                    {
                                                        try
                                                        {
                                                            PhUtils.OpenKeyInRegedit(PhUtils.GetForegroundWindow(), name);
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            PhUtils.ShowException("Unable to open the Registry Editor", ex);
                                                        }
                                                    }
                                                    break;
                                                case "token":
                                                    {
                                                        using (TokenWindow twindow = new TokenWindow(new RemoteTokenHandle(phandle, handle)))
                                                        {
                                                            twindow.ShowDialog();
                                                        }
                                                    }
                                                    break;
                                                case "process":
                                                    {
                                                        dupHandle = new GenericHandle(phandle, handle, (int)OSVersion.MinProcessQueryInfoAccess);
                                                        int pid = ProcessHandle.FromHandle(dupHandle).ProcessId;

                                                        Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], Program.FocusWindow);
                                                    }
                                                    break;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            PhUtils.ShowException("Unable to show object properties", ex);
                                        }
                                    };

                                    control.Controls.Add(b);
                                }
                                break;
                            case "event":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)EventAccess.QueryState);
                                    var eventProps = new EventProperties(EventHandle.FromHandle(dupHandle));
                                    control.Controls.Add(eventProps);
                                }
                                break;
                            case "eventpair":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)EventPairAccess.All);
                                    var eventPairProps = new EventPairProperties(EventPairHandle.FromHandle(dupHandle));
                                    control.Controls.Add(eventPairProps);
                                }
                                break;
                            case "mutant":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)MutantAccess.QueryState);
                                    var mutantProps = new MutantProperties(MutantHandle.FromHandle(dupHandle));
                                    control.Controls.Add(mutantProps);
                                }
                                break;
                            case "section":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)SectionAccess.Query);
                                    var sectionProps = new SectionProperties(SectionHandle.FromHandle(dupHandle));
                                    control.Controls.Add(sectionProps);
                                }
                                break;
                            case "semaphore":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)SemaphoreAccess.QueryState);
                                    var semaphoreProps = new SemaphoreProperties(SemaphoreHandle.FromHandle(dupHandle));
                                    control.Controls.Add(semaphoreProps);
                                }
                                break;
                            case "timer":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)TimerAccess.QueryState);
                                    var timerProps = new TimerProperties(TimerHandle.FromHandle(dupHandle));
                                    control.Controls.Add(timerProps);
                                }
                                break;
                            case "tmrm":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)ResourceManagerAccess.QueryInformation);
                                    var tmRmProps = new TmRmProperties(ResourceManagerHandle.FromHandle(dupHandle));
                                    control.Controls.Add(tmRmProps);
                                }
                                break;
                            case "tmtm":
                                {
                                    dupHandle = new GenericHandle(phandle, handle, (int)TmAccess.QueryInformation);
                                    var tmTmProps = new TmTmProperties(TmHandle.FromHandle(dupHandle));
                                    control.Controls.Add(tmTmProps);
                                }
                                break;
                        }
                    };

                    hw.Init();

                    IntPtr[] pages = new IntPtr[2];
                    pages[0] = hw.CreatePageHandle();
                    pages[1] = CreateSecurityPage(SecurityEditor.EditSecurity2(
                        null,
                        SecurityEditor.GetSecurableWrapper(dupHandle),
                        hw._name,
                        NativeTypeFactory.GetAccessEntries(NativeTypeFactory.GetObjectType(hw._typeName))
                        ));

                    GCHandle gch = GCHandle.Alloc(pages, GCHandleType.Pinned);
                    header.phpage = gch.AddrOfPinnedObject();

                    PropertySheetW(ref header);

                    if (dupHandle != null)
                        dupHandle.Dispose();
                }
            }
            catch (Exception ex)
            {
                PhUtils.ShowException("Unable to show handle properties", ex);
            }
        }