Esempio n. 1
0
        public MainWindow(Mutex mutex, out bool showUsrDiag)
        {
            // data router
            _mutex = mutex;
            br     = new BindingRouter(env);

            // services
            if (!ApiVendor.TryPrepareRestApi())
            {
                InlineLogic.ServerUnreachableLogic();
            }

            showUsrDiag = SupportStatic.RemoteInitialize(br.ConfAutoUpdate);
            SupportStatic.InitializeAll();

            pool = new DataPool(x => LoggingManagementService.WriteLine(x, "UplMgmt"));

            SubprocessManagementService.OnOverrideRequested += br.SaveConfig;
            LoggingManagementService.OnNewLogLine           += br.DummyListener;
            TransmittingManagementService.OnDataOutput      += pool.SinkData;
            TransmittingManagementService.OnDataOutput      += LocalHandler;

            // user interface
            InitializeComponent();
            InitializeWinformComponent();
            CommandBindings.Add(new CommandBinding(BindingRouter.UiSearchLineEnterCommand, OnCommandLineEnter));
            this.DataContext = br;

#if DEBUG
            Title = "Milvaneth Prélude";
#endif

            // subviews
            ip = new ItemOverviewPage(br);
            sp = new SettingPage(br);
            lp = new LogPage(br);
            ap = new AboutPage(br);

            // custom message
            InlineLogic.GlobalMessageLogic();

            if (!showUsrDiag)
            {
                ShowOverlay();
            }

            // finish initialize
            if (br.ConfAutoAttach)
            {
                SubprocessManagementService.SpawnAll(out _);
            }
            if (!br.ConfNotUseHunter)
            {
                SubprocessManagementService.SpawnHunter();
            }

            br.UiActiveTab = 3;
            MainFrame.Navigate(ap);
        }
Esempio n. 2
0
 public static void InitializeAll()
 {
     LoggingManagementService.Initialize();
     DictionaryManagementService.Initialize();
     IconManagementService.Initialize();
     TransmittingManagementService.Initialize();
     SubprocessManagementService.Initialize();
 }
Esempio n. 3
0
        private void Button_Attach_Game(object sender, RoutedEventArgs e)
        {
            var val = (string)GamePidList.SelectedValue;

            if (int.TryParse(val, out var pid))
            {
                SubprocessManagementService.SpawnSpecific(pid);
            }
        }
Esempio n. 4
0
        public static void ExitAll()
        {
            TransmittingManagementService.SendSignal(Signal.CommandParentExit, new[] { Process.GetCurrentProcess().Id.ToString() });

            Thread.Sleep(3000);

            try { TransmittingManagementService.Dispose(); } catch { /* ignored */ }
            try { SubprocessManagementService.Dispose(); } catch { /* ignored */ }
            try { IconManagementService.Dispose(); } catch { /* ignored */ }
            try { DictionaryManagementService.Dispose(); } catch { /* ignored */ }
            try { LoggingManagementService.Dispose(); } catch { /* ignored */ }
        }
        public static bool Collect(int timeout, out LobbyServiceResult service, out LobbyCharacterResult character)
        {
            service   = null;
            character = null;

            SubprocessManagementService.SpawnAll(out _);
            SubprocessManagementService.SpawnHunter();

            lock (LockObject)
            {
                if (!_filterOn)
                {
                    TransmittingManagementService.OnDataOutput += Filter;
                    _filterOn = true;
                }
            }

            int cycle = 0;

            while (Math.Abs(_serviceTime - Environment.TickCount) > 10000 || Math.Abs(_characterTime - Environment.TickCount) > 10000)
            {
                if (100 * cycle > timeout)
                {
                    return(false);
                }

                Thread.Sleep(100);
                cycle++;
            }

            service   = _service;
            character = _character;

            lock (LockObject)
            {
                if (_filterOn)
                {
                    TransmittingManagementService.OnDataOutput -= Filter;
                    _filterOn = false;
                }
            }

            return(true);
        }
        private static void NotificationListener(int sender, Signal sig, DateTime time, string stack, string[] args)
        {
            switch (sig)
            {
            case Signal.ClientInsuffcientPrivilege:
                if (args == null || args.Length < 1 || !int.TryParse(args[0], out _))
                {
                    return;
                }

                LoggingManagementService.WriteLine($"Privilege fail on {sender}, user action is needed", "SigMgmt");
                break;

            case Signal.ClientNetworkFail:
                if (args == null || args.Length < 1 || !int.TryParse(args[0], out _))
                {
                    return;                                                                       // we need validation
                }
                LoggingManagementService.WriteLine($"Network fail on {sender}, user action is needed", "SigMgmt");
                break;

            case Signal.ClientProcessDown:
                if (args == null || args.Length < 1 || !int.TryParse(args[0], out var pid3))
                {
                    return;
                }

                LoggingManagementService.WriteLine($"Game process {pid3} has exited", "SigMgmt");
                break;

            case Signal.ClientPacketParseFail:
                if (args == null || args.Length < 1)
                {
                    return;
                }

                LoggingManagementService.WriteLine($"Malformed packet ({args[0]}) on {sender}, data may loss", "SigMgmt");
                break;

            case Signal.MilvanethSubprocessExit:
                if (args == null || args.Length < 2)
                {
                    return;
                }

                LoggingManagementService.WriteLine($"Monitor process {sender}  has exited: {string.Join("|", args)}",
                                                   "SigMgmt");
                break;

            case Signal.MilvanethComponentExit:
                if (args == null || args.Length < 2)
                {
                    return;
                }

                SubprocessManagementService.KillSpecific(sender);
                LoggingManagementService.WriteLine($"Monitor component {sender}  has exited: {string.Join("|", args)}",
                                                   "SigMgmt");
                break;

            case Signal.MilvanethNeedUpdate:
                if (args == null || args.Length < 2)
                {
                    return;
                }

                SubprocessManagementService.KillSpecific(sender);
                LoggingManagementService.WriteLine($"Update is required by {sender}: {string.Join("|", args)}",
                                                   "SigMgmt");
                break;

            case Signal.MilvanethSubprocessReady:
                if (args == null || args.Length < 1 || !int.TryParse(args[0], out var pid4))
                {
                    return;
                }

                SubprocessManagementService.UpdateRegistryEntity(sender, pid4);
                LoggingManagementService.WriteLine($"Monitor service {sender} has started on {pid4}", "SigMgmt");
                break;

            default:
                break;
            }

            Task.Run(() => InlineLogic.PostSignalNotifyLogic(sig));
        }