Exemplo n.º 1
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);
     });
 }
Exemplo n.º 2
0
 public static void PreloadAddresses()
 {
     // Dummy. Static constructor only needed.
     if (!initialized)
     {
         ActionWrappers.TryCatch(() => { x64LoadLibraryAddress = Getx64LoadLibraryAddress(); });
         ActionWrappers.TryCatch(() => { x86LoadLibraryAddress = Getx86LoadLibraryAddress(); });
         initialized = true;
     }
 }
Exemplo n.º 3
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.TryCatch(() =>
                {
                    var processPath = Path.GetFullPath(process.GetExecutablePath());

                    if (string.Equals(processPath, _applicationPath, StringComparison.OrdinalIgnoreCase))
                    {
                        _processes.Add(process);
                    }
                });
            }
        }