api: fix LastError override
The LastError was overridden by the stdout reader thread exit code masking the true reason why ExecuteRunDll32() failed and even worse: as the thread exited gracefully, the true reason was overridden by ERROR_SUCCESS and returning TRUE (success). Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
3f843c9aab
commit
b0ebb6d0ad
@ -206,9 +206,10 @@ cleanupThreads:
|
||||
CloseHandle(StreamWStdout);
|
||||
StreamWStdout = INVALID_HANDLE_VALUE;
|
||||
WaitForSingleObject(ThreadStdout, INFINITE);
|
||||
if (!GetExitCodeThread(ThreadStdout, &LastError))
|
||||
LastError = LOG_LAST_ERROR(L"Failed to retrieve stdout reader result");
|
||||
else if (LastError != ERROR_SUCCESS)
|
||||
DWORD ThreadResult;
|
||||
if (!GetExitCodeThread(ThreadStdout, &ThreadResult))
|
||||
LOG_LAST_ERROR(L"Failed to retrieve stdout reader result");
|
||||
else if (ThreadResult != ERROR_SUCCESS)
|
||||
LOG_ERROR(L"Failed to read process output", LastError);
|
||||
CloseHandle(ThreadStdout);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user