Implemented system module Information
[reactos.git] / reactos / ntoskrnl / ex / sysinfo.c
1 /* $Id: sysinfo.c,v 1.10 2001/01/18 16:53:50 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 <internal/ex.h>
16 #include <internal/ldr.h>
17
18 #include <internal/debug.h>
19
20 extern ULONG NtGlobalFlag; /* FIXME: it should go in a ddk/?.h */
21
22 /* FUNCTIONS *****************************************************************/
23
24 NTSTATUS
25 STDCALL
26 NtQuerySystemEnvironmentValue (
27 IN PUNICODE_STRING Name,
28 OUT PVOID Value,
29 IN ULONG Length,
30 IN OUT PULONG ReturnLength
31 )
32 {
33 UNIMPLEMENTED;
34 }
35
36
37 NTSTATUS
38 STDCALL
39 NtSetSystemEnvironmentValue (
40 IN PUNICODE_STRING VariableName,
41 IN PUNICODE_STRING Value
42 )
43 {
44 UNIMPLEMENTED;
45 }
46
47
48 /* --- Query/Set System Information --- */
49
50
51 /*
52 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
53 * so the stack is popped only in one place on x86 platform.
54 */
55 #define QSI_USE(n) QSI##n
56 #define QSI_DEF(n) \
57 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
58
59 #define SSI_USE(n) SSI##n
60 #define SSI_DEF(n) \
61 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
62
63 /* Class 0 - Basic Information */
64 QSI_DEF(SystemBasicInformation)
65 {
66 PSYSTEM_BASIC_INFORMATION Sbi
67 = (PSYSTEM_BASIC_INFORMATION) Buffer;
68
69 *ReqSize = sizeof (SYSTEM_BASIC_INFORMATION);
70 /*
71 * Check user buffer's size
72 */
73 if (Size < sizeof (SYSTEM_BASIC_INFORMATION))
74 {
75 return (STATUS_INFO_LENGTH_MISMATCH);
76 }
77
78 Sbi->Reserved = 0;
79 Sbi->TimerResolution = 0; /* FIXME */
80 Sbi->PageSize = PAGESIZE; /* FIXME: it should be PAGE_SIZE */
81 Sbi->NumberOfPhysicalPages = 0; /* FIXME */
82 Sbi->LowestPhysicalPageNumber = 0; /* FIXME */
83 Sbi->HighestPhysicalPageNumber = 0; /* FIXME */
84 Sbi->AllocationGranularity = 65536; /* hard coded on Intel? */
85 Sbi->MinimumUserModeAddress = 0; /* FIXME */
86 Sbi->MaximumUserModeAddress = 0; /* FIXME */
87 Sbi->ActiveProcessorsAffinityMask = 0x00000001; /* FIXME */
88 Sbi->NumberOfProcessors = 1; /* FIXME */
89
90 return (STATUS_SUCCESS);
91 }
92
93 /* Class 1 - Processor Information */
94 QSI_DEF(SystemProcessorInformation)
95 {
96 PSYSTEM_PROCESSOR_INFORMATION Spi
97 = (PSYSTEM_PROCESSOR_INFORMATION) Buffer;
98
99 *ReqSize = sizeof (SYSTEM_PROCESSOR_INFORMATION);
100 /*
101 * Check user buffer's size
102 */
103 if (Size < sizeof (SYSTEM_PROCESSOR_INFORMATION))
104 {
105 return (STATUS_INFO_LENGTH_MISMATCH);
106 }
107
108 /* FIXME: add CPU type detection code */
109 Spi->ProcessorArchitecture = 0; /* FIXME */
110 Spi->ProcessorLevel = 0; /* FIXME */
111 Spi->ProcessorRevision = 0; /* FIXME */
112 Spi->Reserved = 0;
113 Spi->ProcessorFeatureBits = 0x00000000; /* FIXME */
114
115 return (STATUS_SUCCESS);
116 }
117
118 /* Class 2 - Performance Information */
119 QSI_DEF(SystemPerformanceInformation)
120 {
121 PSYSTEM_PERFORMANCE_INFO Spi
122 = (PSYSTEM_PERFORMANCE_INFO) Buffer;
123
124 *ReqSize = sizeof (SYSTEM_PERFORMANCE_INFO);
125 /*
126 * Check user buffer's size
127 */
128 if (Size < sizeof (SYSTEM_PERFORMANCE_INFO))
129 {
130 return (STATUS_INFO_LENGTH_MISMATCH);
131 }
132
133 Spi->IdleProcessorTime.QuadPart = 0; /* FIXME */
134 Spi->IoReadTransferCount.QuadPart = 0; /* FIXME */
135 Spi->IoWriteTransferCount.QuadPart = 0; /* FIXME */
136 Spi->IoOtherTransferCount.QuadPart = 0; /* FIXME */
137 Spi->IoReadOperationCount = 0; /* FIXME */
138 Spi->IoWriteOperationCount = 0; /* FIXME */
139 Spi->IoOtherOperationCount = 0; /* FIXME */
140 Spi->AvailablePages = 0; /* FIXME */
141 Spi->CommitedPages = 0; /* FIXME */
142 Spi->CommitLimit = 0; /* FIXME */
143 Spi->PeakCommitment = 0; /* FIXME */
144 Spi->PageFaultCount = 0; /* FIXME */
145 Spi->CopyOnWriteCount = 0; /* FIXME */
146 Spi->TransitionCount = 0; /* FIXME */
147 Spi->CacheTransitionCount = 0; /* FIXME */
148 Spi->DemandZeroCount = 0; /* FIXME */
149 Spi->PageReadCount = 0; /* FIXME */
150 Spi->PageReadIoCount = 0; /* FIXME */
151 Spi->CacheReadCount = 0; /* FIXME */
152 Spi->CacheIoCount = 0; /* FIXME */
153 Spi->DirtyPagesWriteCount = 0; /* FIXME */
154 Spi->DirtyWriteIoCount = 0; /* FIXME */
155 Spi->MappedPagesWriteCount = 0; /* FIXME */
156 Spi->MappedWriteIoCount = 0; /* FIXME */
157 Spi->PagedPoolPages = 0; /* FIXME */
158 Spi->NonPagedPoolPages = 0; /* FIXME */
159 Spi->Unknown6 = 0; /* FIXME */
160 Spi->Unknown7 = 0; /* FIXME */
161 Spi->Unknown8 = 0; /* FIXME */
162 Spi->Unknown9 = 0; /* FIXME */
163 Spi->MmTotalSystemFreePtes = 0; /* FIXME */
164 Spi->MmSystemCodepage = 0; /* FIXME */
165 Spi->MmTotalSystemDriverPages = 0; /* FIXME */
166 Spi->MmTotalSystemCodePages = 0; /* FIXME */
167 Spi->Unknown10 = 0; /* FIXME */
168 Spi->Unknown11 = 0; /* FIXME */
169 Spi->Unknown12 = 0; /* FIXME */
170 Spi->MmSystemCachePage = 0; /* FIXME */
171 Spi->MmPagedPoolPage = 0; /* FIXME */
172 Spi->MmSystemDriverPage = 0; /* FIXME */
173 Spi->CcFastReadNoWait = 0; /* FIXME */
174 Spi->CcFastReadWait = 0; /* FIXME */
175 Spi->CcFastReadResourceMiss = 0; /* FIXME */
176 Spi->CcFastReadNotPossible = 0; /* FIXME */
177 Spi->CcFastMdlReadNoWait = 0; /* FIXME */
178 Spi->CcFastMdlReadWait = 0; /* FIXME */
179 Spi->CcFastMdlReadResourceMiss = 0; /* FIXME */
180 Spi->CcFastMdlReadNotPossible = 0; /* FIXME */
181 Spi->CcMapDataNoWait = 0; /* FIXME */
182 Spi->CcMapDataWait = 0; /* FIXME */
183 Spi->CcMapDataNoWaitMiss = 0; /* FIXME */
184 Spi->CcMapDataWaitMiss = 0; /* FIXME */
185 Spi->CcPinMappedDataCount = 0; /* FIXME */
186 Spi->CcPinReadNoWait = 0; /* FIXME */
187 Spi->CcPinReadWait = 0; /* FIXME */
188 Spi->CcPinReadNoWaitMiss = 0; /* FIXME */
189 Spi->CcPinReadWaitMiss = 0; /* FIXME */
190 Spi->CcCopyReadNoWait = 0; /* FIXME */
191 Spi->CcCopyReadWait = 0; /* FIXME */
192 Spi->CcCopyReadNoWaitMiss = 0; /* FIXME */
193 Spi->CcCopyReadWaitMiss = 0; /* FIXME */
194 Spi->CcMdlReadNoWait = 0; /* FIXME */
195 Spi->CcMdlReadWait = 0; /* FIXME */
196 Spi->CcMdlReadNoWaitMiss = 0; /* FIXME */
197 Spi->CcMdlReadWaitMiss = 0; /* FIXME */
198 Spi->CcReadaheadIos = 0; /* FIXME */
199 Spi->CcLazyWriteIos = 0; /* FIXME */
200 Spi->CcLazyWritePages = 0; /* FIXME */
201 Spi->CcDataFlushes = 0; /* FIXME */
202 Spi->CcDataPages = 0; /* FIXME */
203 Spi->ContextSwitches = 0; /* FIXME */
204 Spi->Unknown13 = 0; /* FIXME */
205 Spi->Unknown14 = 0; /* FIXME */
206 Spi->SystemCalls = 0; /* FIXME */
207
208 return (STATUS_SUCCESS);
209 }
210
211 /* Class 3 - Time Of Day Information */
212 QSI_DEF(SystemTimeOfDayInformation)
213 {
214 PSYSTEM_TIMEOFDAY_INFORMATION Sti
215 = (PSYSTEM_TIMEOFDAY_INFORMATION) Buffer;
216
217 *ReqSize = sizeof (SYSTEM_TIMEOFDAY_INFORMATION);
218 /*
219 * Check user buffer's size
220 */
221 if (Size < sizeof (SYSTEM_TIMEOFDAY_INFORMATION))
222 {
223 return (STATUS_INFO_LENGTH_MISMATCH);
224 }
225
226 Sti->BootTime.QuadPart = 0; /* FIXME */
227 Sti->CurrentTime.QuadPart = 0; /* FIXME */
228 Sti->TimeZoneBias.QuadPart = 0; /* FIXME */
229 Sti->TimeZoneId = 0; /* FIXME */
230 Sti->Reserved = 0; /* FIXME */
231
232 return (STATUS_SUCCESS);
233 }
234
235 /* Class 4 - Path Information */
236 QSI_DEF(SystemPathInformation)
237 {
238 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
239 return (STATUS_BREAKPOINT);
240 }
241
242 /* Class 5 - Process Information */
243 QSI_DEF(SystemProcessInformation)
244 {
245 /* FIXME: scan the process+thread list */
246 return (STATUS_NOT_IMPLEMENTED);
247 }
248
249 /* Class 6 - Call Count Information */
250 QSI_DEF(SystemCallCountInformation)
251 {
252 /* FIXME */
253 return (STATUS_NOT_IMPLEMENTED);
254 }
255
256 /* Class 7 - Device Information */
257 QSI_DEF(SystemDeviceInformation)
258 {
259 PSYSTEM_DEVICE_INFORMATION Sdi
260 = (PSYSTEM_DEVICE_INFORMATION) Buffer;
261 PCONFIGURATION_INFORMATION ConfigInfo;
262
263 *ReqSize = sizeof (SYSTEM_DEVICE_INFORMATION);
264 /*
265 * Check user buffer's size
266 */
267 if (Size < sizeof (SYSTEM_DEVICE_INFORMATION))
268 {
269 return (STATUS_INFO_LENGTH_MISMATCH);
270 }
271
272 ConfigInfo = IoGetConfigurationInformation ();
273
274 Sdi->NumberOfDisks = ConfigInfo->DiskCount;
275 Sdi->NumberOfFloppies = ConfigInfo->FloppyCount;
276 Sdi->NumberOfCdRoms = ConfigInfo->CDRomCount;
277 Sdi->NumberOfTapes = ConfigInfo->TapeCount;
278 Sdi->NumberOfSerialPorts = ConfigInfo->SerialCount;
279 Sdi->NumberOfParallelPorts = ConfigInfo->ParallelCount;
280
281 return (STATUS_SUCCESS);
282 }
283
284 /* Class 8 - Processor Performance Information */
285 QSI_DEF(SystemProcessorPerformanceInformation)
286 {
287 /* FIXME */
288 return (STATUS_NOT_IMPLEMENTED);
289 }
290
291 /* Class 9 - Flags Information */
292 QSI_DEF(SystemFlagsInformation)
293 {
294 if (sizeof (SYSTEM_FLAGS_INFORMATION) != Size)
295 {
296 * ReqSize = sizeof (SYSTEM_FLAGS_INFORMATION);
297 return (STATUS_INFO_LENGTH_MISMATCH);
298 }
299 ((PSYSTEM_FLAGS_INFORMATION) Buffer)->Flags = NtGlobalFlag;
300 return (STATUS_SUCCESS);
301 }
302
303 SSI_DEF(SystemFlagsInformation)
304 {
305 if (sizeof (SYSTEM_FLAGS_INFORMATION) != Size)
306 {
307 return (STATUS_INFO_LENGTH_MISMATCH);
308 }
309 NtGlobalFlag = ((PSYSTEM_FLAGS_INFORMATION) Buffer)->Flags;
310 return (STATUS_SUCCESS);
311 }
312
313 /* Class 10 - Call Time Information */
314 QSI_DEF(SystemCallTimeInformation)
315 {
316 /* FIXME */
317 return (STATUS_NOT_IMPLEMENTED);
318 }
319
320 /* Class 11 - Module Information */
321 QSI_DEF(SystemModuleInformation)
322 {
323 return LdrpQueryModuleInformation(Buffer, Size, ReqSize);
324 }
325
326 /* Class 12 - Locks Information */
327 QSI_DEF(SystemLocksInformation)
328 {
329 /* FIXME */
330 return (STATUS_NOT_IMPLEMENTED);
331 }
332
333 /* Class 13 - Stack Trace Information */
334 QSI_DEF(SystemStackTraceInformation)
335 {
336 /* FIXME */
337 return (STATUS_NOT_IMPLEMENTED);
338 }
339
340 /* Class 14 - Paged Pool Information */
341 QSI_DEF(SystemPagedPoolInformation)
342 {
343 /* FIXME */
344 return (STATUS_NOT_IMPLEMENTED);
345 }
346
347 /* Class 15 - Non Paged Pool Information */
348 QSI_DEF(SystemNonPagedPoolInformation)
349 {
350 /* FIXME */
351 return (STATUS_NOT_IMPLEMENTED);
352 }
353
354 /* Class 16 - Handle Information */
355 QSI_DEF(SystemHandleInformation)
356 {
357 /* FIXME */
358 return (STATUS_NOT_IMPLEMENTED);
359 }
360
361 /* Class 17 - Information */
362 QSI_DEF(SystemObjectInformation)
363 {
364 /* FIXME */
365 return (STATUS_NOT_IMPLEMENTED);
366 }
367
368 /* Class 18 - Information */
369 QSI_DEF(SystemPageFileInformation)
370 {
371 /* FIXME */
372 return (STATUS_NOT_IMPLEMENTED);
373 }
374
375 /* Class 19 - Vdm Instemul Information */
376 QSI_DEF(SystemVdmInstemulInformation)
377 {
378 /* FIXME */
379 return (STATUS_NOT_IMPLEMENTED);
380 }
381
382 /* Class 20 - Vdm Bop Information */
383 QSI_DEF(SystemVdmBopInformation)
384 {
385 /* FIXME */
386 return (STATUS_NOT_IMPLEMENTED);
387 }
388
389 /* Class 21 - File Cache Information */
390 QSI_DEF(SystemFileCacheInformation)
391 {
392 if (Size < sizeof (SYSTEM_CACHE_INFORMATION))
393 {
394 * ReqSize = sizeof (SYSTEM_CACHE_INFORMATION);
395 return (STATUS_INFO_LENGTH_MISMATCH);
396 }
397 /* FIXME */
398 return (STATUS_NOT_IMPLEMENTED);
399 }
400
401 SSI_DEF(SystemFileCacheInformation)
402 {
403 if (Size < sizeof (SYSTEM_CACHE_INFORMATION))
404 {
405 return (STATUS_INFO_LENGTH_MISMATCH);
406 }
407 /* FIXME */
408 return (STATUS_NOT_IMPLEMENTED);
409 }
410
411 /* Class 22 - Pool Tag Information */
412 QSI_DEF(SystemPoolTagInformation)
413 {
414 /* FIXME */
415 return (STATUS_NOT_IMPLEMENTED);
416 }
417
418 /* Class 23 - Interrupt Information */
419 QSI_DEF(SystemInterruptInformation)
420 {
421 /* FIXME */
422 return (STATUS_NOT_IMPLEMENTED);
423 }
424
425 /* Class 24 - DPC Behaviour Information */
426 QSI_DEF(SystemDpcBehaviourInformation)
427 {
428 /* FIXME */
429 return (STATUS_NOT_IMPLEMENTED);
430 }
431
432 SSI_DEF(SystemDpcBehaviourInformation)
433 {
434 /* FIXME */
435 return (STATUS_NOT_IMPLEMENTED);
436 }
437
438 /* Class 25 - Full Memory Information */
439 QSI_DEF(SystemFullMemoryInformation)
440 {
441 /* FIXME */
442 return (STATUS_NOT_IMPLEMENTED);
443 }
444
445 /* Class 26 - Load Gdi Driver Information */
446 SSI_DEF(SystemLoadGdiDriverInformation)
447 {
448 PSYSTEM_GDI_DRIVER_INFORMATION Sdi
449 = (PSYSTEM_GDI_DRIVER_INFORMATION) Buffer;
450
451 if (sizeof (SYSTEM_GDI_DRIVER_INFORMATION) != Size)
452 {
453 return (STATUS_INFO_LENGTH_MISMATCH);
454 }
455
456 return LdrLoadGdiDriver (&Sdi->DriverName,
457 &Sdi->ImageAddress,
458 &Sdi->SectionPointer,
459 &Sdi->EntryPoint,
460 &Sdi->ExportSectionPointer);
461 }
462
463 /* Class 27 - Unload Gdi Driver Information */
464 SSI_DEF(SystemUnloadGdiDriverInformation)
465 {
466 /* FIXME */
467 return (STATUS_NOT_IMPLEMENTED);
468 }
469
470 /* Class 28 - Time Adjustment Information */
471 QSI_DEF(SystemTimeAdjustmentInformation)
472 {
473 if (sizeof (SYSTEM_TIME_ADJUSTMENT_INFO) > Size)
474 {
475 * ReqSize = sizeof (SYSTEM_TIME_ADJUSTMENT_INFO);
476 return (STATUS_INFO_LENGTH_MISMATCH);
477 }
478 /* FIXME: */
479 return (STATUS_NOT_IMPLEMENTED);
480 }
481
482 SSI_DEF(SystemTimeAdjustmentInformation)
483 {
484 if (sizeof (SYSTEM_TIME_ADJUSTMENT_INFO) > Size)
485 {
486 return (STATUS_INFO_LENGTH_MISMATCH);
487 }
488 /* FIXME: */
489 return (STATUS_NOT_IMPLEMENTED);
490 }
491
492 /* Class 29 - Summary Memory Information */
493 QSI_DEF(SystemSummaryMemoryInformation)
494 {
495 /* FIXME */
496 return (STATUS_NOT_IMPLEMENTED);
497 }
498
499 /* Class 30 - Next Event Id Information */
500 QSI_DEF(SystemNextEventIdInformation)
501 {
502 /* FIXME */
503 return (STATUS_NOT_IMPLEMENTED);
504 }
505
506 /* Class 31 - Event Ids Information */
507 QSI_DEF(SystemEventIdsInformation)
508 {
509 /* FIXME */
510 return (STATUS_NOT_IMPLEMENTED);
511 }
512
513 /* Class 32 - Crach Dump Information */
514 QSI_DEF(SystemCrashDumpInformation)
515 {
516 /* FIXME */
517 return (STATUS_NOT_IMPLEMENTED);
518 }
519
520 /* Class 33 - Exception Information */
521 QSI_DEF(SystemExceptionInformation)
522 {
523 /* FIXME */
524 return (STATUS_NOT_IMPLEMENTED);
525 }
526
527 /* Class 34 - Crach Dump State Information */
528 QSI_DEF(SystemCrashDumpStateInformation)
529 {
530 /* FIXME */
531 return (STATUS_NOT_IMPLEMENTED);
532 }
533
534 /* Class 35 - Kernel Debugger Information */
535 QSI_DEF(SystemKernelDebuggerInformation)
536 {
537 /* FIXME */
538 return (STATUS_NOT_IMPLEMENTED);
539 }
540
541 /* Class 36 - Context Switch Information */
542 QSI_DEF(SystemContextSwitchInformation)
543 {
544 /* FIXME */
545 return (STATUS_NOT_IMPLEMENTED);
546 }
547
548 /* Class 37 - Registry Quota Information */
549 QSI_DEF(SystemRegistryQuotaInformation)
550 {
551 /* FIXME */
552 return (STATUS_NOT_IMPLEMENTED);
553 }
554
555 SSI_DEF(SystemRegistryQuotaInformation)
556 {
557 /* FIXME */
558 return (STATUS_NOT_IMPLEMENTED);
559 }
560
561 /* Class 38 - Extend Service Table Information */
562 SSI_DEF(SystemExtendServiceTableInformation)
563 {
564 /* FIXME */
565 return (STATUS_NOT_IMPLEMENTED);
566 }
567
568 /* Class 39 - Priority Seperation */
569 SSI_DEF(SystemPrioritySeperation)
570 {
571 /* FIXME */
572 return (STATUS_NOT_IMPLEMENTED);
573 }
574
575 /* Class 40 - Plug Play Bus Information */
576 QSI_DEF(SystemPlugPlayBusInformation)
577 {
578 /* FIXME */
579 return (STATUS_NOT_IMPLEMENTED);
580 }
581
582 /* Class 41 - Dock Information */
583 QSI_DEF(SystemDockInformation)
584 {
585 /* FIXME */
586 return (STATUS_NOT_IMPLEMENTED);
587 }
588
589 /* Class 42 - Power Information */
590 QSI_DEF(SystemPowerInformation)
591 {
592 /* FIXME */
593 return (STATUS_NOT_IMPLEMENTED);
594 }
595
596 /* Class 43 - Processor Speed Information */
597 QSI_DEF(SystemProcessorSpeedInformation)
598 {
599 /* FIXME */
600 return (STATUS_NOT_IMPLEMENTED);
601 }
602
603 /* Class 44 - Current Time Zone Information */
604 QSI_DEF(SystemCurrentTimeZoneInformation)
605 {
606 * ReqSize = sizeof (TIME_ZONE_INFORMATION);
607
608 if (sizeof (TIME_ZONE_INFORMATION) != Size)
609 {
610 return (STATUS_INFO_LENGTH_MISMATCH);
611 }
612 /* Copy the time zone information struct */
613 memcpy (
614 Buffer,
615 & SystemTimeZoneInfo,
616 sizeof (TIME_ZONE_INFORMATION)
617 );
618
619 return (STATUS_SUCCESS);
620 }
621
622
623 SSI_DEF(SystemCurrentTimeZoneInformation)
624 {
625 /*
626 * Check user buffer's size
627 */
628 if (Size < sizeof (TIME_ZONE_INFORMATION))
629 {
630 return (STATUS_INFO_LENGTH_MISMATCH);
631 }
632 /* Copy the time zone information struct */
633 memcpy (
634 & SystemTimeZoneInfo,
635 (TIME_ZONE_INFORMATION *) Buffer,
636 sizeof (TIME_ZONE_INFORMATION)
637 );
638 return (STATUS_SUCCESS);
639 }
640
641
642 /* Class 45 - Lookaside Information */
643 QSI_DEF(SystemLookasideInformation)
644 {
645 /* FIXME */
646 return (STATUS_NOT_IMPLEMENTED);
647 }
648
649
650 /* Query/Set Calls Table */
651 typedef
652 struct _QSSI_CALLS
653 {
654 NTSTATUS (* Query) (PVOID,ULONG,PULONG);
655 NTSTATUS (* Set) (PVOID,ULONG);
656
657 } QSSI_CALLS;
658
659 // QS Query & Set
660 // QX Query
661 // XQ Set
662 // XX unknown behaviour
663 //
664 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
665 #define SI_QX(n) {QSI_USE(n),NULL}
666 #define SI_XS(n) {NULL,SSI_USE(n)}
667 #define SI_XX(n) {NULL,NULL}
668
669 static
670 QSSI_CALLS
671 CallQS [] =
672 {
673 SI_QX(SystemBasicInformation),
674 SI_QX(SystemProcessorInformation),
675 SI_QX(SystemPerformanceInformation),
676 SI_QX(SystemTimeOfDayInformation),
677 SI_QX(SystemPathInformation), /* should be SI_XX */
678 SI_QX(SystemProcessInformation),
679 SI_QX(SystemCallCountInformation),
680 SI_QX(SystemDeviceInformation),
681 SI_QX(SystemProcessorPerformanceInformation),
682 SI_QS(SystemFlagsInformation),
683 SI_QX(SystemCallTimeInformation), /* should be SI_XX */
684 SI_QX(SystemModuleInformation),
685 SI_QX(SystemLocksInformation),
686 SI_QX(SystemStackTraceInformation), /* should be SI_XX */
687 SI_QX(SystemPagedPoolInformation), /* should be SI_XX */
688 SI_QX(SystemNonPagedPoolInformation), /* should be SI_XX */
689 SI_QX(SystemHandleInformation),
690 SI_QX(SystemObjectInformation),
691 SI_QX(SystemPageFileInformation),
692 SI_QX(SystemVdmInstemulInformation),
693 SI_QX(SystemVdmBopInformation), /* it should be SI_XX */
694 SI_QS(SystemFileCacheInformation),
695 SI_QX(SystemPoolTagInformation),
696 SI_QX(SystemInterruptInformation),
697 SI_QS(SystemDpcBehaviourInformation),
698 SI_QX(SystemFullMemoryInformation), /* it should be SI_XX */
699 SI_XS(SystemLoadGdiDriverInformation),
700 SI_XS(SystemUnloadGdiDriverInformation),
701 SI_QS(SystemTimeAdjustmentInformation),
702 SI_QX(SystemSummaryMemoryInformation), /* it should be SI_XX */
703 SI_QX(SystemNextEventIdInformation), /* it should be SI_XX */
704 SI_QX(SystemEventIdsInformation), /* it should be SI_XX */
705 SI_QX(SystemCrashDumpInformation),
706 SI_QX(SystemExceptionInformation),
707 SI_QX(SystemCrashDumpStateInformation),
708 SI_QX(SystemKernelDebuggerInformation),
709 SI_QX(SystemContextSwitchInformation),
710 SI_QS(SystemRegistryQuotaInformation),
711 SI_XS(SystemExtendServiceTableInformation),
712 SI_XS(SystemPrioritySeperation),
713 SI_QX(SystemPlugPlayBusInformation), /* it should be SI_XX */
714 SI_QX(SystemDockInformation), /* it should be SI_XX */
715 SI_QX(SystemPowerInformation), /* it should be SI_XX */
716 SI_QX(SystemProcessorSpeedInformation), /* it should be SI_XX */
717 SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */
718 SI_QX(SystemLookasideInformation)
719 };
720
721
722 NTSTATUS
723 STDCALL
724 NtQuerySystemInformation (
725 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
726 OUT PVOID SystemInformation,
727 IN ULONG Length,
728 OUT PULONG ResultLength
729 )
730 {
731 /*
732 * If called from user mode, check
733 * possible unsafe arguments.
734 */
735 #if 0
736 if (KernelMode != KeGetPreviousMode())
737 {
738 // Check arguments
739 //ProbeForWrite(
740 // SystemInformation,
741 // Length
742 // );
743 //ProbeForWrite(
744 // ResultLength,
745 // sizeof (ULONG)
746 // );
747 }
748 #endif
749 /*
750 * Clear the user buffer.
751 */
752 RtlZeroMemory (SystemInformation, Length);
753 /*
754 * Check the request is valid.
755 */
756 if ( (SystemInformationClass >= SystemInformationClassMin)
757 && (SystemInformationClass < SystemInformationClassMax)
758 )
759 {
760 if (NULL != CallQS [SystemInformationClass].Query)
761 {
762 /*
763 * Hand the request to a subhandler.
764 */
765 return CallQS [SystemInformationClass].Query (
766 SystemInformation,
767 Length,
768 ResultLength
769 );
770 }
771 }
772 return (STATUS_INVALID_INFO_CLASS);
773 }
774
775
776 NTSTATUS
777 STDCALL
778 NtSetSystemInformation (
779 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
780 IN PVOID SystemInformation,
781 IN ULONG SystemInformationLength
782 )
783 {
784 /*
785 * If called from user mode, check
786 * possible unsafe arguments.
787 */
788 #if 0
789 if (KernelMode != KeGetPreviousMode())
790 {
791 // Check arguments
792 //ProbeForWrite(
793 // SystemInformation,
794 // Length
795 // );
796 //ProbeForWrite(
797 // ResultLength,
798 // sizeof (ULONG)
799 // );
800 }
801 #endif
802 /*
803 * Check the request is valid.
804 */
805 if ( (SystemInformationClass >= SystemInformationClassMin)
806 && (SystemInformationClass < SystemInformationClassMax)
807 )
808 {
809 if (NULL != CallQS [SystemInformationClass].Set)
810 {
811 /*
812 * Hand the request to a subhandler.
813 */
814 return CallQS [SystemInformationClass].Set (
815 SystemInformation,
816 SystemInformationLength
817 );
818 }
819 }
820 return (STATUS_INVALID_INFO_CLASS);
821 }
822
823
824 NTSTATUS
825 STDCALL
826 NtFlushInstructionCache (
827 IN HANDLE ProcessHandle,
828 IN PVOID BaseAddress,
829 IN UINT NumberOfBytesToFlush
830 )
831 {
832 UNIMPLEMENTED;
833 }
834
835
836 /* EOF */