ReactOS  0.4.14-dev-1331-g167fa2c
bug.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/ke/bug.c
5  * PURPOSE: Bugcheck Support
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 #if defined (ALLOC_PRAGMA)
16 #pragma alloc_text(INIT, KiInitializeBugCheck)
17 #endif
18 
19 /* GLOBALS *******************************************************************/
20 
31 
34 #define TAG_KNMI 'IMNK'
35 
36 /* Bugzilla Reporting */
39 
40 /* PRIVATE FUNCTIONS *********************************************************/
41 
42 PVOID
43 NTAPI
45  OUT PLDR_DATA_TABLE_ENTRY *LdrEntry,
46  IN BOOLEAN DriversOnly,
47  OUT PBOOLEAN InKernel)
48 {
49  ULONG i = 0;
50  PVOID ImageBase, PcBase = NULL;
52  PLIST_ENTRY ListHead, NextEntry;
53 
54  /* Check which list we should use */
57 
58  /* Assume no */
59  *InKernel = FALSE;
60 
61  /* Set list pointers and make sure it's valid */
62  NextEntry = ListHead->Flink;
63  if (NextEntry)
64  {
65  /* Start loop */
66  while (NextEntry != ListHead)
67  {
68  /* Increase entry */
69  i++;
70 
71  /* Check if this is a kernel entry and we only want drivers */
72  if ((i <= 2) && (DriversOnly != FALSE))
73  {
74  /* Skip it */
75  NextEntry = NextEntry->Flink;
76  continue;
77  }
78 
79  /* Get the loader entry */
80  Entry = CONTAINING_RECORD(NextEntry,
82  InLoadOrderLinks);
83 
84  /* Move to the next entry */
85  NextEntry = NextEntry->Flink;
86  ImageBase = Entry->DllBase;
87 
88  /* Check if this is the right one */
89  if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
90  ((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
91  {
92  /* Return this entry */
93  *LdrEntry = Entry;
94  PcBase = ImageBase;
95 
96  /* Check if this was a kernel or HAL entry */
97  if (i <= 2) *InKernel = TRUE;
98  break;
99  }
100  }
101  }
102 
103  /* Return the base address */
104  return PcBase;
105 }
106 
107 PVOID
108 NTAPI
110  OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
111 {
112  PVOID ImageBase, PcBase = NULL;
114  PLIST_ENTRY ListHead, NextEntry;
115 
116  /*
117  * We know this is valid because we should only be called after a
118  * succesfull address from RtlWalkFrameChain for UserMode, which
119  * validates everything for us.
120  */
121  ListHead = &KeGetCurrentThread()->
122  Teb->ProcessEnvironmentBlock->Ldr->InLoadOrderModuleList;
123 
124  /* Set list pointers and make sure it's valid */
125  NextEntry = ListHead->Flink;
126  if (NextEntry)
127  {
128  /* Start loop */
129  while (NextEntry != ListHead)
130  {
131  /* Get the loader entry */
132  Entry = CONTAINING_RECORD(NextEntry,
134  InLoadOrderLinks);
135 
136  /* Move to the next entry */
137  NextEntry = NextEntry->Flink;
138  ImageBase = Entry->DllBase;
139 
140  /* Check if this is the right one */
141  if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
142  ((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
143  {
144  /* Return this entry */
145  *LdrEntry = Entry;
146  PcBase = ImageBase;
147  break;
148  }
149  }
150  }
151 
152  /* Return the base address */
153  return PcBase;
154 }
155 
156 USHORT
157 NTAPI
159  IN ULONG FramesToCapture,
160  OUT PVOID *BackTrace,
161  OUT PULONG BackTraceHash OPTIONAL)
162 {
163  PVOID Frames[2 * 64];
164  ULONG FrameCount;
165  ULONG Hash = 0, i;
166 
167  /* Skip a frame for the caller */
168  FramesToSkip++;
169 
170  /* Don't go past the limit */
171  if ((FramesToCapture + FramesToSkip) >= 128) return 0;
172 
173  /* Do the back trace */
174  FrameCount = RtlWalkFrameChain(Frames, FramesToCapture + FramesToSkip, 1);
175 
176  /* Make sure we're not skipping all of them */
177  if (FrameCount <= FramesToSkip) return 0;
178 
179  /* Loop all the frames */
180  for (i = 0; i < FramesToCapture; i++)
181  {
182  /* Don't go past the limit */
183  if ((FramesToSkip + i) >= FrameCount) break;
184 
185  /* Save this entry and hash it */
186  BackTrace[i] = Frames[FramesToSkip + i];
187  Hash += PtrToUlong(BackTrace[i]);
188  }
189 
190  /* Write the hash */
191  if (BackTraceHash) *BackTraceHash = Hash;
192 
193  /* Clear the other entries and return count */
194  RtlFillMemoryUlong(Frames, 128, 0);
195  return (USHORT)i;
196 }
197 
198 
199 VOID
200 FASTCALL
202  IN ULONG FrameCount)
203 {
204  ULONG i;
205  ULONG_PTR Addr;
206  BOOLEAN InSystem;
207  PVOID p;
208 
209  /* GCC complaints that it may be used uninitialized */
210  PLDR_DATA_TABLE_ENTRY LdrEntry = NULL;
211 
212  /* Loop them */
213  for (i = 0; i < FrameCount; i++)
214  {
215  /* Get the EIP */
216  Addr = Frames[i];
217  if (!Addr)
218  {
219  break;
220  }
221 
222  /* Get the base for this file */
223  if (Addr > (ULONG_PTR)MmHighestUserAddress)
224  {
225  /* We are in kernel */
226  p = KiPcToFileHeader((PVOID)Addr, &LdrEntry, FALSE, &InSystem);
227  }
228  else
229  {
230  /* We are in user land */
231  p = KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry);
232  }
233  if (p)
234  {
235 #ifdef KDBG
236  if (!KdbSymPrintAddress((PVOID)Addr, NULL))
237 #endif
238  {
239  CHAR AnsiName[64];
240 
241  /* Convert module name to ANSI and print it */
243  AnsiName,
244  sizeof(AnsiName));
245  Addr -= (ULONG_PTR)LdrEntry->DllBase;
246  DbgPrint("<%s: %p>", AnsiName, (PVOID)Addr);
247  }
248  }
249  else
250  {
251  /* Print only the address */
252  DbgPrint("<%p>", (PVOID)Addr);
253  }
254 
255  /* Go to the next frame */
256  DbgPrint("\n");
257  }
258 }
259 
260 VOID
261 NTAPI
263  IN ULONG FrameCount OPTIONAL)
264 {
265  ULONG_PTR Frames[32];
266  ULONG RealFrameCount;
267 
268  /* If the caller didn't ask, assume 32 frames */
269  if (!FrameCount || FrameCount > 32) FrameCount = 32;
270 
271  if (Frame)
272  {
273  /* Dump them */
274  KeRosDumpStackFrameArray(Frame, FrameCount);
275  }
276  else
277  {
278  /* Get the current frames (skip the two. One for the dumper, one for the caller) */
279  RealFrameCount = RtlCaptureStackBackTrace(2, FrameCount, (PVOID*)Frames, NULL);
280  DPRINT1("RealFrameCount =%lu\n", RealFrameCount);
281 
282  /* Dump them */
283  KeRosDumpStackFrameArray(Frames, RealFrameCount);
284 
285  /* Count left for user mode? */
286  if (FrameCount - RealFrameCount > 0)
287  {
288  /* Get the current frames */
289  RealFrameCount = KeRosCaptureUserStackBackTrace(-1, FrameCount - RealFrameCount, (PVOID*)Frames, NULL);
290 
291  /* Dump them */
292  KeRosDumpStackFrameArray(Frames, RealFrameCount);
293  }
294  }
295 }
296 
297 VOID
298 INIT_FUNCTION
299 NTAPI
301 {
302  PMESSAGE_RESOURCE_DATA BugCheckData;
303  LDR_RESOURCE_INFO ResourceInfo;
304  PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
306  PLDR_DATA_TABLE_ENTRY LdrEntry;
307 
308  /* Get the kernel entry */
311  InLoadOrderLinks);
312 
313  /* Cache the Bugcheck Message Strings. Prepare the Lookup Data */
314  ResourceInfo.Type = 11;
315  ResourceInfo.Name = 1;
316  ResourceInfo.Language = 9;
317 
318  /* Do the lookup. */
319  Status = LdrFindResource_U(LdrEntry->DllBase,
320  &ResourceInfo,
322  &ResourceDataEntry);
323 
324  /* Make sure it worked */
325  if (NT_SUCCESS(Status))
326  {
327  /* Now actually get a pointer to it */
328  Status = LdrAccessResource(LdrEntry->DllBase,
329  ResourceDataEntry,
330  (PVOID*)&BugCheckData,
331  NULL);
332  if (NT_SUCCESS(Status)) KiBugCodeMessages = BugCheckData;
333  }
334 }
335 
336 BOOLEAN
337 NTAPI
339  OUT PANSI_STRING OutputString OPTIONAL)
340 {
341  ULONG i;
342  ULONG IdOffset;
343  PMESSAGE_RESOURCE_ENTRY MessageEntry;
344  PCHAR BugCode;
345  USHORT Length;
346  BOOLEAN Result = FALSE;
347 
348  /* Make sure we're not bugchecking too early */
349  if (!KiBugCodeMessages) return Result;
350 
351  /*
352  * Globally protect in SEH as we are trying to access data in
353  * dire situations, and potentially going to patch it (see below).
354  */
355  _SEH2_TRY
356  {
357 
358  /*
359  * Make the kernel resource section writable, as we are going to manually
360  * trim the trailing newlines in the bugcheck resource message in place,
361  * when OutputString is NULL and before displaying it on screen.
362  */
364 
365  /* Find the message. This code is based on RtlFindMesssage */
366  for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
367  {
368  /* Check if the ID matches */
369  if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
370  (BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
371  {
372  /* Get offset to entry */
373  MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
375  IdOffset = BugCheckCode - KiBugCodeMessages->Blocks[i].LowId;
376 
377  /* Advance in the entries until finding it */
378  while (IdOffset--)
379  {
380  MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
381  ((ULONG_PTR)MessageEntry + MessageEntry->Length);
382  }
383 
384  /* Make sure it's not Unicode */
385  ASSERT(!(MessageEntry->Flags & MESSAGE_RESOURCE_UNICODE));
386 
387  /* Get the final code */
388  BugCode = (PCHAR)MessageEntry->Text;
389  Length = (USHORT)strlen(BugCode);
390 
391  /* Handle trailing newlines */
392  while ((Length > 0) && ((BugCode[Length - 1] == '\n') ||
393  (BugCode[Length - 1] == '\r') ||
394  (BugCode[Length - 1] == ANSI_NULL)))
395  {
396  /* Directly trim the newline in place if we don't return the string */
397  if (!OutputString) BugCode[Length - 1] = ANSI_NULL;
398 
399  /* Skip the trailing newline */
400  Length--;
401  }
402 
403  /* Check if caller wants an output string */
404  if (OutputString)
405  {
406  /* Return it in the OutputString */
407  OutputString->Buffer = BugCode;
408  OutputString->Length = Length;
409  OutputString->MaximumLength = Length;
410  }
411  else
412  {
413  /* Direct output to screen */
414  InbvDisplayString(BugCode);
415  InbvDisplayString("\r");
416  }
417 
418  /* We're done */
419  Result = TRUE;
420  break;
421  }
422  }
423 
424  }
426  {
427  }
428  _SEH2_END;
429 
430  /* Return the result */
431  return Result;
432 }
433 
434 VOID
435 NTAPI
437 {
438  PKBUGCHECK_CALLBACK_RECORD CurrentRecord;
439  PLIST_ENTRY ListHead, NextEntry, LastEntry;
440  ULONG_PTR Checksum;
441 
442  /* First make sure that the list is initialized... it might not be */
443  ListHead = &KeBugcheckCallbackListHead;
444  if ((!ListHead->Flink) || (!ListHead->Blink))
445  return;
446 
447  /* Loop the list */
448  LastEntry = ListHead;
449  NextEntry = ListHead->Flink;
450  while (NextEntry != ListHead)
451  {
452  /* Get the reord */
453  CurrentRecord = CONTAINING_RECORD(NextEntry,
455  Entry);
456 
457  /* Validate it */
458  // TODO/FIXME: Check whether the memory CurrentRecord points to
459  // is still accessible and valid!
460  if (CurrentRecord->Entry.Blink != LastEntry) return;
461  Checksum = (ULONG_PTR)CurrentRecord->CallbackRoutine;
462  Checksum += (ULONG_PTR)CurrentRecord->Buffer;
463  Checksum += (ULONG_PTR)CurrentRecord->Length;
464  Checksum += (ULONG_PTR)CurrentRecord->Component;
465 
466  /* Make sure it's inserted and validated */
467  if ((CurrentRecord->State == BufferInserted) &&
468  (CurrentRecord->Checksum == Checksum))
469  {
470  /* Call the routine */
471  CurrentRecord->State = BufferStarted;
472  _SEH2_TRY
473  {
474  (CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer,
475  CurrentRecord->Length);
476  CurrentRecord->State = BufferFinished;
477  }
479  {
480  CurrentRecord->State = BufferIncomplete;
481  }
482  _SEH2_END;
483  }
484 
485  /* Go to the next entry */
486  LastEntry = NextEntry;
487  NextEntry = NextEntry->Flink;
488  }
489 }
490 
491 VOID
492 NTAPI
494 {
495  /*
496  * Wrap this in SEH so we don't crash if
497  * there is no debugger or if it disconnected
498  */
499 DoBreak:
500  _SEH2_TRY
501  {
502  /* Breakpoint */
503  DbgBreakPointWithStatus(StatusCode);
504  }
506  {
507  /* No debugger, halt the CPU */
508  HalHaltSystem();
509  }
510  _SEH2_END;
511 
512  /* Break again if this wasn't first try */
513  if (StatusCode != DBG_STATUS_BUGCHECK_FIRST) goto DoBreak;
514 }
515 
516 PCHAR
517 NTAPI
519  OUT PCHAR Ansi,
520  IN ULONG Length)
521 {
522  PCHAR p;
523  PWCHAR pw;
524  ULONG i;
525 
526  /* Set length and normalize it */
527  i = Unicode->Length / sizeof(WCHAR);
528  i = min(i, Length - 1);
529 
530  /* Set source and destination, and copy */
531  pw = Unicode->Buffer;
532  p = Ansi;
533  while (i--) *p++ = (CHAR)*pw++;
534 
535  /* Null terminate and return */
536  *p = ANSI_NULL;
537  return Ansi;
538 }
539 
540 VOID
541 NTAPI
544  IN ULONG ParameterCount,
545  IN PKE_BUGCHECK_UNICODE_TO_ANSI ConversionRoutine)
546 {
547  ULONG i;
548  BOOLEAN InSystem;
549  PLDR_DATA_TABLE_ENTRY LdrEntry;
550  PVOID ImageBase;
551  PUNICODE_STRING DriverName;
552  CHAR AnsiName[32];
553  PIMAGE_NT_HEADERS NtHeader;
555  BOOLEAN FirstRun = TRUE;
556 
557  /* Loop parameters */
558  for (i = 0; i < ParameterCount; i++)
559  {
560  /* Get the base for this parameter */
561  ImageBase = KiPcToFileHeader((PVOID)Parameters[i],
562  &LdrEntry,
563  FALSE,
564  &InSystem);
565  if (!ImageBase)
566  {
567  /* FIXME: Add code to check for unloaded drivers */
568  DPRINT1("Potentially unloaded driver!\n");
569  continue;
570  }
571  else
572  {
573  /* Get the NT Headers and Timestamp */
574  NtHeader = RtlImageNtHeader(LdrEntry->DllBase);
575  TimeStamp = NtHeader->FileHeader.TimeDateStamp;
576 
577  /* Convert the driver name */
578  DriverName = &LdrEntry->BaseDllName;
579  ConversionRoutine(&LdrEntry->BaseDllName,
580  AnsiName,
581  sizeof(AnsiName));
582  }
583 
584  /* Format driver name */
586  "%s** %12s - Address %p base at %p, DateStamp %08lx\r\n",
587  FirstRun ? "\r\n*":"*",
588  AnsiName,
589  (PVOID)Parameters[i],
590  ImageBase,
591  TimeStamp);
592 
593  /* Check if we only had one parameter */
594  if (ParameterCount <= 1)
595  {
596  /* Then just save the name */
597  KiBugCheckDriver = DriverName;
598  }
599  else
600  {
601  /* Otherwise, display the message */
603  }
604 
605  /* Loop again */
606  FirstRun = FALSE;
607  }
608 }
609 
610 VOID
611 NTAPI
613  IN BOOLEAN IsHardError,
614  IN PCHAR HardErrCaption OPTIONAL,
615  IN PCHAR HardErrMessage OPTIONAL,
616  IN PCHAR Message)
617 {
618  CHAR AnsiName[75];
619 
620  /* Check if bootvid is installed */
622  {
623  /* Acquire ownership and reset the display */
626 
627  /* Display blue screen */
628  InbvSolidColorFill(0, 0, 639, 479, 4);
629  InbvSetTextColor(15);
632  InbvSetScrollRegion(0, 0, 639, 479);
633  }
634 
635  /* Check if this is a hard error */
636  if (IsHardError)
637  {
638  /* Display caption and message */
639  if (HardErrCaption) InbvDisplayString(HardErrCaption);
640  if (HardErrMessage) InbvDisplayString(HardErrMessage);
641  }
642 
643  /* Begin the display */
644  InbvDisplayString("\r\n");
645 
646  /* Print out initial message */
647  KeGetBugMessageText(BUGCHECK_MESSAGE_INTRO, NULL);
648  InbvDisplayString("\r\n\r\n");
649 
650  /* Check if we have a driver */
651  if (KiBugCheckDriver)
652  {
653  /* Print out into to driver name */
654  KeGetBugMessageText(BUGCODE_ID_DRIVER, NULL);
655 
656  /* Convert and print out driver name */
657  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
658  InbvDisplayString(" ");
659  InbvDisplayString(AnsiName);
660  InbvDisplayString("\r\n\r\n");
661  }
662 
663  /* Check if this is the generic message */
664  if (MessageId == BUGCODE_PSS_MESSAGE)
665  {
666  /* It is, so get the bug code string as well */
668  InbvDisplayString("\r\n\r\n");
669  }
670 
671  /* Print second introduction message */
672  KeGetBugMessageText(PSS_MESSAGE_INTRO, NULL);
673  InbvDisplayString("\r\n\r\n");
674 
675  /* Get the bug code string */
676  KeGetBugMessageText(MessageId, NULL);
677  InbvDisplayString("\r\n\r\n");
678 
679  /* Print message for technical information */
680  KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
681 
682  /* Show the technical Data */
683  sprintf(AnsiName,
684  "\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
685  (ULONG)KiBugCheckData[0],
686  (PVOID)KiBugCheckData[1],
687  (PVOID)KiBugCheckData[2],
688  (PVOID)KiBugCheckData[3],
689  (PVOID)KiBugCheckData[4]);
690  InbvDisplayString(AnsiName);
691 
692  /* Check if we have a driver*/
693  if (KiBugCheckDriver)
694  {
695  /* Display technical driver data */
697  }
698  else
699  {
700  /* Dump parameter information */
702  (PVOID)&KiBugCheckData[1],
703  4,
705  }
706 }
707 
708 VOID
709 NTAPI
710 KeBugCheckWithTf(IN ULONG BugCheckCode,
711  IN ULONG_PTR BugCheckParameter1,
712  IN ULONG_PTR BugCheckParameter2,
713  IN ULONG_PTR BugCheckParameter3,
714  IN ULONG_PTR BugCheckParameter4,
715  IN PKTRAP_FRAME TrapFrame)
716 {
717  PKPRCB Prcb = KeGetCurrentPrcb();
719  ULONG MessageId;
720  CHAR AnsiName[128];
721  BOOLEAN IsSystem, IsHardError = FALSE, Reboot = FALSE;
722  PCHAR HardErrCaption = NULL, HardErrMessage = NULL;
723  PVOID Pc = NULL, Memory;
724  PVOID DriverBase;
725  PLDR_DATA_TABLE_ENTRY LdrEntry;
726  PULONG_PTR HardErrorParameters;
727  KIRQL OldIrql;
728 #ifdef CONFIG_SMP
729  LONG i = 0;
730 #endif
731 
732  /* Set active bugcheck */
735 
736  /* Check if this is power failure simulation */
737  if (BugCheckCode == POWER_FAILURE_SIMULATE)
738  {
739  /* Call the Callbacks and reboot */
742  }
743 
744  /* Save the IRQL and set hardware trigger */
747 
748  /* Capture the CPU Context */
752 
753  /* FIXME: Call the Watchdog if it's registered */
754 
755  /* Check which bugcode this is */
756  switch (BugCheckCode)
757  {
758  /* These bug checks already have detailed messages, keep them */
759  case UNEXPECTED_KERNEL_MODE_TRAP:
760  case DRIVER_CORRUPTED_EXPOOL:
761  case ACPI_BIOS_ERROR:
762  case ACPI_BIOS_FATAL_ERROR:
763  case THREAD_STUCK_IN_DEVICE_DRIVER:
764  case DATA_BUS_ERROR:
765  case FAT_FILE_SYSTEM:
766  case NO_MORE_SYSTEM_PTES:
767  case INACCESSIBLE_BOOT_DEVICE:
768 
769  /* Keep the same code */
770  MessageId = BugCheckCode;
771  break;
772 
773  /* Check if this is a kernel-mode exception */
774  case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
775  case SYSTEM_THREAD_EXCEPTION_NOT_HANDLED:
776  case KMODE_EXCEPTION_NOT_HANDLED:
777 
778  /* Use the generic text message */
779  MessageId = KMODE_EXCEPTION_NOT_HANDLED;
780  break;
781 
782  /* File-system errors */
783  case NTFS_FILE_SYSTEM:
784 
785  /* Use the generic message for FAT */
786  MessageId = FAT_FILE_SYSTEM;
787  break;
788 
789  /* Check if this is a coruption of the Mm's Pool */
790  case DRIVER_CORRUPTED_MMPOOL:
791 
792  /* Use generic corruption message */
793  MessageId = DRIVER_CORRUPTED_EXPOOL;
794  break;
795 
796  /* Check if this is a signature check failure */
798 
799  /* Use the generic corruption message */
800  MessageId = BUGCODE_PSS_MESSAGE_SIGNATURE;
801  break;
802 
803  /* All other codes */
804  default:
805 
806  /* Use the default bugcheck message */
807  MessageId = BUGCODE_PSS_MESSAGE;
808  break;
809  }
810 
811  /* Save bugcheck data */
812  KiBugCheckData[0] = BugCheckCode;
813  KiBugCheckData[1] = BugCheckParameter1;
814  KiBugCheckData[2] = BugCheckParameter2;
815  KiBugCheckData[3] = BugCheckParameter3;
816  KiBugCheckData[4] = BugCheckParameter4;
817 
818  /* Now check what bugcheck this is */
819  switch (BugCheckCode)
820  {
821  /* Invalid access to R/O memory or Unhandled KM Exception */
822  case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
823  case ATTEMPTED_WRITE_TO_READONLY_MEMORY:
824  case ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY:
825  {
826  /* Check if we have a trap frame */
827  if (!TrapFrame)
828  {
829  /* Use parameter 3 as a trap frame, if it exists */
830  if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
831  }
832 
833  /* Check if we got one now and if we need to get the Program Counter */
834  if ((TrapFrame) &&
835  (BugCheckCode != KERNEL_MODE_EXCEPTION_NOT_HANDLED))
836  {
837  /* Get the Program Counter */
838  Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
839  }
840  break;
841  }
842 
843  /* Wrong IRQL */
844  case IRQL_NOT_LESS_OR_EQUAL:
845  {
846  /*
847  * The NT kernel has 3 special sections:
848  * MISYSPTE, POOLMI and POOLCODE. The bug check code can
849  * determine in which of these sections this bugcode happened
850  * and provide a more detailed analysis. For now, we don't.
851  */
852 
853  /* Program Counter is in parameter 4 */
854  Pc = (PVOID)BugCheckParameter4;
855 
856  /* Get the driver base */
857  DriverBase = KiPcToFileHeader(Pc,
858  &LdrEntry,
859  FALSE,
860  &IsSystem);
861  if (IsSystem)
862  {
863  /*
864  * The error happened inside the kernel or HAL.
865  * Get the memory address that was being referenced.
866  */
867  Memory = (PVOID)BugCheckParameter1;
868 
869  /* Find to which driver it belongs */
870  DriverBase = KiPcToFileHeader(Memory,
871  &LdrEntry,
872  TRUE,
873  &IsSystem);
874  if (DriverBase)
875  {
876  /* Get the driver name and update the bug code */
877  KiBugCheckDriver = &LdrEntry->BaseDllName;
878  KiBugCheckData[0] = DRIVER_PORTION_MUST_BE_NONPAGED;
879  }
880  else
881  {
882  /* Find the driver that unloaded at this address */
883  KiBugCheckDriver = NULL; // FIXME: ROS can't locate
884 
885  /* Check if the cause was an unloaded driver */
886  if (KiBugCheckDriver)
887  {
888  /* Update bug check code */
889  KiBugCheckData[0] =
890  SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD;
891  }
892  }
893  }
894  else
895  {
896  /* Update the bug check code */
897  KiBugCheckData[0] = DRIVER_IRQL_NOT_LESS_OR_EQUAL;
898  }
899 
900  /* Clear Pc so we don't look it up later */
901  Pc = NULL;
902  break;
903  }
904 
905  /* Hard error */
906  case FATAL_UNHANDLED_HARD_ERROR:
907  {
908  /* Copy bug check data from hard error */
909  HardErrorParameters = (PULONG_PTR)BugCheckParameter2;
910  KiBugCheckData[0] = BugCheckParameter1;
911  KiBugCheckData[1] = HardErrorParameters[0];
912  KiBugCheckData[2] = HardErrorParameters[1];
913  KiBugCheckData[3] = HardErrorParameters[2];
914  KiBugCheckData[4] = HardErrorParameters[3];
915 
916  /* Remember that this is hard error and set the caption/message */
917  IsHardError = TRUE;
918  HardErrCaption = (PCHAR)BugCheckParameter3;
919  HardErrMessage = (PCHAR)BugCheckParameter4;
920  break;
921  }
922 
923  /* Page fault */
924  case PAGE_FAULT_IN_NONPAGED_AREA:
925  {
926  /* Assume no driver */
927  DriverBase = NULL;
928 
929  /* Check if we have a trap frame */
930  if (!TrapFrame)
931  {
932  /* We don't, use parameter 3 if possible */
933  if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
934  }
935 
936  /* Check if we have a frame now */
937  if (TrapFrame)
938  {
939  /* Get the Program Counter */
940  Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
941  KiBugCheckData[3] = (ULONG_PTR)Pc;
942 
943  /* Find out if was in the kernel or drivers */
944  DriverBase = KiPcToFileHeader(Pc,
945  &LdrEntry,
946  FALSE,
947  &IsSystem);
948  }
949  else
950  {
951  /* Can't blame a driver, assume system */
952  IsSystem = TRUE;
953  }
954 
955  /* FIXME: Check for session pool in addition to special pool */
956 
957  /* Special pool has its own bug check codes */
958  if (MmIsSpecialPoolAddress((PVOID)BugCheckParameter1))
959  {
960  if (MmIsSpecialPoolAddressFree((PVOID)BugCheckParameter1))
961  {
962  KiBugCheckData[0] = IsSystem
963  ? PAGE_FAULT_IN_FREED_SPECIAL_POOL
964  : DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL;
965  }
966  else
967  {
968  KiBugCheckData[0] = IsSystem
969  ? PAGE_FAULT_BEYOND_END_OF_ALLOCATION
970  : DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION;
971  }
972  }
973  else if (!DriverBase)
974  {
975  /* Find the driver that unloaded at this address */
976  KiBugCheckDriver = NULL; // FIXME: ROS can't locate
977 
978  /* Check if the cause was an unloaded driver */
979  if (KiBugCheckDriver)
980  {
981  KiBugCheckData[0] =
982  DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS;
983  }
984  }
985  break;
986  }
987 
988  /* Check if the driver forgot to unlock pages */
989  case DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS:
990 
991  /* Program Counter is in parameter 1 */
992  Pc = (PVOID)BugCheckParameter1;
993  break;
994 
995  /* Check if the driver consumed too many PTEs */
996  case DRIVER_USED_EXCESSIVE_PTES:
997 
998  /* Loader entry is in parameter 1 */
999  LdrEntry = (PVOID)BugCheckParameter1;
1000  KiBugCheckDriver = &LdrEntry->BaseDllName;
1001  break;
1002 
1003  /* Check if the driver has a stuck thread */
1004  case THREAD_STUCK_IN_DEVICE_DRIVER:
1005 
1006  /* The name is in Parameter 3 */
1007  KiBugCheckDriver = (PVOID)BugCheckParameter3;
1008  break;
1009 
1010  /* Anything else */
1011  default:
1012  break;
1013  }
1014 
1015  /* Do we have a driver name? */
1016  if (KiBugCheckDriver)
1017  {
1018  /* Convert it to ANSI */
1019  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
1020  }
1021  else
1022  {
1023  /* Do we have a Program Counter? */
1024  if (Pc)
1025  {
1026  /* Dump image name */
1027  KiDumpParameterImages(AnsiName,
1028  (PULONG_PTR)&Pc,
1029  1,
1031  }
1032  }
1033 
1034  /* Check if we need to save the context for KD */
1036 
1037  /* Check if a debugger is connected */
1038  if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
1039  {
1040  /* Crash on the debugger console */
1041  DbgPrint("\n*** Fatal System Error: 0x%08lx\n"
1042  " (0x%p,0x%p,0x%p,0x%p)\n\n",
1043  KiBugCheckData[0],
1044  KiBugCheckData[1],
1045  KiBugCheckData[2],
1046  KiBugCheckData[3],
1047  KiBugCheckData[4]);
1048 
1049  /* Check if the debugger isn't currently connected */
1050  if (!KdDebuggerNotPresent)
1051  {
1052  /* Check if we have a driver to blame */
1053  if (KiBugCheckDriver)
1054  {
1055  /* Dump it */
1056  DbgPrint("Driver at fault: %s.\n", AnsiName);
1057  }
1058 
1059  /* Check if this was a hard error */
1060  if (IsHardError)
1061  {
1062  /* Print caption and message */
1063  if (HardErrCaption) DbgPrint(HardErrCaption);
1064  if (HardErrMessage) DbgPrint(HardErrMessage);
1065  }
1066 
1067  /* Break in the debugger */
1069  }
1070  }
1071 
1072  /* Raise IRQL to HIGH_LEVEL */
1073  _disable();
1075 
1076  /* Avoid recursion */
1078  {
1079 #ifdef CONFIG_SMP
1080  /* Set CPU that is bug checking now */
1081  KeBugCheckOwner = Prcb->Number;
1082 
1083  /* Freeze the other CPUs */
1084  for (i = 0; i < KeNumberProcessors; i++)
1085  {
1087  {
1088  /* Send the IPI and give them one second to catch up */
1089  KiIpiSend(1 << i, IPI_FREEZE);
1090  KeStallExecutionProcessor(1000000);
1091  }
1092  }
1093 #endif
1094 
1095  /* Display the BSOD */
1096  KiDisplayBlueScreen(MessageId,
1097  IsHardError,
1098  HardErrCaption,
1099  HardErrMessage,
1100  AnsiName);
1101 
1102  // TODO/FIXME: Run the registered reason-callbacks from
1103  // the KeBugcheckReasonCallbackListHead list with the
1104  // KbCallbackReserved1 reason.
1105 
1106  /* Check if the debugger is disabled but we can enable it */
1107  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
1108  {
1109  /* Enable it */
1111  }
1112  else
1113  {
1114  /* Otherwise, print the last line */
1115  InbvDisplayString("\r\n");
1116  }
1117 
1118  /* Save the context */
1120 
1121  /* FIXME: Support Triage Dump */
1122 
1123  /* FIXME: Write the crash dump */
1124  }
1125  else
1126  {
1127  /* Increase recursion count */
1130  {
1131  /* Break in the debugger */
1133  }
1134  else if (KeBugCheckOwnerRecursionCount > 2)
1135  {
1136  /* Halt execution */
1137  while (TRUE);
1138  }
1139  }
1140 
1141  /* Call the Callbacks */
1143 
1144  /* FIXME: Call Watchdog if enabled */
1145 
1146  /* Check if we have to reboot */
1147  if (Reboot)
1148  {
1149  /* Unload symbols */
1152  }
1153 
1154  /* Attempt to break in the debugger (otherwise halt CPU) */
1156 
1157  /* Shouldn't get here */
1158  ASSERT(FALSE);
1159  while (TRUE);
1160 }
1161 
1162 BOOLEAN
1163 NTAPI
1165 {
1166  BOOLEAN Handled = FALSE;
1167  PKNMI_HANDLER_CALLBACK NmiData;
1168 
1169  /* Parse the list of callbacks */
1170  NmiData = KiNmiCallbackListHead;
1171  while (NmiData)
1172  {
1173  /* Save if this callback has handled it -- all it takes is one */
1174  Handled |= NmiData->Callback(NmiData->Context, Handled);
1175  NmiData = NmiData->Next;
1176  }
1177 
1178  /* Has anyone handled this? */
1179  return Handled;
1180 }
1181 
1182 /* PUBLIC FUNCTIONS **********************************************************/
1183 
1184 /*
1185  * @unimplemented
1186  */
1187 NTSTATUS
1188 NTAPI
1190  IN ULONG Flags,
1191  OUT PVOID Buffer,
1193  OUT ULONG BufferNeeded OPTIONAL)
1194 {
1195  UNIMPLEMENTED;
1196  return STATUS_UNSUCCESSFUL;
1197 }
1198 
1199 /*
1200  * @implemented
1201  */
1202 BOOLEAN
1203 NTAPI
1205 {
1206  KIRQL OldIrql;
1207  BOOLEAN Status = FALSE;
1208 
1209  /* Raise IRQL to High */
1211 
1212  /* Check the Current State */
1213  if (CallbackRecord->State == BufferInserted)
1214  {
1215  /* Reset state and remove from list */
1216  CallbackRecord->State = BufferEmpty;
1217  RemoveEntryList(&CallbackRecord->Entry);
1218  Status = TRUE;
1219  }
1220 
1221  /* Lower IRQL and return */
1223  return Status;
1224 }
1225 
1226 /*
1227  * @implemented
1228  */
1229 BOOLEAN
1230 NTAPI
1232  IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord)
1233 {
1234  KIRQL OldIrql;
1235  BOOLEAN Status = FALSE;
1236 
1237  /* Raise IRQL to High */
1239 
1240  /* Check the Current State */
1241  if (CallbackRecord->State == BufferInserted)
1242  {
1243  /* Reset state and remove from list */
1244  CallbackRecord->State = BufferEmpty;
1245  RemoveEntryList(&CallbackRecord->Entry);
1246  Status = TRUE;
1247  }
1248 
1249  /* Lower IRQL and return */
1251  return Status;
1252 }
1253 
1254 /*
1255  * @implemented
1256  */
1257 BOOLEAN
1258 NTAPI
1261  IN PVOID Buffer,
1262  IN ULONG Length,
1263  IN PUCHAR Component)
1264 {
1265  KIRQL OldIrql;
1266  BOOLEAN Status = FALSE;
1267 
1268  /* Raise IRQL to High */
1270 
1271  /* Check the Current State first so we don't double-register */
1272  if (CallbackRecord->State == BufferEmpty)
1273  {
1274  /* Set the Callback Settings and insert into the list */
1275  CallbackRecord->Length = Length;
1276  CallbackRecord->Buffer = Buffer;
1277  CallbackRecord->Component = Component;
1278  CallbackRecord->CallbackRoutine = CallbackRoutine;
1279  CallbackRecord->State = BufferInserted;
1280  InsertTailList(&KeBugcheckCallbackListHead, &CallbackRecord->Entry);
1281  Status = TRUE;
1282  }
1283 
1284  /* Lower IRQL and return */
1286  return Status;
1287 }
1288 
1289 /*
1290  * @implemented
1291  */
1292 BOOLEAN
1293 NTAPI
1295  IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
1298  IN PUCHAR Component)
1299 {
1300  KIRQL OldIrql;
1301  BOOLEAN Status = FALSE;
1302 
1303  /* Raise IRQL to High */
1305 
1306  /* Check the Current State first so we don't double-register */
1307  if (CallbackRecord->State == BufferEmpty)
1308  {
1309  /* Set the Callback Settings and insert into the list */
1310  CallbackRecord->Component = Component;
1311  CallbackRecord->CallbackRoutine = CallbackRoutine;
1312  CallbackRecord->State = BufferInserted;
1313  CallbackRecord->Reason = Reason;
1315  &CallbackRecord->Entry);
1316  Status = TRUE;
1317  }
1318 
1319  /* Lower IRQL and return */
1321  return Status;
1322 }
1323 
1324 /*
1325  * @implemented
1326  */
1327 PVOID
1328 NTAPI
1330  IN PVOID Context)
1331 {
1332  KIRQL OldIrql;
1333  PKNMI_HANDLER_CALLBACK NmiData, Next;
1335 
1336  /* Allocate NMI callback data */
1337  NmiData = ExAllocatePoolWithTag(NonPagedPool, sizeof(*NmiData), TAG_KNMI);
1338  if (!NmiData) return NULL;
1339 
1340  /* Fill in the information */
1341  NmiData->Callback = CallbackRoutine;
1342  NmiData->Context = Context;
1343  NmiData->Handle = NmiData;
1344 
1345  /* Insert it into NMI callback list */
1347  NmiData->Next = KiNmiCallbackListHead;
1349  NmiData,
1350  NmiData->Next);
1351  ASSERT(Next == NmiData->Next);
1353 
1354  /* Return the opaque "handle" */
1355  return NmiData->Handle;
1356 }
1357 
1358 /*
1359  * @implemented
1360  */
1361 NTSTATUS
1362 NTAPI
1364 {
1365  KIRQL OldIrql;
1366  PKNMI_HANDLER_CALLBACK NmiData;
1367  PKNMI_HANDLER_CALLBACK* Previous;
1369 
1370  /* Find in the list the NMI callback corresponding to the handle */
1372  Previous = &KiNmiCallbackListHead;
1373  NmiData = *Previous;
1374  while (NmiData)
1375  {
1376  if (NmiData->Handle == Handle)
1377  {
1378  /* The handle is the pointer to the callback itself */
1379  ASSERT(Handle == NmiData);
1380 
1381  /* Found it, remove from the list */
1382  *Previous = NmiData->Next;
1383  break;
1384  }
1385 
1386  /* Not found; try again */
1387  Previous = &NmiData->Next;
1388  NmiData = *Previous;
1389  }
1391 
1392  /* If we have found the entry, free it */
1393  if (NmiData)
1394  {
1395  ExFreePoolWithTag(NmiData, TAG_KNMI);
1396  return STATUS_SUCCESS;
1397  }
1398 
1399  return STATUS_INVALID_HANDLE;
1400 }
1401 
1402 /*
1403  * @implemented
1404  */
1405 VOID
1406 NTAPI
1407 KeBugCheckEx(IN ULONG BugCheckCode,
1408  IN ULONG_PTR BugCheckParameter1,
1409  IN ULONG_PTR BugCheckParameter2,
1410  IN ULONG_PTR BugCheckParameter3,
1411  IN ULONG_PTR BugCheckParameter4)
1412 {
1413  /* Call the internal API */
1414  KeBugCheckWithTf(BugCheckCode,
1415  BugCheckParameter1,
1416  BugCheckParameter2,
1417  BugCheckParameter3,
1418  BugCheckParameter4,
1419  NULL);
1420 }
1421 
1422 /*
1423  * @implemented
1424  */
1425 VOID
1426 NTAPI
1427 KeBugCheck(ULONG BugCheckCode)
1428 {
1429  /* Call the internal API */
1430  KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
1431 }
1432 
1433 /*
1434  * @implemented
1435  */
1436 VOID
1437 NTAPI
1439 {
1440  /* Disable interrupts */
1441  KiHardwareTrigger = 1;
1442  _disable();
1443 
1444  /* Check the bugcheck count */
1446  {
1447  /* There was only one, is the debugger disabled? */
1448  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
1449  {
1450  /* Enable the debugger */
1451  KdInitSystem(0, NULL);
1452  }
1453  }
1454 
1455  /* Break in the debugger */
1457 }
1458 
1459 /* EOF */
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
BOOLEAN NTAPI KeGetBugMessageText(IN ULONG BugCheckCode, OUT PANSI_STRING OutputString OPTIONAL)
Definition: bug.c:338
static int Hash(const char *)
Definition: reader.c:2257
#define MESSAGE_RESOURCE_UNICODE
Definition: rtltypes.h:349
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
#define IN
Definition: typedefs.h:39
UCHAR DebuggerSavedIRQL
Definition: ketypes.h:739
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:29
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
Definition: rtltypes.h:1831
#define TRUE
Definition: types.h:120
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:324
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
LONG KeBugCheckOwnerRecursionCount
Definition: bug.c:25
BOOLEAN NTAPI KeRegisterBugCheckReasonCallback(IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord, IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine, IN KBUGCHECK_CALLBACK_REASON Reason, IN PUCHAR Component)
Definition: bug.c:1294
Type
Definition: Type.h:6
BOOLEAN KdbSymPrintAddress(IN PVOID Address, IN PKTRAP_FRAME Context)
Print address...
Definition: kdb_symbols.c:148
struct _Entry Entry
Definition: kefuncs.h:627
#define DbgPrint
Definition: loader.c:25
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
VOID INIT_FUNCTION NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:300
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
Definition: bug.c:26
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1679
struct _LIST_ENTRY * Blink
Definition: typedefs.h:121
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:572
#define DBG_STATUS_BUGCHECK_FIRST
Definition: kdtypes.h:41
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
NTSTATUS NTAPI KeInitializeCrashDumpHeader(IN ULONG Type, IN ULONG Flags, OUT PVOID Buffer, IN ULONG BufferSize, OUT ULONG BufferNeeded OPTIONAL)
Definition: bug.c:1189
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1063
static ULONGLONG Memory
Definition: CcMapData_drv.c:35
ULONG_PTR KiBugCheckData[5]
Definition: bug.c:30
#define MAXULONG_PTR
Definition: basetsd.h:103
BOOLEAN KdPitchDebugger
Definition: kdmain.c:52
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:719
VOID NTAPI KiDoBugCheckCallbacks(VOID)
Definition: bug.c:436
uint16_t * PWCHAR
Definition: typedefs.h:55
PNMI_CALLBACK Callback
Definition: ke.h:76
#define InsertTailList(ListHead, Entry)
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
ULONG64 SavedContext
Definition: wdbgexts.h:182
#define FASTCALL
Definition: nt_native.h:50
USHORT Flags
Definition: rtltypes.h:1834
ULONG_PTR Type
Definition: ldrtypes.h:181
VOID NTAPI KeBugCheckWithTf(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4, IN PKTRAP_FRAME TrapFrame)
Definition: bug.c:710
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
PVOID NTAPI KiRosPcToUserFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
Definition: bug.c:109
KBUGCHECK_CALLBACK_ROUTINE * PKBUGCHECK_CALLBACK_ROUTINE
Definition: ketypes.h:320
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:75
_SEH2_TRY
Definition: create.c:4250
ULONG KeBugCheckOwner
Definition: bug.c:24
uint32_t ULONG_PTR
Definition: typedefs.h:64
VOID NTAPI MmMakeKernelResourceSectionWritable(VOID)
Definition: sysldr.c:2317
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
PVOID DllBase
Definition: btrfs_drv.h:1857
#define sprintf(buf, format,...)
Definition: sprintf.c:55
VOID NTAPI KeRosDumpStackFrames(IN PULONG_PTR Frame OPTIONAL, IN ULONG FrameCount OPTIONAL)
Definition: bug.c:262
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:337
#define IPI_FREEZE
Definition: ketypes.h:234
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define DBG_STATUS_FATAL
Definition: kdtypes.h:43
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
VOID NTAPI KiBugCheckDebugBreak(IN ULONG StatusCode)
Definition: bug.c:493
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
KSPIN_LOCK KiNmiCallbackListLock
Definition: bug.c:33
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define ANSI_NULL
long LONG
Definition: pedump.c:60
VOID NTAPI KiDumpParameterImages(IN PCHAR Message, IN PULONG_PTR Parameters, IN ULONG ParameterCount, IN PKE_BUGCHECK_UNICODE_TO_ANSI ConversionRoutine)
Definition: bug.c:542
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
CONTEXT ContextFrame
Definition: ketypes.h:531
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define DBG_STATUS_BUGCHECK_SECOND
Definition: kdtypes.h:42
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead
Definition: bug.c:32
Definition: bl.h:892
unsigned char BOOLEAN
ULONG_PTR Name
Definition: ldrtypes.h:182
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:48
#define ACPI_BIOS_ERROR(plist)
Definition: acoutput.h:243
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
VOID NTAPI KeEnterKernelDebugger(VOID)
Definition: bug.c:1438
Definition: pedump.c:457
Definition: bufpool.h:45
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
KBUGCHECK_REASON_CALLBACK_ROUTINE * PKBUGCHECK_REASON_CALLBACK_ROUTINE
Definition: ketypes.h:259
void * PVOID
Definition: retypes.h:9
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
VOID NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:695
#define PtrToUlong(u)
Definition: config.h:107
NTSTATUS NTAPI LdrAccessResource(_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)
#define PCHAR
Definition: match.c:90
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
BOOLEAN NTAPI MmIsSpecialPoolAddressFree(IN PVOID P)
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
_In_ HANDLE Handle
Definition: extypes.h:390
VOID NTAPI DbgUnLoadImageSymbols(_In_ PSTRING Name, _In_ PVOID Base, _In_ ULONG_PTR ProcessId)
PCHAR(NTAPI * PKE_BUGCHECK_UNICODE_TO_ANSI)(IN PUNICODE_STRING Unicode, IN PCHAR Ansi, IN ULONG Length)
Definition: ke.h:82
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1835
NTSTATUS NTAPI KdEnableDebuggerWithLock(IN BOOLEAN NeedLock)
Definition: kdmain.c:364
#define TAG_KNMI
Definition: bug.c:34
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ BOOLEAN Handled
Definition: ketypes.h:337
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
PVOID NTAPI KiPcToFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:44
#define BufferSize
Definition: classpnp.h:419
KSPIN_LOCK BugCheckCallbackLock
Definition: bug.c:23
KDDEBUGGER_DATA64 * KdDebuggerDataBlock
Definition: kdpacket.c:21
#define HalHaltSystem
Definition: halfuncs.h:43
UNICODE_STRING KeRosBiosDate
Definition: bug.c:37
LIST_ENTRY KeBugcheckReasonCallbackListHead
Definition: bug.c:22
VOID NTAPI KiDisplayBlueScreen(IN ULONG MessageId, IN BOOLEAN IsHardError, IN PCHAR HardErrCaption OPTIONAL, IN PCHAR HardErrMessage OPTIONAL, IN PCHAR Message)
Definition: bug.c:612
VOID NTAPI HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
Definition: reboot.c:22
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CHAR Message[80]
Definition: alive.c:5
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:531
char * PBOOLEAN
Definition: retypes.h:11
NMI_CALLBACK * PNMI_CALLBACK
Definition: ketypes.h:338
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:372
Definition: btrfs_drv.h:1853
#define KeGetTrapFramePc(TrapFrame)
Definition: ke.h:130
Definition: typedefs.h:118
USHORT Length
Definition: rtltypes.h:1833
BOOLEAN NTAPI KeDeregisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
Definition: bug.c:1204
VOID FASTCALL KiIpiSend(KAFFINITY TargetSet, ULONG IpiRequest)
ULONG KeBugCheckActive
Definition: bug.c:24
SECURITY_INTEGER TimeStamp
Definition: sspi.h:78
UNICODE_STRING KeRosVideoBiosDate
Definition: bug.c:38
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:609
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:633
UNICODE_STRING KeRosVideoBiosVersion
Definition: bug.c:38
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define RESOURCE_DATA_LEVEL
Definition: ldrtypes.h:33
_SEH2_END
Definition: create.c:4424
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:667
#define InterlockedIncrement
Definition: armddk.h:53
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kdinit.c:169
UNICODE_STRING KeRosProcessorName
Definition: bug.c:37
VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: bug.c:1407
unsigned short USHORT
Definition: pedump.c:61
ULONG NTAPI RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags)
Definition: libsupp.c:227
MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY]
Definition: rtltypes.h:1848
USHORT NTAPI KeRosCaptureUserStackBackTrace(IN ULONG FramesToSkip, IN ULONG FramesToCapture, OUT PVOID *BackTrace, OUT PULONG BackTraceHash OPTIONAL)
Definition: bug.c:158
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:21
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:518
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1672
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:625
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:465
ULONG_PTR Language
Definition: ldrtypes.h:183
BOOLEAN NTAPI KeRegisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord, IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Buffer, IN ULONG Length, IN PUCHAR Component)
Definition: bug.c:1259
#define OUT
Definition: typedefs.h:40
NTSYSAPI USHORT NTAPI RtlCaptureStackBackTrace(_In_ ULONG FramesToSkip, _In_ ULONG FramesToCapture, _Out_writes_to_(FramesToCapture, return) PVOID *BackTrace, _Out_opt_ PULONG BackTraceHash)
USHORT Number
Definition: ketypes.h:559
void __cdecl _disable(void)
Definition: intrin_arm.h:365
BOOLEAN NTAPI KiHandleNmi(VOID)
Definition: bug.c:1164
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:64
#define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE
Definition: ntstatus.h:815
KBUGCHECK_CALLBACK_REASON
Definition: ketypes.h:247
NTSTATUS NTAPI KeDeregisterNmiCallback(IN PVOID Handle)
Definition: bug.c:1363
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
UNICODE_STRING KeRosBiosVersion
Definition: bug.c:37
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PVOID NTAPI KeRegisterNmiCallback(IN PNMI_CALLBACK CallbackRoutine, IN PVOID Context)
Definition: bug.c:1329
GLfloat GLfloat p
Definition: glext.h:8902
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:684
#define KeGetCurrentThread
Definition: hal.h:44
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
VOID FASTCALL KeRosDumpStackFrameArray(IN PULONG_PTR Frames, IN ULONG FrameCount)
Definition: bug.c:201
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:45
signed int * PLONG
Definition: retypes.h:5
ULONG KiHardwareTrigger
Definition: bug.c:28
#define CHAR(Char)
BOOLEAN NTAPI MmIsSpecialPoolAddress(IN PVOID P)
BOOLEAN KdDebuggerNotPresent
Definition: kdmain.c:50
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:95
base of all file and directory entries
Definition: entries.h:82
BOOLEAN NTAPI KeDeregisterBugCheckReasonCallback(IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord)
Definition: bug.c:1231
ULONG KeBugCheckCount
Definition: bug.c:27
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68