Partial Implementation of NtQuerySystemInformation and NtSetSystemInformation
[reactos.git] / reactos / ntoskrnl / ex / sysinfo.c
1 /* $Id: sysinfo.c,v 1.3 1999/08/11 23:27:58 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/sysinfo.c
6 * PURPOSE: System information functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <ddk/zwtypes.h>
16 #include <string.h>
17 #include <internal/ex.h>
18
19 #include <internal/debug.h>
20
21 /* FUNCTIONS *****************************************************************/
22
23 NTSTATUS
24 STDCALL
25 NtQuerySystemEnvironmentValue (
26 IN PUNICODE_STRING Name,
27 OUT PVOID Value,
28 IN ULONG Length,
29 IN OUT PULONG ReturnLength
30 )
31 {
32 UNIMPLEMENTED;
33 }
34
35
36 NTSTATUS
37 STDCALL
38 NtSetSystemEnvironmentValue (
39 IN PUNICODE_STRING VariableName,
40 IN PUNICODE_STRING Value
41 )
42 {
43 UNIMPLEMENTED;
44 }
45
46
47 NTSTATUS
48 STDCALL
49 NtQuerySystemInformation (
50 IN CINT SystemInformationClass,
51 OUT PVOID SystemInformation,
52 IN ULONG Length,
53 OUT PULONG ResultLength
54 )
55 {
56 /*
57 * If called from user mode, check
58 * possible unsafe arguments.
59 */
60 #if 0
61 if (KernelMode != KeGetPreviousMode())
62 {
63 // Check arguments
64 //ProbeForWrite(
65 // SystemInformation,
66 // Length
67 // );
68 //ProbeForWrite(
69 // ResultLength,
70 // sizeof (ULONG)
71 // );
72 }
73 #endif
74 /*
75 * Clear the user buffer.
76 */
77 memset(
78 SystemInformation,
79 0,
80 Length
81 );
82 /*
83 * Check the request is valid.
84 */
85 switch (SystemInformationClass)
86 {
87 #if 0
88 /*---*/
89 case SystemPerformanceInformation:
90 /*
91 * Check user buffer's size
92 */
93 if (Length < sizeof())
94 {
95 *ResultLength =
96 return STATUS_INFO_LENGTH_MISMATCH;
97 }
98 /* FIXME */
99 return STATUS_SUCCESS;
100 /*---*/
101 case SystemDriverInformation:
102 /* Check user buffer's size */
103 if (Length < sizeof (SYSTEM_DRIVER_INFO))
104 {
105 *ResultLength = sizeof (SYSTEM_DRIVER_INFO);
106 return STATUS_INFO_LENGTH_MISMATCH;
107 }
108 /* FIXME: */
109 return STATUS_SUCCESS;
110 /*---*/
111 case SystemCacheInformation:
112 /* Check user buffer's size */
113 if (Length < sizeof (SYSTEM_CACHE_INFORMATION))
114 {
115 *ResultLength = sizeof (SYSTEM_CACHE_INFORMATION);
116 return STATUS_INFO_LENGTH_MISMATCH;
117 }
118 return STATUS_SUCCESS;
119 /*---*/
120 case SystemTimeAdjustmentInformation:
121 /*
122 * Check user buffer's size
123 */
124 if (Length < sizeof (SYSTEM_TIME_ADJUSTMENT))
125 {
126 *ResultLength = sizeof (SYSTEM_TIME_ADJUSTMENT);
127 return STATUS_INFO_LENGTH_MISMATCH;
128 }
129 /* FIXME: */
130 return STATUS_SUCCESS;
131 /*---*/
132 case SystemConfigurationInformation:
133 {
134 PSYSTEM_CONFIGURATION_INFO Sci
135 = (PSYSTEM_CONFIGURATION_INFO) SystemInformation;
136
137 *ResultLength = sizeof (SYSTEM_CONFIGUTATION_INFO);
138 /*
139 * Check user buffer's size
140 */
141 if (Length < sizeof (SYSTEM_CONFIGURATION_INFO))
142 {
143 return STATUS_INFO_LENGTH_MISMATCH;
144 }
145 /*
146 * Fill the object with config data.
147 * FIXME: some data should come from the
148 * registry.
149 */
150 Sci->tag2.tag1.ProcessorAchitecture
151 = 80586;
152 Sci->tag2.tag1.Reserved
153 = 0x00000000;
154 Sci->PageSize
155 = 4096;
156 return STATUS_SUCCESS;
157 }
158 #endif
159
160 case SystemTimeZoneInformation: /* 44 */
161 *ResultLength = sizeof (TIME_ZONE_INFORMATION);
162
163 /*
164 * Check user buffer's size
165 */
166 if (Length < sizeof (TIME_ZONE_INFORMATION))
167 {
168 return STATUS_INFO_LENGTH_MISMATCH;
169 }
170
171 /* Copy the time zone information struct */
172 memcpy (SystemInformation,
173 &SystemTimeZoneInfo,
174 sizeof (TIME_ZONE_INFORMATION));
175
176 return STATUS_SUCCESS;
177
178 }
179 return STATUS_INVALID_INFO_CLASS;
180 }
181
182
183 NTSTATUS
184 STDCALL
185 NtSetSystemInformation (
186 IN CINT SystemInformationClass,
187 IN PVOID SystemInformation,
188 IN ULONG SystemInformationLength
189 )
190 {
191 /*
192 * If called from user mode, check
193 * possible unsafe arguments.
194 */
195 #if 0
196 if (KernelMode != KeGetPreviousMode())
197 {
198 // Check arguments
199 //ProbeForWrite(
200 // SystemInformation,
201 // Length
202 // );
203 //ProbeForWrite(
204 // ResultLength,
205 // sizeof (ULONG)
206 // );
207 }
208 #endif
209
210 /*
211 * Check the request is valid.
212 */
213 switch (SystemInformationClass)
214 {
215
216
217 case SystemTimeZoneInformation: /* 44 */
218 /*
219 * Check user buffer's size
220 */
221 if (SystemInformationLength < sizeof (TIME_ZONE_INFORMATION))
222 {
223 return STATUS_INFO_LENGTH_MISMATCH;
224 }
225
226 /* Copy the time zone information struct */
227 memcpy (&SystemTimeZoneInfo,
228 &SystemInformation,
229 sizeof (TIME_ZONE_INFORMATION));
230
231 return STATUS_SUCCESS;
232 }
233
234 return STATUS_INVALID_INFO_CLASS;
235 }
236
237
238 NTSTATUS
239 STDCALL
240 NtFlushInstructionCache (
241 IN HANDLE ProcessHandle,
242 IN PVOID BaseAddress,
243 IN UINT NumberOfBytesToFlush
244 )
245 {
246 UNIMPLEMENTED;
247 }