PROJECT ReactOS kernel-mode tests LICENSE GPLv2 See COPYING in the top

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
/*
* PROJECT: ReactOS kernel-mode tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
* PURPOSE: Kernel-Mode Test for SeAppendPrivileges / SePrivilegeCheck /
* SeQueryInformationToken (TokenPrimaryGroup, TokenPrivileges,
* TokenSessionId, TokenSource) / SeFreePrivileges
* PROGRAMMER:
*/
/*
NTSTATUS SeAppendPrivileges(
_Inout_ PACCESS_STATE AccessState,
_In_ PPRIVILEGE_SET Privileges
);
BOOLEAN SePrivilegeCheck(
_Inout_ PPRIVILEGE_SET RequiredPrivileges,
_In_ PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
_In_ KPROCESSOR_MODE AccessMode
);
NTSTATUS SeQueryInformationToken(
_In_ PACCESS_TOKEN Token,
_In_ TOKEN_INFORMATION_CLASS TokenInformationClass,
_Out_ PVOID *TokenInformation
);
VOID SeFreePrivileges(
_In_ PPRIVILEGE_SET Privileges
);
*/
#include <kmt_test.h>
#include <debug.h>
static
VOID
Testfunction(VOID) {
//NTSTATUS Status;
BOOLEAN privchek;
PPRIVILEGE_SET privset;
/*typedef struct _PRIVILEGE_SET {
DWORD PrivilegeCount;
DWORD Control;
LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
} PRIVILEGE_SET, *PPRIVILEGE_SET;*/
PSECURITY_SUBJECT_CONTEXT secsubobj;
privchek = SePrivilegeCheck(privset, pseccon, UserMode);
ok_eq_bool(privchek, FALSE);
privchek = SePrivilegeCheck(privset, secsubobj, UserMode);
ok_eq_bool(privchek, FALSE);
privchek = SePrivilegeCheck(privset, secsubobj, KernelMode);//must be true
ok_eq_bool(privchek, TRUE);
PTOKEN_PRIMARY_GROUP tokprimgr;
PTOKEN_PRIVILEGES tokpriv;
PTOKEN_SESSION_ID tokpriv;
PTOKEN_SOURCE toksource;
//Status = SeQueryInformationToken(TOKEN_QUERY, TokenPrimaryGroup, tokprimgr);
//Status = SeQueryInformationToken(TOKEN_QUERY, TokenPrivileges, tokpriv);
//Status = SeQueryInformationToken(TOKEN_QUERY, TokenSessionId, tokpriv);
//Status = SeQueryInformationToken(TOKEN_QUERY_SOURCE, TokenSource, toksource);
}
START_TEST(Trytest)
{
Testfunction();
ok(1, "This test should succeed.\n");
ok(0, "This test should fail.\n");
trace("Message from kernel, low-irql. %s. %ls.\n", "Format strings work", L"Even with Unicode");
ok_irql(DISPATCH_LEVEL);
ok_eq_int(5, 6);
ok_eq_uint(6U, 7U);
ok_eq_long(1L, 2L);
ok_eq_ulong(3LU, 4LU);
ok_eq_pointer((PVOID)8, (PVOID)9);
ok_eq_hex(0x1234LU, 0x5678LU);
ok_eq_bool(TRUE, TRUE);
ok_eq_bool(TRUE, FALSE);
ok_eq_bool(FALSE, TRUE);
ok_bool_true(FALSE, "foo");
ok_bool_false(TRUE, "bar");
ok_eq_print(1, 2, "%i");
ok_eq_str("Hello", "world");
ok_eq_wstr(L"ABC", L"DEF");
}