diff options
author | Pali Rohár <pali@kernel.org> | 2024-02-28 01:06:38 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2024-04-05 13:14:04 +0200 |
commit | 90251023d44d50973e956d308b29a53ae84668e3 (patch) | |
tree | ddcb706e5f5c3a4d1d7bc61117fa2273e7053848 | |
parent | 1836a2d4c62a3adbad269e8177528c42daf40f42 (diff) | |
download | pciutils-90251023d44d50973e956d308b29a53ae84668e3.tar.gz |
windows: Correctly propagate error code from win32_call_func_with_tcb_privilege()
Cleanup phase may change error code as it calls other WinAPI functions.
-rw-r--r-- | lib/win32-helpers.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/win32-helpers.c b/lib/win32-helpers.c index d370d5c..5338efa 100644 --- a/lib/win32-helpers.c +++ b/lib/win32-helpers.c @@ -1227,6 +1227,7 @@ win32_call_func_with_tcb_privilege(BOOL (*function)(LPVOID), LPVOID argument) HANDLE lsass_process; HANDLE lsass_token; + DWORD error; BOOL ret; impersonate_privilege_enabled = FALSE; @@ -1374,6 +1375,8 @@ err_privilege_not_held: goto ret; ret: + error = GetLastError(); + if (revert_to_old_token) win32_revert_to_token(old_token); @@ -1383,5 +1386,7 @@ ret: if (lsass_token) CloseHandle(lsass_token); + SetLastError(error); + return ret; } |