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);
33 Test_TimeAdjustment(void)
35 SYSTEM_QUERY_TIME_ADJUST_INFORMATION TimeInfoOrg
, GetTimeInfo
;
36 SYSTEM_SET_TIME_ADJUST_INFORMATION SetTimeInfo
;
42 SetTimeInfo
.TimeAdjustment
= 0;
43 SetTimeInfo
.Enable
= 0;
45 /* Query original values */
46 Status
= NtQuerySystemInformation(SystemTimeAdjustmentInformation
,
51 /* Test without privilege */
52 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
55 ok_ntstatus(Status
, STATUS_PRIVILEGE_NOT_HELD
);
57 /* Get the required privilege */
60 /* Test wrong length */
61 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
63 sizeof(SetTimeInfo
) + 1);
64 ok_ntstatus(Status
, STATUS_INFO_LENGTH_MISMATCH
);
66 /* Test both members 0 */
67 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
70 ok_ntstatus(Status
, STATUS_INVALID_PARAMETER_2
);
73 SetTimeInfo
.TimeAdjustment
= -1;
74 SetTimeInfo
.Enable
= 0;
75 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
78 ok_ntstatus(Status
, STATUS_SUCCESS
);
80 /* Query the result */
81 Status
= NtQuerySystemInformation(SystemTimeAdjustmentInformation
,
85 ok_ntstatus(Status
, STATUS_SUCCESS
);
86 ok_long(GetTimeInfo
.TimeAdjustment
, -1);
87 ok_long(GetTimeInfo
.Enable
, 0);
90 SetTimeInfo
.TimeAdjustment
= -1;
91 SetTimeInfo
.Enable
= 1;
92 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
95 ok_ntstatus(Status
, STATUS_SUCCESS
);
97 /* Query the result */
98 Status
= NtQuerySystemInformation(SystemTimeAdjustmentInformation
,
102 ok_ntstatus(Status
, STATUS_SUCCESS
);
103 ok_long(GetTimeInfo
.TimeAdjustment
, GetTimeInfo
.TimeIncrement
);
104 ok_long(GetTimeInfo
.Enable
, 1);
106 /* Restore original values */
107 SetTimeInfo
.TimeAdjustment
= TimeInfoOrg
.TimeAdjustment
;
108 SetTimeInfo
.Enable
= TimeInfoOrg
.Enable
;;
109 Status
= NtSetSystemInformation(SystemTimeAdjustmentInformation
,
111 sizeof(SetTimeInfo
));
112 ok_ntstatus(Status
, STATUS_SUCCESS
);
116 START_TEST(NtSystemInformation
)
118 Test_TimeAdjustment();