1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE:         Test for NtOpenProcessToken[Ex]
5  * PROGRAMMER:      Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include "precomp.h"
9 
10 START_TEST(NtOpenProcessToken)
11 {
12     NTSTATUS Status;
13     HANDLE TokenHandle;
14 
15     Status = NtOpenProcessToken(NtCurrentProcess(),
16                                 TOKEN_READ,
17                                 &TokenHandle);
18     ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
19     if (NT_SUCCESS(Status))
20     {
21         ok((LONG_PTR)TokenHandle > 0, "TokenHandle = %p\n", TokenHandle);
22         Status = NtClose(TokenHandle);
23         ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
24     }
25 
26     Status = NtOpenProcessTokenEx(NtCurrentProcess(),
27                                   TOKEN_READ,
28                                   0,
29                                   &TokenHandle);
30     ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
31     if (NT_SUCCESS(Status))
32     {
33         ok((LONG_PTR)TokenHandle > 0, "TokenHandle = %p\n", TokenHandle);
34         Status = NtClose(TokenHandle);
35         ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
36     }
37 
38     Status = NtOpenProcessTokenEx(NtCurrentProcess(),
39                                   TOKEN_READ,
40                                   OBJ_KERNEL_HANDLE,
41                                   &TokenHandle);
42     ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
43     if (NT_SUCCESS(Status))
44     {
45         ok((LONG_PTR)TokenHandle > 0, "TokenHandle = %p\n", TokenHandle);
46         Status = NtClose(TokenHandle);
47         ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status);
48     }
49 }
50