示例#1
0
 private bool Respawn()
 {
     _ulteriusInstance = null;
     _ulteriusInstance = WardenProcess.Start(_ulteriusPath, string.Empty, null, true).GetAwaiter().GetResult();
     if (_ulteriusInstance == null || !_ulteriusInstance.IsTreeActive())
     {
         return(false);
     }
     _ulteriusInstance.OnStateChange += UlteriusInstanceOnOnStateChange;
     return(true);
 }
示例#2
0
        private static async Task Start()
        {
            WardenManager.Initialize();
            Console.Write("Enter the process ID: ");
            var processId = int.Parse(Console.ReadLine());
            var test      = WardenProcess.GetProcessFromId(processId);

            test.OnProcessAdded += delegate(object sender, ProcessAddedEventArgs args)
            {
                if (args.ParentId == test.Id)
                {
                    Console.WriteLine($"Added child {args.Name}({args.Id}) to root process {test.Name}({test.Id})");
                }
                else
                {
                    var parentInfo = test.FindChildById(args.ParentId);
                    if (parentInfo != null)
                    {
                        Console.WriteLine($"Added child process {args.Name}({args.Id}) to child {parentInfo.Name}({parentInfo.Id})");
                    }
                }
            };
            test.OnStateChange += delegate(object sender, StateEventArgs args)
            {
                Console.WriteLine($"---\nName: {test.Name}\nId: {test.Id}\nstate changed to {args.State}\n---");
            };
            test.OnChildStateChange += delegate(object sender, StateEventArgs args)
            {
                var childInfo = test.FindChildById(args.Id);
                if (childInfo != null)
                {
                    Console.WriteLine($"---\nName: {childInfo.Name}\nId: {childInfo.Id}\nParentId:{childInfo.ParentId}\nstated changed to {args.State}\n---");
                }
            };
            Console.WriteLine($"Hooked into {test.Name}({test.Id})");
            Console.Read();
            Console.WriteLine("Start notepad");
            var wardenTest = await WardenProcess.Start("notepad.exe", string.Empty, ProcessTypes.Win32);

            if (wardenTest != null)
            {
                wardenTest.OnStateChange += delegate(object sender, StateEventArgs args)
                {
                    Console.WriteLine($"---\nName: {wardenTest.Name}\nId: {wardenTest.Id}\nstate changed to {args.State}\n---");
                };
            }
            Console.ReadKey(true);
        }
示例#3
0
        public async void WardenGetsTestProcessInformation()
        {
            WardenManager.Initialize();
            var testProcess = await WardenProcess.Start("TestProcess.exe", string.Empty, ProcessTypes.Win32);

            var children = testProcess.Children.ToArray();

            testProcess.OnChildStateChange += TestProcessOnOnChildStateChange;
            await Task.Delay(5000);

            Assert.NotEmpty(testProcess.Children);
            testProcess.Kill();
            await Task.Delay(2000);

            Assert.True(testProcess.State == ProcessState.Dead);
        }
示例#4
0
文件: Program.cs 项目: zaksnet/warden
        private static void Main(string[] args)
        {
            var process = WardenProcess.GetCurrentProcess();

            Console.WriteLine(process.Info);

            SystemProcessMonitor.Start(new MonitorOptions());

            WardenProcess.Start(new WardenStartInfo
            {
                FileName = "spotify://album:27ftYHLeunzcSzb33Wk1hf",
                Track    = false,
            });

            var solitaire = WardenProcess.Start(
                new WardenStartInfo
            {
                FileName    = "xboxliveapp-1297287741:",
                TargetImage = "C:\\Program Files\\WindowsApps\\Microsoft.MicrosoftSolitaireCollection_4.7.10142.0_x64__8wekyb3d8bbwe\\Solitaire.exe",
                Track       = true,
            }, OnFound);

            if (solitaire is { Info : not null })
示例#5
0
        private static async Task Start()
        {
            WardenManager.Initialize(new WardenOptions
            {
                CleanOnExit     = true,
                DeepKill        = true,
                ReadFileHeaders = true
            });
            Console.Write("Enter the process ID: ");
            var processId = int.Parse(Console.ReadLine());
            var test      = WardenProcess.GetProcessFromId(processId);

            if (test != null)
            {
                test.OnProcessAdded += delegate(object sender, ProcessAddedEventArgs args)
                {
                    if (args.ParentId == test.Id)
                    {
                        Console.WriteLine($"Added child {args.Name}({args.Id}) to root process {test.Name}({test.Id})");
                    }
                    else
                    {
                        var parentInfo = test.FindChildById(args.ParentId);
                        if (parentInfo != null)
                        {
                            Console.WriteLine($"Added child process {args.Name}({args.Id}) to child {parentInfo.Name}({parentInfo.Id})");
                        }
                    }
                };
                test.OnStateChange += delegate(object sender, StateEventArgs args)
                {
                    Console.WriteLine($"---\nName: {test.Name}\nId: {test.Id}\nstate changed to {args.State}\n---");
                };
                test.OnChildStateChange += delegate(object sender, StateEventArgs args)
                {
                    var childInfo = test.FindChildById(args.Id);
                    if (childInfo != null)
                    {
                        Console.WriteLine($"---\nName: {childInfo.Name}\nId: {childInfo.Id}\nParentId:{childInfo.ParentId}\nstated changed to {args.State}\n---");
                    }
                };
                Console.WriteLine($"Hooked into {test.Name}({test.Id})");
                Console.Read();
                Console.WriteLine(JsonConvert.SerializeObject(test, Formatting.Indented));
                test.Kill();
            }



            Console.WriteLine("Start notepad");
            var wardenTest = await WardenProcess.Start("notepad", string.Empty, null);

            if (wardenTest != null)
            {
                wardenTest.OnStateChange += delegate(object sender, StateEventArgs args)
                {
                    Console.WriteLine($"---\nName: {wardenTest.Name}\nId: {wardenTest.Id}\nstate changed to {args.State}\n---");
                };
            }
            Console.ReadKey(true);
        }