コード例 #1
0
        /// <summary>
        /// Injects the Reloaded bootstrapper into an active process.
        /// </summary>
        /// <exception cref="ArgumentException">DLL Injection failed, likely due to bad DLL or application.</exception>
        public void Inject()
        {
            long handle = _injector.Inject(GetBootstrapperPath(_process));

            if (handle == 0)
            {
                throw new ArgumentException(Errors.DllInjectionFailed());
            }

            // Wait until mod loader loads.
            // If debugging, ignore timeout.
            bool WhileCondition()
            {
                if (CheckRemoteDebuggerPresent(_process.Handle, out var isDebuggerPresent))
                {
                    return(isDebuggerPresent);
                }

                return(false);
            }

            ActionWrappers.TryGetValueWhile(() =>
            {
                // Exit if application crashes while loading Reloaded..
                if (_process.HasExited)
                {
                    return(0);
                }

                return(Client.GetPort((int)_process.Id));
            }, WhileCondition, _xamlModLoaderSetupTimeout.Get(), _xamlModLoaderSetupSleepTime.Get());
        }
コード例 #2
0
 private void ApplicationLaunched(object sender, EventArrivedEventArgs e)
 {
     ActionWrappers.TryCatch(() =>
     {
         var processId = Convert.ToInt32(e.NewEvent.Properties[WmiProcessidName].Value);
         var process   = Process.GetProcessById(processId);
         RaiseOnNewProcess(process);
     });
 }
コード例 #3
0
 public static void PreloadAddresses()
 {
     // Dummy. Static constructor only needed.
     if (!initialized)
     {
         ActionWrappers.TryCatch(() => { x64LoadLibraryAddress = Getx64LoadLibraryAddress(); });
         ActionWrappers.TryCatch(() => { x86LoadLibraryAddress = Getx86LoadLibraryAddress(); });
         initialized = true;
     }
 }
コード例 #4
0
        private void BuildInitialProcesses(CancellationToken token = default)
        {
            var allProcesses = Process.GetProcesses();

            _processes = new HashSet <Process>(allProcesses.Length);

            foreach (var process in allProcesses)
            {
                if (token.IsCancellationRequested)
                {
                    return;
                }

                ActionWrappers.TryCatchDiscard(() =>
                {
                    var processPath = Path.GetFullPath(process.GetExecutablePath());

                    if (string.Equals(processPath, _applicationPath, StringComparison.OrdinalIgnoreCase))
                    {
                        _processes.Add(process);
                    }
                });
            }
        }
コード例 #5
0
 private void OnAvailableXamlFilesUpdated(object sender, FileSystemEventArgs e)
 {
     ActionWrappers.ExecuteWithApplicationDispatcher(PopulateXamlFiles);
 }