public ProcessWatcher(IProcessProxy processProxy, IProcessDiscoveryMethod discoveryMethod)
        {
            if (IntPtr.Size != 4)
            logger.Warn("Process Stalker: IntPtr Size != 4"); //Ensure we're running in 32-bit or WoW64

             this.processProxy = processProxy;
             this.discoveryMethod = discoveryMethod;

             //Bubble events from our stalker method to the event handlers of the process stalker
             discoveryMethod.ProcessDiscovered += (a, b) => {
            var capture = NewProcessFound;
            if (capture != null) {
            #if !DEBUG
               try {
            #endif
                  capture(a, b);
            #if !DEBUG
               } catch (Exception e) {
                  logger.Error("ERROR: " + e.ToString());
                  throw;
               }
            #endif
            }
             };
        }
        public BrowserManager(IBrowserConfiguration configuration, IProcessProxy processProxy)
        {
            this.browserConfiguration = configuration;
            this.processProxy         = processProxy;

            this.DetectDefaultBrowserDefinition();
        }
Exemple #3
0
        public static void Execute <TCommand>(this TCommand command, IProcessProxy injectedProcess = null) where TCommand : Command
        {
            var process = injectedProcess ?? new ProcessProxy();

            var arguments = String.Join(" ", command.Switches.Select(x => x.ToString()));
            var info      = new ProcessStartInfo
            {
                FileName        = command.Program,
                Arguments       = arguments,
                UseShellExecute = false,
            };

            process.StartInfo = info;
            process.Start();
            process.WaitForExit();

            if (process.ExitCode != 0)
            {
                throw new ExitCodeException($"Something went wrong. Arguments: {arguments}");
            }

            if (injectedProcess == null)
            {
                process.Dispose();
            }
        }
        public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
             processProxy = new ProcessProxy();
             var pofContext = new PofContext().With(x => {
            x.MergeContext(new DspPofContext());
            x.MergeContext(new TrinketsApiPofContext());
            x.MergeContext(new TrinketsImplPofContext());
             });
             ICollectionFactory collectionFactory = new CollectionFactory();
             IFileSystemProxy fileSystemProxy = new FileSystemProxy(streamFactory);
             IThreadingProxy threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
             var dnsProxy = new DnsProxy();
             INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));
             pofSerializer = new PofSerializer(pofContext);
             PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

             ProxyGenerator proxyGenerator = new ProxyGenerator();
             var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

             // construct libdsp local service node
             ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
             ServiceClient localServiceClient = serviceClientFactory.Construct(clusteringConfiguration);
             keepaliveObjects.Add(localServiceClient);

             temporaryFileService = localServiceClient.GetService<TemporaryFileService>();

             var processInjector = new ProcessInjectorImpl();
             ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);
             processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
             IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
             BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();
             trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
             trinketDtpServerFactory = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
Exemple #5
0
        private void CreateProccess(IProcessProxy processProxy, string binaryPath, string arguments)
        {
            var processStartInfo = new ProcessStartInfo
            {
                FileName               = binaryPath,
                Arguments              = arguments,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                CreateNoWindow         = true
            };

            try
            {
                this.process = processProxy.Start(processStartInfo);

                if (this.process != null)
                {
                    this.process.OutputDataReceived += this.ProcessOutputDataReceived;
                    this.process.BeginOutputReadLine();
                }
                else
                {
                    throw new NullReferenceException("IProcessProxy produced null object");
                }
            }
            catch (Exception ex)
            {
                throw new AggregateException(string.Format("Failed to run process '{0}' with arguments '{1}'", binaryPath, arguments), new[] { ex });
            }
        }
Exemple #6
0
        public ProcessWatcher(IProcessProxy processProxy, IProcessDiscoveryMethod discoveryMethod)
        {
            if (IntPtr.Size != 4)
            {
                logger.Warn("Process Stalker: IntPtr Size != 4"); //Ensure we're running in 32-bit or WoW64
            }
            this.processProxy    = processProxy;
            this.discoveryMethod = discoveryMethod;

            //Bubble events from our stalker method to the event handlers of the process stalker
            discoveryMethod.ProcessDiscovered += (a, b) => {
                var capture = NewProcessFound;
                if (capture != null)
                {
#if !DEBUG
                    try {
#endif
                    capture(a, b);
#if !DEBUG
                }
                catch (Exception e) {
                    logger.Error("ERROR: " + e.ToString());
                    throw;
                }
#endif
                }
            };
        }
 public CommandLineSteamProxy(IProcessProxy processProxy, string steamPath)
 {
     _processProxy = processProxy;
     _steamExePath = steamPath;
     BasePath = Path.GetDirectoryName(_steamExePath);
     UsersPath = Path.Combine(BasePath, "userdata");
     ApplicationsPath = Path.Combine(BasePath, @"Steamapps\Common");
 }
        public ProcessManagerFactory(IProcessProxy processProxy)
        {
            if (processProxy == null)
            {
                throw new ArgumentNullException(nameof(processProxy));
            }

            this.processProxy = processProxy;
        }
Exemple #9
0
        public ProcessManager(IProcessProxy processProxy, string binaryPath, string arguments)
        {
            if (processProxy == null)
            {
                throw new ArgumentNullException(nameof(processProxy));
            }

            this.CreateProccess(processProxy, binaryPath, arguments);
        }
 public static async Task PumpOutput(this IProcessProxy proxy, Action <string> outputLine)
 {
     while (!proxy.HasExited)
     {
         if (await proxy.ReadLineAsync() is { } line)
         {
             outputLine(line);
         }
     }
 }
        public LeagueSessionServiceImpl(IProcessProxy processProxy, LeagueProcessWatcherService leagueProcessWatcherService)
        {
            this.processProxy = processProxy;
            this.leagueProcessWatcherService = leagueProcessWatcherService;

            leagueProcessWatcherService.RadsUserKernelLaunched += HandleLeagueProcessLaunched;
            leagueProcessWatcherService.LauncherLaunched       += HandleLeagueProcessLaunched;
            leagueProcessWatcherService.PatcherLaunched        += HandleLeagueProcessLaunched;
            leagueProcessWatcherService.AirClientLaunched      += HandleLeagueProcessLaunched;
            leagueProcessWatcherService.GameClientLaunched     += HandleLeagueProcessLaunched;
        }
Exemple #12
0
        private async Task PumpOutputStream(IProcessProxy process)
        {
            while (!process.HasExited)
            {
                var line = await process.ReadLineAsync();

                if (line != null)
                {
                    Output.Add(line);
                }
            }
        }
        private static int Invoke(IFileSystem fileSystem, IProcessProxy processProxy, IConsole?console = null)
        {
            var command = new ValidateCommand()
            {
                Handler = new ValidateCommand.CommandHandler(
                    MockEnvironmentProxy.Default,
                    processProxy,
                    fileSystem,
                    MockLoggerFactory.CreateGenericLogger <ValidateCommand>()),
            };

            return(command.Invoke("", console));
        }
        public TrinketProxyEgg()
        {
            streamFactory = new StreamFactory();
            processProxy  = new ProcessProxy();
            var pofContext = new PofContext().With(x => {
                x.MergeContext(new DspPofContext());
                x.MergeContext(new TrinketsApiPofContext());
                x.MergeContext(new TrinketsImplPofContext());
            });
            ICollectionFactory collectionFactory = new CollectionFactory();
            IFileSystemProxy   fileSystemProxy   = new FileSystemProxy(streamFactory);
            IThreadingProxy    threadingProxy    = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory());
            var dnsProxy = new DnsProxy();
            INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy));

            pofSerializer = new PofSerializer(pofContext);
            PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer);

            ProxyGenerator proxyGenerator       = new ProxyGenerator();
            var            serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory);

            // construct libdsp local service node
            ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration();
            ServiceClient           localServiceClient      = serviceClientFactory.Construct(clusteringConfiguration);

            keepaliveObjects.Add(localServiceClient);

            temporaryFileService = localServiceClient.GetService <TemporaryFileService>();

            var processInjector = new ProcessInjectorImpl();
            ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200);

            processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration);
            IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory();
            BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl();

            trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy);
            trinketDtpServerFactory  = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator);
        }
Exemple #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProgramRunner"/> class.
 /// </summary>
 /// <param name="process">The process.</param>
 /// <param name="fileSystem">The file system.</param>
 /// <exception cref="ArgumentNullException">
 /// process
 /// or
 /// fileSystem
 /// </exception>
 public ProgramRunner(IProcessProxy process, IFileSystem fileSystem)
 {
     this.process    = process ?? throw new ArgumentNullException(nameof(process));
     this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
 }
Exemple #16
0
 public CommandHandler(IEnvironmentProxy environmentProxy, IProcessProxy processProxy, IFileSystem fileSystem, ILogger <ValidateCommand> logger)
     : base(fileSystem, logger)
 {
     this.environmentProxy = environmentProxy;
     this.processProxy     = processProxy;
 }
 public ProcessWatcherServiceImpl(IProcessProxy processProxy, IProcessWatcher processWatcher)
 {
     logger.Info("Constructing Process Watching Service");
      this.processProxy = processProxy;
      this.processWatcher = processWatcher;
 }
 public ProcessWatcherServiceImpl(IProcessProxy processProxy, IProcessWatcher processWatcher)
 {
     logger.Info("Constructing Process Watching Service");
     this.processProxy   = processProxy;
     this.processWatcher = processWatcher;
 }
Exemple #19
0
 public NetworkingService(IProcessProxy _processProxy)
 {
     processProxy = _processProxy;
 }
 public GetCookbookByIdQueryHandler(IProcessProxy processProxy)
 {
     _processProxy = processProxy;
 }