aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-11-06 16:50:00 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-07 15:04:33 +0100
commitb0ebb6d0ad5dbf1a8aff14a7c8aa2089de6e66ff (patch)
treeccb7d75b3c6c9ccd65f885059fb925fb9ad5d478 /api
parentproj: use less scary caps for zip license file (diff)
downloadwintun-b0ebb6d0ad5dbf1a8aff14a7c8aa2089de6e66ff.tar.xz
wintun-b0ebb6d0ad5dbf1a8aff14a7c8aa2089de6e66ff.zip
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>
Diffstat (limited to 'api')
-rw-r--r--api/rundll32_i.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/api/rundll32_i.c b/api/rundll32_i.c
index 1b0a8d4..1623409 100644
--- a/api/rundll32_i.c
+++ b/api/rundll32_i.c
@@ -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);
}