9ef57da3ebbfe24082f567f3a1909e3ff97de4bd
[reactos.git] / rosapps / applications / sysutils / qssi / qssi.c
1 /* $Id$
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 class 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 WINAPI 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 WINAPI
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 WINAPI
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 WINAPI
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 WINAPI
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 WINAPI
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 WINAPI
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%08lx\n", Info.Reserved);
430 printf (" TimerResolution %ld\n", Info.TimerResolution);
431 printf (" PageSize %ld\n", Info.PageSize);
432 printf (" NumberOfPhysicalPages %ld\n", Info.NumberOfPhysicalPages);
433 printf (" LowestPhysicalPageNumber %ld\n", Info.LowestPhysicalPageNumber);
434 printf (" HighestPhysicalPageNumber %ld\n", Info.HighestPhysicalPageNumber);
435 printf (" AllocationGranularity %ld\n", Info.AllocationGranularity);
436 printf (" MinimumUserModeAddress 0x%08lx (%ld)\n", Info.MinimumUserModeAddress, Info.MinimumUserModeAddress);
437 printf (" MaximumUserModeAddress 0x%08lx (%ld)\n", Info.MaximumUserModeAddress, Info.MaximumUserModeAddress);
438 printf (" ActiveProcessorsAffinityMask 0x%08lx\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 %08lx\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 %08lx\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 : %08lx\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: %08lx\n", Info.Flags);
952 if (FLG_STOP_ON_EXCEPTION & Info.Flags) printf ("\tSTOP_ON_EXCEPTION\n");
953 if (FLG_STOP_ON_HANG_GUI & Info.Flags) printf ("\tSTOP_ON_HANG_GUI\n");
954 if (FLG_SHOW_LDR_SNAPS & Info.Flags) printf ("\tSHOW_LDR_SNAPS\n");
955 if (FLG_DEBUG_INITIAL_COMMAND & Info.Flags) printf ("\tDEBUG_INITIAL_COMMAND\n");
956 if (FLG_HEAP_ENABLE_TAIL_CHECK & Info.Flags) printf ("\tHEAP_ENABLE_TAIL_CHECK\n");
957 if (FLG_HEAP_ENABLE_FREE_CHECK & Info.Flags) printf ("\tHEAP_ENABLE_FREE_CHECK\n");
958 if (FLG_HEAP_ENABLE_TAGGING & Info.Flags) printf ("\tHEAP_ENABLE_TAGGING\n");
959 if (FLG_HEAP_ENABLE_TAG_BY_DLL & Info.Flags) printf ("\tHEAP_ENABLE_TAG_BY_DLL\n");
960 if (FLG_HEAP_ENABLE_CALL_TRACING & Info.Flags) printf ("\tHEAP_ENABLE_CALL_TRACING\n");
961 if (FLG_HEAP_DISABLE_COALESCING & Info.Flags) printf ("\tHEAP_DISABLE_COALESCING\n");
962 if (FLG_HEAP_VALIDATE_PARAMETERS & Info.Flags) printf ("\tHEAP_VALIDATE_PARAMETERS\n");
963 if (FLG_HEAP_VALIDATE_ALL & Info.Flags) printf ("\tHEAP_VALIDATE_ALL\n");
964 if (FLG_POOL_ENABLE_TAIL_CHECK & Info.Flags) printf ("\tPOOL_ENABLE_TAIL_CHECK\n");
965 if (FLG_POOL_ENABLE_FREE_CHECK & Info.Flags) printf ("\tPOOL_ENABLE_FREE_CHECK\n");
966 if (FLG_POOL_ENABLE_TAGGING & Info.Flags) printf ("\tPOOL_ENABLE_TAGGING\n");
967 if (FLG_USER_STACK_TRACE_DB & Info.Flags) printf ("\tUSER_STACK_TRACE_DB\n");
968 if (FLG_KERNEL_STACK_TRACE_DB & Info.Flags) printf ("\tKERNEL_STACK_TRACE_DB\n");
969 if (FLG_MAINTAIN_OBJECT_TYPELIST & Info.Flags) printf ("\tMAINTAIN_OBJECT_TYPELIST\n");
970 if (FLG_IGNORE_DEBUG_PRIV & Info.Flags) printf ("\tIGNORE_DEBUG_PRIV\n");
971 if (FLG_ENABLE_CSRDEBUG & Info.Flags) printf ("\tENABLE_CSRDEBUG\n");
972 if (FLG_ENABLE_KDEBUG_SYMBOL_LOAD & Info.Flags) printf ("\tENABLE_KDEBUG_SYMBOL_LOAD\n");
973 if (FLG_DISABLE_PAGE_KERNEL_STACKS & Info.Flags) printf ("\tDISABLE_PAGE_KERNEL_STACKS\n");
974 if (FLG_ENABLE_CLOSE_EXCEPTION & Info.Flags) printf ("\tENABLE_CLOSE_EXCEPTION\n");
975 if (FLG_ENABLE_EXCEPTION_LOGGING & Info.Flags) printf ("\tENABLE_EXCEPTION_LOGGING\n");
976 if (FLG_ENABLE_DBGPRINT_BUFFERING & Info.Flags) printf ("\tENABLE_DBGPRINT_BUFFERING\n");
977 if (FLG_UNKNOWN_01000000 & Info.Flags) printf ("\tUNKNOWN_01000000\n");
978 if (FLG_UNKNOWN_02000000 & Info.Flags) printf ("\tUNKNOWN_02000000\n");
979 if (FLG_UNKNOWN_04000000 & Info.Flags) printf ("\tUNKNOWN_04000000\n");
980 if (FLG_UNKNOWN_10000000 & Info.Flags) printf ("\tUNKNOWN_10000000\n");
981 if (FLG_UNKNOWN_20000000 & Info.Flags) printf ("\tUNKNOWN_20000000\n");
982 if (FLG_UNKNOWN_40000000 & Info.Flags) printf ("\tUNKNOWN_40000000\n");
983 if (FLG_UNKNOWN_80000000 & Info.Flags) printf ("\tUNKNOWN_80000000\n");
984
985 return EXIT_SUCCESS;
986 }
987
988
989 /**********************************************************************
990 *
991 * DESCRIPTION
992 *
993 * NOTE
994 * Class 10.
995 */
996 CMD_DEF(10)
997 CMD_NOT_IMPLEMENTED
998
999
1000 /**********************************************************************
1001 *
1002 * DESCRIPTION
1003 *
1004 * NOTE
1005 * Class 11.
1006 *
1007 * NOTE
1008 * Code originally in Yariv Kaplan's NtDriverList,
1009 * at http://www.internals.com/, adapted to ReactOS
1010 * structures layout.
1011 */
1012 CMD_DEF(11)
1013 {
1014 NTSTATUS Status = STATUS_SUCCESS;
1015 PSYSTEM_MODULE_INFORMATION pInfo = NULL;
1016 LONG Length = 0;
1017 INT Index;
1018 const PCHAR hr =
1019 "-------- -------- -------- ---------------------------------------\n";
1020
1021
1022 /*
1023 * Obtain required buffer size
1024 */
1025 Status = NtQuerySystemInformation (
1026 11,
1027 & pInfo,
1028 0, /* query size */
1029 & Length
1030 );
1031 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1032 {
1033 /*
1034 * Allocate buffer
1035 */
1036 pInfo = GlobalAlloc (GMEM_ZEROINIT, Length);
1037 if (NULL == pInfo)
1038 {
1039 printf ("Could not allocate memory.\n");
1040 return EXIT_FAILURE;
1041 }
1042 }
1043 else
1044 {
1045 PrintStatus (Status);
1046 return EXIT_FAILURE;
1047 }
1048 /*
1049 * Get module list from ntoskrnl.exe
1050 */
1051 Status = NtQuerySystemInformation (
1052 11,
1053 pInfo,
1054 Length,
1055 & Length
1056 );
1057 if (!NT_SUCCESS(Status))
1058 {
1059 PrintStatus (Status);
1060 return EXIT_FAILURE;
1061 }
1062 printf ("Index Address Size Name\n");
1063 printf (hr);
1064
1065 for ( Index = 0;
1066 (Index < (int) pInfo->Count);
1067 Index ++
1068 )
1069 {
1070 printf (
1071 "%8lx %8p %8lx %s\n",
1072 pInfo->Module[Index].EntryIndex,
1073 pInfo->Module[Index].BaseAddress,
1074 pInfo->Module[Index].Size,
1075 pInfo->Module[Index].Name
1076 );
1077 }
1078 printf (hr);
1079
1080 GlobalFree (pInfo);
1081
1082 return EXIT_SUCCESS;
1083 }
1084
1085
1086 /**********************************************************************
1087 *
1088 * DESCRIPTION
1089 *
1090 * NOTE
1091 * Class 12.
1092 */
1093 CMD_DEF(12)
1094 {
1095 NTSTATUS Status = STATUS_SUCCESS;
1096 PSYSTEM_RESOURCE_LOCK_INFO pInfo = NULL;
1097 LONG Length = 0;
1098 INT Index;
1099 const PCHAR hr =
1100 "-------- -------- -------- -------- -------- -------- ------------\n";
1101
1102 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1103 /* FIXME: check NULL==pInfo */
1104
1105 /*
1106 * Obtain required buffer size
1107 */
1108 Status = NtQuerySystemInformation (
1109 12,
1110 pInfo,
1111 BUFFER_SIZE_DEFAULT, /* query size */
1112 & Length
1113 );
1114 if (STATUS_SUCCESS != Status)
1115 {
1116 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1117 {
1118 /*
1119 * Allocate buffer
1120 */
1121 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1122 if (NULL == pInfo)
1123 {
1124 printf ("Could not allocate memory.\n");
1125 return EXIT_FAILURE;
1126 }
1127 }
1128 else
1129 {
1130 PrintStatus (Status);
1131 GlobalFree (pInfo);
1132 return EXIT_FAILURE;
1133 }
1134 }
1135 /*
1136 * Get locked resource list from ntoskrnl.exe
1137 */
1138 Status = NtQuerySystemInformation (
1139 12,
1140 pInfo,
1141 Length,
1142 & Length
1143 );
1144 if (!NT_SUCCESS(Status))
1145 {
1146 PrintStatus (Status);
1147 GlobalFree (pInfo);
1148 return EXIT_FAILURE;
1149 }
1150 printf ("Address Active # Content# Sh/Wait Exc/Wait\n");
1151 printf (hr);
1152
1153 for ( Index = 0;
1154 (Index < (int) pInfo->Count);
1155 Index ++
1156 )
1157 {
1158 printf (
1159 "%08lx %8ld %8ld %8ld %8ld %08lx\n",
1160 pInfo->Lock[Index].ResourceAddress,
1161 pInfo->Lock[Index].ActiveCount,
1162 pInfo->Lock[Index].ContentionCount,
1163 pInfo->Lock[Index].NumberOfSharedWaiters,
1164 pInfo->Lock[Index].NumberOfExclusiveWaiters,
1165 pInfo->Lock[Index].Unknown
1166 );
1167 }
1168 printf (hr);
1169
1170 GlobalFree (pInfo);
1171
1172 return EXIT_SUCCESS;
1173 }
1174
1175
1176 /**********************************************************************
1177 *
1178 * DESCRIPTION
1179 *
1180 * NOTE
1181 * Class 13.
1182 */
1183 CMD_DEF(13)
1184 CMD_NOT_IMPLEMENTED
1185
1186
1187 /**********************************************************************
1188 *
1189 * DESCRIPTION
1190 *
1191 * NOTE
1192 * Class 14.
1193 */
1194 CMD_DEF(14)
1195 CMD_NOT_IMPLEMENTED
1196
1197
1198 /**********************************************************************
1199 *
1200 * DESCRIPTION
1201 *
1202 * NOTE
1203 * Class 15.
1204 */
1205 CMD_DEF(15)
1206 CMD_NOT_IMPLEMENTED
1207
1208
1209 /**********************************************************************
1210 *
1211 * DESCRIPTION
1212 *
1213 * NOTE
1214 * Class 16. You can not pass 0 as the initial output buffer's
1215 * size to get back the needed buffer size.
1216 */
1217 CMD_DEF(16)
1218 {
1219 NTSTATUS Status = STATUS_SUCCESS;
1220 PSYSTEM_HANDLE_INFORMATION pInfo = NULL;
1221 LONG Length = 0;
1222 INT Index;
1223 const PCHAR hr =
1224 "-------- -------- -------- -------- -------- ----------\n";
1225 CHAR FlagsString [9] = {0};
1226
1227 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1228
1229 /*
1230 * Obtain required buffer size
1231 */
1232 Status = NtQuerySystemInformation (
1233 16,
1234 pInfo,
1235 BUFFER_SIZE_DEFAULT,
1236 & Length
1237 );
1238 if (STATUS_SUCCESS != Status)
1239 {
1240 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1241 {
1242 /*
1243 * Allocate buffer
1244 */
1245 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1246 if (NULL == pInfo)
1247 {
1248 printf ("\tCould not allocate memory.\n");
1249 return EXIT_FAILURE;
1250 }
1251 }
1252 else
1253 {
1254 PrintStatus (Status);
1255 GlobalFree (pInfo);
1256 return EXIT_FAILURE;
1257 }
1258 }
1259 /*
1260 * Get handle table from ntoskrnl.exe
1261 */
1262 Status = NtQuerySystemInformation (
1263 16,
1264 pInfo,
1265 Length,
1266 & Length
1267 );
1268 if (!NT_SUCCESS(Status))
1269 {
1270 PrintStatus (Status);
1271 GlobalFree (pInfo);
1272 return EXIT_FAILURE;
1273 }
1274 printf ("Handle OwnerPID ObjPtr Access Flags Type\n");
1275 printf (hr);
1276
1277 for ( Index = 0;
1278 (Index < (int) pInfo->Count);
1279 Index ++
1280 )
1281 {
1282 printf (
1283 "%8x %8lx %8p %8lx %s %s\n",
1284 pInfo->Handle[Index].HandleValue,
1285 pInfo->Handle[Index].OwnerPid,
1286 pInfo->Handle[Index].ObjectPointer,
1287 pInfo->Handle[Index].AccessMask,
1288 ByteToBinaryString (
1289 pInfo->Handle[Index].HandleFlags,
1290 FlagsString
1291 ),
1292 HandleTypeToObjectName (pInfo->Handle[Index].ObjectType)
1293 );
1294 }
1295 printf (hr);
1296
1297 DumpData (Length, pInfo);
1298
1299 GlobalFree (pInfo);
1300
1301 return EXIT_SUCCESS;
1302 }
1303
1304
1305 /**********************************************************************
1306 *
1307 * DESCRIPTION
1308 *
1309 * NOTE
1310 * Class 17.
1311 */
1312 CMD_DEF(17)
1313 CMD_NOT_IMPLEMENTED
1314
1315
1316 /**********************************************************************
1317 *
1318 * DESCRIPTION
1319 *
1320 * NOTE
1321 * Class 18.
1322 */
1323 CMD_DEF(18)
1324 {
1325 NTSTATUS Status;
1326 PSYSTEM_PAGEFILE_INFORMATION pInfo = NULL;
1327 LONG Length = 0;
1328
1329 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1330 /* FIXME: check pInfo */
1331
1332 Status = NtQuerySystemInformation(
1333 18,
1334 pInfo,
1335 BUFFER_SIZE_DEFAULT,
1336 & Length
1337 );
1338 if (STATUS_SUCCESS != Status)
1339 {
1340 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1341 {
1342 /*
1343 * Allocate buffer
1344 */
1345 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1346 if (NULL == pInfo)
1347 {
1348 printf ("Could not allocate memory.\n");
1349 return EXIT_FAILURE;
1350 }
1351 }
1352 else
1353 {
1354 PrintStatus (Status);
1355 GlobalFree (pInfo);
1356 return EXIT_FAILURE;
1357 }
1358 }
1359 Status = NtQuerySystemInformation (
1360 18,
1361 pInfo,
1362 Length,
1363 & Length
1364 );
1365 if (!NT_SUCCESS(Status))
1366 {
1367 PrintStatus (Status);
1368 GlobalFree (pInfo);
1369 return EXIT_FAILURE;
1370 }
1371
1372 while (1)
1373 {
1374 wprintf (L" \"%s\":\n", pInfo->PagefileFileName.Buffer);
1375 wprintf (L"\tRelativeOffset %08x\n", pInfo->RelativeOffset);
1376 wprintf (L"\tCurrentSizePages %ld\n", pInfo->CurrentSizePages);
1377 wprintf (L"\tTotalUsedPages %ld\n", pInfo->TotalUsedPages);
1378 wprintf (L"\tPeakUsedPages %ld\n", pInfo->PeakUsedPages);
1379
1380 if (0 == pInfo->RelativeOffset)
1381 {
1382 break;
1383 }
1384 printf ("\n");
1385 (ULONG) pInfo += pInfo->RelativeOffset;
1386 }
1387
1388 DumpData (Length, pInfo);
1389
1390 GlobalFree (pInfo);
1391
1392 return EXIT_SUCCESS;
1393 }
1394
1395
1396 /**********************************************************************
1397 *
1398 * DESCRIPTION
1399 *
1400 * NOTE
1401 * Class 19.
1402 */
1403 CMD_DEF(19)
1404 {
1405 NTSTATUS Status;
1406 SYSTEM_VDM_INFORMATION Info;
1407
1408 RtlZeroMemory (& Info, sizeof Info);
1409 Status = NtQuerySystemInformation (
1410 19,
1411 & Info,
1412 sizeof Info,
1413 NULL
1414 );
1415 if (!NT_SUCCESS(Status))
1416 {
1417 PrintStatus (Status);
1418 return EXIT_FAILURE;
1419 }
1420 printf (" VdmSegmentNotPresentCount = %ld\n", Info.VdmSegmentNotPresentCount);
1421 printf (" VdmINSWCount = %ld\n", Info.VdmINSWCount);
1422 printf (" VdmESPREFIXCount = %ld\n", Info.VdmESPREFIXCount);
1423 printf (" VdmCSPREFIXCount = %ld\n", Info.VdmCSPREFIXCount);
1424 printf (" VdmSSPREFIXCount = %ld\n", Info.VdmSSPREFIXCount);
1425 printf (" VdmDSPREFIXCount = %ld\n", Info.VdmDSPREFIXCount);
1426 printf (" VdmFSPREFIXCount = %ld\n", Info.VdmFSPREFIXCount);
1427 printf (" VdmGSPREFIXCount = %ld\n", Info.VdmGSPREFIXCount);
1428 printf (" VdmOPER32PREFIXCount = %ld\n", Info.VdmOPER32PREFIXCount);
1429 printf (" VdmADDR32PREFIXCount = %ld\n", Info.VdmADDR32PREFIXCount);
1430 printf (" VdmINSBCount = %ld\n", Info.VdmINSBCount);
1431 printf (" VdmINSWV86Count = %ld\n", Info.VdmINSWV86Count);
1432 printf (" VdmOUTSBCount = %ld\n", Info.VdmOUTSBCount);
1433 printf (" VdmOUTSWCount = %ld\n", Info.VdmOUTSWCount);
1434 printf (" VdmPUSHFCount = %ld\n", Info.VdmPUSHFCount);
1435 printf (" VdmPOPFCount = %ld\n", Info.VdmPOPFCount);
1436 printf (" VdmINTNNCount = %ld\n", Info.VdmINTNNCount);
1437 printf (" VdmINTOCount = %ld\n", Info.VdmINTOCount);
1438 printf (" VdmIRETCount = %ld\n", Info.VdmIRETCount);
1439 printf (" VdmINBIMMCount = %ld\n", Info.VdmINBIMMCount);
1440 printf (" VdmINWIMMCount = %ld\n", Info.VdmINWIMMCount);
1441 printf (" VdmOUTBIMMCount = %ld\n", Info.VdmOUTBIMMCount);
1442 printf (" VdmOUTWIMMCount = %ld\n", Info.VdmOUTWIMMCount);
1443 printf (" VdmINBCount = %ld\n", Info.VdmINBCount);
1444 printf (" VdmINWCount = %ld\n", Info.VdmINWCount);
1445 printf (" VdmOUTBCount = %ld\n", Info.VdmOUTBCount);
1446 printf (" VdmOUTWCount = %ld\n", Info.VdmOUTWCount);
1447 printf (" VdmLOCKPREFIXCount = %ld\n", Info.VdmLOCKPREFIXCount);
1448 printf (" VdmREPNEPREFIXCount = %ld\n", Info.VdmREPNEPREFIXCount);
1449 printf (" VdmREPPREFIXCount = %ld\n", Info.VdmREPPREFIXCount);
1450 printf (" VdmHLTCount = %ld\n", Info.VdmHLTCount);
1451 printf (" VdmCLICount = %ld\n", Info.VdmCLICount);
1452 printf (" VdmSTICount = %ld\n", Info.VdmSTICount);
1453 printf (" VdmBopCount = %ld\n", Info.VdmBopCount);
1454
1455 return EXIT_SUCCESS;
1456 }
1457
1458
1459 /**********************************************************************
1460 *
1461 * DESCRIPTION
1462 *
1463 * NOTE
1464 * Class 20.
1465 */
1466 CMD_DEF(20)
1467 CMD_NOT_IMPLEMENTED
1468
1469
1470 /**********************************************************************
1471 *
1472 * DESCRIPTION
1473 *
1474 * NOTE
1475 * Class 21.
1476 */
1477 CMD_DEF(21)
1478 {
1479 NTSTATUS Status;
1480 SYSTEM_CACHE_INFORMATION Si;
1481
1482 RtlZeroMemory (
1483 (PVOID) & Si,
1484 sizeof Si
1485 );
1486 Status = NtQuerySystemInformation (
1487 21,
1488 & Si,
1489 sizeof Si,
1490 0
1491 );
1492 if (!NT_SUCCESS(Status))
1493 {
1494 PrintStatus (Status);
1495 return EXIT_FAILURE;
1496 }
1497 printf ("\tSize:\n");
1498 printf ("\t\tCurrent = %ld\n", Si.CurrentSize);
1499 printf ("\t\tPeak = %ld\n\n", Si.PeakSize);
1500 printf ("\tPageFaults:\n\t\tCount = %ld\n\n", Si.PageFaultCount);
1501 printf ("\tWorking Set:\n");
1502 printf ("\t\tMinimum = %ld\n", Si.MinimumWorkingSet );
1503 printf ("\t\tMaximum = %ld\n", Si.MaximumWorkingSet );
1504
1505 return EXIT_SUCCESS;
1506 }
1507
1508
1509 /**********************************************************************
1510 *
1511 * DESCRIPTION
1512 * Get statistic data about tagged pools. Not implemented in the
1513 * free build.
1514 *
1515 * NOTE
1516 * Class 22.
1517 */
1518 CMD_DEF(22)
1519 {
1520 NTSTATUS Status;
1521 PSYSTEM_POOL_TAG_INFO pInfo = NULL;
1522 ULONG Length;
1523 ULONG PoolIndex;
1524
1525 pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT);
1526 /* FIXME: check pInfo */
1527
1528 Status = NtQuerySystemInformation(
1529 22,
1530 pInfo,
1531 BUFFER_SIZE_DEFAULT,
1532 & Length
1533 );
1534 if (STATUS_SUCCESS != Status)
1535 {
1536 if (STATUS_INFO_LENGTH_MISMATCH == Status)
1537 {
1538 /*
1539 * Allocate buffer
1540 */
1541 pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT);
1542 if (NULL == pInfo)
1543 {
1544 printf ("Could not allocate memory.\n");
1545 return EXIT_FAILURE;
1546 }
1547 }
1548 else
1549 {
1550 PrintStatus (Status);
1551 GlobalFree (pInfo);
1552 return EXIT_FAILURE;
1553 }
1554 }
1555 Status = NtQuerySystemInformation (
1556 22,
1557 pInfo,
1558 Length,
1559 & Length
1560 );
1561 if (!NT_SUCCESS(Status))
1562 {
1563 PrintStatus (Status);
1564 GlobalFree (pInfo);
1565 return EXIT_FAILURE;
1566 }
1567
1568 for ( PoolIndex = 0;
1569 (PoolIndex < pInfo->Count);
1570 PoolIndex ++
1571 )
1572 {
1573 wprintf (L"\t%08x:\n", pInfo->PoolEntry[PoolIndex].Tag);
1574 wprintf (L"\t\tPaged:\t\tNon Paged:\n");
1575 wprintf (
1576 L"\t\tAllocationCount = %ld\tAllocationCount = %ld\n",
1577 pInfo->PoolEntry[PoolIndex].Paged.AllocationCount,
1578 pInfo->PoolEntry[PoolIndex].NonPaged.AllocationCount
1579 );
1580 wprintf (
1581 L"\t\tFreeCount = %ld\tFreeCount = %ld\n",
1582 pInfo->PoolEntry[PoolIndex].Paged.FreeCount,
1583 pInfo->PoolEntry[PoolIndex].NonPaged.FreeCount
1584 );
1585 wprintf (
1586 L"\t\tSizeBytes = %ld\tSizeBytes = %ld\n",
1587 pInfo->PoolEntry[PoolIndex].Paged.SizeBytes,
1588 pInfo->PoolEntry[PoolIndex].NonPaged.SizeBytes
1589 );
1590 }
1591
1592 DumpData (Length, pInfo);
1593
1594 GlobalFree (pInfo);
1595
1596 return EXIT_SUCCESS;
1597 }
1598
1599
1600 /**********************************************************************
1601 *
1602 * DESCRIPTION
1603 *
1604 * NOTE
1605 * Class 23.
1606 */
1607 CMD_DEF(23)
1608 {
1609 NTSTATUS Status;
1610 SYSTEM_PROCESSOR_SCHEDULE_INFO Info;
1611
1612 RtlZeroMemory (
1613 & Info,
1614 sizeof Info
1615 );
1616 Status = NtQuerySystemInformation (
1617 23,
1618 & Info,
1619 sizeof Info,
1620 NULL
1621 );
1622 if (STATUS_SUCCESS != Status)
1623 {
1624 PrintStatus (Status);
1625 return EXIT_FAILURE;
1626 }
1627
1628 printf ("\tnContextSwitches = %ld\n", Info.nContextSwitches);
1629 printf ("\tnDPCQueued = %ld\n", Info.nDPCQueued);
1630 printf ("\tnDPCRate = %ld\n", Info.nDPCRate);
1631 printf ("\tTimerResolution = %ld\n", Info.TimerResolution);
1632 printf ("\tnDPCBypasses = %ld\n", Info.nDPCBypasses);
1633 printf ("\tnAPCBypasses = %ld\n", Info.nAPCBypasses);
1634
1635 DumpData (sizeof Info, & Info);
1636
1637 return EXIT_SUCCESS;
1638
1639 }
1640
1641
1642 /**********************************************************************
1643 *
1644 * DESCRIPTION
1645 *
1646 * NOTE
1647 * Class 24.
1648 */
1649 CMD_DEF(24)
1650 {
1651 NTSTATUS Status;
1652 SYSTEM_DPC_INFORMATION Info;
1653
1654 RtlZeroMemory (
1655 & Info,
1656 sizeof Info
1657 );
1658 Status = NtQuerySystemInformation (
1659 24,
1660 & Info,
1661 sizeof Info,
1662 NULL
1663 );
1664 if (STATUS_SUCCESS != Status)
1665 {
1666 PrintStatus (Status);
1667 return EXIT_FAILURE;
1668 }
1669
1670 if (Application.Flag.Verbose)
1671 {
1672 printf ("\tUnused = %ld\n", Info.Unused);
1673 }
1674 printf ("\tKiMaximumDpcQueueDepth = %ld\n", Info.KiMaximumDpcQueueDepth);
1675 printf ("\tKiMinimumDpcRate = %ld\n", Info.KiMinimumDpcRate);
1676 printf ("\tKiAdjustDpcThreshold = %ld\n", Info.KiAdjustDpcThreshold);
1677 printf ("\tKiIdealDpcRate = %ld\n", Info.KiIdealDpcRate);
1678
1679 DumpData (sizeof Info, & Info);
1680
1681 return EXIT_SUCCESS;
1682 }
1683
1684
1685 /**********************************************************************
1686 *
1687 * DESCRIPTION
1688 *
1689 * NOTE
1690 * Class 25.
1691 */
1692 CMD_DEF(25)
1693 CMD_NOT_IMPLEMENTED
1694
1695
1696 /**********************************************************************
1697 *
1698 * DESCRIPTION
1699 *
1700 * NOTE
1701 * Class 26.
1702 */
1703 CMD_DEF(26)
1704 CMD_NOT_IMPLEMENTED
1705
1706 /**********************************************************************
1707 *
1708 * DESCRIPTION
1709 *
1710 * NOTE
1711 * Class 27.
1712 */
1713 CMD_DEF(27)
1714 CMD_NOT_IMPLEMENTED
1715
1716
1717 /**********************************************************************
1718 *
1719 * DESCRIPTION
1720 *
1721 * NOTE
1722 * Class 28.
1723 */
1724 CMD_DEF(28)
1725 {
1726 NTSTATUS Status = STATUS_SUCCESS;
1727 SYSTEM_QUERY_TIME_ADJUSTMENT Info;
1728
1729 RtlZeroMemory (& Info, sizeof Info);
1730 Status = NtQuerySystemInformation (
1731 28,
1732 & Info,
1733 sizeof Info,
1734 0
1735 );
1736 if (!NT_SUCCESS(Status))
1737 {
1738 PrintStatus (Status);
1739 return EXIT_FAILURE;
1740 }
1741 printf ("\tKeTimeAdjustment = %ld\n", Info.TimeAdjustment);
1742 printf ("\tKeMaximumIncrement = %ld\n", Info.MaximumIncrement);
1743 printf ("\tKeTimeSynchronization = %s\n", TF(Info.TimeSynchronization));
1744
1745 return EXIT_SUCCESS;
1746 }
1747
1748
1749 /**********************************************************************
1750 *
1751 * DESCRIPTION
1752 *
1753 * NOTE
1754 * Class 29.
1755 */
1756 CMD_DEF(29)
1757 CMD_NOT_IMPLEMENTED
1758
1759
1760 /**********************************************************************
1761 *
1762 * DESCRIPTION
1763 *
1764 * NOTE
1765 * Class 30.
1766 */
1767 CMD_DEF(30)
1768 CMD_NOT_IMPLEMENTED
1769
1770
1771 /**********************************************************************
1772 *
1773 * DESCRIPTION
1774 *
1775 * NOTE
1776 * Class 31.
1777 */
1778 CMD_DEF(31)
1779 CMD_NOT_IMPLEMENTED
1780
1781
1782 /**********************************************************************
1783 *
1784 * DESCRIPTION
1785 *
1786 * NOTE
1787 * Class 32.
1788 */
1789 CMD_DEF(32)
1790 CMD_NOT_IMPLEMENTED
1791
1792
1793 /**********************************************************************
1794 *
1795 * DESCRIPTION
1796 *
1797 * NOTE
1798 * Class 33.
1799 */
1800 CMD_DEF(33)
1801 CMD_NOT_IMPLEMENTED
1802
1803
1804 /**********************************************************************
1805 *
1806 * DESCRIPTION
1807 *
1808 * NOTE
1809 * Class 34.
1810 */
1811 CMD_DEF(34)
1812 CMD_NOT_IMPLEMENTED
1813
1814
1815 /**********************************************************************
1816 *
1817 * DESCRIPTION
1818 *
1819 * NOTE
1820 * Class 35.
1821 */
1822 CMD_DEF(35)
1823 {
1824 NTSTATUS Status;
1825 SYSTEM_DEBUGGER_INFO Info;
1826
1827 RtlZeroMemory (& Info, sizeof Info);
1828 Status = NtQuerySystemInformation (
1829 35,
1830 & Info,
1831 sizeof Info,
1832 NULL
1833 );
1834 if (STATUS_SUCCESS != Status)
1835 {
1836 PrintStatus (Status);
1837 return EXIT_FAILURE;
1838 }
1839 printf ("\tKdDebuggerEnabled = %s\n", TF(Info.KdDebuggerEnabled));
1840 printf ("\tKdDebuggerPresent = %s\n", TF(Info.KdDebuggerPresent));
1841
1842 DumpData (sizeof Info, & Info);
1843
1844 return EXIT_SUCCESS;
1845 }
1846
1847
1848 /**********************************************************************
1849 *
1850 * DESCRIPTION
1851 *
1852 * NOTE
1853 * Class 36.
1854 */
1855 CMD_DEF(36)
1856 CMD_NOT_IMPLEMENTED
1857
1858
1859 /**********************************************************************
1860 *
1861 * DESCRIPTION
1862 *
1863 * NOTE
1864 * Class 37.
1865 */
1866 CMD_DEF(37)
1867 {
1868 NTSTATUS Status = STATUS_SUCCESS;
1869 SYSTEM_QUOTA_INFORMATION Info;
1870
1871 RtlZeroMemory (& Info, sizeof Info);
1872 Status = NtQuerySystemInformation (
1873 37,
1874 & Info,
1875 sizeof Info,
1876 0
1877 );
1878 if (!NT_SUCCESS(Status))
1879 {
1880 PrintStatus (Status);
1881 return EXIT_FAILURE;
1882 }
1883 printf ("\tCmpGlobalQuota = %ld\n", Info.CmpGlobalQuota);
1884 printf ("\tCmpGlobalQuotaUsed = %ld\n", Info.CmpGlobalQuotaUsed);
1885 printf ("\tMmSizeofPagedPoolInBytes = %ld\n", Info.MmSizeofPagedPoolInBytes);
1886
1887 return EXIT_SUCCESS;
1888 }
1889
1890
1891 /**********************************************************************
1892 *
1893 * DESCRIPTION
1894 *
1895 * NOTE
1896 * Class 38.
1897 */
1898 CMD_DEF(38)
1899 CMD_NOT_IMPLEMENTED
1900
1901
1902 /**********************************************************************
1903 *
1904 * DESCRIPTION
1905 *
1906 * NOTE
1907 * Class 39.
1908 */
1909 CMD_DEF(39)
1910 CMD_NOT_IMPLEMENTED
1911
1912
1913 /**********************************************************************
1914 *
1915 * DESCRIPTION
1916 *
1917 * NOTE
1918 * Class 40.
1919 */
1920 CMD_DEF(40)
1921 CMD_NOT_IMPLEMENTED
1922
1923
1924 /**********************************************************************
1925 *
1926 * DESCRIPTION
1927 *
1928 * NOTE
1929 * Class 41.
1930 */
1931 CMD_DEF(41)
1932 CMD_NOT_IMPLEMENTED
1933
1934
1935 /**********************************************************************
1936 *
1937 * DESCRIPTION
1938 *
1939 * NOTE
1940 * Class 42.
1941 */
1942 CMD_DEF(42)
1943 CMD_NOT_IMPLEMENTED
1944
1945
1946 /**********************************************************************
1947 *
1948 * DESCRIPTION
1949 *
1950 * NOTE
1951 * Class 43.
1952 */
1953 CMD_DEF(43)
1954 CMD_NOT_IMPLEMENTED
1955
1956
1957 /**********************************************************************
1958 *
1959 * DESCRIPTION
1960 * Dump the system TIME_ZONE_INFORMATION object.
1961 *
1962 * NOTE
1963 * Class 44.
1964 */
1965 CMD_DEF(44)
1966 {
1967 NTSTATUS Status;
1968 SYSTEM_TIME_ZONE_INFORMATION Tzi;
1969 WCHAR Name [33];
1970
1971 RtlZeroMemory (& Tzi, sizeof Tzi);
1972 Status = NtQuerySystemInformation(
1973 44,
1974 & Tzi,
1975 sizeof Tzi,
1976 0
1977 );
1978 if (!NT_SUCCESS(Status))
1979 {
1980 PrintStatus (Status);
1981 return EXIT_FAILURE;
1982 }
1983 printf (
1984 " Bias........: %ld'\n",
1985 Tzi.Bias /* LONG */
1986 );
1987
1988 printf (" Standard\n");
1989 RtlZeroMemory (
1990 (PVOID) Name,
1991 sizeof Name
1992 );
1993 lstrcpynW (
1994 Name,
1995 Tzi.StandardName, /* WCHAR [32] */
1996 32
1997 );
1998 wprintf (
1999 L"\tName: \"%s\"\n",
2000 Name
2001 );
2002
2003 PrintUtcDateTime (
2004 "\tDate: %s\n",
2005 (PTIME) & Tzi.StandardDate /* SYSTEMTIME */
2006 );
2007
2008 printf ("\tBias: %ld'\n",
2009 Tzi.StandardBias /* LONG */
2010 );
2011
2012 printf (" Daylight\n");
2013 RtlZeroMemory (
2014 (PVOID) Name,
2015 sizeof Name
2016 );
2017 lstrcpynW (
2018 Name,
2019 Tzi.DaylightName, /* WCHAR [32] */
2020 32
2021 );
2022 wprintf (
2023 L"\tName: \"%s\"\n",
2024 Name
2025 );
2026
2027 PrintUtcDateTime (
2028 "\tDate: %s\n",
2029 (PTIME) & Tzi.DaylightDate /* SYSTEMTIME */
2030 );
2031
2032 printf (
2033 "\tBias: %ld'\n",
2034 Tzi.DaylightBias /* LONG */
2035 );
2036
2037 return EXIT_SUCCESS;
2038 }
2039
2040
2041 /**********************************************************************
2042 *
2043 * DESCRIPTION
2044 *
2045 * NOTE
2046 * Class 45.
2047 */
2048 CMD_DEF(45)
2049 CMD_NOT_IMPLEMENTED
2050
2051
2052 /**********************************************************************
2053 *
2054 * DESCRIPTION
2055 *
2056 * NOTE
2057 * Class 46.
2058 */
2059 CMD_DEF(46)
2060 CMD_NOT_IMPLEMENTED
2061
2062
2063 /**********************************************************************
2064 *
2065 * DESCRIPTION
2066 *
2067 * NOTE
2068 * Class 47.
2069 */
2070 CMD_DEF(47)
2071 CMD_NOT_IMPLEMENTED
2072
2073
2074 /**********************************************************************
2075 *
2076 * DESCRIPTION
2077 *
2078 * NOTE
2079 * Class 48.
2080 */
2081 CMD_DEF(48)
2082 CMD_NOT_IMPLEMENTED
2083
2084
2085 /**********************************************************************
2086 *
2087 * DESCRIPTION
2088 *
2089 * NOTE
2090 * Class 49.
2091 */
2092 CMD_DEF(49)
2093 CMD_NOT_IMPLEMENTED
2094
2095
2096 /**********************************************************************
2097 *
2098 * DESCRIPTION
2099 *
2100 * NOTE
2101 * Class 50.
2102 */
2103 CMD_DEF(50)
2104 CMD_NOT_IMPLEMENTED
2105
2106
2107 /**********************************************************************
2108 *
2109 * DESCRIPTION
2110 *
2111 * NOTE
2112 * Class 51.
2113 */
2114 CMD_DEF(51)
2115 CMD_NOT_IMPLEMENTED
2116
2117
2118 /**********************************************************************
2119 *
2120 * DESCRIPTION
2121 *
2122 * NOTE
2123 * Class 52.
2124 */
2125 CMD_DEF(52)
2126 CMD_NOT_IMPLEMENTED
2127
2128
2129 /**********************************************************************
2130 *
2131 * DESCRIPTION
2132 *
2133 * NOTE
2134 * Class 53.
2135 */
2136 CMD_DEF(53)
2137 CMD_NOT_IMPLEMENTED
2138
2139
2140 /**********************************************************************
2141 * Miscellanea Commands
2142 **********************************************************************/
2143
2144 CMD_DEF(ver)
2145 {
2146 INT Total = 0;
2147
2148 Total =
2149 printf (
2150 "ReactOS Operating System - http://www.reactos.com/\n"
2151 "QSI - Query System Information (compiled on %s, %s)\n"
2152 "Copyright (c) 1999-2001 Emanuele Aliberti et alii\n\n"
2153 "Run the command in verbose mode, for full license information.\n\n",
2154 __DATE__, __TIME__
2155 );
2156
2157 if (Application.Flag.Verbose)
2158 {
2159 Total +=
2160 printf (
2161 "This program is free software; you can redistribute it and/or modify\n"
2162 "it under the terms of the GNU General Public License as published by\n"
2163 "the Free Software Foundation; either version 2 of the License, or\n"
2164 "(at your option) any later version.\n\n"
2165
2166 "This program is distributed in the hope that it will be useful,\n"
2167 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
2168 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
2169 "GNU General Public License for more details.\n\n"
2170
2171 "You should have received a copy of the GNU General Public License\n"
2172 "along with this program; if not, write to the Free Software\n"
2173 "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"
2174 "(See also http://www.fsf.org/).\n"
2175 );
2176 }
2177 return (Total);
2178 }
2179
2180
2181 CMD_DEF(exit)
2182 {
2183 Application.Active = FALSE;
2184 return EXIT_SUCCESS;
2185 }
2186
2187
2188 extern COMMAND_DESCRIPTOR Commands [];
2189
2190 CMD_DEF(help)
2191 {
2192 int i;
2193
2194 if (Application.Flag.Verbose)
2195 {
2196 printf ("Commands:\n");
2197 }
2198 for ( i = 0;
2199 (NULL != Commands[i].Name);
2200 i ++
2201 )
2202 {
2203 printf (
2204 (strlen (Commands[i].Name) > 7)
2205 ? "%s\t: %s\n"
2206 : "%s\t\t: %s\n",
2207 Commands[i].Name,
2208 Commands[i].Description
2209 );
2210 }
2211 return EXIT_SUCCESS;
2212 }
2213
2214
2215 CMD_DEF(credits)
2216 {
2217 return
2218 printf (
2219 "\nReactOS (http://www.reactos.com/):\n"
2220 "\tEmanuele Aliberti\n"
2221 "\tEric Kohl\n\n"
2222
2223 "HandleEx:\n"
2224 "\tMark Russinovich (http://www.sysinternals.com/)\n\n"
2225
2226 "NtDriverList:\n"
2227 "\tYariv Kaplan (http://www.internals.com/)\n\n"
2228
2229 "Undocumented SYSTEM_POOL_INFORMATION:\n"
2230 "\tKlaus P. Gerlicher\n\n"
2231
2232 "Undocumented Windows NT:\n"
2233 "\tPrasad Dabak, Sandeep Phadke, and Milind Borate\n\n"
2234
2235 "Windows NT/2000 Native API Reference:\n"
2236 "\tGary Nebbett\n\n"
2237
2238 "comp.os.ms-windows.programmer.nt.kernel-mode\n"
2239 "\t(many postings with sample code)\n"
2240 );
2241 }
2242
2243
2244 CMD_DEF(verbose)
2245 {
2246 Application.Flag.Verbose = ~Application.Flag.Verbose;
2247 return printf (
2248 "Verbose mode is %s.\n",
2249 ONOFF(Application.Flag.Verbose)
2250 );
2251 }
2252
2253
2254 CMD_DEF(dump)
2255 {
2256 Application.Flag.Dump = ~Application.Flag.Dump;
2257 return printf (
2258 "Dump mode is %s.\n",
2259 ONOFF(Application.Flag.Dump)
2260 );
2261 }
2262
2263
2264 /**********************************************************************
2265 * Commands table
2266 **********************************************************************/
2267
2268 COMMAND_DESCRIPTOR
2269 Commands [] =
2270 {
2271 /* System information classes */
2272
2273 { /* 0 Q */
2274 "basic",
2275 CMD_REF(0),
2276 "Basic system information"
2277 },
2278 { /* 1 Q */
2279 "processor",
2280 CMD_REF(1),
2281 "Processor characteristics"
2282 },
2283 { /* 2 Q */
2284 "perf",
2285 CMD_REF(2),
2286 "System performance data"
2287 },
2288 { /* 3 Q */
2289 "time",
2290 CMD_REF(3),
2291 "System times"
2292 },
2293 { /* 4 Q (checked build only) */
2294 "path",
2295 CMD_REF(4),
2296 "Path (checked build only)"
2297 },
2298 { /* 5 Q */
2299 "process",
2300 CMD_REF(5),
2301 "Process & thread tables"
2302 },
2303 { /* 6 Q */
2304 "callcount",
2305 CMD_REF(6),
2306 "Call count information"
2307 },
2308 { /* 7 Q */
2309 "device",
2310 CMD_REF(7),
2311 "I/O devices in the system, by class"
2312 },
2313 { /* 8 Q */
2314 "performance",
2315 CMD_REF(8),
2316 "Processor performance"
2317 },
2318 { /* 9 QS */
2319 "flags",
2320 CMD_REF(9),
2321 "System wide flags"
2322 },
2323 { /* 10 */
2324 "call",
2325 CMD_REF(10),
2326 "Call time"
2327 },
2328 { /* 11 Q */
2329 "module",
2330 CMD_REF(11),
2331 "Table of kernel modules"
2332 },
2333 { /* 12 Q */
2334 "locks",
2335 CMD_REF(12),
2336 "Table of locks on resources"
2337 },
2338 { /* 13 */
2339 "stack",
2340 CMD_REF(13),
2341 "Stack trace"
2342 },
2343 { /* 14 */
2344 "ppool",
2345 CMD_REF(14),
2346 "Paged pool"
2347 },
2348 { /* 15 */
2349 "nppool",
2350 CMD_REF(15),
2351 "Non paged pool"
2352 },
2353 { /* 16 Q */
2354 "handle",
2355 CMD_REF(16),
2356 "Table of handles"
2357 },
2358 { /* 17 Q */
2359 "object",
2360 CMD_REF(17),
2361 "Table of executive objects"
2362 },
2363 { /* 18 Q */
2364 "pagefile",
2365 CMD_REF(18),
2366 "Virtual memory paging files"
2367 },
2368 { /* 19 Q */
2369 "vdmie",
2370 CMD_REF(19),
2371 "Virtual DOS Machine instruction emulation (VDM)"
2372 },
2373 { /* 20 */
2374 "vdmbop",
2375 CMD_REF(20),
2376 "Bop (VDM)"
2377 },
2378 { /* 21 QS */
2379 "cache",
2380 CMD_REF(21),
2381 "File cache"
2382 },
2383 { /* 22 Q */
2384 "pooltag",
2385 CMD_REF(22),
2386 "Tagged pools statistics (checked build only)"
2387 },
2388 { /* 23 Q */
2389 "int",
2390 CMD_REF(23),
2391 "Processor schedule information (interrupt)"
2392 },
2393 { /* 24 QS */
2394 "dpc",
2395 CMD_REF(24),
2396 "Deferred procedure call behaviour (DPC)"
2397 },
2398 { /* 25 */
2399 "fullmem",
2400 CMD_REF(25),
2401 "Full memory"
2402 },
2403 { /* 26 S (callable) */
2404 "loadpe",
2405 CMD_REF(26),
2406 "Load a kernel mode DLL (module in PE format)"
2407 },
2408 { /* 27 S (callable) */
2409 "unloadpe",
2410 CMD_REF(27),
2411 "Unload a kernel mode DLL (module in Pe format)"
2412 },
2413 { /* 28 QS */
2414 "timeadj",
2415 CMD_REF(28),
2416 "Time adjustment"
2417 },
2418 { /* 29 */
2419 "smem",
2420 CMD_REF(29),
2421 "Summary memory"
2422 },
2423 { /* 30 */
2424 "event",
2425 CMD_REF(30),
2426 "Next event ID"
2427 },
2428 { /* 31 */
2429 "events",
2430 CMD_REF(31),
2431 "Event IDs"
2432 },
2433 { /* 32 Q */
2434 "crash",
2435 CMD_REF(32),
2436 "Crash Dump Section"
2437 },
2438 { /* 33 Q */
2439 "exceptions",
2440 CMD_REF(33),
2441 "Exceptions"
2442 },
2443 { /* 34 Q */
2444 "crashstate",
2445 CMD_REF(34),
2446 "Crash Dump State"
2447 },
2448 { /* 35 Q */
2449 "debugger",
2450 CMD_REF(35),
2451 "Kernel debugger"
2452 },
2453 { /* 36 Q */
2454 "cswitch",
2455 CMD_REF(36),
2456 "Thread context switch counters"
2457 },
2458 { /* 37 QS */
2459 "regquota",
2460 CMD_REF(37),
2461 "Registry quota values"
2462 },
2463 { /* 38 S */
2464 "est",
2465 CMD_REF(38),
2466 "Extended service table"
2467 },
2468 { /* 39 S */
2469 "prisep",
2470 CMD_REF(39),
2471 "Priority Separation"
2472 },
2473 { /* 40 */
2474 "ppbus",
2475 CMD_REF(40),
2476 "Plug & play bus"
2477 },
2478 { /* 41 */
2479 "dock",
2480 CMD_REF(41),
2481 "Dock"
2482 },
2483 { /* 42 */
2484 "power",
2485 CMD_REF(42),
2486 "Power"
2487 },
2488 { /* 43 */
2489 "procspeed",
2490 CMD_REF(43),
2491 "Processor speed"
2492 },
2493 { /* 44 QS */
2494 "tz",
2495 CMD_REF(44),
2496 "Current time zone (TZ)"
2497 },
2498 { /* 45 Q */
2499 "lookaside",
2500 CMD_REF(45),
2501 "Lookaside"
2502 },
2503 /* NT5 */
2504 { /* 46 Q */
2505 "tslip",
2506 CMD_REF(46),
2507 "Set time slip (5.0)"
2508 },
2509 { /* 47 Q */
2510 "csession",
2511 CMD_REF(47),
2512 "Create session (5.0)"
2513 },
2514 { /* 48 Q */
2515 "dsession",
2516 CMD_REF(48),
2517 "Delete session (5.0)"
2518 },
2519 { /* 49 Q */
2520 "#49",
2521 CMD_REF(49),
2522 "UNKNOWN (5.0)"
2523 },
2524 { /* 50 Q */
2525 "range",
2526 CMD_REF(50),
2527 "Range start (5.0)"
2528 },
2529 { /* 51 Q */
2530 "verifier",
2531 CMD_REF(51),
2532 "Verifier (5.0)"
2533 },
2534 { /* 52 Q */
2535 "addverif",
2536 CMD_REF(52),
2537 "Add verifier (5.0)"
2538 },
2539 { /* 53 Q */
2540 "sesproc",
2541 CMD_REF(53),
2542 "Session processes (5.0)"
2543 },
2544 /* User commands */
2545 {
2546 "?",
2547 CMD_REF(help),
2548 "Same as 'help'"
2549 },
2550 {
2551 "help",
2552 CMD_REF(help),
2553 "Print this command directory"
2554 },
2555 {
2556 "credits",
2557 CMD_REF(credits),
2558 "Print the list of people and sources that made QSI possible"
2559 },
2560 {
2561 "ver",
2562 CMD_REF(ver),
2563 "Print version number and license information"
2564 },
2565 {
2566 "exit",
2567 CMD_REF(exit),
2568 "Exit to operating system"
2569 },
2570 {
2571 "dump",
2572 CMD_REF(dump),
2573 "Enable/disable dumping raw data returned by system"
2574 },
2575 {
2576 "verbose",
2577 CMD_REF(verbose),
2578 "Enable/disable printing unused, unknown, and service fields"
2579 },
2580
2581 { NULL, NULL }
2582 };
2583
2584
2585
2586 /* user input --> command decoder */
2587
2588
2589 COMMAND_CALL
2590 DecodeCommand (LPCSTR Command)
2591 {
2592 int i;
2593
2594 for ( i = 0;
2595 ( Commands[i].Name
2596 && stricmp (Commands[i].Name,Command)
2597 );
2598 ++i
2599 );
2600 return Commands[i].EntryPoint;
2601 }
2602
2603 INT
2604 ParseCommandLine (
2605 LPCSTR CommandLine,
2606 LPCSTR CommandArgv []
2607 )
2608 {
2609 INT ArgC = 0;
2610 LPCSTR Separators = " \t";
2611
2612 for ( CommandArgv [ArgC] = strtok ((char*)CommandLine, (char*)Separators);
2613 (ArgC < ARGV_SIZE);
2614 CommandArgv [ArgC] = (LPCSTR) strtok (NULL, (char*)Separators)
2615 )
2616 {
2617 if (NULL == CommandArgv [ArgC++])
2618 {
2619 break;
2620 }
2621 }
2622 return (ArgC);
2623 }
2624
2625
2626 int
2627 main (int argc, char * argv [])
2628 {
2629 CHAR CommandLine [_MAX_PATH];
2630
2631 INT CommandArgc;
2632 LPCSTR CommandArgv [ARGV_SIZE];
2633
2634 /*
2635 * Initialize rt data.
2636 */
2637 Application.Heap = GetProcessHeap ();
2638 Application.Active = TRUE;
2639 /*
2640 * r-e-p loop.
2641 */
2642 while (Application.Active)
2643 {
2644 /* Print the prompt string. */
2645 if (! Application.Flag.Batch)
2646 {
2647 printf ("\r\nsystem> ");
2648 }
2649 /* Read user command. */
2650 gets (CommandLine);
2651 /* Parse the user command */
2652 CommandArgc = ParseCommandLine (
2653 CommandLine,
2654 CommandArgv
2655 );
2656 if (0 != CommandArgc)
2657 {
2658 COMMAND_CALL CommandCall = NULL;
2659
2660 /* decode */
2661 if ((CommandCall = DecodeCommand (CommandArgv[0])))
2662 {
2663 /* execute */
2664 Application.ExitCode =
2665 CommandCall (
2666 CommandArgc,
2667 CommandArgv
2668 );
2669 }
2670 else
2671 {
2672 printf ("Unknown command (type help for a list of valid commands).\n");
2673 }
2674 }
2675
2676 }
2677 if (! Application.Flag.Batch)
2678 {
2679 printf ("Bye\n");
2680 }
2681 return (EXIT_SUCCESS);
2682 }
2683
2684 /* EOF */