Skip to content

Commit 0d3ce1c

Browse files
committed
StartProcessCreateBreakawayFromJob: dispose the process on failure here instead of the caller
1 parent 5b45c8a commit 0d3ce1c

4 files changed

Lines changed: 21 additions & 16 deletions

File tree

FlashpointSecurePlayer/FlashpointSecurePlayerGUI.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -657,13 +657,6 @@ private void ActivateMode(TemplateElement templateElement, ErrorDelegate errorDe
657657
LogExceptionToLauncher(ex);
658658
// popup message box and blow up
659659
errorDelegate(Properties.Resources.JobObjectNotCreated);
660-
661-
if (softwareProcess != null) {
662-
softwareProcess.Kill();
663-
softwareProcess.Dispose();
664-
softwareProcess = null;
665-
}
666-
667660
Environment.Exit(-1);
668661
throw new InvalidModeException("The Mode failed to create a Job Object.");
669662
}

FlashpointSecurePlayer/RegistryStates.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ public async Task StartImportAsync(string templateName, BINARY_TYPE binaryType)
762762
}
763763

764764
if (resumeEventWaitHandle == null) {
765-
throw new InvalidOperationException("resumeEventWaitHandle must not be NULL.");
765+
throw new InvalidOperationException("resumeEventWaitHandle is null.");
766766
}
767767

768768
try {
@@ -863,7 +863,7 @@ private async Task StopImportAsync(bool sync) {
863863
base.StopImport();
864864

865865
if (resumeEventWaitHandle == null) {
866-
throw new InvalidOperationException("resumeEventWaitHandle must not be NULL.");
866+
throw new InvalidOperationException("resumeEventWaitHandle is null.");
867867
}
868868

869869
resumeEventWaitHandle.Set();
@@ -1532,7 +1532,7 @@ private void GotValue(RegistryTraceData registryTraceData) {
15321532
// with reassurance the control has installed already
15331533
// therefore, key names will be redirected properly
15341534
if (resumeEventWaitHandle == null) {
1535-
throw new InvalidOperationException("resumeEventWaitHandle must not be NULL.");
1535+
throw new InvalidOperationException("resumeEventWaitHandle is null.");
15361536
}
15371537

15381538
resumeEventWaitHandle.WaitOne();

FlashpointSecurePlayer/Shared.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,11 +2679,23 @@ public static void StartProcessCreateBreakawayFromJob(ProcessStartInfo processSt
26792679

26802680
try {
26812681
process = Process.GetProcessById((int)processInformation.dwProcessId);
2682-
ProcessSync.Start(process);
26832682

2684-
if (ResumeThread(processInformation.hThread) == -1) {
2685-
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
2686-
return;
2683+
if (process == null) {
2684+
throw new InvalidOperationException("process is null.");
2685+
}
2686+
2687+
try {
2688+
ProcessSync.Start(process);
2689+
2690+
if (ResumeThread(processInformation.hThread) == -1) {
2691+
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
2692+
return;
2693+
}
2694+
} catch {
2695+
process.Kill();
2696+
process.Dispose();
2697+
process = null;
2698+
throw;
26872699
}
26882700
} finally {
26892701
if (!CloseHandle(processInformation.hProcess)) {

FlashpointSecurePlayer/WebBrowserMode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam) {
6060
public WINDOWPLACEMENT WindowPlacement {
6161
get {
6262
if (!IsHandleCreated || Handle == IntPtr.Zero) {
63-
throw new InvalidOperationException("Handle must not be NULL.");
63+
throw new InvalidOperationException("Handle is null.");
6464
}
6565

6666
WINDOWPLACEMENT value = new WINDOWPLACEMENT();
@@ -74,7 +74,7 @@ public WINDOWPLACEMENT WindowPlacement {
7474

7575
set {
7676
if (!IsHandleCreated || Handle == IntPtr.Zero) {
77-
throw new InvalidOperationException("Handle must not be NULL.");
77+
throw new InvalidOperationException("Handle is null.");
7878
}
7979

8080
value.length = Marshal.SizeOf(value);

0 commit comments

Comments
 (0)