2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtQuery/SetSystemInformation
5 * PROGRAMMERS: Timo Kreuzer
10 #define WIN32_NO_STATUS
11 #include <ndk/exfuncs.h>
19 OpenProcessToken(GetCurrentProcess(),
20 TOKEN_ADJUST_PRIVILEGES
| TOKEN_QUERY
,
23 LookupPrivilegeValue(NULL
, SE_SYSTEMTIME_NAME
, &tkp
.Privileges
[0].Luid
);
25 tkp
.PrivilegeCount
= 1;
26 tkp
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
28 AdjustTokenPrivileges(hToken
, FALSE
, &tkp
, 0, NULL
, 0);
34 Test_TimeAdjustment(void)
36 SYSTEM_QUERY_TIME_ADJUST_INFORMATION TimeInfoOrg
, GetTimeInfo
;
37 SYSTEM_SET_TIME_ADJUST_INFORMATION SetTimeInfo
;
41 SetTimeInfo
.TimeAdjustment
= 0;
42 SetTimeInfo
.Enable
= 0;
44 /* Query original values */
45 Status
= NtQuerySystemInformation(SystemTimeAdjustmentInformation
,
50 /* Test without privilege */
51 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
54 ok_ntstatus(Status
, STATUS_PRIVILEGE_NOT_HELD
);
56 /* Get the required privilege */
59 /* Test wrong length */
60 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
62 sizeof(SetTimeInfo
) + 1);
63 ok_ntstatus(Status
, STATUS_INFO_LENGTH_MISMATCH
);
65 /* Test both members 0 */
66 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
69 ok_ntstatus(Status
, STATUS_INVALID_PARAMETER_2
);
72 SetTimeInfo
.TimeAdjustment
= -1;
73 SetTimeInfo
.Enable
= 0;
74 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
77 ok_ntstatus(Status
, STATUS_SUCCESS
);
79 /* Query the result */
80 Status
= NtQuerySystemInformation(SystemTimeAdjustmentInformation
,
84 ok_ntstatus(Status
, STATUS_SUCCESS
);
85 ok_long(GetTimeInfo
.TimeAdjustment
, -1);
86 ok_long(GetTimeInfo
.Enable
, 0);
89 SetTimeInfo
.TimeAdjustment
= -1;
90 SetTimeInfo
.Enable
= 1;
91 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
94 ok_ntstatus(Status
, STATUS_SUCCESS
);
96 /* Query the result */
97 Status
= NtQuerySystemInformation(SystemTimeAdjustmentInformation
,
101 ok_ntstatus(Status
, STATUS_SUCCESS
);
102 ok_long(GetTimeInfo
.TimeAdjustment
, GetTimeInfo
.TimeIncrement
);
103 ok_long(GetTimeInfo
.Enable
, 1);
105 /* Restore original values */
106 SetTimeInfo
.TimeAdjustment
= TimeInfoOrg
.TimeAdjustment
;
107 SetTimeInfo
.Enable
= TimeInfoOrg
.Enable
;;
108 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
110 sizeof(SetTimeInfo
));
111 ok_ntstatus(Status
, STATUS_SUCCESS
);
115 START_TEST(NtSystemInformation
)
117 Test_TimeAdjustment();