public void HandlePreclientProcessLaunchedTest() { const int processId = 13337; var process = CreateUntrackedMock <IProcess>(); var preclientConfiguration = CreateUntrackedMock <TrinketSpawnConfiguration>(); When(process.Id).ThenReturn(processId); When(leagueTrinketSpawnConfigurationFactory.GetPreclientConfiguration()).ThenReturn(preclientConfiguration); testObj.HandlePreclientProcessLaunched(process); Verify(leagueTrinketSpawnConfigurationFactory).GetPreclientConfiguration(); Verify(trinketSpawner).SpawnTrinket(process, preclientConfiguration); VerifyNoMoreInteractions(); }
internal void HandlePreclientProcessLaunched(IProcess processInput) { var process = Process.GetProcessById(processInput.Id); var threads = process.Threads.Cast <ProcessThread>().ToArray(); var suspendedThreadsHandles = threads.Select(thread => OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id)).ToArray(); foreach (var suspendedThreadHandle in suspendedThreadsHandles) { SuspendThread(suspendedThreadHandle); } trinketSpawner.SpawnTrinket( processInput, leagueTrinketSpawnConfigurationFactory.GetPreclientConfiguration() ); foreach (var suspendedThreadHandle in suspendedThreadsHandles) { ResumeThread(suspendedThreadHandle); } }