wtsapi32-WTSQueryUserToken: Return a real handle and set last error on failure.

This commit is contained in:
Sebastian Lackner 2016-02-13 07:30:47 +01:00
parent e0c5f8a2b9
commit eb8ffcc900
2 changed files with 17 additions and 9 deletions

View File

@ -7189,7 +7189,7 @@ fi
if test "$enable_wtsapi32_WTSQueryUserToken" -eq 1; then
patch_apply wtsapi32-WTSQueryUserToken/0001-wtsapi32-Improve-WTSQueryUserToken-stub.patch
(
echo '+ { "Sebastian Lackner", "wtsapi32: Improve WTSQueryUserToken stub.", 1 },';
echo '+ { "Sebastian Lackner", "wtsapi32: Improve WTSQueryUserToken stub.", 2 },';
) >> "$patchlist"
fi

View File

@ -1,23 +1,31 @@
From 83df2a25df1f0a9e057fbac19c2c1601373b9c38 Mon Sep 17 00:00:00 2001
From ed5c597acaf69d26f736c90502946292eeef6e40 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 11 Feb 2016 19:07:36 +0100
Subject: wtsapi32: Improve WTSQueryUserToken stub.
Subject: wtsapi32: Improve WTSQueryUserToken stub. (v2)
---
dlls/wtsapi32/wtsapi32.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
dlls/wtsapi32/wtsapi32.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c
index c668604..e1a9cd2 100644
index c668604..6f8223c 100644
--- a/dlls/wtsapi32/wtsapi32.c
+++ b/dlls/wtsapi32/wtsapi32.c
@@ -243,7 +243,8 @@ BOOL WINAPI WTSQuerySessionInformationW(
@@ -243,7 +243,16 @@ BOOL WINAPI WTSQuerySessionInformationW(
BOOL WINAPI WTSQueryUserToken(ULONG session_id, PHANDLE token)
{
FIXME("%u %p\n", session_id, token);
- return FALSE;
+ if (token) *token = GetCurrentProcessToken();
+ return token != NULL;
+
+ if (!token)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ return DuplicateHandle(GetCurrentProcess(), GetCurrentProcessToken(),
+ GetCurrentProcess(), token,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
}
/************************************************************