Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.5 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. ready.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Ramon J San Andres (ramonsa) 8-Nov-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. DECLARE_API( ready )
  16. /*++
  17. Routine Description:
  18. Arguments:
  19. args -
  20. Return Value:
  21. None
  22. --*/
  23. {
  24. ULONG KiDispatcherReadyListHead;
  25. LIST_ENTRY ReadyList[MAXIMUM_PRIORITY];
  26. ULONG result;
  27. DWORD Flags = 6;
  28. LONG i;
  29. BOOLEAN ThreadDumped = FALSE;
  30. sscanf(args, "%lx", &Flags);
  31. KiDispatcherReadyListHead = GetExpression( "KiDispatcherReadyListHead" );
  32. if ( KiDispatcherReadyListHead ) {
  33. if ( !ReadMemory( (DWORD)KiDispatcherReadyListHead,
  34. ReadyList,
  35. sizeof(ReadyList),
  36. &result) ) {
  37. dprintf("Could not read contents of KiDispatcherReadyListHead at %08lx\n", KiDispatcherReadyListHead);
  38. return;
  39. }
  40. for (i = MAXIMUM_PRIORITY-1; i >= 0 ; i -= 1 ) {
  41. if ((ULONG)ReadyList[i].Flink != KiDispatcherReadyListHead+i*sizeof(LARGE_INTEGER)) {
  42. DWORD ThreadEntry;
  43. ETHREAD Thread;
  44. dprintf("Ready Threads at priority %ld\n", i);
  45. for (ThreadEntry = (DWORD)ReadyList[i].Flink ;
  46. ThreadEntry != KiDispatcherReadyListHead+i*sizeof(LARGE_INTEGER) ;
  47. ThreadEntry = (DWORD)Thread.Tcb.WaitListEntry.Flink ) {
  48. PETHREAD ThreadBaseAddress = CONTAINING_RECORD(ThreadEntry, ETHREAD, Tcb.WaitListEntry);
  49. if ( !ReadMemory( (DWORD)ThreadBaseAddress,
  50. &Thread,
  51. sizeof(ETHREAD),
  52. &result) ) {
  53. dprintf("Could not read contents of thread %lx\n", ThreadBaseAddress);
  54. }
  55. DumpThread(dwProcessor," ", &Thread, ThreadBaseAddress, Flags);
  56. ThreadDumped = TRUE;
  57. }
  58. } else {
  59. if (ReadyList[i].Flink != ReadyList[i].Blink) {
  60. dprintf("Ready linked list may to be corrupt...\n");
  61. }
  62. }
  63. }
  64. if (!ThreadDumped) {
  65. dprintf("No threads in READY state\n");
  66. }
  67. } else {
  68. dprintf("Could not determine address of KiDispatcherReadyListHead\n");
  69. return;
  70. }
  71. }