10b67019f454d6adc49b315f7e7aad855e4683d7
[reactos.git] / rosapps / sysutils / qsi.c
1 /* $Id: qsi.c,v 1.4 2001/01/13 18:17:17 ea Exp $
2 *
3 * PROJECT : ReactOS Operating System (see http://www.reactos.com/)
4 * DESCRIPTION: Tool to query system information
5 * FILE : rosapps/sysutils/qsi.c
6 * AUTHOR : Emanuele Aliberti
7 * LICENSE : GNU GPL (see http://www.gnu.org/)
8 * DATE : 1999-07-28
9 *
10 * BUILD INSTRUCTIONS
11 * If you got this code directly from the CVS repository on
12 * mok.lcvm.com, it should be ok to run "make sqi.exe" from the
13 * current directory. Otherwise, be sure the directories
14 * "rosapps" and "reactos" are siblings (see the FILE file
15 * in the header).
16 *
17 * REVISIONS
18 * 2000-02-12 (ea)
19 * Partially rewritten to run as a tool to query
20 * every system information class data.
21 * 2000-04-23 (ea)
22 * Added almost all structures for getting system
23 * information (from UNDOCNT.H by Dabak et alii).
24 * 2001-01-13 (ea)
25 * New QSI classe names used by E.Kohl.
26 */
27 #include <windows.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <wchar.h>
32
33 #define NTOS_MODE_USER
34 #include <ntos.h>
35
36 typedef
37 struct _FLAGS
38 {
39 DWORD Verbose:1; /* print unknown, unused, service fields */
40 DWORD Dump:1; /* raw dump output buffer */
41 DWORD Batch:1; /* no shell (for future use) */
42 } FLAGS;
43
44 static
45 struct
46 {
47 FLAGS Flag;
48 BOOL Active;
49 HANDLE Heap;
50 INT ExitCode;
51
52 } Application =
53 {
54 {0, 0},
55 FALSE
56 };
57
58 #define ONOFF(b) ((b)?"on":"off")
59
60 #define ARGV_SIZE 64
61
62 #define BUFFER_SIZE_DEFAULT 65536
63
64 #define TF(b) ((b)?"true":"false")
65
66 typedef
67 INT (* COMMAND_CALL) (INT ArgC,LPCSTR ArgV []);
68
69
70
71 VOID STDCALL PrintStatus (NTSTATUS Status);
72
73 #define CMD_REF(n) CMD_##n
74 #define CMD_DEF(n) INT CMD_REF(n) (INT argc, LPCSTR argv [])
75 #define CMD_NOT_IMPLEMENTED {printf("%s not implemented\n", argv[0]);return(0);}
76
77 typedef
78 struct _COMMAND_DESCRIPTOR
79 {
80 LPCSTR Name;
81 COMMAND_CALL EntryPoint;
82 LPCSTR Description;
83
84 } COMMAND_DESCRIPTOR, * PCOMMAND_DESCRIPTOR;
85
86
87 /* Fast BYTE to binary representation */
88
89 #define BIT(n,m) (((n)&(m))?'1':'0')
90 LPSTR
91 STDCALL
92 ByteToBinaryString (
93 BYTE Byte,
94 CHAR Binary [8]
95 )
96 {
97 Binary [7] = BIT(Byte,0x01);
98 Binary [6] = BIT(Byte,0x02);
99 Binary [5] = BIT(Byte,0x04);
100 Binary [4] = BIT(Byte,0x08);
101 Binary [3] = BIT(Byte,0x10);
102 Binary [2] = BIT(Byte,0x20);
103 Binary [1] = BIT(Byte,0x40);
104 Binary [0] = BIT(Byte,0x80);
105 return (LPSTR) Binary;
106 }
107
108 /* --- */
109 VOID
110 STDCALL
111 DumpData (int Size, PVOID pData )
112 {
113 PBYTE Buffer = (PBYTE) pData;
114 PBYTE Base = Buffer;
115 int i;
116 const int Width = 16;
117
118 if (! Application.Flag.Dump)
119 {
120 return;
121 }
122 while (Size > 0)
123 {
124 printf ("%04x: ", (Buffer - Base));
125 for ( i = 0;
126 (i < Width);
127 ++i
128 )
129 {
130 if (Size - i > 0)
131 {
132 printf (
133 "%02x%c",
134 Buffer[i],
135 (i % 4 == 3) ? '|' : ' '
136 );
137 }
138 else
139 {
140 printf (" ");
141 }
142 }
143 printf (" ");
144 for ( i = 0;
145 (i < Width);
146 ++i
147 )
148 {
149 if (Size - i > 0)
150 {
151 printf (
152 "%c",
153 ( (Buffer[i] > ' ')
154 && (Buffer[i] < 127)
155 )
156 ? Buffer[i]
157 : ' '
158 );
159 }
160 }
161 printf ("\n");
162 Buffer += Width;
163 Size -= Width;
164 }
165 printf ("\n");
166 }
167
168 /* --- */
169
170 static
171 LPTSTR
172 KernelObjectName [] =
173 {
174 _T("0"), /* FIXME */
175 _T("1"), /* FIXME */
176 _T("Directory"),
177 _T("SymbolicLink"),
178 _T("Token"),
179 _T("Process"),
180 _T("Thread"),
181 _T("Event"),
182 _T("8"), /* FIXME */
183 _T("Mutant"),
184 _T("Semaphore"),
185 _T("Timer"),
186 _T("12"), /* FIXME */
187 _T("WindowStation"),
188 _T("Desktop"),
189 _T("Section"),
190 _T("Key"),
191 _T("Port"),
192 _T("18"), /* FIXME */
193 _T("19"), /* FIXME */
194 _T("20"), /* FIXME */
195 _T("21"), /* FIXME */
196 _T("IoCompletion"),
197 _T("File"),
198 NULL
199 };
200
201
202 LPTSTR
203 STDCALL
204 HandleTypeToObjectName (
205 DWORD HandleType
206 )
207 {
208 if (HandleType > 23) /* FIXME: use a symbol not a literal */
209 {
210 return _T("Unknown");
211 }
212 return KernelObjectName [HandleType];
213 }
214
215
216 /* --- */
217
218 int
219 STDCALL
220 FindRequiredBufferSize (int i, int step)
221 {
222 NTSTATUS Status = STATUS_INFO_LENGTH_MISMATCH;
223 BYTE Buffer [BUFFER_SIZE_DEFAULT];
224 INT Size;
225 LONG Length = 0;
226
227
228 Size = step = (step > 0 ? step : 1);
229 while ( (Size < sizeof Buffer)
230 && (Status == STATUS_INFO_LENGTH_MISMATCH)
231 )
232 {
233 if (Application.Flag.Verbose)
234 {
235 printf ("\tTry %d", Size);
236 }
237 RtlZeroMemory (Buffer, sizeof Buffer);
238 Length = 0;
239 Status = NtQuerySystemInformation (
240 i,
241 & Buffer,
242 Size,
243 & Length
244 );
245 if (STATUS_SUCCESS == Status)
246 {
247 printf ("Length = %d\n", Size);
248 return Size;
249 }
250 if (Length > 0)
251 {
252 Size = Length;
253 }
254 else
255 {
256 /* FIXME: slow linear search! */
257 Size += step;
258 }
259 }
260 printf ("No valid buffer length found!\n");
261 return -1;
262 }
263
264
265 VOID
266 STDCALL
267 PrintStatus (NTSTATUS Status)
268 {
269 LPCSTR StatusName = NULL;
270
271 switch (Status)
272 {
273 case STATUS_INVALID_INFO_CLASS:
274 StatusName = "STATUS_INVALID_INFO_CLASS";
275 break;
276 case STATUS_INFO_LENGTH_MISMATCH:
277 StatusName = "STATUS_INFO_LENGTH_MISMATCH";
278 break;
279 case STATUS_ACCESS_VIOLATION:
280 StatusName = "STATUS_ACCESS_VIOLATION";
281 break;
282 case STATUS_NOT_IMPLEMENTED:
283 StatusName = "STATUS_NOT_IMPLEMENTED";
284 break;
285 case STATUS_BREAKPOINT:
286 StatusName = "STATUS_BREAKPOINT";
287 break;
288 }
289 if (NULL != StatusName)
290 {
291 printf ("\tStatus = %s\n", StatusName);
292 return;
293 }
294 printf ("\tStatus = 0x%08lX\n", Status );
295 }
296
297 /* Auxiliary functions */
298
299 PCHAR
300 DaysOfWeek [] =
301 {
302 "Sunday",
303 "Monday",
304 "Tuesday",
305 "Wednesday",
306 "Thursday",
307 "Friday",
308 "Saturday",
309 "Sunday"
310 };
311
312 VOID
313 STDCALL
314 PrintUtcDateTime (LPCSTR Template, PTIME UtcTime)
315 {
316 CHAR UtcTimeString [64];
317 TIME_FIELDS UtcTimeFields;
318
319 RtlTimeToTimeFields (
320 (PLARGE_INTEGER) UtcTime,
321 & UtcTimeFields
322 );
323 sprintf (
324 UtcTimeString,
325 "%s %d-%02d-%02d %02d:%02d:%02d.%03d UTC",
326 DaysOfWeek[UtcTimeFields.Weekday],
327 UtcTimeFields.Year,
328 UtcTimeFields.Month,
329 UtcTimeFields.Day,
330 UtcTimeFields.Hour,
331 UtcTimeFields.Minute,
332 UtcTimeFields.Second,
333 UtcTimeFields.Milliseconds
334 );
335 printf (
336 Template,
337 UtcTimeString
338 );
339 }
340
341
342 /**********************************************************************
343 * Dumpers
344 **********************************************************************/
345
346
347 /**********************************************************************
348 *
349 * DESCRIPTION
350 * Dump whatever we get by calling NtQuerySystemInformation with
351 * a user provided system information class id.
352 * NOTE
353 * NtQuerySystemInformation called with user class id.
354 */
355 CMD_DEF(unknown)
356 {
357 int _id = atoi ((char*)(argv[0] + 1)); /* "#24" */
358 /* ^ */
359 int Size = -1;
360 PBYTE Buffer = NULL;
361 NTSTATUS Status;
362
363
364 printf ("SystemInformation %d:\n", _id);
365 /* Find buffer size */
366 Size = FindRequiredBufferSize (_id, 1);
367 if (-1 == Size)
368 {
369 printf("\t(no data)\n");
370 return EXIT_FAILURE;
371 }
372 /* Allocate the buffer */
373 Buffer = GlobalAlloc (GMEM_ZEROINIT, Size);
374 if (NULL == Buffer)
375 {
376 printf ("#%d: could not allocate %d bytes\n", _id, Size);
377 return EXIT_FAILURE;
378 }
379 /* Query the executive */
380 Status = NtQuerySystemInformation (
381 _id,
382 Buffer,
383 Size,
384 NULL
385 );
386 if (!NT_SUCCESS(Status))
387 {
388 PrintStatus (Status);
389 FindRequiredBufferSize (_id, 1);
390 GlobalFree (Buffer);
391 return EXIT_FAILURE;
392 }
393 /* Print the data */
394 DumpData (Size, Buffer);
395 /* --- */
396 GlobalFree (Buffer);
397
398 return EXIT_SUCCESS;
399 }
400
401
402 /**********************************************************************
403 *
404 * DESCRIPTION
405 *
406 * NOTE
407 * Class 0.
408 */
409 CMD_DEF(0)
410 {
411 NTSTATUS Status;
412 SYSTEM_BASIC_INFORMATION Info;
413
414 RtlZeroMemory (
415 (PVOID) & Info,
416 sizeof Info
417 );
418 Status = NtQuerySystemInformation (
419 0,
420 & Info,
421 sizeof Info,
422 NULL
423 );
424 if (STATUS_SUCCESS != Status)
425 {
426 PrintStatus (Status);
427 return EXIT_FAILURE;
428 }
429 printf (" Reserved 0x%08x\n", Info.Reserved);
430 printf (" TimerResolution %d\n", Info.TimerResolution);
431 printf (" PageSize %d\n", Info.PageSize);
432 printf (" NumberOfPhysicalPages %d\n", Info.NumberOfPhysicalPages);
433 printf (" LowestPhysicalPageNumber %d\n", Info.LowestPhysicalPageNumber);
434 printf (" HighestPhysicalPageNumber %d\n", Info.HighestPhysicalPageNumber);
435 printf (" AllocationGranularity %d\n", Info.AllocationGranularity);
436 printf (" MinimumUserModeAddress 0x%08x (%d)\n", Info.MinimumUserModeAddress, Info.MinimumUserModeAddress);
437 printf (" MaximumUserModeAddress 0x%08x (%d)\n", Info.MaximumUserModeAddress, Info.MaximumUserModeAddress);
438 printf (" ActiveProcessorsAffinityMask 0x%08x\n", Info.ActiveProcessorsAffinityMask);
439 printf (" NumberOfProcessors %d\n", (int) Info.NumberOfProcessors);
440
441 return EXIT_SUCCESS;
442 }
443
444
445 /**********************************************************************
446 *
447 * DESCRIPTION
448 *
449 * NOTE
450 * Class 1.
451 */
452 CMD_DEF(1)
453 {
454 NTSTATUS Status;
455 SYSTEM_PROCESSOR_INFORMATION Info;
456
457 RtlZeroMemory (
458 (PVOID) & Info,
459 sizeof Info
460 );
461 Status = NtQuerySystemInformation (
462 1,
463 & Info,
464 sizeof Info,
465 NULL
466 );
467 if (STATUS_SUCCESS != Status)
468 {
469 PrintStatus (Status);
470 return EXIT_FAILURE;
471 }
472 printf (" ProcessorArchitecture %d\n", Info.ProcessorArchitecture);
473 printf (" ProcessorLevel %d\n", Info.ProcessorLevel);
474 printf (" ProcessorRevision %d\n", Info.ProcessorRevision);
475 printf (" Reserved 0x%08x\n", Info.Reserved);
476 printf (" FeatureBits %08x\n", Info.ProcessorFeatureBits);
477 /* FIXME: decode feature bits */
478
479 return EXIT_SUCCESS;
480 }
481
482
483 /**********************************************************************
484 *
485 * DESCRIPTION
486 * System performance information.
487 *
488 * NOTE
489 * Class 2.
490 */
491 CMD_DEF(2)
492 {
493 NTSTATUS Status = STATUS_SUCCESS;
494 PSYSTEM_PERFORMANCE_INFO Info;
495 LONG Length = 0;
496
497
498 Status = NtQuerySystemInformation (
499 2,
500 & Info,
501 sizeof Info,
502 & Length
503 );
504 if (STATUS_SUCCESS != Status)
505 {
506 PrintStatus (Status);
507 return EXIT_FAILURE;
508 }
509 printf ("Not implemented.\n");
510 #if 0
511 LARGE_INTEGER TotalProcessorTime;
512 LARGE_INTEGER IoReadTransferCount;
513 LARGE_INTEGER IoWriteTransferCount;
514 LARGE_INTEGER IoOtherTransferCount;
515 ULONG IoReadOperationCount;
516 ULONG IoWriteOperationCount;
517 ULONG IoOtherOperationCount;
518 ULONG MmAvailablePages;
519 ULONG MmTotalCommitedPages;
520 ULONG MmTotalCommitLimit;
521 ULONG MmPeakLimit;
522 ULONG PageFaults;
523 ULONG WriteCopies;
524 ULONG TransitionFaults;
525 ULONG Unknown1;
526 ULONG DemandZeroFaults;
527 ULONG PagesInput;
528 ULONG PagesRead;
529 ULONG Unknown2;
530 ULONG Unknown3;
531 ULONG PagesOutput;
532 ULONG PageWrites;
533 ULONG Unknown4;
534 ULONG Unknown5;
535 ULONG PoolPagedBytes;
536 ULONG PoolNonPagedBytes;
537 ULONG Unknown6;
538 ULONG Unknown7;
539 ULONG Unknown8;
540 ULONG Unknown9;
541 ULONG MmTotalSystemFreePtes;
542 ULONG MmSystemCodepage;
543 ULONG MmTotalSystemDriverPages;
544 ULONG MmTotalSystemCodePages;
545 ULONG Unknown10;
546 ULONG Unknown11;
547 ULONG Unknown12;
548 ULONG MmSystemCachePage;
549 ULONG MmPagedPoolPage;
550 ULONG MmSystemDriverPage;
551 ULONG CcFastReadNoWait;
552 ULONG CcFastReadWait;
553 ULONG CcFastReadResourceMiss;
554 ULONG CcFastReadNotPossible;
555 ULONG CcFastMdlReadNoWait;
556 ULONG CcFastMdlReadWait;
557 ULONG CcFastMdlReadResourceMiss;
558 ULONG CcFastMdlReadNotPossible;
559 ULONG CcMapDataNoWait;
560 ULONG CcMapDataWait;
561 ULONG CcMapDataNoWaitMiss;
562 ULONG CcMapDataWaitMiss;
563 ULONG CcPinMappedDataCount;
564 ULONG CcPinReadNoWait;
565 ULONG CcPinReadWait;
566 ULONG CcPinReadNoWaitMiss;
567 ULONG CcPinReadWaitMiss;
568 ULONG CcCopyReadNoWait;
569 ULONG CcCopyReadWait;
570 ULONG CcCopyReadNoWaitMiss;
571 ULONG CcCopyReadWaitMiss;
572 ULONG CcMdlReadNoWait;
573 ULONG CcMdlReadWait;
574 ULONG CcMdlReadNoWaitMiss;
575 ULONG CcMdlReadWaitMiss;
576 ULONG CcReadaheadIos;
577 ULONG CcLazyWriteIos;
578 ULONG CcLazyWritePages;
579 ULONG CcDataFlushes;
580 ULONG CcDataPages;
581 ULONG ContextSwitches;
582 ULONG Unknown13;
583 ULONG Unknown14;
584 ULONG SystemCalls;
585 #endif
586 return EXIT_SUCCESS;
587 }
588
589
590 /**********************************************************************
591 *
592 * DESCRIPTION
593 *
594 * NOTE
595 * Class 3.
596 */
597 CMD_DEF(3)
598 {
599 NTSTATUS Status;
600 SYSTEM_TIMEOFDAY_INFORMATION Info;
601
602 Status = NtQuerySystemInformation (
603 3,
604 & Info,
605 sizeof Info,
606 NULL
607 );
608 if (STATUS_SUCCESS != Status)
609 {
610 PrintStatus (Status);
611 return EXIT_FAILURE;
612 }
613 PrintUtcDateTime (" BootTime %s\n", (PTIME) & Info.BootTime);
614 PrintUtcDateTime (" CurrentTime %s\n", (PTIME) & Info.CurrentTime);
615 PrintUtcDateTime (" TimeZoneBias %s\n", (PTIME) & Info.TimeZoneBias); /* FIXME */
616 printf (" TimeZoneId %ld\n", Info.TimeZoneId);
617 printf (" Reserved %08x\n", Info.Reserved);
618
619 return EXIT_SUCCESS;
620 }
621
622
623 /**********************************************************************
624 *
625 * DESCRIPTION
626 *
627 * NOTE
628 * Class 4.
629 */
630 CMD_DEF(4)
631 {
632 NTSTATUS Status;
633 SYSTEM_PATH_INFORMATION Info;
634 CHAR _Info [_MAX_PATH];
635 ULONG Length = 0;
636
637 RtlZeroMemory (& Info, _MAX_PATH);
638 Status = NtQuerySystemInformation (
639 4,
640 & _Info,
641 _MAX_PATH,
642 & Length
643 );
644 if (STATUS_SUCCESS != Status)
645 {
646 PrintStatus (Status);
647 DumpData (_MAX_PATH, & _Info);
648 return EXIT_FAILURE;
649 }
650 DumpData (_MAX_PATH, & _Info);
651 return EXIT_SUCCESS;
652 }
653
654
655 /**********************************************************************
656 *
657 * DESCRIPTION
658 * A snapshot of the process+thread tables.
659 *
660 * NOTE
661 * Class 5.
662 */
663 CMD_DEF(5)
664 {
665 NTSTATUS Status = STATUS_SUCCESS;
666 PSYSTEM_PROCESS_INFORMATION pInfo = NULL;
667 LONG Length = 0;
668 ULONG ThreadIndex;
669
670 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
671 /* FIXME: check NULL==pInfo */
672
673 /*
674 * Obtain required buffer size
675 */
676 Status = NtQuerySystemInformation (
677 5,
678 pInfo,
679 BUFFER_SIZE_DEFAULT,
680 & Length
681 );
682 if (STATUS_SUCCESS != Status)
683 {
684 if (STATUS_INFO_LENGTH_MISMATCH == Status)
685 {
686 /*
687 * Allocate buffer
688 */
689 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
690 if (NULL == pInfo)
691 {
692 printf ("\tCould not allocate memory.\n");
693 return EXIT_FAILURE;
694 }
695 }
696 else
697 {
698 PrintStatus (Status);
699 GlobalFree (pInfo);
700 return EXIT_FAILURE;
701 }
702 }
703 /*
704 * Get process+thread list from ntoskrnl.exe
705 */
706 Status = NtQuerySystemInformation (
707 SystemProcessInformation,
708 pInfo,
709 Length,
710 & Length
711 );
712 if (!NT_SUCCESS(Status))
713 {
714 PrintStatus (Status);
715 GlobalFree (pInfo);
716 return EXIT_FAILURE;
717 }
718
719 while (1)
720 {
721 wprintf (L"%s:\n", (pInfo->Name.Length ? pInfo->Name.Buffer : L"*idle*") );
722 if (Application.Flag.Verbose)
723 {
724 wprintf (L"\tRelativeOffset = 0x%08x\n", pInfo->RelativeOffset);
725 }
726 wprintf (L"\tThreads = %ld\n", pInfo->ThreadCount);
727 wprintf (L"\tHandles = %ld\n", pInfo->HandleCount);
728 wprintf (L"\tBasePriority = %ld\n", pInfo->BasePriority);
729 wprintf (L"\tPID = %ld\n", pInfo->ProcessId);
730 wprintf (L"\tPPID = %ld\n", pInfo->ParentProcessId);
731 wprintf (L"\tVirtualSize:\t\tWorkingSetSize:\n");
732 wprintf (L"\t\tPeak : %ld\t\t\tPeak : %ld\n",
733 pInfo->PeakVirtualSizeBytes,
734 pInfo->PeakWorkingSetSizeBytes
735 );
736 wprintf (L"\t\tTotal: %ld\t\t\tTotal: %ld\n",
737 pInfo->TotalVirtualSizeBytes,
738 pInfo->TotalWorkingSetSizeBytes
739 );
740 wprintf (L"\tPagedPoolUsage:\t\tNonPagedPoolUsage:\n");
741 wprintf (L"\t\tPeak : %ld\t\t\tPeak : %ld\n",
742 pInfo->PeakPagedPoolUsagePages,
743 pInfo->TotalPagedPoolUsagePages
744 );
745 wprintf (L"\t\tTotal: %ld\t\t\tTotal: %ld\n",
746 pInfo->PeakNonPagedPoolUsagePages,
747 pInfo->TotalNonPagedPoolUsagePages
748 );
749 wprintf (L"\tPageFileUsage:\n");
750 wprintf (L"\t\tPeak : %ld\n", pInfo->PeakPageFileUsageBytes);
751 wprintf (L"\t\tTotal: %ld\n", pInfo->TotalPageFileUsageBytes);
752
753 wprintf (L"\tPageFaultCount = %ld\n", pInfo->PageFaultCount);
754 wprintf (L"\tTotalPrivateBytes = %ld\n", pInfo->TotalPrivateBytes);
755 /* Threads */
756 for ( ThreadIndex = 0;
757 (ThreadIndex < pInfo->ThreadCount);
758 ThreadIndex ++
759 )
760 {
761 wprintf (L"\t%x in %x:\n",
762 pInfo->ThreadSysInfo[ThreadIndex].ClientId.UniqueThread,
763 pInfo->ThreadSysInfo[ThreadIndex].ClientId.UniqueProcess
764 );
765 PrintUtcDateTime (
766 "\t\tKernelTime = %s\n",
767 & (pInfo->ThreadSysInfo[ThreadIndex].KernelTime)
768 );
769 PrintUtcDateTime (
770 "\t\tUserTime = %s\n",
771 & (pInfo->ThreadSysInfo[ThreadIndex].UserTime)
772 );
773 PrintUtcDateTime (
774 "\t\tCreateTime = %s\n",
775 & (pInfo->ThreadSysInfo[ThreadIndex].CreateTime)
776 );
777 wprintf (L"\t\tTickCount = %ld\n",
778 pInfo->ThreadSysInfo[ThreadIndex].TickCount
779 );
780 wprintf (L"\t\tStartEIP = 0x%08x\n",
781 pInfo->ThreadSysInfo[ThreadIndex].StartEIP
782 );
783 /* CLIENT_ID ClientId; */
784 wprintf (L"\t\tDynamicPriority = %d\n",
785 pInfo->ThreadSysInfo[ThreadIndex].DynamicPriority
786 );
787 wprintf (L"\t\tBasePriority = %d\n",
788 pInfo->ThreadSysInfo[ThreadIndex].BasePriority
789 );
790 wprintf (L"\t\tnSwitches = %ld\n",
791 pInfo->ThreadSysInfo[ThreadIndex].nSwitches
792 );
793 wprintf (L"\t\tState = 0x%08x\n",
794 pInfo->ThreadSysInfo[ThreadIndex].State
795 );
796 wprintf (L"\t\tWaitReason = %ld\n",
797 pInfo->ThreadSysInfo[ThreadIndex].WaitReason
798 );
799 }
800 /* Next */
801 if (0 == pInfo->RelativeOffset)
802 {
803 break;
804 }
805 (ULONG) pInfo += pInfo->RelativeOffset;
806 }
807
808 DumpData (Length, pInfo);
809
810 GlobalFree (pInfo);
811
812 return EXIT_SUCCESS;
813 }
814
815
816 /**********************************************************************
817 *
818 * DESCRIPTION
819 *
820 * NOTE
821 * Class 6.
822 */
823 CMD_DEF(6)
824 {
825 NTSTATUS Status;
826 SYSTEM_SDT_INFORMATION Info;
827 ULONG Length = 0;
828
829 /* FIXME */
830 RtlZeroMemory (& Info, sizeof Info);
831 Status = NtQuerySystemInformation (
832 6,
833 & Info,
834 sizeof Info,
835 & Length
836 );
837 if (STATUS_SUCCESS != Status)
838 {
839 PrintStatus (Status);
840 DumpData (Length, & Info);
841 return EXIT_FAILURE;
842 }
843 printf (" BufferLength = %ld\n", Info.BufferLength);
844 printf (" NumberOfSystemServiceTables = %ld\n", Info.NumberOfSystemServiceTables);
845 printf (" NumberOfServices = %ld\n", Info.NumberOfServices [0]);
846 printf (" ServiceCounters = %ld\n", Info.ServiceCounters [0]);
847
848 DumpData (Length, & Info);
849
850 return EXIT_SUCCESS;
851 }
852
853
854 /**********************************************************************
855 *
856 * DESCRIPTION
857 *
858 * NOTE
859 * Class 7.
860 */
861 CMD_DEF(7)
862 {
863 NTSTATUS Status = STATUS_SUCCESS;
864 SYSTEM_DEVICE_INFORMATION Info;
865 ULONG Length = 0;
866
867 Status = NtQuerySystemInformation (
868 7,
869 & Info,
870 sizeof Info,
871 & Length
872 );
873 if (STATUS_SUCCESS != Status)
874 {
875 PrintStatus (Status);
876 return EXIT_FAILURE;
877 }
878 printf (" Number Of Disks %ld\n", Info.NumberOfDisks);
879 printf (" Number Of Floppies %ld\n", Info.NumberOfFloppies);
880 printf (" Number Of CD-ROMs %ld\n", Info.NumberOfCdRoms);
881 printf (" Number Of Tapes %ld\n", Info.NumberOfTapes);
882 printf (" Number Of Serial Ports %ld\n", Info.NumberOfSerialPorts);
883 printf (" Number Of Parallel Ports %ld\n", Info.NumberOfParallelPorts);
884
885 DumpData (Length, & Info);
886
887 return EXIT_SUCCESS;
888 }
889
890
891 /**********************************************************************
892 *
893 * DESCRIPTION
894 *
895 * NOTE
896 * Class 8.
897 */
898 CMD_DEF(8)
899 {
900 NTSTATUS Status;
901 SYSTEM_PROCESSORTIME_INFO Info;
902 ULONG Length = 0;
903
904 Status = NtQuerySystemInformation (
905 8,
906 & Info,
907 sizeof Info,
908 & Length
909 );
910 if (STATUS_SUCCESS != Status)
911 {
912 PrintStatus (Status);
913 return EXIT_FAILURE;
914 }
915 PrintUtcDateTime (" TotalProcessorRunTime : %s\n", & Info.TotalProcessorRunTime);
916 PrintUtcDateTime (" TotalProcessorTime : %s\n", & Info.TotalProcessorTime);
917 PrintUtcDateTime (" TotalProcessorUserTime: %s\n", & Info.TotalProcessorUserTime);
918 PrintUtcDateTime (" TotalDPCTime : %s\n", & Info.TotalDPCTime);
919 PrintUtcDateTime (" TotalInterruptTime : %s\n", & Info.TotalInterruptTime);
920 printf (" TotalInterrupts : %ld\n", Info.TotalInterrupts);
921 printf (" Unused : %08x\n", Info.Unused);
922
923 return EXIT_SUCCESS;
924 }
925
926
927 /**********************************************************************
928 *
929 * DESCRIPTION
930 *
931 * NOTE
932 * Class 9.
933 */
934 CMD_DEF(9)
935 {
936 NTSTATUS Status;
937 SYSTEM_FLAGS_INFORMATION Info;
938 ULONG Length = 0;
939
940 Status = NtQuerySystemInformation (
941 9,
942 & Info,
943 sizeof Info,
944 & Length
945 );
946 if (STATUS_SUCCESS != Status)
947 {
948 PrintStatus (Status);
949 return EXIT_FAILURE;
950 }
951 printf (" NtGlobalFlag: %08x\n", Info.Flags);
952 /* FIXME: decode each flag */
953
954 return EXIT_SUCCESS;
955 }
956
957
958 /**********************************************************************
959 *
960 * DESCRIPTION
961 *
962 * NOTE
963 * Class 10.
964 */
965 CMD_DEF(10)
966 CMD_NOT_IMPLEMENTED
967
968
969 /**********************************************************************
970 *
971 * DESCRIPTION
972 *
973 * NOTE
974 * Class 11.
975 *
976 * NOTE
977 * Code originally in Yariv Kaplan's NtDriverList,
978 * at http://www.internals.com/, adapted to ReactOS
979 * structures layout.
980 */
981 CMD_DEF(11)
982 {
983 NTSTATUS Status = STATUS_SUCCESS;
984 PSYSTEM_MODULE_INFORMATION pInfo = NULL;
985 LONG Length = 0;
986 INT Index;
987 const PCHAR hr =
988 "-------- -------- -------- ---------------------------------------\n";
989
990
991 /*
992 * Obtain required buffer size
993 */
994 Status = NtQuerySystemInformation (
995 11,
996 & pInfo,
997 0, /* query size */
998 & Length
999 );
1000 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1001 {
1002 /*
1003 * Allocate buffer
1004 */
1005 pInfo = GlobalAlloc (GMEM_ZEROINIT, Length);
1006 if (NULL == pInfo)
1007 {
1008 printf ("Could not allocate memory.\n");
1009 return EXIT_FAILURE;
1010 }
1011 }
1012 else
1013 {
1014 PrintStatus (Status);
1015 return EXIT_FAILURE;
1016 }
1017 /*
1018 * Get module list from ntoskrnl.exe
1019 */
1020 Status = NtQuerySystemInformation (
1021 11,
1022 pInfo,
1023 Length,
1024 & Length
1025 );
1026 if (!NT_SUCCESS(Status))
1027 {
1028 PrintStatus (Status);
1029 return EXIT_FAILURE;
1030 }
1031 printf ("Index Address Size Name\n");
1032 printf (hr);
1033
1034 for ( Index = 0;
1035 (Index < (int) pInfo->Count);
1036 Index ++
1037 )
1038 {
1039 printf (
1040 "%8x %08x %8x %s\n",
1041 pInfo->Module[Index].ModuleEntryIndex,
1042 pInfo->Module[Index].ModuleBaseAddress,
1043 pInfo->Module[Index].ModuleSize,
1044 pInfo->Module[Index].ModuleName
1045 );
1046 }
1047 printf (hr);
1048
1049 GlobalFree (pInfo);
1050
1051 return EXIT_SUCCESS;
1052 }
1053
1054
1055 /**********************************************************************
1056 *
1057 * DESCRIPTION
1058 *
1059 * NOTE
1060 * Class 12.
1061 */
1062 CMD_DEF(12)
1063 {
1064 NTSTATUS Status = STATUS_SUCCESS;
1065 PSYSTEM_RESOURCE_LOCK_INFO pInfo = NULL;
1066 LONG Length = 0;
1067 INT Index;
1068 const PCHAR hr =
1069 "-------- -------- -------- -------- -------- -------- ------------\n";
1070
1071 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1072 /* FIXME: check NULL==pInfo */
1073
1074 /*
1075 * Obtain required buffer size
1076 */
1077 Status = NtQuerySystemInformation (
1078 12,
1079 pInfo,
1080 BUFFER_SIZE_DEFAULT, /* query size */
1081 & Length
1082 );
1083 if (STATUS_SUCCESS != Status)
1084 {
1085 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1086 {
1087 /*
1088 * Allocate buffer
1089 */
1090 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1091 if (NULL == pInfo)
1092 {
1093 printf ("Could not allocate memory.\n");
1094 return EXIT_FAILURE;
1095 }
1096 }
1097 else
1098 {
1099 PrintStatus (Status);
1100 GlobalFree (pInfo);
1101 return EXIT_FAILURE;
1102 }
1103 }
1104 /*
1105 * Get locked resource list from ntoskrnl.exe
1106 */
1107 Status = NtQuerySystemInformation (
1108 12,
1109 pInfo,
1110 Length,
1111 & Length
1112 );
1113 if (!NT_SUCCESS(Status))
1114 {
1115 PrintStatus (Status);
1116 GlobalFree (pInfo);
1117 return EXIT_FAILURE;
1118 }
1119 printf ("Address Active # Content# Sh/Wait Exc/Wait\n");
1120 printf (hr);
1121
1122 for ( Index = 0;
1123 (Index < (int) pInfo->Count);
1124 Index ++
1125 )
1126 {
1127 printf (
1128 "%08x %8ld %8ld %8ld %8ld %08x\n",
1129 pInfo->Lock[Index].ResourceAddress,
1130 pInfo->Lock[Index].ActiveCount,
1131 pInfo->Lock[Index].ContentionCount,
1132 pInfo->Lock[Index].NumberOfSharedWaiters,
1133 pInfo->Lock[Index].NumberOfExclusiveWaiters,
1134 pInfo->Lock[Index].Unknown
1135 );
1136 }
1137 printf (hr);
1138
1139 GlobalFree (pInfo);
1140
1141 return EXIT_SUCCESS;
1142 }
1143
1144
1145 /**********************************************************************
1146 *
1147 * DESCRIPTION
1148 *
1149 * NOTE
1150 * Class 13.
1151 */
1152 CMD_DEF(13)
1153 CMD_NOT_IMPLEMENTED
1154
1155
1156 /**********************************************************************
1157 *
1158 * DESCRIPTION
1159 *
1160 * NOTE
1161 * Class 14.
1162 */
1163 CMD_DEF(14)
1164 CMD_NOT_IMPLEMENTED
1165
1166
1167 /**********************************************************************
1168 *
1169 * DESCRIPTION
1170 *
1171 * NOTE
1172 * Class 15.
1173 */
1174 CMD_DEF(15)
1175 CMD_NOT_IMPLEMENTED
1176
1177
1178 /**********************************************************************
1179 *
1180 * DESCRIPTION
1181 *
1182 * NOTE
1183 * Class 16. You can not pass 0 as the initial output buffer's
1184 * size to get back the needed buffer size.
1185 */
1186 CMD_DEF(16)
1187 {
1188 NTSTATUS Status = STATUS_SUCCESS;
1189 PSYSTEM_HANDLE_INFORMATION pInfo = NULL;
1190 LONG Length = 0;
1191 INT Index;
1192 const PCHAR hr =
1193 "-------- -------- -------- -------- -------- ----------\n";
1194 CHAR FlagsString [9] = {0};
1195
1196 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1197
1198 /*
1199 * Obtain required buffer size
1200 */
1201 Status = NtQuerySystemInformation (
1202 16,
1203 pInfo,
1204 BUFFER_SIZE_DEFAULT,
1205 & Length
1206 );
1207 if (STATUS_SUCCESS != Status)
1208 {
1209 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1210 {
1211 /*
1212 * Allocate buffer
1213 */
1214 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1215 if (NULL == pInfo)
1216 {
1217 printf ("\tCould not allocate memory.\n");
1218 return EXIT_FAILURE;
1219 }
1220 }
1221 else
1222 {
1223 PrintStatus (Status);
1224 GlobalFree (pInfo);
1225 return EXIT_FAILURE;
1226 }
1227 }
1228 /*
1229 * Get handle table from ntoskrnl.exe
1230 */
1231 Status = NtQuerySystemInformation (
1232 16,
1233 pInfo,
1234 Length,
1235 & Length
1236 );
1237 if (!NT_SUCCESS(Status))
1238 {
1239 PrintStatus (Status);
1240 GlobalFree (pInfo);
1241 return EXIT_FAILURE;
1242 }
1243 printf ("Handle OwnerPID ObjPtr Access Flags Type\n");
1244 printf (hr);
1245
1246 for ( Index = 0;
1247 (Index < (int) pInfo->Count);
1248 Index ++
1249 )
1250 {
1251 printf (
1252 "%8x %8x %8x %8x %s %s\n",
1253 pInfo->Handle[Index].HandleValue,
1254 pInfo->Handle[Index].OwnerPid,
1255 pInfo->Handle[Index].ObjectPointer,
1256 pInfo->Handle[Index].AccessMask,
1257 ByteToBinaryString (
1258 pInfo->Handle[Index].HandleFlags,
1259 FlagsString
1260 ),
1261 HandleTypeToObjectName (pInfo->Handle[Index].ObjectType)
1262 );
1263 }
1264 printf (hr);
1265
1266 DumpData (Length, pInfo);
1267
1268 GlobalFree (pInfo);
1269
1270 return EXIT_SUCCESS;
1271 }
1272
1273
1274 /**********************************************************************
1275 *
1276 * DESCRIPTION
1277 *
1278 * NOTE
1279 * Class 17.
1280 */
1281 CMD_DEF(17)
1282 CMD_NOT_IMPLEMENTED
1283
1284
1285 /**********************************************************************
1286 *
1287 * DESCRIPTION
1288 *
1289 * NOTE
1290 * Class 18.
1291 */
1292 CMD_DEF(18)
1293 {
1294 NTSTATUS Status;
1295 PSYSTEM_PAGEFILE_INFORMATION pInfo = NULL;
1296 LONG Length = 0;
1297
1298 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1299 /* FIXME: check pInfo */
1300
1301 Status = NtQuerySystemInformation(
1302 18,
1303 pInfo,
1304 BUFFER_SIZE_DEFAULT,
1305 & Length
1306 );
1307 if (STATUS_SUCCESS != Status)
1308 {
1309 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1310 {
1311 /*
1312 * Allocate buffer
1313 */
1314 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1315 if (NULL == pInfo)
1316 {
1317 printf ("Could not allocate memory.\n");
1318 return EXIT_FAILURE;
1319 }
1320 }
1321 else
1322 {
1323 PrintStatus (Status);
1324 GlobalFree (pInfo);
1325 return EXIT_FAILURE;
1326 }
1327 }
1328 Status = NtQuerySystemInformation (
1329 18,
1330 pInfo,
1331 Length,
1332 & Length
1333 );
1334 if (!NT_SUCCESS(Status))
1335 {
1336 PrintStatus (Status);
1337 GlobalFree (pInfo);
1338 return EXIT_FAILURE;
1339 }
1340
1341 while (1)
1342 {
1343 wprintf (L" \"%s\":\n", pInfo->PagefileFileName.Buffer);
1344 wprintf (L"\tRelativeOffset %08x\n", pInfo->RelativeOffset);
1345 wprintf (L"\tCurrentSizePages %ld\n", pInfo->CurrentSizePages);
1346 wprintf (L"\tTotalUsedPages %ld\n", pInfo->TotalUsedPages);
1347 wprintf (L"\tPeakUsedPages %ld\n", pInfo->PeakUsedPages);
1348
1349 if (0 == pInfo->RelativeOffset)
1350 {
1351 break;
1352 }
1353 printf ("\n");
1354 (ULONG) pInfo += pInfo->RelativeOffset;
1355 }
1356
1357 DumpData (Length, pInfo);
1358
1359 GlobalFree (pInfo);
1360
1361 return EXIT_SUCCESS;
1362 }
1363
1364
1365 /**********************************************************************
1366 *
1367 * DESCRIPTION
1368 *
1369 * NOTE
1370 * Class 19.
1371 */
1372 CMD_DEF(19)
1373 {
1374 NTSTATUS Status;
1375 SYSTEM_VDM_INFORMATION Info;
1376
1377 RtlZeroMemory (& Info, sizeof Info);
1378 Status = NtQuerySystemInformation (
1379 19,
1380 & Info,
1381 sizeof Info,
1382 NULL
1383 );
1384 if (!NT_SUCCESS(Status))
1385 {
1386 PrintStatus (Status);
1387 return EXIT_FAILURE;
1388 }
1389 printf (" VdmSegmentNotPresentCount = %ld\n", Info.VdmSegmentNotPresentCount);
1390 printf (" VdmINSWCount = %ld\n", Info.VdmINSWCount);
1391 printf (" VdmESPREFIXCount = %ld\n", Info.VdmESPREFIXCount);
1392 printf (" VdmCSPREFIXCount = %ld\n", Info.VdmCSPREFIXCount);
1393 printf (" VdmSSPREFIXCount = %ld\n", Info.VdmSSPREFIXCount);
1394 printf (" VdmDSPREFIXCount = %ld\n", Info.VdmDSPREFIXCount);
1395 printf (" VdmFSPREFIXCount = %ld\n", Info.VdmFSPREFIXCount);
1396 printf (" VdmGSPREFIXCount = %ld\n", Info.VdmGSPREFIXCount);
1397 printf (" VdmOPER32PREFIXCount = %ld\n", Info.VdmOPER32PREFIXCount);
1398 printf (" VdmADDR32PREFIXCount = %ld\n", Info.VdmADDR32PREFIXCount);
1399 printf (" VdmINSBCount = %ld\n", Info.VdmINSBCount);
1400 printf (" VdmINSWV86Count = %ld\n", Info.VdmINSWV86Count);
1401 printf (" VdmOUTSBCount = %ld\n", Info.VdmOUTSBCount);
1402 printf (" VdmOUTSWCount = %ld\n", Info.VdmOUTSWCount);
1403 printf (" VdmPUSHFCount = %ld\n", Info.VdmPUSHFCount);
1404 printf (" VdmPOPFCount = %ld\n", Info.VdmPOPFCount);
1405 printf (" VdmINTNNCount = %ld\n", Info.VdmINTNNCount);
1406 printf (" VdmINTOCount = %ld\n", Info.VdmINTOCount);
1407 printf (" VdmIRETCount = %ld\n", Info.VdmIRETCount);
1408 printf (" VdmINBIMMCount = %ld\n", Info.VdmINBIMMCount);
1409 printf (" VdmINWIMMCount = %ld\n", Info.VdmINWIMMCount);
1410 printf (" VdmOUTBIMMCount = %ld\n", Info.VdmOUTBIMMCount);
1411 printf (" VdmOUTWIMMCount = %ld\n", Info.VdmOUTWIMMCount);
1412 printf (" VdmINBCount = %ld\n", Info.VdmINBCount);
1413 printf (" VdmINWCount = %ld\n", Info.VdmINWCount);
1414 printf (" VdmOUTBCount = %ld\n", Info.VdmOUTBCount);
1415 printf (" VdmOUTWCount = %ld\n", Info.VdmOUTWCount);
1416 printf (" VdmLOCKPREFIXCount = %ld\n", Info.VdmLOCKPREFIXCount);
1417 printf (" VdmREPNEPREFIXCount = %ld\n", Info.VdmREPNEPREFIXCount);
1418 printf (" VdmREPPREFIXCount = %ld\n", Info.VdmREPPREFIXCount);
1419 printf (" VdmHLTCount = %ld\n", Info.VdmHLTCount);
1420 printf (" VdmCLICount = %ld\n", Info.VdmCLICount);
1421 printf (" VdmSTICount = %ld\n", Info.VdmSTICount);
1422 printf (" VdmBopCount = %ld\n", Info.VdmBopCount);
1423
1424 return EXIT_SUCCESS;
1425 }
1426
1427
1428 /**********************************************************************
1429 *
1430 * DESCRIPTION
1431 *
1432 * NOTE
1433 * Class 20.
1434 */
1435 CMD_DEF(20)
1436 CMD_NOT_IMPLEMENTED
1437
1438
1439 /**********************************************************************
1440 *
1441 * DESCRIPTION
1442 *
1443 * NOTE
1444 * Class 21.
1445 */
1446 CMD_DEF(21)
1447 {
1448 NTSTATUS Status;
1449 SYSTEM_CACHE_INFORMATION Si;
1450
1451 RtlZeroMemory (
1452 (PVOID) & Si,
1453 sizeof Si
1454 );
1455 Status = NtQuerySystemInformation (
1456 21,
1457 & Si,
1458 sizeof Si,
1459 0
1460 );
1461 if (!NT_SUCCESS(Status))
1462 {
1463 PrintStatus (Status);
1464 return EXIT_FAILURE;
1465 }
1466 printf ("\tSize:\n");
1467 printf ("\t\tCurrent = %ld\n", Si.CurrentSize);
1468 printf ("\t\tPeak = %ld\n\n", Si.PeakSize);
1469 printf ("\tPageFaults:\n\t\tCount = %ld\n\n", Si.PageFaultCount);
1470 printf ("\tWorking Set:\n");
1471 printf ("\t\tMinimum = %ld\n", Si.MinimumWorkingSet );
1472 printf ("\t\tMaximum = %ld\n", Si.MaximumWorkingSet );
1473
1474 return EXIT_SUCCESS;
1475 }
1476
1477
1478 /**********************************************************************
1479 *
1480 * DESCRIPTION
1481 * Get statistic data about tagged pools. Not implemented in the
1482 * free build.
1483 *
1484 * NOTE
1485 * Class 22.
1486 */
1487 CMD_DEF(22)
1488 {
1489 NTSTATUS Status;
1490 PSYSTEM_POOL_TAG_INFO pInfo = NULL;
1491 ULONG Length;
1492 ULONG PoolIndex;
1493
1494 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1495 /* FIXME: check pInfo */
1496
1497 Status = NtQuerySystemInformation(
1498 22,
1499 pInfo,
1500 BUFFER_SIZE_DEFAULT,
1501 & Length
1502 );
1503 if (STATUS_SUCCESS != Status)
1504 {
1505 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1506 {
1507 /*
1508 * Allocate buffer
1509 */
1510 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1511 if (NULL == pInfo)
1512 {
1513 printf ("Could not allocate memory.\n");
1514 return EXIT_FAILURE;
1515 }
1516 }
1517 else
1518 {
1519 PrintStatus (Status);
1520 GlobalFree (pInfo);
1521 return EXIT_FAILURE;
1522 }
1523 }
1524 Status = NtQuerySystemInformation (
1525 22,
1526 pInfo,
1527 Length,
1528 & Length
1529 );
1530 if (!NT_SUCCESS(Status))
1531 {
1532 PrintStatus (Status);
1533 GlobalFree (pInfo);
1534 return EXIT_FAILURE;
1535 }
1536
1537 for ( PoolIndex = 0;
1538 (PoolIndex < pInfo->Count);
1539 PoolIndex ++
1540 )
1541 {
1542 wprintf (L"\t%08x:\n", pInfo->PoolEntry[PoolIndex].Tag);
1543 wprintf (L"\t\tPaged:\t\tNon Paged:\n");
1544 wprintf (
1545 L"\t\tAllocationCount = %ld\tAllocationCount = %ld\n",
1546 pInfo->PoolEntry[PoolIndex].Paged.AllocationCount,
1547 pInfo->PoolEntry[PoolIndex].NonPaged.AllocationCount
1548 );
1549 wprintf (
1550 L"\t\tFreeCount = %ld\tFreeCount = %ld\n",
1551 pInfo->PoolEntry[PoolIndex].Paged.FreeCount,
1552 pInfo->PoolEntry[PoolIndex].NonPaged.FreeCount
1553 );
1554 wprintf (
1555 L"\t\tSizeBytes = %ld\tSizeBytes = %ld\n",
1556 pInfo->PoolEntry[PoolIndex].Paged.SizeBytes,
1557 pInfo->PoolEntry[PoolIndex].NonPaged.SizeBytes
1558 );
1559 }
1560
1561 DumpData (Length, pInfo);
1562
1563 GlobalFree (pInfo);
1564
1565 return EXIT_SUCCESS;
1566 }
1567
1568
1569 /**********************************************************************
1570 *
1571 * DESCRIPTION
1572 *
1573 * NOTE
1574 * Class 23.
1575 */
1576 CMD_DEF(23)
1577 {
1578 NTSTATUS Status;
1579 SYSTEM_PROCESSOR_SCHEDULE_INFO Info;
1580
1581 RtlZeroMemory (
1582 & Info,
1583 sizeof Info
1584 );
1585 Status = NtQuerySystemInformation (
1586 23,
1587 & Info,
1588 sizeof Info,
1589 NULL
1590 );
1591 if (STATUS_SUCCESS != Status)
1592 {
1593 PrintStatus (Status);
1594 return EXIT_FAILURE;
1595 }
1596
1597 printf ("\tnContextSwitches = %ld\n", Info.nContextSwitches);
1598 printf ("\tnDPCQueued = %ld\n", Info.nDPCQueued);
1599 printf ("\tnDPCRate = %ld\n", Info.nDPCRate);
1600 printf ("\tTimerResolution = %ld\n", Info.TimerResolution);
1601 printf ("\tnDPCBypasses = %ld\n", Info.nDPCBypasses);
1602 printf ("\tnAPCBypasses = %ld\n", Info.nAPCBypasses);
1603
1604 DumpData (sizeof Info, & Info);
1605
1606 return EXIT_SUCCESS;
1607
1608 }
1609
1610
1611 /**********************************************************************
1612 *
1613 * DESCRIPTION
1614 *
1615 * NOTE
1616 * Class 24.
1617 */
1618 CMD_DEF(24)
1619 {
1620 NTSTATUS Status;
1621 SYSTEM_DPC_INFORMATION Info;
1622
1623 RtlZeroMemory (
1624 & Info,
1625 sizeof Info
1626 );
1627 Status = NtQuerySystemInformation (
1628 24,
1629 & Info,
1630 sizeof Info,
1631 NULL
1632 );
1633 if (STATUS_SUCCESS != Status)
1634 {
1635 PrintStatus (Status);
1636 return EXIT_FAILURE;
1637 }
1638
1639 if (Application.Flag.Verbose)
1640 {
1641 printf ("\tUnused = %ld\n", Info.Unused);
1642 }
1643 printf ("\tKiMaximumDpcQueueDepth = %ld\n", Info.KiMaximumDpcQueueDepth);
1644 printf ("\tKiMinimumDpcRate = %ld\n", Info.KiMinimumDpcRate);
1645 printf ("\tKiAdjustDpcThreshold = %ld\n", Info.KiAdjustDpcThreshold);
1646 printf ("\tKiIdealDpcRate = %ld\n", Info.KiIdealDpcRate);
1647
1648 DumpData (sizeof Info, & Info);
1649
1650 return EXIT_SUCCESS;
1651 }
1652
1653
1654 /**********************************************************************
1655 *
1656 * DESCRIPTION
1657 *
1658 * NOTE
1659 * Class 25.
1660 */
1661 CMD_DEF(25)
1662 CMD_NOT_IMPLEMENTED
1663
1664
1665 /**********************************************************************
1666 *
1667 * DESCRIPTION
1668 *
1669 * NOTE
1670 * Class 26.
1671 */
1672 CMD_DEF(26)
1673 CMD_NOT_IMPLEMENTED
1674
1675 /**********************************************************************
1676 *
1677 * DESCRIPTION
1678 *
1679 * NOTE
1680 * Class 27.
1681 */
1682 CMD_DEF(27)
1683 CMD_NOT_IMPLEMENTED
1684
1685
1686 /**********************************************************************
1687 *
1688 * DESCRIPTION
1689 *
1690 * NOTE
1691 * Class 28.
1692 */
1693 CMD_DEF(28)
1694 {
1695 NTSTATUS Status = STATUS_SUCCESS;
1696 SYSTEM_TIME_ADJUSTMENT_INFO Info;
1697
1698 RtlZeroMemory (& Info, sizeof Info);
1699 Status = NtQuerySystemInformation (
1700 28,
1701 & Info,
1702 sizeof Info,
1703 0
1704 );
1705 if (!NT_SUCCESS(Status))
1706 {
1707 PrintStatus (Status);
1708 return EXIT_FAILURE;
1709 }
1710 printf ("\tKeTimeAdjustment = %ld\n", Info.KeTimeAdjustment);
1711 printf ("\tKeMaximumIncrement = %ld\n", Info.KeMaximumIncrement);
1712 printf ("\tKeTimeSynchronization = %s\n", TF(Info.KeTimeSynchronization));
1713
1714 return EXIT_SUCCESS;
1715 }
1716
1717
1718 /**********************************************************************
1719 *
1720 * DESCRIPTION
1721 *
1722 * NOTE
1723 * Class 29.
1724 */
1725 CMD_DEF(29)
1726 CMD_NOT_IMPLEMENTED
1727
1728
1729 /**********************************************************************
1730 *
1731 * DESCRIPTION
1732 *
1733 * NOTE
1734 * Class 30.
1735 */
1736 CMD_DEF(30)
1737 CMD_NOT_IMPLEMENTED
1738
1739
1740 /**********************************************************************
1741 *
1742 * DESCRIPTION
1743 *
1744 * NOTE
1745 * Class 31.
1746 */
1747 CMD_DEF(31)
1748 CMD_NOT_IMPLEMENTED
1749
1750
1751 /**********************************************************************
1752 *
1753 * DESCRIPTION
1754 *
1755 * NOTE
1756 * Class 32.
1757 */
1758 CMD_DEF(32)
1759 CMD_NOT_IMPLEMENTED
1760
1761
1762 /**********************************************************************
1763 *
1764 * DESCRIPTION
1765 *
1766 * NOTE
1767 * Class 33.
1768 */
1769 CMD_DEF(33)
1770 CMD_NOT_IMPLEMENTED
1771
1772
1773 /**********************************************************************
1774 *
1775 * DESCRIPTION
1776 *
1777 * NOTE
1778 * Class 34.
1779 */
1780 CMD_DEF(34)
1781 CMD_NOT_IMPLEMENTED
1782
1783
1784 /**********************************************************************
1785 *
1786 * DESCRIPTION
1787 *
1788 * NOTE
1789 * Class 35.
1790 */
1791 CMD_DEF(35)
1792 {
1793 NTSTATUS Status;
1794 SYSTEM_DEBUGGER_INFO Info;
1795
1796 RtlZeroMemory (& Info, sizeof Info);
1797 Status = NtQuerySystemInformation (
1798 35,
1799 & Info,
1800 sizeof Info,
1801 NULL
1802 );
1803 if (STATUS_SUCCESS != Status)
1804 {
1805 PrintStatus (Status);
1806 return EXIT_FAILURE;
1807 }
1808 printf ("\tKdDebuggerEnabled = %s\n", TF(Info.KdDebuggerEnabled));
1809 printf ("\tKdDebuggerPresent = %s\n", TF(Info.KdDebuggerPresent));
1810
1811 DumpData (sizeof Info, & Info);
1812
1813 return EXIT_SUCCESS;
1814 }
1815
1816
1817 /**********************************************************************
1818 *
1819 * DESCRIPTION
1820 *
1821 * NOTE
1822 * Class 36.
1823 */
1824 CMD_DEF(36)
1825 CMD_NOT_IMPLEMENTED
1826
1827
1828 /**********************************************************************
1829 *
1830 * DESCRIPTION
1831 *
1832 * NOTE
1833 * Class 37.
1834 */
1835 CMD_DEF(37)
1836 {
1837 NTSTATUS Status = STATUS_SUCCESS;
1838 SYSTEM_QUOTA_INFORMATION Info;
1839
1840 RtlZeroMemory (& Info, sizeof Info);
1841 Status = NtQuerySystemInformation (
1842 37,
1843 & Info,
1844 sizeof Info,
1845 0
1846 );
1847 if (!NT_SUCCESS(Status))
1848 {
1849 PrintStatus (Status);
1850 return EXIT_FAILURE;
1851 }
1852 printf ("\tCmpGlobalQuota = %ld\n", Info.CmpGlobalQuota);
1853 printf ("\tCmpGlobalQuotaUsed = %ld\n", Info.CmpGlobalQuotaUsed);
1854 printf ("\tMmSizeofPagedPoolInBytes = %ld\n", Info.MmSizeofPagedPoolInBytes);
1855
1856 return EXIT_SUCCESS;
1857 }
1858
1859
1860 /**********************************************************************
1861 *
1862 * DESCRIPTION
1863 *
1864 * NOTE
1865 * Class 38.
1866 */
1867 CMD_DEF(38)
1868 CMD_NOT_IMPLEMENTED
1869
1870
1871 /**********************************************************************
1872 *
1873 * DESCRIPTION
1874 *
1875 * NOTE
1876 * Class 39.
1877 */
1878 CMD_DEF(39)
1879 CMD_NOT_IMPLEMENTED
1880
1881
1882 /**********************************************************************
1883 *
1884 * DESCRIPTION
1885 *
1886 * NOTE
1887 * Class 40.
1888 */
1889 CMD_DEF(40)
1890 CMD_NOT_IMPLEMENTED
1891
1892
1893 /**********************************************************************
1894 *
1895 * DESCRIPTION
1896 *
1897 * NOTE
1898 * Class 41.
1899 */
1900 CMD_DEF(41)
1901 CMD_NOT_IMPLEMENTED
1902
1903
1904 /**********************************************************************
1905 *
1906 * DESCRIPTION
1907 *
1908 * NOTE
1909 * Class 42.
1910 */
1911 CMD_DEF(42)
1912 CMD_NOT_IMPLEMENTED
1913
1914
1915 /**********************************************************************
1916 *
1917 * DESCRIPTION
1918 *
1919 * NOTE
1920 * Class 43.
1921 */
1922 CMD_DEF(43)
1923 CMD_NOT_IMPLEMENTED
1924
1925
1926 /**********************************************************************
1927 *
1928 * DESCRIPTION
1929 * Dump the system TIME_ZONE_INFORMATION object.
1930 *
1931 * NOTE
1932 * Class 44.
1933 */
1934 CMD_DEF(44)
1935 {
1936 #if 0
1937 NTSTATUS Status;
1938 TIME_ZONE_INFORMATION Tzi;
1939 WCHAR Name [33];
1940
1941 RtlZeroMemory (& Tzi, sizeof Tzi);
1942 Status = NtQuerySystemInformation(
1943 SystemTimeZoneInformation,
1944 & Tzi,
1945 sizeof Tzi,
1946 0
1947 );
1948 if (!NT_SUCCESS(Status))
1949 {
1950 PrintStatus (Status);
1951 return EXIT_FAILURE;
1952 }
1953 printf (
1954 "12h/24h.....: %dh\n",
1955 0 /* FIXME: */
1956 );
1957 printf (
1958 "Bias........: %d'\n",
1959 Tzi.Bias /* LONG */
1960 );
1961
1962 printf ("Standard\n");
1963 RtlZeroMemory (
1964 (PVOID) Name,
1965 sizeof Name
1966 );
1967 lstrcpynW (
1968 Name,
1969 Tzi.StandardName, /* WCHAR [32] */
1970 32
1971 );
1972 wprintf (
1973 L"\tName: \"%s\"\n",
1974 Name
1975 );
1976
1977 PrintUtcDateTime (
1978 "\tDate: %s\n",
1979 & Tzi.StandardDate /* SYSTEMTIME */
1980 );
1981
1982 printf ("\tBias: %d'\n",
1983 Tzi.StandardBias /* LONG */
1984 );
1985
1986 printf ("Daylight\n");
1987 RtlZeroMemory (
1988 (PVOID) Name,
1989 sizeof Name
1990 );
1991 lstrcpynW (
1992 Name,
1993 Tzi.DaylightName, /* WCHAR [32] */
1994 32
1995 );
1996 wprintf (
1997 L"\tName: \"%s\"\n",
1998 Name
1999 );
2000
2001 PrintUtcDateTime (
2002 "\tDate: %s\n",
2003 & Tzi.DaylightDate /* SYSTEMTIME */
2004 );
2005
2006 printf (
2007 "\tBias: %d'\n",
2008 Tzi.DaylightBias /* LONG */
2009 );
2010 #endif
2011 return EXIT_SUCCESS;
2012 }
2013
2014
2015 /**********************************************************************
2016 *
2017 * DESCRIPTION
2018 *
2019 * NOTE
2020 * Class 45.
2021 */
2022 CMD_DEF(45)
2023 CMD_NOT_IMPLEMENTED
2024
2025
2026 /**********************************************************************
2027 *
2028 * DESCRIPTION
2029 *
2030 * NOTE
2031 * Class 46.
2032 */
2033 CMD_DEF(46)
2034 CMD_NOT_IMPLEMENTED
2035
2036
2037 /**********************************************************************
2038 *
2039 * DESCRIPTION
2040 *
2041 * NOTE
2042 * Class 47.
2043 */
2044 CMD_DEF(47)
2045 CMD_NOT_IMPLEMENTED
2046
2047
2048 /**********************************************************************
2049 *
2050 * DESCRIPTION
2051 *
2052 * NOTE
2053 * Class 48.
2054 */
2055 CMD_DEF(48)
2056 CMD_NOT_IMPLEMENTED
2057
2058
2059 /**********************************************************************
2060 *
2061 * DESCRIPTION
2062 *
2063 * NOTE
2064 * Class 49.
2065 */
2066 CMD_DEF(49)
2067 CMD_NOT_IMPLEMENTED
2068
2069
2070 /**********************************************************************
2071 *
2072 * DESCRIPTION
2073 *
2074 * NOTE
2075 * Class 50.
2076 */
2077 CMD_DEF(50)
2078 CMD_NOT_IMPLEMENTED
2079
2080
2081 /**********************************************************************
2082 *
2083 * DESCRIPTION
2084 *
2085 * NOTE
2086 * Class 51.
2087 */
2088 CMD_DEF(51)
2089 CMD_NOT_IMPLEMENTED
2090
2091
2092 /**********************************************************************
2093 *
2094 * DESCRIPTION
2095 *
2096 * NOTE
2097 * Class 52.
2098 */
2099 CMD_DEF(52)
2100 CMD_NOT_IMPLEMENTED
2101
2102
2103 /**********************************************************************
2104 *
2105 * DESCRIPTION
2106 *
2107 * NOTE
2108 * Class 53.
2109 */
2110 CMD_DEF(53)
2111 CMD_NOT_IMPLEMENTED
2112
2113
2114 /**********************************************************************
2115 * Miscellanea Commands
2116 **********************************************************************/
2117
2118 CMD_DEF(ver)
2119 {
2120 INT Total = 0;
2121
2122 Total =
2123 printf (
2124 "ReactOS Operating System - http://www.reactos.com/\n"
2125 "QSI - Query System Information (compiled on %s, %s)\n"
2126 "Copyright (c) 1999-2001 Emanuele Aliberti et alii\n\n"
2127 "Run the command in verbose mode, for full license information.\n\n",
2128 __DATE__, __TIME__
2129 );
2130
2131 if (Application.Flag.Verbose)
2132 {
2133 Total +=
2134 printf (
2135 "This program is free software; you can redistribute it and/or modify\n"
2136 "it under the terms of the GNU General Public License as published by\n"
2137 "the Free Software Foundation; either version 2 of the License, or\n"
2138 "(at your option) any later version.\n\n"
2139
2140 "This program is distributed in the hope that it will be useful,\n"
2141 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
2142 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
2143 "GNU General Public License for more details.\n\n"
2144
2145 "You should have received a copy of the GNU General Public License\n"
2146 "along with this program; if not, write to the Free Software\n"
2147 "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"
2148 "(See also http://www.fsf.org/).\n"
2149 );
2150 }
2151 return (Total);
2152 }
2153
2154
2155 CMD_DEF(exit)
2156 {
2157 Application.Active = FALSE;
2158 return EXIT_SUCCESS;
2159 }
2160
2161
2162 extern COMMAND_DESCRIPTOR Commands [];
2163
2164 CMD_DEF(help)
2165 {
2166 int i;
2167
2168 if (Application.Flag.Verbose)
2169 {
2170 printf ("Commands:\n");
2171 }
2172 for ( i = 0;
2173 (NULL != Commands[i].Name);
2174 i ++
2175 )
2176 {
2177 printf (
2178 (strlen (Commands[i].Name) > 7)
2179 ? "%s\t: %s\n"
2180 : "%s\t\t: %s\n",
2181 Commands[i].Name,
2182 Commands[i].Description
2183 );
2184 }
2185 return EXIT_SUCCESS;
2186 }
2187
2188
2189 CMD_DEF(credits)
2190 {
2191 return
2192 printf (
2193 "\nReactOS (http://www.reactos.com/):\n"
2194 "\tEmanuele Aliberti\n"
2195 "\tEric Kohl\n\n"
2196
2197 "HandleEx:\n"
2198 "\tMark Russinovich (http://www.sysinternals.com/)\n\n"
2199
2200 "NtDriverList:\n"
2201 "\tYariv Kaplan (http://www.internals.com/)\n\n"
2202
2203 "Undocumented SYSTEM_POOL_INFORMATION:\n"
2204 "\tKlaus P. Gerlicher\n\n"
2205
2206 "Undocumented Windows NT:\n"
2207 "\tPrasad Dabak, Sandeep Phadke, and Milind Borate\n\n"
2208
2209 "Windows NT/2000 Native API Reference:\n"
2210 "\tGary Nebbett\n\n"
2211
2212 "comp.os.ms-windows.programmer.nt.kernel-mode\n"
2213 "\t(many postings with sample code)\n"
2214 );
2215 }
2216
2217
2218 CMD_DEF(verbose)
2219 {
2220 Application.Flag.Verbose = ~Application.Flag.Verbose;
2221 return printf (
2222 "Verbose mode is %s.\n",
2223 ONOFF(Application.Flag.Verbose)
2224 );
2225 }
2226
2227
2228 CMD_DEF(dump)
2229 {
2230 Application.Flag.Dump = ~Application.Flag.Dump;
2231 return printf (
2232 "Dump mode is %s.\n",
2233 ONOFF(Application.Flag.Dump)
2234 );
2235 }
2236
2237
2238 /**********************************************************************
2239 * Commands table
2240 **********************************************************************/
2241
2242 COMMAND_DESCRIPTOR
2243 Commands [] =
2244 {
2245 /* System information classes */
2246
2247 { /* 0 Q */
2248 "basic",
2249 CMD_REF(0),
2250 "Basic system information"
2251 },
2252 { /* 1 Q */
2253 "processor",
2254 CMD_REF(1),
2255 "Processor characteristics"
2256 },
2257 { /* 2 Q */
2258 "perf",
2259 CMD_REF(2),
2260 "System performance data"
2261 },
2262 { /* 3 Q */
2263 "time",
2264 CMD_REF(3),
2265 "System times"
2266 },
2267 { /* 4 Q (checked build only) */
2268 "path",
2269 CMD_REF(4),
2270 "Path (checked build only)"
2271 },
2272 { /* 5 Q */
2273 "process",
2274 CMD_REF(5),
2275 "Process & thread tables"
2276 },
2277 { /* 6 Q */
2278 "callcount",
2279 CMD_REF(6),
2280 "Call count information"
2281 },
2282 { /* 7 Q */
2283 "device",
2284 CMD_REF(7),
2285 "I/O devices in the system, by class"
2286 },
2287 { /* 8 Q */
2288 "performance",
2289 CMD_REF(8),
2290 "Processor performance"
2291 },
2292 { /* 9 QS */
2293 "flags",
2294 CMD_REF(9),
2295 "System wide flags"
2296 },
2297 { /* 10 */
2298 "call",
2299 CMD_REF(10),
2300 "Call time"
2301 },
2302 { /* 11 Q */
2303 "module",
2304 CMD_REF(11),
2305 "Table of kernel modules"
2306 },
2307 { /* 12 Q */
2308 "locks",
2309 CMD_REF(12),
2310 "Table of locks on resources"
2311 },
2312 { /* 13 */
2313 "stack",
2314 CMD_REF(13),
2315 "Stack trace"
2316 },
2317 { /* 14 */
2318 "ppool",
2319 CMD_REF(14),
2320 "Paged pool"
2321 },
2322 { /* 15 */
2323 "nppool",
2324 CMD_REF(15),
2325 "Non paged pool"
2326 },
2327 { /* 16 Q */
2328 "handle",
2329 CMD_REF(16),
2330 "Table of handles"
2331 },
2332 { /* 17 Q */
2333 "object",
2334 CMD_REF(17),
2335 "Table of executive objects"
2336 },
2337 { /* 18 Q */
2338 "pagefile",
2339 CMD_REF(18),
2340 "Virtual memory paging files"
2341 },
2342 { /* 19 Q */
2343 "vdmie",
2344 CMD_REF(19),
2345 "Virtual DOS Machine instruction emulation (VDM)"
2346 },
2347 { /* 20 */
2348 "vdmbop",
2349 CMD_REF(20),
2350 "Bop (VDM)"
2351 },
2352 { /* 21 QS */
2353 "cache",
2354 CMD_REF(21),
2355 "File cache"
2356 },
2357 { /* 22 Q */
2358 "pooltag",
2359 CMD_REF(22),
2360 "Tagged pools statistics (checked build only)"
2361 },
2362 { /* 23 Q */
2363 "int",
2364 CMD_REF(23),
2365 "Processor schedule information (interrupt)"
2366 },
2367 { /* 24 QS */
2368 "dpc",
2369 CMD_REF(24),
2370 "Deferred procedure call behaviour (DPC)"
2371 },
2372 { /* 25 */
2373 "fullmem",
2374 CMD_REF(25),
2375 "Full memory"
2376 },
2377 { /* 26 S (callable) */
2378 "loadpe",
2379 CMD_REF(26),
2380 "Load a kernel mode DLL (module in PE format)"
2381 },
2382 { /* 27 S (callable) */
2383 "unloadpe",
2384 CMD_REF(27),
2385 "Unload a kernel mode DLL (module in Pe format)"
2386 },
2387 { /* 28 QS */
2388 "timeadj",
2389 CMD_REF(28),
2390 "Time adjustment"
2391 },
2392 { /* 29 */
2393 "smem",
2394 CMD_REF(29),
2395 "Summary memory"
2396 },
2397 { /* 30 */
2398 "event",
2399 CMD_REF(30),
2400 "Next event ID"
2401 },
2402 { /* 31 */
2403 "events",
2404 CMD_REF(31),
2405 "Event IDs"
2406 },
2407 { /* 32 Q */
2408 "crash",
2409 CMD_REF(32),
2410 "Crash Dump Section"
2411 },
2412 { /* 33 Q */
2413 "exceptions",
2414 CMD_REF(33),
2415 "Exceptions"
2416 },
2417 { /* 34 Q */
2418 "crashstate",
2419 CMD_REF(34),
2420 "Crash Dump State"
2421 },
2422 { /* 35 Q */
2423 "debugger",
2424 CMD_REF(35),
2425 "Kernel debugger"
2426 },
2427 { /* 36 Q */
2428 "cswitch",
2429 CMD_REF(36),
2430 "Thread context switch counters"
2431 },
2432 { /* 37 QS */
2433 "regquota",
2434 CMD_REF(37),
2435 "Registry quota values"
2436 },
2437 { /* 38 S */
2438 "est",
2439 CMD_REF(38),
2440 "Extended service table"
2441 },
2442 { /* 39 S */
2443 "prisep",
2444 CMD_REF(39),
2445 "Priority Separation"
2446 },
2447 { /* 40 */
2448 "ppbus",
2449 CMD_REF(40),
2450 "Plug & play bus"
2451 },
2452 { /* 41 */
2453 "dock",
2454 CMD_REF(41),
2455 "Dock"
2456 },
2457 { /* 42 */
2458 "power",
2459 CMD_REF(42),
2460 "Power"
2461 },
2462 { /* 43 */
2463 "procspeed",
2464 CMD_REF(43),
2465 "Processor speed"
2466 },
2467 { /* 44 QS */
2468 "tz",
2469 CMD_REF(44),
2470 "Current time zone (TZ)"
2471 },
2472 { /* 45 Q */
2473 "lookaside",
2474 CMD_REF(45),
2475 "Lookaside"
2476 },
2477 /* NT5 */
2478 { /* 46 Q */
2479 "tslip",
2480 CMD_REF(46),
2481 "Set time slip (5.0)"
2482 },
2483 { /* 47 Q */
2484 "csession",
2485 CMD_REF(47),
2486 "Create session (5.0)"
2487 },
2488 { /* 48 Q */
2489 "dsession",
2490 CMD_REF(48),
2491 "Delete session (5.0)"
2492 },
2493 { /* 49 Q */
2494 "#49",
2495 CMD_REF(49),
2496 "UNKNOWN (5.0)"
2497 },
2498 { /* 50 Q */
2499 "range",
2500 CMD_REF(50),
2501 "Range start (5.0)"
2502 },
2503 { /* 51 Q */
2504 "verifier",
2505 CMD_REF(51),
2506 "Verifier (5.0)"
2507 },
2508 { /* 52 Q */
2509 "addverif",
2510 CMD_REF(52),
2511 "Add verifier (5.0)"
2512 },
2513 { /* 53 Q */
2514 "sesproc",
2515 CMD_REF(53),
2516 "Session processes (5.0)"
2517 },
2518 /* User commands */
2519 {
2520 "?",
2521 CMD_REF(help),
2522 "Same as 'help'"
2523 },
2524 {
2525 "help",
2526 CMD_REF(help),
2527 "Print this command directory"
2528 },
2529 {
2530 "credits",
2531 CMD_REF(credits),
2532 "Print the list of people and sources that made QSI possible"
2533 },
2534 {
2535 "ver",
2536 CMD_REF(ver),
2537 "Print version number and license information"
2538 },
2539 {
2540 "exit",
2541 CMD_REF(exit),
2542 "Exit to operating system"
2543 },
2544 {
2545 "dump",
2546 CMD_REF(dump),
2547 "Enable/disable dumping raw data returned by system"
2548 },
2549 {
2550 "verbose",
2551 CMD_REF(verbose),
2552 "Enable/disable printing unused, unknown, and service fields"
2553 },
2554
2555 { NULL, NULL }
2556 };
2557
2558
2559
2560 /* user input --> command decoder */
2561
2562
2563 COMMAND_CALL
2564 DecodeCommand (LPCSTR Command)
2565 {
2566 int i;
2567
2568 for ( i = 0;
2569 ( Commands[i].Name
2570 && stricmp (Commands[i].Name,Command)
2571 );
2572 ++i
2573 );
2574 return Commands[i].EntryPoint;
2575 }
2576
2577 INT
2578 ParseCommandLine (
2579 LPCSTR CommandLine,
2580 LPCSTR CommandArgv []
2581 )
2582 {
2583 INT ArgC = 0;
2584 LPCSTR Separators = " \t";
2585
2586 for ( CommandArgv [ArgC] = strtok ((char*)CommandLine, (char*)Separators);
2587 (ArgC < ARGV_SIZE);
2588 CommandArgv [ArgC] = (LPCSTR) strtok (NULL, (char*)Separators)
2589 )
2590 {
2591 if (NULL == CommandArgv [ArgC++])
2592 {
2593 break;
2594 }
2595 }
2596 return (ArgC);
2597 }
2598
2599
2600 int
2601 main (int argc, char * argv [])
2602 {
2603 CHAR CommandLine [_MAX_PATH];
2604
2605 INT CommandArgc;
2606 LPCSTR CommandArgv [ARGV_SIZE];
2607
2608 /*
2609 * Initialize rt data.
2610 */
2611 Application.Heap = GetProcessHeap ();
2612 Application.Active = TRUE;
2613 /*
2614 * r-e-p loop.
2615 */
2616 while (Application.Active)
2617 {
2618 /* Print the prompt string. */
2619 if (! Application.Flag.Batch)
2620 {
2621 printf ("\r\nsystem> ");
2622 }
2623 /* Read user command. */
2624 gets (CommandLine);
2625 /* Parse the user command */
2626 CommandArgc = ParseCommandLine (
2627 CommandLine,
2628 CommandArgv
2629 );
2630 if (0 != CommandArgc)
2631 {
2632 COMMAND_CALL CommandCall = NULL;
2633
2634 /* decode */
2635 if ((CommandCall = DecodeCommand (CommandArgv[0])))
2636 {
2637 /* execute */
2638 Application.ExitCode =
2639 CommandCall (
2640 CommandArgc,
2641 CommandArgv
2642 );
2643 }
2644 else
2645 {
2646 printf ("Unknown command (type help for a list of valid commands).\n");
2647 }
2648 }
2649
2650 }
2651 if (! Application.Flag.Batch)
2652 {
2653 printf ("Bye\n");
2654 }
2655 return (EXIT_SUCCESS);
2656 }
2657
2658 /* EOF */