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.

129 lines
3.0 KiB

4 years ago
  1. #define TARGET_MIPS
  2. #include <platform.h>
  3. #include <crash.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. extern PDUMP_HEADER DumpHeader;
  7. extern PUSERMODE_CRASHDUMP_HEADER DumpHeaderUser;
  8. extern PVOID DumpContext;
  9. extern PKPRCB KiProcessors[];
  10. extern ULONG KiPcrBaseAddress;
  11. extern BOOL UserModeDump;
  12. DmpReadControlSpaceMip(
  13. USHORT Processor,
  14. PVOID TargetBaseAddress,
  15. PVOID UserInterfaceBuffer,
  16. ULONG TransferCount,
  17. PULONG ActualBytesRead
  18. )
  19. {
  20. DWORD NumberOfEntries;
  21. DWORD i;
  22. DWORD cb;
  23. DWORD StartAddr;
  24. LPDWORD EntryBuffer;
  25. PTB_ENTRY TbEntry;
  26. //
  27. // Read TB entries.
  28. //
  29. NumberOfEntries = TransferCount / sizeof(TB_ENTRY);
  30. //
  31. // Trim number of entries to tb range
  32. //
  33. cb = NumberOfEntries * sizeof(TB_ENTRY);
  34. EntryBuffer = (PULONG)UserInterfaceBuffer;
  35. StartAddr = (DWORD)KiProcessors[Processor] +
  36. (DWORD)&(((PKPRCB)0)->ProcessorState.TbEntry) +
  37. (DWORD)((DWORD)TargetBaseAddress * sizeof(TB_ENTRY));
  38. TbEntry = malloc( cb );
  39. cb = DmpReadMemory( (LPVOID)StartAddr, TbEntry, cb );
  40. for (i=0; i<NumberOfEntries; i++) {
  41. *(PENTRYLO)EntryBuffer++ = TbEntry[i].Entrylo0;
  42. *(PENTRYLO)EntryBuffer++ = TbEntry[i].Entrylo1;
  43. *(PENTRYHI)EntryBuffer++ = TbEntry[i].Entryhi;
  44. *(PPAGEMASK)EntryBuffer++ = TbEntry[i].Pagemask;
  45. }
  46. return TRUE;
  47. }
  48. BOOL
  49. DmpGetContextMip(
  50. IN ULONG Processor,
  51. OUT PVOID Context
  52. )
  53. {
  54. DWORD StartAddr;
  55. DWORD ContextSize;
  56. BOOL rc;
  57. if ( DumpHeader->MajorVersion > 3 ) {
  58. ContextSize = sizeof(CONTEXT);
  59. } else {
  60. ContextSize = FIELD_OFFSET(CONTEXT, ContextFlags) + 4;
  61. }
  62. if (UserModeDump) {
  63. if (Processor > DumpHeaderUser->ThreadCount-1) {
  64. return FALSE;
  65. }
  66. StartAddr = Processor * ContextSize;
  67. CopyMemory(Context, (PVOID)StartAddr, ContextSize);
  68. return TRUE;
  69. } else {
  70. StartAddr = (DWORD)KiProcessors[Processor] +
  71. (DWORD)&(((PKPRCB)0)->ProcessorState);
  72. rc = DmpReadMemory( (PVOID)StartAddr, Context, ContextSize);
  73. if ( DumpHeader->MajorVersion > 3 ) {
  74. ((PCONTEXT)Context)->ContextFlags |= CONTEXT_EXTENDED_INTEGER;
  75. } else {
  76. ((PCONTEXT)Context)->ContextFlags |= CONTEXT_INTEGER;
  77. }
  78. return rc;
  79. }
  80. }
  81. INT
  82. DmpGetCurrentProcessorMip(
  83. VOID
  84. )
  85. {
  86. ULONG i;
  87. CONTEXT Context;
  88. for (i=0; i<DumpHeader->NumberProcessors; i++) {
  89. if (DmpGetContextMip( i, &Context )) {
  90. if (DumpHeader->MajorVersion > 3) {
  91. if (Context.XIntSp == ((PCONTEXT)DumpContext)->XIntSp) {
  92. return i;
  93. }
  94. } else {
  95. if (Context.IntSp == ((PCONTEXT)DumpContext)->IntSp) {
  96. return i;
  97. }
  98. }
  99. }
  100. }
  101. return -1;
  102. }