From 91a50a4b9745572c57b8fe207dc0c297c1c5c970 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 4 May 2015 20:28:55 -0400 Subject: [PATCH] VBOX: Explicitly check the return value if CreateProcess fails while attempting to launch vboxsvc.exe. --- samples/vboxwrapper/vbox_mscom_impl.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/samples/vboxwrapper/vbox_mscom_impl.cpp b/samples/vboxwrapper/vbox_mscom_impl.cpp index a0a7d7c60a..29aa034970 100644 --- a/samples/vboxwrapper/vbox_mscom_impl.cpp +++ b/samples/vboxwrapper/vbox_mscom_impl.cpp @@ -2287,7 +2287,8 @@ int VBOX_VM::launch_vboxsvc() { command = "\"VBoxSVC.exe\" --logrotate 1"; - CreateProcess( + // Execute command + if (!CreateProcess( NULL, (LPTSTR)command.c_str(), NULL, @@ -2298,7 +2299,16 @@ int VBOX_VM::launch_vboxsvc() { virtualbox_home_directory.c_str(), &si, &pi - ); + )) { + vboxlog_msg( + "Status Report: Launching vboxsvc.exe failed!." + ); + vboxlog_msg( + " Error: %s (%d)", + windows_format_error_string(GetLastError(), buf, sizeof(buf)), + GetLastError() + ); + } if (pi.hThread) CloseHandle(pi.hThread); if (pi.hProcess) { @@ -2306,9 +2316,6 @@ int VBOX_VM::launch_vboxsvc() { vboxsvc_pid = pi.dwProcessId; vboxsvc_pid_handle = pi.hProcess; retval = BOINC_SUCCESS; - } else { - vboxlog_msg("Status Report: Launching vboxsvc.exe failed!."); - vboxlog_msg(" Error: %s", windows_format_error_string(GetLastError(), buf, sizeof(buf))); } } }