Jacek Caban : server: Support token object type.

Alexandre Julliard julliard at winehq.org
Fri Feb 22 15:22:11 CST 2019


Module: wine
Branch: master
Commit: c55c4ab88c7178f92ca21813ed138a9528f04dad
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c55c4ab88c7178f92ca21813ed138a9528f04dad

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Feb 22 13:14:20 2019 +0100

server: Support token object type.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/om.c | 10 ++++++++++
 server/token.c        | 10 +++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index 516304e..3110dbf 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -1348,6 +1348,7 @@ static void test_query_object(void)
     UNICODE_STRING path, session, *str;
     char dir[MAX_PATH], tmp_path[MAX_PATH], file1[MAX_PATH + 16];
     LARGE_INTEGER size;
+    BOOL ret;
 
     sprintf( tmp_path, "\\Sessions\\%u", NtCurrentTeb()->Peb->SessionId );
     pRtlCreateUnicodeStringFromAsciiz( &session, tmp_path );
@@ -1566,6 +1567,15 @@ static void test_query_object(void)
 
     test_object_type( GetCurrentThread(), "Thread" );
     test_no_file_info( GetCurrentThread() );
+
+    ret = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &handle);
+    ok(ret, "OpenProcessToken failed: %u\n", GetLastError());
+
+    test_object_type( handle, "Token" );
+    test_no_file_info( handle );
+
+    pNtClose(handle);
+
 }
 
 static void test_type_mismatch(void)
diff --git a/server/token.c b/server/token.c
index d88f16c..e440d48 100644
--- a/server/token.c
+++ b/server/token.c
@@ -134,6 +134,7 @@ struct group
 };
 
 static void token_dump( struct object *obj, int verbose );
+static struct object_type *token_get_type( struct object *obj );
 static unsigned int token_map_access( struct object *obj, unsigned int access );
 static void token_destroy( struct object *obj );
 
@@ -141,7 +142,7 @@ static const struct object_ops token_ops =
 {
     sizeof(struct token),      /* size */
     token_dump,                /* dump */
-    no_get_type,               /* get_type */
+    token_get_type,            /* get_type */
     no_add_queue,              /* add_queue */
     NULL,                      /* remove_queue */
     NULL,                      /* signaled */
@@ -167,6 +168,13 @@ static void token_dump( struct object *obj, int verbose )
              token->token_id.low_part, token->primary, token->impersonation_level );
 }
 
+static struct object_type *token_get_type( struct object *obj )
+{
+    static const WCHAR name[] = {'T','o','k','e','n'};
+    static const struct unicode_str str = { name, sizeof(name) };
+    return get_object_type( &str );
+}
+
 static unsigned int token_map_access( struct object *obj, unsigned int access )
 {
     if (access & GENERIC_READ)    access |= TOKEN_READ;




More information about the wine-cvs mailing list