Example #1
0
        private void ExecuteProcess()
        {
            Process = new Process();

            // ProcessのFileNameにパスを入れて起動する際は絶対パスがいる
            var fullPath = Path.GetFullPath(ExePath);

            Process.StartInfo.FileName  = fullPath;
            Process.EnableRaisingEvents = true;
            Process.Exited += EndProcess;

            Process.Start();

            OnProcessStarted?.Invoke(this);
        }
        private static void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var running = Process.GetProcesses().Select(x => x.ProcessName).ToList();

            foreach (var setting in AutomaticDimmerSettings)
            {
                if (running.Contains(setting.ProcessName) && !RunningProcesses.Contains(setting.ProcessName))
                {
                    RunningProcesses.Add(setting.ProcessName);
                    OnProcessStarted?.Invoke(setting.DimmedScreen);
                }
                else if (!running.Contains(setting.ProcessName) && RunningProcesses.Contains(setting.ProcessName))
                {
                    RunningProcesses.Remove(setting.ProcessName);
                    OnProcessClosed?.Invoke(setting.DimmedScreen);
                }
            }
        }
Example #3
0
        public void AddProcess(Application app, bool IsBackGroundProcess = false)
        {
            app.AppProcess = new Process(_pidcounter);
            if (!mManager.Allocate(app))
            {
                System.Windows.MessageBox.Show($"Could not allocate enough memory for that.\nAlloation Scheme: {mManager.AllocationMode.ToString()}", "OUT OF MEMORY", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return;
            }
            app.AppWindowLogic.AppData = app;
            Apps.Add(app);
            if (IsBackGroundProcess)
            {
                app.IsSystemApp = true;
            }

            OnProcessStarted?.Invoke(app);
            _pidcounter++;
        }
Example #4
0
        public void Inject()
        {
            StartupConfiguration configuration = ConfigurationManager.Instance.Startup;

            if (configuration is null)
            {
                logger.Error("startup configuration is null");
                return;
            }

            int port = ProxyPort;

            _hook = new HookElement();
            {
                _hook.IpcServer = RemoteHooking.IpcCreateServer <BotoxHookInterface <T> >(ref _hook.ChannelName, WellKnownObjectMode.Singleton);
            }

            RemoteHooking.CreateAndInject(
                configuration.game_location,
                string.Empty,
                0x00000004,
                InjectionOptions.DoNotRequireStrongName,
                configuration.dll_location,
                configuration.dll_location,
                out _hook.ProcessId,
                _hook.ChannelName,
                port);

            Proxy = new CustomProxy <T>(ProxyPort, _hook.ProcessId);

            Process process = Process.GetProcessById(_hook.ProcessId);

            process.EnableRaisingEvents = true;

            if (process.WaitForInputIdle())
            {
                logger.Info($"process opened : {process.ProcessName} {process.Id}");
                OnProcessStarted?.Invoke(this);
            }

            process.Exited += Process_Exited;
        }