ReactOS  0.4.15-dev-3207-ga415bd4
bug.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for bug.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define TAG_KNMI   'IMNK'
 

Functions

PVOID NTAPI KiPcToFileHeader (IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
 
PVOID NTAPI KiRosPcToUserFileHeader (IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
 
USHORT NTAPI KeRosCaptureUserStackBackTrace (IN ULONG FramesToSkip, IN ULONG FramesToCapture, OUT PVOID *BackTrace, OUT PULONG BackTraceHash OPTIONAL)
 
VOID FASTCALL KeRosDumpStackFrameArray (IN PULONG_PTR Frames, IN ULONG FrameCount)
 
VOID NTAPI KeRosDumpStackFrames (IN PULONG_PTR Frame OPTIONAL, IN ULONG FrameCount OPTIONAL)
 
VOID NTAPI KiInitializeBugCheck (VOID)
 
BOOLEAN NTAPI KeGetBugMessageText (IN ULONG BugCheckCode, OUT PANSI_STRING OutputString OPTIONAL)
 
VOID NTAPI KiDoBugCheckCallbacks (VOID)
 
VOID NTAPI KiBugCheckDebugBreak (IN ULONG StatusCode)
 
PCHAR NTAPI KeBugCheckUnicodeToAnsi (IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
 
VOID NTAPI KiDumpParameterImages (IN PCHAR Message, IN PULONG_PTR Parameters, IN ULONG ParameterCount, IN PKE_BUGCHECK_UNICODE_TO_ANSI ConversionRoutine)
 
VOID NTAPI KiDisplayBlueScreen (IN ULONG MessageId, IN BOOLEAN IsHardError, IN PCHAR HardErrCaption OPTIONAL, IN PCHAR HardErrMessage OPTIONAL, IN PCHAR Message)
 
DECLSPEC_NORETURN 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)
 
BOOLEAN NTAPI KiHandleNmi (VOID)
 
NTSTATUS NTAPI KeInitializeCrashDumpHeader (IN ULONG Type, IN ULONG Flags, OUT PVOID Buffer, IN ULONG BufferSize, OUT ULONG BufferNeeded OPTIONAL)
 
BOOLEAN NTAPI KeDeregisterBugCheckCallback (IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
 
BOOLEAN NTAPI KeDeregisterBugCheckReasonCallback (IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord)
 
BOOLEAN NTAPI KeRegisterBugCheckCallback (IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord, IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, IN PVOID Buffer, IN ULONG Length, IN PUCHAR Component)
 
BOOLEAN NTAPI KeRegisterBugCheckReasonCallback (IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord, IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine, IN KBUGCHECK_CALLBACK_REASON Reason, IN PUCHAR Component)
 
PVOID NTAPI KeRegisterNmiCallback (IN PNMI_CALLBACK CallbackRoutine, IN PVOID Context)
 
NTSTATUS NTAPI KeDeregisterNmiCallback (IN PVOID Handle)
 
DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx (IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
 
DECLSPEC_NORETURN VOID NTAPI KeBugCheck (ULONG BugCheckCode)
 
VOID NTAPI KeEnterKernelDebugger (VOID)
 

Variables

LIST_ENTRY KeBugcheckCallbackListHead
 
LIST_ENTRY KeBugcheckReasonCallbackListHead
 
KSPIN_LOCK BugCheckCallbackLock
 
ULONG KeBugCheckActive
 
ULONG KeBugCheckOwner
 
LONG KeBugCheckOwnerRecursionCount
 
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
 
ULONG KeBugCheckCount = 1
 
ULONG KiHardwareTrigger
 
PUNICODE_STRING KiBugCheckDriver
 
ULONG_PTR KiBugCheckData [5]
 
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead = NULL
 
KSPIN_LOCK KiNmiCallbackListLock
 
UNICODE_STRING KeRosProcessorName
 
UNICODE_STRING KeRosBiosDate
 
UNICODE_STRING KeRosBiosVersion
 
UNICODE_STRING KeRosVideoBiosDate
 
UNICODE_STRING KeRosVideoBiosVersion
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file bug.c.

◆ TAG_KNMI

#define TAG_KNMI   'IMNK'

Definition at line 31 of file bug.c.

Function Documentation

◆ KeBugCheck()

DECLSPEC_NORETURN VOID NTAPI KeBugCheck ( ULONG  BugCheckCode)

Definition at line 1427 of file bug.c.

1428 {
1429  /* Call the internal API */
1430  KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
1431 }
DECLSPEC_NORETURN 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:708
#define NULL
Definition: types.h:112

Referenced by CcInitCacheZeroPage(), CcpDereferenceCache(), CcRosRequestVacb(), CcScheduleReadAhead(), ClassSendStartUnit(), ExeFmtpReadFile(), ExInitSystem(), ExpInitializeExecutive(), ExpInitNls(), FsRtlCreateSectionForDataScan(), HalpInitializeTsc(), i8042KbdInterruptService(), KdbEnterDebuggerException(), KdpCauseBugCheck(), KeDetachProcess(), Kei386EoiHelper(), KeRaiseIrqlToDpcLevel(), KeUnstackDetachProcess(), KeWaitForMultipleObjects(), KfLowerIrql(), KfRaiseIrql(), KiInitializeCpu(), KiSetAffinityThread(), KiSystemStartupBootStack(), KiThreadStartup(), KiUnexpectedInterrupt(), MiBalancerThread(), MiInitBalancerThread(), MiReadPageFile(), MiRosUnmapViewOfSection(), MiTrimMemoryConsumer(), MmAccessFaultSectionView(), MmAllocPage(), MmAllocSwapPage(), MmCreatePageFileMapping(), MmCreateVirtualMapping(), MmCreateVirtualMappingUnsafe(), MmDeleteRmap(), MmDeleteVirtualMapping(), MmFreeSwapPage(), MmInsertRmap(), MmNotPresentFaultSectionView(), MmPageOutPhysicalAddress(), MmpPageOutPhysicalAddress(), MmReleasePageMemoryConsumer(), MmRequestPageMemoryConsumer(), MmSetDirtyBit(), MmSetPageProtect(), MmSharePageEntrySectionSegment(), MmspPageAlignSegments(), MmUnsharePageEntrySectionSegment(), MmWriteToSwapPage(), MupDereferenceMasterQueryContext(), Phase1InitializationDiscard(), PpInitSystem(), PspDeleteProcess(), PspDeleteThread(), PspSystemThreadStartup(), RawDispatch(), TdiAddressSizeFromType(), USBCCGP_PDOSelectConfiguration(), UserProcessCreate(), VfatReadFileData(), VfatWriteFileData(), and xHalIoAssignDriveLetters().

◆ KeBugCheckEx()

DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx ( IN ULONG  BugCheckCode,
IN ULONG_PTR  BugCheckParameter1,
IN ULONG_PTR  BugCheckParameter2,
IN ULONG_PTR  BugCheckParameter3,
IN ULONG_PTR  BugCheckParameter4 
)

Definition at line 1406 of file bug.c.

1411 {
1412  /* Call the internal API */
1413  KeBugCheckWithTf(BugCheckCode,
1414  BugCheckParameter1,
1415  BugCheckParameter2,
1416  BugCheckParameter3,
1417  BugCheckParameter4,
1418  NULL);
1419 }
DECLSPEC_NORETURN 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:708
#define NULL
Definition: types.h:112

◆ KeBugCheckUnicodeToAnsi()

PCHAR NTAPI KeBugCheckUnicodeToAnsi ( IN PUNICODE_STRING  Unicode,
OUT PCHAR  Ansi,
IN ULONG  Length 
)

Definition at line 515 of file bug.c.

518 {
519  PCHAR p;
520  PWCHAR pw;
521  ULONG i;
522 
523  /* Set length and normalize it */
524  i = Unicode->Length / sizeof(WCHAR);
525  i = min(i, Length - 1);
526 
527  /* Set source and destination, and copy */
528  pw = Unicode->Buffer;
529  p = Ansi;
530  while (i--) *p++ = (CHAR)*pw++;
531 
532  /* Null terminate and return */
533  *p = ANSI_NULL;
534  return Ansi;
535 }
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
uint16_t * PWCHAR
Definition: typedefs.h:56
#define ANSI_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
#define CHAR(Char)

Referenced by KeBugCheckWithTf(), KeRosDumpStackFrameArray(), and KiDisplayBlueScreen().

◆ KeBugCheckWithTf()

DECLSPEC_NORETURN 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 at line 708 of file bug.c.

714 {
715  PKPRCB Prcb = KeGetCurrentPrcb();
717  ULONG MessageId;
718  CHAR AnsiName[128];
719  BOOLEAN IsSystem, IsHardError = FALSE, Reboot = FALSE;
720  PCHAR HardErrCaption = NULL, HardErrMessage = NULL;
721  PVOID Pc = NULL, Memory;
722  PVOID DriverBase;
723  PLDR_DATA_TABLE_ENTRY LdrEntry;
724  PULONG_PTR HardErrorParameters;
725  KIRQL OldIrql;
726 #ifdef CONFIG_SMP
727  LONG i = 0;
728 #endif
729 
730  /* Set active bugcheck */
733 
734  /* Check if this is power failure simulation */
735  if (BugCheckCode == POWER_FAILURE_SIMULATE)
736  {
737  /* Call the Callbacks and reboot */
740  }
741 
742  /* Save the IRQL and set hardware trigger */
745 
746  /* Capture the CPU Context */
750 
751  /* FIXME: Call the Watchdog if it's registered */
752 
753  /* Check which bugcode this is */
754  switch (BugCheckCode)
755  {
756  /* These bug checks already have detailed messages, keep them */
757  case UNEXPECTED_KERNEL_MODE_TRAP:
758  case DRIVER_CORRUPTED_EXPOOL:
759  case ACPI_BIOS_ERROR:
760  case ACPI_BIOS_FATAL_ERROR:
761  case THREAD_STUCK_IN_DEVICE_DRIVER:
762  case DATA_BUS_ERROR:
763  case FAT_FILE_SYSTEM:
764  case NO_MORE_SYSTEM_PTES:
765  case INACCESSIBLE_BOOT_DEVICE:
766 
767  /* Keep the same code */
768  MessageId = BugCheckCode;
769  break;
770 
771  /* Check if this is a kernel-mode exception */
772  case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
773  case SYSTEM_THREAD_EXCEPTION_NOT_HANDLED:
774  case KMODE_EXCEPTION_NOT_HANDLED:
775 
776  /* Use the generic text message */
777  MessageId = KMODE_EXCEPTION_NOT_HANDLED;
778  break;
779 
780  /* File-system errors */
781  case NTFS_FILE_SYSTEM:
782 
783  /* Use the generic message for FAT */
784  MessageId = FAT_FILE_SYSTEM;
785  break;
786 
787  /* Check if this is a coruption of the Mm's Pool */
788  case DRIVER_CORRUPTED_MMPOOL:
789 
790  /* Use generic corruption message */
791  MessageId = DRIVER_CORRUPTED_EXPOOL;
792  break;
793 
794  /* Check if this is a signature check failure */
796 
797  /* Use the generic corruption message */
798  MessageId = BUGCODE_PSS_MESSAGE_SIGNATURE;
799  break;
800 
801  /* All other codes */
802  default:
803 
804  /* Use the default bugcheck message */
805  MessageId = BUGCODE_PSS_MESSAGE;
806  break;
807  }
808 
809  /* Save bugcheck data */
810  KiBugCheckData[0] = BugCheckCode;
811  KiBugCheckData[1] = BugCheckParameter1;
812  KiBugCheckData[2] = BugCheckParameter2;
813  KiBugCheckData[3] = BugCheckParameter3;
814  KiBugCheckData[4] = BugCheckParameter4;
815 
816  /* Now check what bugcheck this is */
817  switch (BugCheckCode)
818  {
819  /* Invalid access to R/O memory or Unhandled KM Exception */
820  case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
821  case ATTEMPTED_WRITE_TO_READONLY_MEMORY:
822  case ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY:
823  {
824  /* Check if we have a trap frame */
825  if (!TrapFrame)
826  {
827  /* Use parameter 3 as a trap frame, if it exists */
828  if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
829  }
830 
831  /* Check if we got one now and if we need to get the Program Counter */
832  if ((TrapFrame) &&
833  (BugCheckCode != KERNEL_MODE_EXCEPTION_NOT_HANDLED))
834  {
835  /* Get the Program Counter */
836  Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
837  }
838  break;
839  }
840 
841  /* Wrong IRQL */
842  case IRQL_NOT_LESS_OR_EQUAL:
843  {
844  /*
845  * The NT kernel has 3 special sections:
846  * MISYSPTE, POOLMI and POOLCODE. The bug check code can
847  * determine in which of these sections this bugcode happened
848  * and provide a more detailed analysis. For now, we don't.
849  */
850 
851  /* Program Counter is in parameter 4 */
852  Pc = (PVOID)BugCheckParameter4;
853 
854  /* Get the driver base */
855  DriverBase = KiPcToFileHeader(Pc,
856  &LdrEntry,
857  FALSE,
858  &IsSystem);
859  if (IsSystem)
860  {
861  /*
862  * The error happened inside the kernel or HAL.
863  * Get the memory address that was being referenced.
864  */
865  Memory = (PVOID)BugCheckParameter1;
866 
867  /* Find to which driver it belongs */
868  DriverBase = KiPcToFileHeader(Memory,
869  &LdrEntry,
870  TRUE,
871  &IsSystem);
872  if (DriverBase)
873  {
874  /* Get the driver name and update the bug code */
875  KiBugCheckDriver = &LdrEntry->BaseDllName;
876  KiBugCheckData[0] = DRIVER_PORTION_MUST_BE_NONPAGED;
877  }
878  else
879  {
880  /* Find the driver that unloaded at this address */
881  KiBugCheckDriver = NULL; // FIXME: ROS can't locate
882 
883  /* Check if the cause was an unloaded driver */
884  if (KiBugCheckDriver)
885  {
886  /* Update bug check code */
887  KiBugCheckData[0] =
888  SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD;
889  }
890  }
891  }
892  else
893  {
894  /* Update the bug check code */
895  KiBugCheckData[0] = DRIVER_IRQL_NOT_LESS_OR_EQUAL;
896  }
897 
898  /* Clear Pc so we don't look it up later */
899  Pc = NULL;
900  break;
901  }
902 
903  /* Hard error */
904  case FATAL_UNHANDLED_HARD_ERROR:
905  {
906  /* Copy bug check data from hard error */
907  HardErrorParameters = (PULONG_PTR)BugCheckParameter2;
908  KiBugCheckData[0] = BugCheckParameter1;
909  KiBugCheckData[1] = HardErrorParameters[0];
910  KiBugCheckData[2] = HardErrorParameters[1];
911  KiBugCheckData[3] = HardErrorParameters[2];
912  KiBugCheckData[4] = HardErrorParameters[3];
913 
914  /* Remember that this is hard error and set the caption/message */
915  IsHardError = TRUE;
916  HardErrCaption = (PCHAR)BugCheckParameter3;
917  HardErrMessage = (PCHAR)BugCheckParameter4;
918  break;
919  }
920 
921  /* Page fault */
922  case PAGE_FAULT_IN_NONPAGED_AREA:
923  {
924  /* Assume no driver */
925  DriverBase = NULL;
926 
927  /* Check if we have a trap frame */
928  if (!TrapFrame)
929  {
930  /* We don't, use parameter 3 if possible */
931  if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
932  }
933 
934  /* Check if we have a frame now */
935  if (TrapFrame)
936  {
937  /* Get the Program Counter */
938  Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
939  KiBugCheckData[3] = (ULONG_PTR)Pc;
940 
941  /* Find out if was in the kernel or drivers */
942  DriverBase = KiPcToFileHeader(Pc,
943  &LdrEntry,
944  FALSE,
945  &IsSystem);
946  }
947  else
948  {
949  /* Can't blame a driver, assume system */
950  IsSystem = TRUE;
951  }
952 
953  /* FIXME: Check for session pool in addition to special pool */
954 
955  /* Special pool has its own bug check codes */
956  if (MmIsSpecialPoolAddress((PVOID)BugCheckParameter1))
957  {
958  if (MmIsSpecialPoolAddressFree((PVOID)BugCheckParameter1))
959  {
960  KiBugCheckData[0] = IsSystem
961  ? PAGE_FAULT_IN_FREED_SPECIAL_POOL
962  : DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL;
963  }
964  else
965  {
966  KiBugCheckData[0] = IsSystem
967  ? PAGE_FAULT_BEYOND_END_OF_ALLOCATION
968  : DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION;
969  }
970  }
971  else if (!DriverBase)
972  {
973  /* Find the driver that unloaded at this address */
974  KiBugCheckDriver = NULL; // FIXME: ROS can't locate
975 
976  /* Check if the cause was an unloaded driver */
977  if (KiBugCheckDriver)
978  {
979  KiBugCheckData[0] =
980  DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS;
981  }
982  }
983  break;
984  }
985 
986  /* Check if the driver forgot to unlock pages */
987  case DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS:
988 
989  /* Program Counter is in parameter 1 */
990  Pc = (PVOID)BugCheckParameter1;
991  break;
992 
993  /* Check if the driver consumed too many PTEs */
994  case DRIVER_USED_EXCESSIVE_PTES:
995 
996  /* Loader entry is in parameter 1 */
997  LdrEntry = (PVOID)BugCheckParameter1;
998  KiBugCheckDriver = &LdrEntry->BaseDllName;
999  break;
1000 
1001  /* Check if the driver has a stuck thread */
1002  case THREAD_STUCK_IN_DEVICE_DRIVER:
1003 
1004  /* The name is in Parameter 3 */
1005  KiBugCheckDriver = (PVOID)BugCheckParameter3;
1006  break;
1007 
1008  /* Anything else */
1009  default:
1010  break;
1011  }
1012 
1013  /* Do we have a driver name? */
1014  if (KiBugCheckDriver)
1015  {
1016  /* Convert it to ANSI */
1017  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
1018  }
1019  else
1020  {
1021  /* Do we have a Program Counter? */
1022  if (Pc)
1023  {
1024  /* Dump image name */
1025  KiDumpParameterImages(AnsiName,
1026  (PULONG_PTR)&Pc,
1027  1,
1029  }
1030  }
1031 
1032  /* Check if we need to save the context for KD */
1034 
1035  /* Check if a debugger is connected */
1036  if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
1037  {
1038  /* Crash on the debugger console */
1039  DbgPrint("\n*** Fatal System Error: 0x%08lx\n"
1040  " (0x%p,0x%p,0x%p,0x%p)\n\n",
1041  KiBugCheckData[0],
1042  KiBugCheckData[1],
1043  KiBugCheckData[2],
1044  KiBugCheckData[3],
1045  KiBugCheckData[4]);
1046 
1047  /* Check if the debugger isn't currently connected */
1048  if (!KdDebuggerNotPresent)
1049  {
1050  /* Check if we have a driver to blame */
1051  if (KiBugCheckDriver)
1052  {
1053  /* Dump it */
1054  DbgPrint("Driver at fault: %s.\n", AnsiName);
1055  }
1056 
1057  /* Check if this was a hard error */
1058  if (IsHardError)
1059  {
1060  /* Print caption and message */
1061  if (HardErrCaption) DbgPrint(HardErrCaption);
1062  if (HardErrMessage) DbgPrint(HardErrMessage);
1063  }
1064 
1065  /* Break in the debugger */
1067  }
1068  }
1069 
1070  /* Raise IRQL to HIGH_LEVEL */
1071  _disable();
1073 
1074  /* Avoid recursion */
1076  {
1077 #ifdef CONFIG_SMP
1078  /* Set CPU that is bug checking now */
1079  KeBugCheckOwner = Prcb->Number;
1080 
1081  /* Freeze the other CPUs */
1082  for (i = 0; i < KeNumberProcessors; i++)
1083  {
1085  {
1086  /* Send the IPI and give them one second to catch up */
1087  KiIpiSend(1 << i, IPI_FREEZE);
1088  KeStallExecutionProcessor(1000000);
1089  }
1090  }
1091 #endif
1092 
1093  /* Display the BSOD */
1094  KiDisplayBlueScreen(MessageId,
1095  IsHardError,
1096  HardErrCaption,
1097  HardErrMessage,
1098  AnsiName);
1099 
1100  // TODO/FIXME: Run the registered reason-callbacks from
1101  // the KeBugcheckReasonCallbackListHead list with the
1102  // KbCallbackReserved1 reason.
1103 
1104  /* Check if the debugger is disabled but we can enable it */
1105  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
1106  {
1107  /* Enable it */
1109  }
1110  else
1111  {
1112  /* Otherwise, print the last line */
1113  InbvDisplayString("\r\n");
1114  }
1115 
1116  /* Save the context */
1118 
1119  /* FIXME: Support Triage Dump */
1120 
1121  /* FIXME: Write the crash dump */
1122  }
1123  else
1124  {
1125  /* Increase recursion count */
1128  {
1129  /* Break in the debugger */
1131  }
1132  else if (KeBugCheckOwnerRecursionCount > 2)
1133  {
1134  /* Halt execution */
1135  while (TRUE);
1136  }
1137  }
1138 
1139  /* Call the Callbacks */
1141 
1142  /* FIXME: Call Watchdog if enabled */
1143 
1144  /* Check if we have to reboot */
1145  if (Reboot)
1146  {
1147  /* Unload symbols */
1150  }
1151 
1152  /* Attempt to break in the debugger (otherwise halt CPU) */
1154 
1155  /* Shouldn't get here */
1156  ASSERT(FALSE);
1157  while (TRUE);
1158 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
BOOLEAN KdDebuggerEnabled
Definition: kddata.c:83
#define KeGetTrapFramePc(TrapFrame)
Definition: ke.h:37
UCHAR DebuggerSavedIRQL
Definition: ketypes.h:743
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:26
LONG KeBugCheckOwnerRecursionCount
Definition: bug.c:22
#define DbgPrint
Definition: hal.h:12
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:569
#define DBG_STATUS_BUGCHECK_FIRST
Definition: kdtypes.h:41
char CHAR
Definition: xmlstorage.h:175
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
ULONG_PTR KiBugCheckData[5]
Definition: bug.c:27
#define MAXULONG_PTR
Definition: basetsd.h:103
BOOLEAN KdPitchDebugger
Definition: kddata.c:81
VOID NTAPI KiDoBugCheckCallbacks(VOID)
Definition: bug.c:433
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
ULONG64 SavedContext
Definition: wdbgexts.h:182
ULONG KeBugCheckOwner
Definition: bug.c:21
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:337
#define IPI_FREEZE
Definition: ketypes.h:238
UCHAR KIRQL
Definition: env_spec_w32.h:591
BOOLEAN KdDebuggerNotPresent
Definition: kddata.c:82
VOID NTAPI KiBugCheckDebugBreak(IN ULONG StatusCode)
Definition: bug.c:490
#define FALSE
Definition: types.h:117
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:539
CONTEXT ContextFrame
Definition: ketypes.h:535
#define DBG_STATUS_BUGCHECK_SECOND
Definition: kdtypes.h:42
Definition: bl.h:892
unsigned char BOOLEAN
#define ACPI_BIOS_ERROR(plist)
Definition: acoutput.h:243
void * PVOID
Definition: retypes.h:9
#define PCHAR
Definition: match.c:90
KIRQL OldIrql
Definition: mm.h:1502
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
BOOLEAN NTAPI MmIsSpecialPoolAddressFree(IN PVOID P)
VOID NTAPI DbgUnLoadImageSymbols(_In_ PSTRING Name, _In_ PVOID Base, _In_ ULONG_PTR ProcessId)
NTSTATUS NTAPI KdEnableDebuggerWithLock(IN BOOLEAN NeedLock)
Definition: kdapi.c:1959
#define ASSERT(a)
Definition: mode.c:44
PVOID NTAPI KiPcToFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:41
KDDEBUGGER_DATA64 * KdDebuggerDataBlock
Definition: kdpacket.c:21
VOID NTAPI KiDisplayBlueScreen(IN ULONG MessageId, IN BOOLEAN IsHardError, IN PCHAR HardErrCaption OPTIONAL, IN PCHAR HardErrMessage OPTIONAL, IN PCHAR Message)
Definition: bug.c:609
VOID NTAPI HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
Definition: reboot.c:22
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:583
#define InterlockedDecrement
Definition: armddk.h:52
VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:362
Definition: btrfs_drv.h:1922
VOID FASTCALL KiIpiSend(KAFFINITY TargetSet, ULONG IpiRequest)
ULONG KeBugCheckActive
Definition: bug.c:21
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define InterlockedIncrement
Definition: armddk.h:53
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
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:515
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define NULL
Definition: types.h:112
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
struct tagContext Context
Definition: acpixf.h:1034
USHORT Number
Definition: ketypes.h:563
void __cdecl _disable(void)
Definition: intrin_arm.h:365
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE
Definition: ntstatus.h:829
signed int * PLONG
Definition: retypes.h:5
ULONG KiHardwareTrigger
Definition: bug.c:25
BOOLEAN NTAPI MmIsSpecialPoolAddress(IN PVOID P)
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:96
ULONG KeBugCheckCount
Definition: bug.c:24

Referenced by KeBugCheck(), and KeBugCheckEx().

◆ KeDeregisterBugCheckCallback()

BOOLEAN NTAPI KeDeregisterBugCheckCallback ( IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)

Definition at line 1202 of file bug.c.

1203 {
1204  KIRQL OldIrql;
1205  BOOLEAN Status = FALSE;
1206 
1207  /* Raise IRQL to High */
1209 
1210  /* Check the Current State */
1212  {
1213  /* Reset state and remove from list */
1216  Status = TRUE;
1217  }
1218 
1219  /* Lower IRQL and return */
1221  return Status;
1222 }
#define TRUE
Definition: types.h:120
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

Referenced by NdisMDeregisterAdapterShutdownHandler().

◆ KeDeregisterBugCheckReasonCallback()

BOOLEAN NTAPI KeDeregisterBugCheckReasonCallback ( IN PKBUGCHECK_REASON_CALLBACK_RECORD  CallbackRecord)

Definition at line 1229 of file bug.c.

1231 {
1232  KIRQL OldIrql;
1233  BOOLEAN Status = FALSE;
1234 
1235  /* Raise IRQL to High */
1237 
1238  /* Check the Current State */
1240  {
1241  /* Reset state and remove from list */
1244  Status = TRUE;
1245  }
1246 
1247  /* Lower IRQL and return */
1249  return Status;
1250 }
#define TRUE
Definition: types.h:120
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

◆ KeDeregisterNmiCallback()

NTSTATUS NTAPI KeDeregisterNmiCallback ( IN PVOID  Handle)

Definition at line 1361 of file bug.c.

1362 {
1363  KIRQL OldIrql;
1364  PKNMI_HANDLER_CALLBACK NmiData;
1365  PKNMI_HANDLER_CALLBACK* Previous;
1367 
1368  /* Find in the list the NMI callback corresponding to the handle */
1370  Previous = &KiNmiCallbackListHead;
1371  NmiData = *Previous;
1372  while (NmiData)
1373  {
1374  if (NmiData->Handle == Handle)
1375  {
1376  /* The handle is the pointer to the callback itself */
1377  ASSERT(Handle == NmiData);
1378 
1379  /* Found it, remove from the list */
1380  *Previous = NmiData->Next;
1381  break;
1382  }
1383 
1384  /* Not found; try again */
1385  Previous = &NmiData->Next;
1386  NmiData = *Previous;
1387  }
1389 
1390  /* If we have found the entry, free it */
1391  if (NmiData)
1392  {
1393  ExFreePoolWithTag(NmiData, TAG_KNMI);
1394  return STATUS_SUCCESS;
1395  }
1396 
1397  return STATUS_INVALID_HANDLE;
1398 }
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1686
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:80
UCHAR KIRQL
Definition: env_spec_w32.h:591
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead
Definition: bug.c:29
KIRQL OldIrql
Definition: mm.h:1502
#define TAG_KNMI
Definition: bug.c:31
#define ASSERT(a)
Definition: mode.c:44
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1679
_In_ HANDLE Handle
Definition: extypes.h:390
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ KeEnterKernelDebugger()

VOID NTAPI KeEnterKernelDebugger ( VOID  )

Definition at line 1438 of file bug.c.

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 }
BOOLEAN KdDebuggerEnabled
Definition: kddata.c:83
BOOLEAN KdPitchDebugger
Definition: kddata.c:81
#define DBG_STATUS_FATAL
Definition: kdtypes.h:43
VOID NTAPI KiBugCheckDebugBreak(IN ULONG StatusCode)
Definition: bug.c:490
#define InterlockedDecrement
Definition: armddk.h:52
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
#define NULL
Definition: types.h:112
void __cdecl _disable(void)
Definition: intrin_arm.h:365
signed int * PLONG
Definition: retypes.h:5
ULONG KiHardwareTrigger
Definition: bug.c:25
ULONG KeBugCheckCount
Definition: bug.c:24

◆ KeGetBugMessageText()

BOOLEAN NTAPI KeGetBugMessageText ( IN ULONG  BugCheckCode,
OUT PANSI_STRING OutputString  OPTIONAL 
)

Definition at line 335 of file bug.c.

337 {
338  ULONG i;
339  ULONG IdOffset;
340  PMESSAGE_RESOURCE_ENTRY MessageEntry;
341  PCHAR BugCode;
342  USHORT Length;
343  BOOLEAN Result = FALSE;
344 
345  /* Make sure we're not bugchecking too early */
346  if (!KiBugCodeMessages) return Result;
347 
348  /*
349  * Globally protect in SEH as we are trying to access data in
350  * dire situations, and potentially going to patch it (see below).
351  */
352  _SEH2_TRY
353  {
354 
355  /*
356  * Make the kernel resource section writable, as we are going to manually
357  * trim the trailing newlines in the bugcheck resource message in place,
358  * when OutputString is NULL and before displaying it on screen.
359  */
361 
362  /* Find the message. This code is based on RtlFindMesssage */
363  for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
364  {
365  /* Check if the ID matches */
366  if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
367  (BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
368  {
369  /* Get offset to entry */
370  MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
372  IdOffset = BugCheckCode - KiBugCodeMessages->Blocks[i].LowId;
373 
374  /* Advance in the entries until finding it */
375  while (IdOffset--)
376  {
377  MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
378  ((ULONG_PTR)MessageEntry + MessageEntry->Length);
379  }
380 
381  /* Make sure it's not Unicode */
382  ASSERT(!(MessageEntry->Flags & MESSAGE_RESOURCE_UNICODE));
383 
384  /* Get the final code */
385  BugCode = (PCHAR)MessageEntry->Text;
386  Length = (USHORT)strlen(BugCode);
387 
388  /* Handle trailing newlines */
389  while ((Length > 0) && ((BugCode[Length - 1] == '\n') ||
390  (BugCode[Length - 1] == '\r') ||
391  (BugCode[Length - 1] == ANSI_NULL)))
392  {
393  /* Directly trim the newline in place if we don't return the string */
394  if (!OutputString) BugCode[Length - 1] = ANSI_NULL;
395 
396  /* Skip the trailing newline */
397  Length--;
398  }
399 
400  /* Check if caller wants an output string */
401  if (OutputString)
402  {
403  /* Return it in the OutputString */
404  OutputString->Buffer = BugCode;
405  OutputString->Length = Length;
406  OutputString->MaximumLength = Length;
407  }
408  else
409  {
410  /* Direct output to screen */
411  InbvDisplayString(BugCode);
412  InbvDisplayString("\r");
413  }
414 
415  /* We're done */
416  Result = TRUE;
417  break;
418  }
419  }
420 
421  }
423  {
424  }
425  _SEH2_END;
426 
427  /* Return the result */
428  return Result;
429 }
signed char * PCHAR
Definition: retypes.h:7
#define MESSAGE_RESOURCE_UNICODE
Definition: rtltypes.h:349
Definition: rtltypes.h:1891
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
Definition: bug.c:23
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:569
USHORT Flags
Definition: rtltypes.h:1894
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID NTAPI MmMakeKernelResourceSectionWritable(VOID)
Definition: sysldr.c:2324
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
#define FALSE
Definition: types.h:117
#define ANSI_NULL
unsigned char BOOLEAN
_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
#define PCHAR
Definition: match.c:90
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1895
#define ASSERT(a)
Definition: mode.c:44
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
USHORT Length
Definition: rtltypes.h:1893
_SEH2_END
Definition: create.c:4400
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
unsigned short USHORT
Definition: pedump.c:61
MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY]
Definition: rtltypes.h:1908
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40

Referenced by KiDisplayBlueScreen().

◆ KeInitializeCrashDumpHeader()

NTSTATUS NTAPI KeInitializeCrashDumpHeader ( IN ULONG  Type,
IN ULONG  Flags,
OUT PVOID  Buffer,
IN ULONG  BufferSize,
OUT ULONG BufferNeeded  OPTIONAL 
)

Definition at line 1187 of file bug.c.

1192 {
1193  UNIMPLEMENTED;
1194  return STATUS_UNSUCCESSFUL;
1195 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UNIMPLEMENTED
Definition: debug.h:115

◆ KeRegisterBugCheckCallback()

BOOLEAN NTAPI KeRegisterBugCheckCallback ( IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord,
IN PKBUGCHECK_CALLBACK_ROUTINE  CallbackRoutine,
IN PVOID  Buffer,
IN ULONG  Length,
IN PUCHAR  Component 
)

Definition at line 1257 of file bug.c.

1262 {
1263  KIRQL OldIrql;
1264  BOOLEAN Status = FALSE;
1265 
1266  /* Raise IRQL to High */
1268 
1269  /* Check the Current State first so we don't double-register */
1271  {
1272  /* Set the Callback Settings and insert into the list */
1273  CallbackRecord->Length = Length;
1274  CallbackRecord->Buffer = Buffer;
1279  Status = TRUE;
1280  }
1281 
1282  /* Lower IRQL and return */
1284  return Status;
1285 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
_In_ ULONG Component
Definition: potypes.h:496
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:299
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:18
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39

Referenced by NdisMRegisterAdapterShutdownHandler().

◆ KeRegisterBugCheckReasonCallback()

BOOLEAN NTAPI KeRegisterBugCheckReasonCallback ( IN PKBUGCHECK_REASON_CALLBACK_RECORD  CallbackRecord,
IN PKBUGCHECK_REASON_CALLBACK_ROUTINE  CallbackRoutine,
IN KBUGCHECK_CALLBACK_REASON  Reason,
IN PUCHAR  Component 
)

Definition at line 1292 of file bug.c.

1297 {
1298  KIRQL OldIrql;
1299  BOOLEAN Status = FALSE;
1300 
1301  /* Raise IRQL to High */
1303 
1304  /* Check the Current State first so we don't double-register */
1306  {
1307  /* Set the Callback Settings and insert into the list */
1313  &CallbackRecord->Entry);
1314  Status = TRUE;
1315  }
1316 
1317  /* Lower IRQL and return */
1319  return Status;
1320 }
KBUGCHECK_CALLBACK_REASON Reason
Definition: ketypes.h:302
#define TRUE
Definition: types.h:120
_In_ ULONG Component
Definition: potypes.h:496
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:299
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
LIST_ENTRY KeBugcheckReasonCallbackListHead
Definition: bug.c:19
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47

◆ KeRegisterNmiCallback()

PVOID NTAPI KeRegisterNmiCallback ( IN PNMI_CALLBACK  CallbackRoutine,
IN PVOID  Context 
)

Definition at line 1327 of file bug.c.

1329 {
1330  KIRQL OldIrql;
1331  PKNMI_HANDLER_CALLBACK NmiData, Next;
1333 
1334  /* Allocate NMI callback data */
1335  NmiData = ExAllocatePoolWithTag(NonPagedPool, sizeof(*NmiData), TAG_KNMI);
1336  if (!NmiData) return NULL;
1337 
1338  /* Fill in the information */
1339  NmiData->Callback = CallbackRoutine;
1340  NmiData->Context = Context;
1341  NmiData->Handle = NmiData;
1342 
1343  /* Insert it into NMI callback list */
1345  NmiData->Next = KiNmiCallbackListHead;
1347  NmiData,
1348  NmiData->Next);
1349  ASSERT(Next == NmiData->Next);
1351 
1352  /* Return the opaque "handle" */
1353  return NmiData->Handle;
1354 }
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1686
PNMI_CALLBACK Callback
Definition: ke.h:81
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:80
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ PFLT_GET_OPERATION_STATUS_CALLBACK CallbackRoutine
Definition: fltkernel.h:1035
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead
Definition: bug.c:29
KIRQL OldIrql
Definition: mm.h:1502
#define TAG_KNMI
Definition: bug.c:31
#define ASSERT(a)
Definition: mode.c:44
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1679
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034

Referenced by DriverEntry().

◆ KeRosCaptureUserStackBackTrace()

USHORT NTAPI KeRosCaptureUserStackBackTrace ( IN ULONG  FramesToSkip,
IN ULONG  FramesToCapture,
OUT PVOID BackTrace,
OUT PULONG BackTraceHash  OPTIONAL 
)

Definition at line 155 of file bug.c.

159 {
160  PVOID Frames[2 * 64];
161  ULONG FrameCount;
162  ULONG Hash = 0, i;
163 
164  /* Skip a frame for the caller */
165  FramesToSkip++;
166 
167  /* Don't go past the limit */
168  if ((FramesToCapture + FramesToSkip) >= 128) return 0;
169 
170  /* Do the back trace */
171  FrameCount = RtlWalkFrameChain(Frames, FramesToCapture + FramesToSkip, 1);
172 
173  /* Make sure we're not skipping all of them */
174  if (FrameCount <= FramesToSkip) return 0;
175 
176  /* Loop all the frames */
177  for (i = 0; i < FramesToCapture; i++)
178  {
179  /* Don't go past the limit */
180  if ((FramesToSkip + i) >= FrameCount) break;
181 
182  /* Save this entry and hash it */
183  BackTrace[i] = Frames[FramesToSkip + i];
184  Hash += PtrToUlong(BackTrace[i]);
185  }
186 
187  /* Write the hash */
189 
190  /* Clear the other entries and return count */
191  RtlFillMemoryUlong(Frames, 128, 0);
192  return (USHORT)i;
193 }
static int Hash(const char *)
Definition: reader.c:2257
_In_ ULONG FramesToCapture
_In_ ULONG _Out_opt_ PULONG BackTraceHash
#define PtrToUlong(u)
Definition: config.h:107
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
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
unsigned short USHORT
Definition: pedump.c:61
ULONG NTAPI RtlWalkFrameChain(OUT PVOID *Callers, IN ULONG Count, IN ULONG Flags)
Definition: libsupp.c:227
unsigned int ULONG
Definition: retypes.h:1

Referenced by KeRosDumpStackFrames().

◆ KeRosDumpStackFrameArray()

VOID FASTCALL KeRosDumpStackFrameArray ( IN PULONG_PTR  Frames,
IN ULONG  FrameCount 
)

Definition at line 198 of file bug.c.

200 {
201  ULONG i;
202  ULONG_PTR Addr;
203  BOOLEAN InSystem;
204  PVOID p;
205 
206  /* GCC complaints that it may be used uninitialized */
207  PLDR_DATA_TABLE_ENTRY LdrEntry = NULL;
208 
209  /* Loop them */
210  for (i = 0; i < FrameCount; i++)
211  {
212  /* Get the EIP */
213  Addr = Frames[i];
214  if (!Addr)
215  {
216  break;
217  }
218 
219  /* Get the base for this file */
220  if (Addr > (ULONG_PTR)MmHighestUserAddress)
221  {
222  /* We are in kernel */
223  p = KiPcToFileHeader((PVOID)Addr, &LdrEntry, FALSE, &InSystem);
224  }
225  else
226  {
227  /* We are in user land */
228  p = KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry);
229  }
230  if (p)
231  {
232 #ifdef KDBG
233  if (!KdbSymPrintAddress((PVOID)Addr, NULL))
234 #endif
235  {
236  CHAR AnsiName[64];
237 
238  /* Convert module name to ANSI and print it */
240  AnsiName,
241  sizeof(AnsiName));
242  Addr -= (ULONG_PTR)LdrEntry->DllBase;
243  DbgPrint("<%s: %p>", AnsiName, (PVOID)Addr);
244  }
245  }
246  else
247  {
248  /* Print only the address */
249  DbgPrint("<%p>", (PVOID)Addr);
250  }
251 
252  /* Go to the next frame */
253  DbgPrint("\n");
254  }
255 }
BOOLEAN KdbSymPrintAddress(IN PVOID Address, IN PCONTEXT Context)
Print address...
Definition: kdb_symbols.c:148
#define DbgPrint
Definition: hal.h:12
char CHAR
Definition: xmlstorage.h:175
PVOID NTAPI KiRosPcToUserFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
Definition: bug.c:106
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1926
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
PVOID NTAPI KiPcToFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:41
Definition: btrfs_drv.h:1922
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
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:515
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define NULL
Definition: types.h:112
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by KeRosDumpStackFrames().

◆ KeRosDumpStackFrames()

VOID NTAPI KeRosDumpStackFrames ( IN PULONG_PTR Frame  OPTIONAL,
IN ULONG FrameCount  OPTIONAL 
)

Definition at line 259 of file bug.c.

261 {
262  ULONG_PTR Frames[32];
263  ULONG RealFrameCount;
264 
265  /* If the caller didn't ask, assume 32 frames */
266  if (!FrameCount || FrameCount > 32) FrameCount = 32;
267 
268  if (Frame)
269  {
270  /* Dump them */
271  KeRosDumpStackFrameArray(Frame, FrameCount);
272  }
273  else
274  {
275  /* Get the current frames (skip the two. One for the dumper, one for the caller) */
276  RealFrameCount = RtlCaptureStackBackTrace(2, FrameCount, (PVOID*)Frames, NULL);
277  DPRINT1("RealFrameCount =%lu\n", RealFrameCount);
278 
279  /* Dump them */
280  KeRosDumpStackFrameArray(Frames, RealFrameCount);
281 
282  /* Count left for user mode? */
283  if (FrameCount - RealFrameCount > 0)
284  {
285  /* Get the current frames */
286  RealFrameCount = KeRosCaptureUserStackBackTrace(-1, FrameCount - RealFrameCount, (PVOID*)Frames, NULL);
287 
288  /* Dump them */
289  KeRosDumpStackFrameArray(Frames, RealFrameCount);
290  }
291  }
292 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
USHORT NTAPI KeRosCaptureUserStackBackTrace(IN ULONG FramesToSkip, IN ULONG FramesToCapture, OUT PVOID *BackTrace, OUT PULONG BackTraceHash OPTIONAL)
Definition: bug.c:155
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI USHORT NTAPI RtlCaptureStackBackTrace(_In_ ULONG FramesToSkip, _In_ ULONG FramesToCapture, _Out_writes_to_(FramesToCapture, return) PVOID *BackTrace, _Out_opt_ PULONG BackTraceHash)
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL KeRosDumpStackFrameArray(IN PULONG_PTR Frames, IN ULONG FrameCount)
Definition: bug.c:198

◆ KiBugCheckDebugBreak()

VOID NTAPI KiBugCheckDebugBreak ( IN ULONG  StatusCode)

Definition at line 490 of file bug.c.

491 {
492  /*
493  * Wrap this in SEH so we don't crash if
494  * there is no debugger or if it disconnected
495  */
496 DoBreak:
497  _SEH2_TRY
498  {
499  /* Breakpoint */
500  DbgBreakPointWithStatus(StatusCode);
501  }
503  {
504  /* No debugger, halt the CPU */
505  HalHaltSystem();
506  }
507  _SEH2_END;
508 
509  /* Break again if this wasn't first try */
510  if (StatusCode != DBG_STATUS_BUGCHECK_FIRST) goto DoBreak;
511 }
#define DBG_STATUS_BUGCHECK_FIRST
Definition: kdtypes.h:41
_SEH2_TRY
Definition: create.c:4226
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define HalHaltSystem
Definition: halfuncs.h:43
_SEH2_END
Definition: create.c:4400
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KiDisplayBlueScreen()

VOID NTAPI KiDisplayBlueScreen ( IN ULONG  MessageId,
IN BOOLEAN  IsHardError,
IN PCHAR HardErrCaption  OPTIONAL,
IN PCHAR HardErrMessage  OPTIONAL,
IN PCHAR  Message 
)

Definition at line 609 of file bug.c.

614 {
615  CHAR AnsiName[75];
616 
617  /* Check if bootvid is installed */
619  {
620  /* Acquire ownership and reset the display */
623 
624  /* Display blue screen */
630  }
631 
632  /* Check if this is a hard error */
633  if (IsHardError)
634  {
635  /* Display caption and message */
636  if (HardErrCaption) InbvDisplayString(HardErrCaption);
637  if (HardErrMessage) InbvDisplayString(HardErrMessage);
638  }
639 
640  /* Begin the display */
641  InbvDisplayString("\r\n");
642 
643  /* Print out initial message */
644  KeGetBugMessageText(BUGCHECK_MESSAGE_INTRO, NULL);
645  InbvDisplayString("\r\n\r\n");
646 
647  /* Check if we have a driver */
648  if (KiBugCheckDriver)
649  {
650  /* Print out into to driver name */
651  KeGetBugMessageText(BUGCODE_ID_DRIVER, NULL);
652 
653  /* Convert and print out driver name */
654  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
655  InbvDisplayString(" ");
656  InbvDisplayString(AnsiName);
657  InbvDisplayString("\r\n\r\n");
658  }
659 
660  /* Check if this is the generic message */
661  if (MessageId == BUGCODE_PSS_MESSAGE)
662  {
663  /* It is, so get the bug code string as well */
665  InbvDisplayString("\r\n\r\n");
666  }
667 
668  /* Print second introduction message */
669  KeGetBugMessageText(PSS_MESSAGE_INTRO, NULL);
670  InbvDisplayString("\r\n\r\n");
671 
672  /* Get the bug code string */
673  KeGetBugMessageText(MessageId, NULL);
674  InbvDisplayString("\r\n\r\n");
675 
676  /* Print message for technical information */
677  KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
678 
679  /* Show the technical Data */
680  sprintf(AnsiName,
681  "\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
682  (ULONG)KiBugCheckData[0],
683  (PVOID)KiBugCheckData[1],
684  (PVOID)KiBugCheckData[2],
685  (PVOID)KiBugCheckData[3],
686  (PVOID)KiBugCheckData[4]);
687  InbvDisplayString(AnsiName);
688 
689  /* Check if we have a driver*/
690  if (KiBugCheckDriver)
691  {
692  /* Display technical driver data */
694  }
695  else
696  {
697  /* Dump parameter information */
699  (PVOID)&KiBugCheckData[1],
700  4,
702  }
703 }
BOOLEAN NTAPI KeGetBugMessageText(IN ULONG BugCheckCode, OUT PANSI_STRING OutputString OPTIONAL)
Definition: bug.c:335
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:26
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:569
char CHAR
Definition: xmlstorage.h:175
#define SCREEN_WIDTH
Definition: pc98video.c:27
ULONG_PTR KiBugCheckData[5]
Definition: bug.c:27
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:716
#define BV_COLOR_WHITE
Definition: display.h:30
#define BV_COLOR_BLUE
Definition: display.h:19
#define sprintf(buf, format,...)
Definition: sprintf.c:55
VOID NTAPI KiDumpParameterImages(IN PCHAR Message, IN PULONG_PTR Parameters, IN ULONG ParameterCount, IN PKE_BUGCHECK_UNICODE_TO_ANSI ConversionRoutine)
Definition: bug.c:539
VOID NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:692
#define SCREEN_HEIGHT
Definition: pc98video.c:28
CHAR Message[80]
Definition: alive.c:5
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:528
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:606
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:630
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:664
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:515
#define NULL
Definition: types.h:112
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:622
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI InbvSetScrollRegion(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom)
Definition: inbv.c:681

Referenced by KeBugCheckWithTf().

◆ KiDoBugCheckCallbacks()

VOID NTAPI KiDoBugCheckCallbacks ( VOID  )

Definition at line 433 of file bug.c.

434 {
435  PKBUGCHECK_CALLBACK_RECORD CurrentRecord;
436  PLIST_ENTRY ListHead, NextEntry, LastEntry;
437  ULONG_PTR Checksum;
438 
439  /* First make sure that the list is initialized... it might not be */
440  ListHead = &KeBugcheckCallbackListHead;
441  if ((!ListHead->Flink) || (!ListHead->Blink))
442  return;
443 
444  /* Loop the list */
445  LastEntry = ListHead;
446  NextEntry = ListHead->Flink;
447  while (NextEntry != ListHead)
448  {
449  /* Get the reord */
450  CurrentRecord = CONTAINING_RECORD(NextEntry,
452  Entry);
453 
454  /* Validate it */
455  // TODO/FIXME: Check whether the memory CurrentRecord points to
456  // is still accessible and valid!
457  if (CurrentRecord->Entry.Blink != LastEntry) return;
458  Checksum = (ULONG_PTR)CurrentRecord->CallbackRoutine;
459  Checksum += (ULONG_PTR)CurrentRecord->Buffer;
460  Checksum += (ULONG_PTR)CurrentRecord->Length;
461  Checksum += (ULONG_PTR)CurrentRecord->Component;
462 
463  /* Make sure it's inserted and validated */
464  if ((CurrentRecord->State == BufferInserted) &&
465  (CurrentRecord->Checksum == Checksum))
466  {
467  /* Call the routine */
468  CurrentRecord->State = BufferStarted;
469  _SEH2_TRY
470  {
471  (CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer,
472  CurrentRecord->Length);
473  CurrentRecord->State = BufferFinished;
474  }
476  {
477  CurrentRecord->State = BufferIncomplete;
478  }
479  _SEH2_END;
480  }
481 
482  /* Go to the next entry */
483  LastEntry = NextEntry;
484  NextEntry = NextEntry->Flink;
485  }
486 }
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:324
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
Definition: typedefs.h:119
_SEH2_END
Definition: create.c:4400
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:18
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
base of all file and directory entries
Definition: entries.h:82

Referenced by KeBugCheckWithTf().

◆ KiDumpParameterImages()

VOID NTAPI KiDumpParameterImages ( IN PCHAR  Message,
IN PULONG_PTR  Parameters,
IN ULONG  ParameterCount,
IN PKE_BUGCHECK_UNICODE_TO_ANSI  ConversionRoutine 
)

Definition at line 539 of file bug.c.

543 {
544  ULONG i;
545  BOOLEAN InSystem;
546  PLDR_DATA_TABLE_ENTRY LdrEntry;
547  PVOID ImageBase;
548  PUNICODE_STRING DriverName;
549  CHAR AnsiName[32];
550  PIMAGE_NT_HEADERS NtHeader;
552  BOOLEAN FirstRun = TRUE;
553 
554  /* Loop parameters */
555  for (i = 0; i < ParameterCount; i++)
556  {
557  /* Get the base for this parameter */
558  ImageBase = KiPcToFileHeader((PVOID)Parameters[i],
559  &LdrEntry,
560  FALSE,
561  &InSystem);
562  if (!ImageBase)
563  {
564  /* FIXME: Add code to check for unloaded drivers */
565  DPRINT1("Potentially unloaded driver!\n");
566  continue;
567  }
568  else
569  {
570  /* Get the NT Headers and Timestamp */
571  NtHeader = RtlImageNtHeader(LdrEntry->DllBase);
572  TimeStamp = NtHeader->FileHeader.TimeDateStamp;
573 
574  /* Convert the driver name */
575  DriverName = &LdrEntry->BaseDllName;
576  ConversionRoutine(&LdrEntry->BaseDllName,
577  AnsiName,
578  sizeof(AnsiName));
579  }
580 
581  /* Format driver name */
583  "%s** %12s - Address %p base at %p, DateStamp %08lx\r\n",
584  FirstRun ? "\r\n*":"*",
585  AnsiName,
586  (PVOID)Parameters[i],
587  ImageBase,
588  TimeStamp);
589 
590  /* Check if we only had one parameter */
591  if (ParameterCount <= 1)
592  {
593  /* Then just save the name */
594  KiBugCheckDriver = DriverName;
595  }
596  else
597  {
598  /* Otherwise, display the message */
600  }
601 
602  /* Loop again */
603  FirstRun = FALSE;
604  }
605 }
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:26
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:863
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:569
char CHAR
Definition: xmlstorage.h:175
PVOID DllBase
Definition: btrfs_drv.h:1926
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
PVOID NTAPI KiPcToFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:41
CHAR Message[80]
Definition: alive.c:5
Definition: btrfs_drv.h:1922
SECURITY_INTEGER TimeStamp
Definition: sspi.h:78
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
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:665
unsigned int ULONG
Definition: retypes.h:1

Referenced by KeBugCheckWithTf(), and KiDisplayBlueScreen().

◆ KiHandleNmi()

BOOLEAN NTAPI KiHandleNmi ( VOID  )

Definition at line 1162 of file bug.c.

1163 {
1164  BOOLEAN Handled = FALSE;
1165  PKNMI_HANDLER_CALLBACK NmiData;
1166 
1167  /* Parse the list of callbacks */
1168  NmiData = KiNmiCallbackListHead;
1169  while (NmiData)
1170  {
1171  /* Save if this callback has handled it -- all it takes is one */
1172  Handled |= NmiData->Callback(NmiData->Context, Handled);
1173  NmiData = NmiData->Next;
1174  }
1175 
1176  /* Has anyone handled this? */
1177  return Handled;
1178 }
PNMI_CALLBACK Callback
Definition: ke.h:81
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:80
#define FALSE
Definition: types.h:117
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead
Definition: bug.c:29
unsigned char BOOLEAN
_In_ BOOLEAN Handled
Definition: ketypes.h:337

Referenced by KiTrap02Handler().

◆ KiInitializeBugCheck()

VOID NTAPI KiInitializeBugCheck ( VOID  )

Definition at line 297 of file bug.c.

298 {
300  LDR_RESOURCE_INFO ResourceInfo;
301  PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
303  PLDR_DATA_TABLE_ENTRY LdrEntry;
304 
305  /* Get the kernel entry */
308  InLoadOrderLinks);
309 
310  /* Cache the Bugcheck Message Strings. Prepare the Lookup Data */
311  ResourceInfo.Type = 11;
312  ResourceInfo.Name = 1;
313  ResourceInfo.Language = 9;
314 
315  /* Do the lookup. */
316  Status = LdrFindResource_U(LdrEntry->DllBase,
317  &ResourceInfo,
319  &ResourceDataEntry);
320 
321  /* Make sure it worked */
322  if (NT_SUCCESS(Status))
323  {
324  /* Now actually get a pointer to it */
325  Status = LdrAccessResource(LdrEntry->DllBase,
326  ResourceDataEntry,
327  (PVOID*)&BugCheckData,
328  NULL);
330  }
331 }
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
Definition: bug.c:23
LONG NTSTATUS
Definition: precomp.h:26
ULONG_PTR Type
Definition: ldrtypes.h:181
PVOID DllBase
Definition: btrfs_drv.h:1926
ULONG_PTR Name
Definition: ldrtypes.h:182
Definition: pedump.c:457
NTSTATUS NTAPI LdrFindResource_U(_In_ PVOID BaseAddress, _In_ PLDR_RESOURCE_INFO ResourceInfo, _In_ ULONG Level, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry)
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
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
NTSTATUS NTAPI LdrAccessResource(_In_ PVOID BaseAddress, _In_ PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry, _Out_opt_ PVOID *Resource, _Out_opt_ PULONG Size)
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static tBugCheckData BugCheckData
Definition: btrfs_drv.h:1922
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
#define RESOURCE_DATA_LEVEL
Definition: ldrtypes.h:33
#define NULL
Definition: types.h:112
ULONG_PTR Language
Definition: ldrtypes.h:183

Referenced by ExpInitializeExecutive().

◆ KiPcToFileHeader()

PVOID NTAPI KiPcToFileHeader ( IN PVOID  Pc,
OUT PLDR_DATA_TABLE_ENTRY LdrEntry,
IN BOOLEAN  DriversOnly,
OUT PBOOLEAN  InKernel 
)

Definition at line 41 of file bug.c.

45 {
46  ULONG i = 0;
47  PVOID ImageBase, PcBase = NULL;
49  PLIST_ENTRY ListHead, NextEntry;
50 
51  /* Check which list we should use */
54 
55  /* Assume no */
56  *InKernel = FALSE;
57 
58  /* Set list pointers and make sure it's valid */
59  NextEntry = ListHead->Flink;
60  if (NextEntry)
61  {
62  /* Start loop */
63  while (NextEntry != ListHead)
64  {
65  /* Increase entry */
66  i++;
67 
68  /* Check if this is a kernel entry and we only want drivers */
69  if ((i <= 2) && (DriversOnly != FALSE))
70  {
71  /* Skip it */
72  NextEntry = NextEntry->Flink;
73  continue;
74  }
75 
76  /* Get the loader entry */
77  Entry = CONTAINING_RECORD(NextEntry,
79  InLoadOrderLinks);
80 
81  /* Move to the next entry */
82  NextEntry = NextEntry->Flink;
83  ImageBase = Entry->DllBase;
84 
85  /* Check if this is the right one */
86  if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
87  ((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
88  {
89  /* Return this entry */
90  *LdrEntry = Entry;
91  PcBase = ImageBase;
92 
93  /* Check if this was a kernel or HAL entry */
94  if (i <= 2) *InKernel = TRUE;
95  break;
96  }
97  }
98  }
99 
100  /* Return the base address */
101  return PcBase;
102 }
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
if(dx==0 &&dy==0)
Definition: linetemp.h:174
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
Definition: btrfs_drv.h:1922
Definition: typedefs.h:119
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
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
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82

Referenced by KeBugCheckWithTf(), KeRosDumpStackFrameArray(), KiDumpParameterImages(), and RtlPcToFileHeader().

◆ KiRosPcToUserFileHeader()

PVOID NTAPI KiRosPcToUserFileHeader ( IN PVOID  Pc,
OUT PLDR_DATA_TABLE_ENTRY LdrEntry 
)

Definition at line 106 of file bug.c.

108 {
109  PVOID ImageBase, PcBase = NULL;
111  PLIST_ENTRY ListHead, NextEntry;
112 
113  /*
114  * We know this is valid because we should only be called after a
115  * succesfull address from RtlWalkFrameChain for UserMode, which
116  * validates everything for us.
117  */
118  ListHead = &KeGetCurrentThread()->
119  Teb->ProcessEnvironmentBlock->Ldr->InLoadOrderModuleList;
120 
121  /* Set list pointers and make sure it's valid */
122  NextEntry = ListHead->Flink;
123  if (NextEntry)
124  {
125  /* Start loop */
126  while (NextEntry != ListHead)
127  {
128  /* Get the loader entry */
129  Entry = CONTAINING_RECORD(NextEntry,
131  InLoadOrderLinks);
132 
133  /* Move to the next entry */
134  NextEntry = NextEntry->Flink;
135  ImageBase = Entry->DllBase;
136 
137  /* Check if this is the right one */
138  if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
139  ((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
140  {
141  /* Return this entry */
142  *LdrEntry = Entry;
143  PcBase = ImageBase;
144  break;
145  }
146  }
147  }
148 
149  /* Return the base address */
150  return PcBase;
151 }
struct _Entry Entry
Definition: kefuncs.h:627
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: btrfs_drv.h:1922
Definition: typedefs.h:119
#define NULL
Definition: types.h:112
#define KeGetCurrentThread
Definition: hal.h:55
base of all file and directory entries
Definition: entries.h:82

Referenced by KeRosDumpStackFrameArray().

Variable Documentation

◆ BugCheckCallbackLock

KSPIN_LOCK BugCheckCallbackLock

Definition at line 20 of file bug.c.

Referenced by KiInitializeKernel(), and KiInitSystem().

◆ KeBugCheckActive

ULONG KeBugCheckActive

Definition at line 21 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugcheckCallbackListHead

LIST_ENTRY KeBugcheckCallbackListHead

◆ KeBugCheckCount

ULONG KeBugCheckCount = 1

Definition at line 24 of file bug.c.

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KeBugCheckOwner

ULONG KeBugCheckOwner

Definition at line 21 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugCheckOwnerRecursionCount

LONG KeBugCheckOwnerRecursionCount

Definition at line 22 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugcheckReasonCallbackListHead

LIST_ENTRY KeBugcheckReasonCallbackListHead

Definition at line 19 of file bug.c.

Referenced by KeRegisterBugCheckReasonCallback(), KiInitializeKernel(), and KiInitSystem().

◆ KeRosBiosDate

UNICODE_STRING KeRosBiosDate

Definition at line 34 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosBiosVersion

UNICODE_STRING KeRosBiosVersion

Definition at line 34 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosProcessorName

UNICODE_STRING KeRosProcessorName

Definition at line 34 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosVideoBiosDate

UNICODE_STRING KeRosVideoBiosDate

Definition at line 35 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosVideoBiosVersion

UNICODE_STRING KeRosVideoBiosVersion

Definition at line 35 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KiBugCheckData

◆ KiBugCheckDriver

PUNICODE_STRING KiBugCheckDriver

Definition at line 26 of file bug.c.

Referenced by KeBugCheckWithTf(), KiDisplayBlueScreen(), and KiDumpParameterImages().

◆ KiBugCodeMessages

PMESSAGE_RESOURCE_DATA KiBugCodeMessages

Definition at line 23 of file bug.c.

Referenced by KeGetBugMessageText(), and KiInitializeBugCheck().

◆ KiHardwareTrigger

ULONG KiHardwareTrigger

Definition at line 25 of file bug.c.

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KiNmiCallbackListHead

PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead = NULL

Definition at line 29 of file bug.c.

Referenced by KeDeregisterNmiCallback(), KeRegisterNmiCallback(), and KiHandleNmi().

◆ KiNmiCallbackListLock

KSPIN_LOCK KiNmiCallbackListLock

Definition at line 30 of file bug.c.

Referenced by KiAcquireNmiListLock(), and KiReleaseNmiListLock().