ReactOS  0.4.14-dev-593-g1793dcc
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 KeRosDumpTriageForBugZillaReport (VOID)
 
VOID INIT_FUNCTION 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)
 
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)
 
VOID NTAPI KeBugCheckEx (IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
 
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 12 of file bug.c.

◆ TAG_KNMI

#define TAG_KNMI   'IMNK'

Definition at line 34 of file bug.c.

Function Documentation

◆ KeBugCheck()

VOID NTAPI KeBugCheck ( ULONG  BugCheckCode)

Definition at line 1507 of file bug.c.

1508 {
1509  /* Call the internal API */
1510  KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
1511 }
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:778
smooth NULL
Definition: ftsmooth.c:416

Referenced by abort(), CcInitCacheZeroPage(), CcpDereferenceCache(), CcReadVirtualAddress(), CcRosMapVacbInKernelSpace(), CcRosMarkDirtyFile(), CcRosRequestVacb(), CcScheduleReadAhead(), CcWriteVirtualAddress(), ClassSendStartUnit(), ExeFmtpReadFile(), ExInitSystem(), ExpInitializeExecutive(), ExpInitNls(), FsRtlCreateSectionForDataScan(), HalpAssignPCISlotResources(), HalpInitializeTsc(), i8042KbdInterruptService(), KdbEnterDebuggerException(), KeDetachProcess(), Kei386EoiHelper(), KeRaiseIrqlToDpcLevel(), KeUnstackDetachProcess(), KeWaitForMultipleObjects(), KfLowerIrql(), KfRaiseIrql(), KiDispatchException(), KiInitializeCpu(), KiSetAffinityThread(), KiSystemStartupBootStack(), KiThreadStartup(), KiUnexpectedInterrupt(), MiBalancerThread(), MiInitBalancerThread(), MiReadPageFile(), MiRosUnmapViewOfSection(), MiTrimMemoryConsumer(), MmAccessFaultSectionView(), MmAllocPage(), MmAllocSwapPage(), MmCreatePageFileMapping(), MmCreatePhysicalMemorySection(), MmCreateVirtualMapping(), MmCreateVirtualMappingUnsafe(), MmDeleteAllRmaps(), MmDeletePageFileMapping(), MmDeleteRmap(), MmFreeSectionPage(), MmFreeSectionSegments(), MmFreeSwapPage(), MmGetPageTableForProcess(), MmInsertRmap(), MmNotPresentFaultCachePage(), MmNotPresentFaultSectionView(), MmPageOutPhysicalAddress(), MmPageOutSectionView(), MmpPageOutPhysicalAddress(), MmReleasePageMemoryConsumer(), MmRequestPageMemoryConsumer(), MmSetCleanAllRmaps(), MmSetCleanPage(), MmSetDirtyAllRmaps(), MmSetDirtyPage(), MmSetPageProtect(), MmSharePageEntrySectionSegment(), MmspPageAlignSegments(), MmUnsharePageEntrySectionSegment(), MmWritePageSectionView(), MmWriteToSwapPage(), MupDereferenceMasterQueryContext(), Phase1InitializationDiscard(), PpInitSystem(), ProtectToPTE(), PspDeleteProcess(), PspDeleteThread(), PspSystemThreadStartup(), RawDispatch(), ScsiClassReleaseQueue(), TdiAddressSizeFromType(), USBCCGP_PDOSelectConfiguration(), UserProcessCreate(), VfatReadFileData(), VfatWriteFileData(), and xHalIoAssignDriveLetters().

◆ KeBugCheckEx()

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 1487 of file bug.c.

1492 {
1493  /* Call the internal API */
1494  KeBugCheckWithTf(BugCheckCode,
1495  BugCheckParameter1,
1496  BugCheckParameter2,
1497  BugCheckParameter3,
1498  BugCheckParameter4,
1499  NULL);
1500 }
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:778
smooth NULL
Definition: ftsmooth.c:416

◆ KeBugCheckUnicodeToAnsi()

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

Definition at line 586 of file bug.c.

589 {
590  PCHAR p;
591  PWCHAR pw;
592  ULONG i;
593 
594  /* Set length and normalize it */
595  i = Unicode->Length / sizeof(WCHAR);
596  i = min(i, Length - 1);
597 
598  /* Set source and destination, and copy */
599  pw = Unicode->Buffer;
600  p = Ansi;
601  while (i--) *p++ = (CHAR)*pw++;
602 
603  /* Null terminate and return */
604  *p = ANSI_NULL;
605  return Ansi;
606 }
signed char * PCHAR
Definition: retypes.h:7
uint16_t * PWCHAR
Definition: typedefs.h:54
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 ANSI_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#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()

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 778 of file bug.c.

784 {
785  PKPRCB Prcb = KeGetCurrentPrcb();
787  ULONG MessageId;
788  CHAR AnsiName[128];
789  BOOLEAN IsSystem, IsHardError = FALSE, Reboot = FALSE;
790  PCHAR HardErrCaption = NULL, HardErrMessage = NULL;
791  PVOID Pc = NULL, Memory;
792  PVOID DriverBase;
793  PLDR_DATA_TABLE_ENTRY LdrEntry;
794  PULONG_PTR HardErrorParameters;
795  KIRQL OldIrql;
796 #ifdef CONFIG_SMP
797  LONG i = 0;
798 #endif
799 
800  /* Set active bugcheck */
803 
804  /* Check if this is power failure simulation */
805  if (BugCheckCode == POWER_FAILURE_SIMULATE)
806  {
807  /* Call the Callbacks and reboot */
810  }
811 
812  /* Save the IRQL and set hardware trigger */
815 
816  /* Capture the CPU Context */
820 
821  /* FIXME: Call the Watchdog if it's registered */
822 
823  /* Check which bugcode this is */
824  switch (BugCheckCode)
825  {
826  /* These bug checks already have detailed messages, keep them */
827  case UNEXPECTED_KERNEL_MODE_TRAP:
828  case DRIVER_CORRUPTED_EXPOOL:
829  case ACPI_BIOS_ERROR:
830  case ACPI_BIOS_FATAL_ERROR:
831  case THREAD_STUCK_IN_DEVICE_DRIVER:
832  case DATA_BUS_ERROR:
833  case FAT_FILE_SYSTEM:
834  case NO_MORE_SYSTEM_PTES:
835  case INACCESSIBLE_BOOT_DEVICE:
836 
837  /* Keep the same code */
838  MessageId = BugCheckCode;
839  break;
840 
841  /* Check if this is a kernel-mode exception */
842  case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
843  case SYSTEM_THREAD_EXCEPTION_NOT_HANDLED:
844  case KMODE_EXCEPTION_NOT_HANDLED:
845 
846  /* Use the generic text message */
847  MessageId = KMODE_EXCEPTION_NOT_HANDLED;
848  break;
849 
850  /* File-system errors */
851  case NTFS_FILE_SYSTEM:
852 
853  /* Use the generic message for FAT */
854  MessageId = FAT_FILE_SYSTEM;
855  break;
856 
857  /* Check if this is a coruption of the Mm's Pool */
858  case DRIVER_CORRUPTED_MMPOOL:
859 
860  /* Use generic corruption message */
861  MessageId = DRIVER_CORRUPTED_EXPOOL;
862  break;
863 
864  /* Check if this is a signature check failure */
866 
867  /* Use the generic corruption message */
868  MessageId = BUGCODE_PSS_MESSAGE_SIGNATURE;
869  break;
870 
871  /* All other codes */
872  default:
873 
874  /* Use the default bugcheck message */
875  MessageId = BUGCODE_PSS_MESSAGE;
876  break;
877  }
878 
879  /* Save bugcheck data */
880  KiBugCheckData[0] = BugCheckCode;
881  KiBugCheckData[1] = BugCheckParameter1;
882  KiBugCheckData[2] = BugCheckParameter2;
883  KiBugCheckData[3] = BugCheckParameter3;
884  KiBugCheckData[4] = BugCheckParameter4;
885 
886  /* Now check what bugcheck this is */
887  switch (BugCheckCode)
888  {
889  /* Invalid access to R/O memory or Unhandled KM Exception */
890  case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
891  case ATTEMPTED_WRITE_TO_READONLY_MEMORY:
892  case ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY:
893  {
894  /* Check if we have a trap frame */
895  if (!TrapFrame)
896  {
897  /* Use parameter 3 as a trap frame, if it exists */
898  if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
899  }
900 
901  /* Check if we got one now and if we need to get the Program Counter */
902  if ((TrapFrame) &&
903  (BugCheckCode != KERNEL_MODE_EXCEPTION_NOT_HANDLED))
904  {
905  /* Get the Program Counter */
906  Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
907  }
908  break;
909  }
910 
911  /* Wrong IRQL */
912  case IRQL_NOT_LESS_OR_EQUAL:
913  {
914  /*
915  * The NT kernel has 3 special sections:
916  * MISYSPTE, POOLMI and POOLCODE. The bug check code can
917  * determine in which of these sections this bugcode happened
918  * and provide a more detailed analysis. For now, we don't.
919  */
920 
921  /* Program Counter is in parameter 4 */
922  Pc = (PVOID)BugCheckParameter4;
923 
924  /* Get the driver base */
925  DriverBase = KiPcToFileHeader(Pc,
926  &LdrEntry,
927  FALSE,
928  &IsSystem);
929  if (IsSystem)
930  {
931  /*
932  * The error happened inside the kernel or HAL.
933  * Get the memory address that was being referenced.
934  */
935  Memory = (PVOID)BugCheckParameter1;
936 
937  /* Find to which driver it belongs */
938  DriverBase = KiPcToFileHeader(Memory,
939  &LdrEntry,
940  TRUE,
941  &IsSystem);
942  if (DriverBase)
943  {
944  /* Get the driver name and update the bug code */
945  KiBugCheckDriver = &LdrEntry->BaseDllName;
946  KiBugCheckData[0] = DRIVER_PORTION_MUST_BE_NONPAGED;
947  }
948  else
949  {
950  /* Find the driver that unloaded at this address */
951  KiBugCheckDriver = NULL; // FIXME: ROS can't locate
952 
953  /* Check if the cause was an unloaded driver */
954  if (KiBugCheckDriver)
955  {
956  /* Update bug check code */
957  KiBugCheckData[0] =
958  SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD;
959  }
960  }
961  }
962  else
963  {
964  /* Update the bug check code */
965  KiBugCheckData[0] = DRIVER_IRQL_NOT_LESS_OR_EQUAL;
966  }
967 
968  /* Clear Pc so we don't look it up later */
969  Pc = NULL;
970  break;
971  }
972 
973  /* Hard error */
974  case FATAL_UNHANDLED_HARD_ERROR:
975  {
976  /* Copy bug check data from hard error */
977  HardErrorParameters = (PULONG_PTR)BugCheckParameter2;
978  KiBugCheckData[0] = BugCheckParameter1;
979  KiBugCheckData[1] = HardErrorParameters[0];
980  KiBugCheckData[2] = HardErrorParameters[1];
981  KiBugCheckData[3] = HardErrorParameters[2];
982  KiBugCheckData[4] = HardErrorParameters[3];
983 
984  /* Remember that this is hard error and set the caption/message */
985  IsHardError = TRUE;
986  HardErrCaption = (PCHAR)BugCheckParameter3;
987  HardErrMessage = (PCHAR)BugCheckParameter4;
988  break;
989  }
990 
991  /* Page fault */
992  case PAGE_FAULT_IN_NONPAGED_AREA:
993  {
994  /* Assume no driver */
995  DriverBase = NULL;
996 
997  /* Check if we have a trap frame */
998  if (!TrapFrame)
999  {
1000  /* We don't, use parameter 3 if possible */
1001  if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
1002  }
1003 
1004  /* Check if we have a frame now */
1005  if (TrapFrame)
1006  {
1007  /* Get the Program Counter */
1008  Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
1009  KiBugCheckData[3] = (ULONG_PTR)Pc;
1010 
1011  /* Find out if was in the kernel or drivers */
1012  DriverBase = KiPcToFileHeader(Pc,
1013  &LdrEntry,
1014  FALSE,
1015  &IsSystem);
1016  }
1017  else
1018  {
1019  /* Can't blame a driver, assume system */
1020  IsSystem = TRUE;
1021  }
1022 
1023  /* FIXME: Check for session pool in addition to special pool */
1024 
1025  /* Special pool has its own bug check codes */
1026  if (MmIsSpecialPoolAddress((PVOID)BugCheckParameter1))
1027  {
1028  if (MmIsSpecialPoolAddressFree((PVOID)BugCheckParameter1))
1029  {
1030  KiBugCheckData[0] = IsSystem
1031  ? PAGE_FAULT_IN_FREED_SPECIAL_POOL
1032  : DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL;
1033  }
1034  else
1035  {
1036  KiBugCheckData[0] = IsSystem
1037  ? PAGE_FAULT_BEYOND_END_OF_ALLOCATION
1038  : DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION;
1039  }
1040  }
1041  else if (!DriverBase)
1042  {
1043  /* Find the driver that unloaded at this address */
1044  KiBugCheckDriver = NULL; // FIXME: ROS can't locate
1045 
1046  /* Check if the cause was an unloaded driver */
1047  if (KiBugCheckDriver)
1048  {
1049  KiBugCheckData[0] =
1050  DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS;
1051  }
1052  }
1053  break;
1054  }
1055 
1056  /* Check if the driver forgot to unlock pages */
1057  case DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS:
1058 
1059  /* Program Counter is in parameter 1 */
1060  Pc = (PVOID)BugCheckParameter1;
1061  break;
1062 
1063  /* Check if the driver consumed too many PTEs */
1064  case DRIVER_USED_EXCESSIVE_PTES:
1065 
1066  /* Loader entry is in parameter 1 */
1067  LdrEntry = (PVOID)BugCheckParameter1;
1068  KiBugCheckDriver = &LdrEntry->BaseDllName;
1069  break;
1070 
1071  /* Check if the driver has a stuck thread */
1072  case THREAD_STUCK_IN_DEVICE_DRIVER:
1073 
1074  /* The name is in Parameter 3 */
1075  KiBugCheckDriver = (PVOID)BugCheckParameter3;
1076  break;
1077 
1078  /* Anything else */
1079  default:
1080  break;
1081  }
1082 
1083  /* Do we have a driver name? */
1084  if (KiBugCheckDriver)
1085  {
1086  /* Convert it to ANSI */
1087  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
1088  }
1089  else
1090  {
1091  /* Do we have a Program Counter? */
1092  if (Pc)
1093  {
1094  /* Dump image name */
1095  KiDumpParameterImages(AnsiName,
1096  (PULONG_PTR)&Pc,
1097  1,
1099  }
1100  }
1101 
1102  /* Check if we need to save the context for KD */
1104 
1105  /* Check if a debugger is connected */
1106  if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
1107  {
1108  /* Crash on the debugger console */
1109  DbgPrint("\n*** Fatal System Error: 0x%08lx\n"
1110  " (0x%p,0x%p,0x%p,0x%p)\n\n",
1111  KiBugCheckData[0],
1112  KiBugCheckData[1],
1113  KiBugCheckData[2],
1114  KiBugCheckData[3],
1115  KiBugCheckData[4]);
1116 
1117  /* Check if the debugger isn't currently connected */
1118  if (!KdDebuggerNotPresent)
1119  {
1120  /* Check if we have a driver to blame */
1121  if (KiBugCheckDriver)
1122  {
1123  /* Dump it */
1124  DbgPrint("Driver at fault: %s.\n", AnsiName);
1125  }
1126 
1127  /* Check if this was a hard error */
1128  if (IsHardError)
1129  {
1130  /* Print caption and message */
1131  if (HardErrCaption) DbgPrint(HardErrCaption);
1132  if (HardErrMessage) DbgPrint(HardErrMessage);
1133  }
1134 
1135  /* Break in the debugger */
1137  }
1138  else
1139  {
1140  /*
1141  * ROS HACK.
1142  * Ok, so debugging is enabled, but KDBG isn't there.
1143  * We'll manually dump the stack for the user.
1144  */
1146 
1147  /* ROS HACK 2: Generate something useful for Bugzilla */
1149  }
1150  }
1151 
1152  /* Raise IRQL to HIGH_LEVEL */
1153  _disable();
1155 
1156  /* Avoid recursion */
1158  {
1159 #ifdef CONFIG_SMP
1160  /* Set CPU that is bug checking now */
1161  KeBugCheckOwner = Prcb->Number;
1162 
1163  /* Freeze the other CPUs */
1164  for (i = 0; i < KeNumberProcessors; i++)
1165  {
1167  {
1168  /* Send the IPI and give them one second to catch up */
1169  KiIpiSend(1 << i, IPI_FREEZE);
1170  KeStallExecutionProcessor(1000000);
1171  }
1172  }
1173 #endif
1174 
1175  /* Display the BSOD */
1176  KiDisplayBlueScreen(MessageId,
1177  IsHardError,
1178  HardErrCaption,
1179  HardErrMessage,
1180  AnsiName);
1181 
1182  // TODO/FIXME: Run the registered reason-callbacks from
1183  // the KeBugcheckReasonCallbackListHead list with the
1184  // KbCallbackReserved1 reason.
1185 
1186  /* Check if the debugger is disabled but we can enable it */
1187  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
1188  {
1189  /* Enable it */
1191  }
1192  else
1193  {
1194  /* Otherwise, print the last line */
1195  InbvDisplayString("\r\n");
1196  }
1197 
1198  /* Save the context */
1200 
1201  /* FIXME: Support Triage Dump */
1202 
1203  /* FIXME: Write the crash dump */
1204  }
1205  else
1206  {
1207  /* Increase recursion count */
1210  {
1211  /* Break in the debugger */
1213  }
1214  else if (KeBugCheckOwnerRecursionCount > 2)
1215  {
1216  /* Halt execution */
1217  while (TRUE);
1218  }
1219  }
1220 
1221  /* Call the Callbacks */
1223 
1224  /* FIXME: Call Watchdog if enabled */
1225 
1226  /* Check if we have to reboot */
1227  if (Reboot)
1228  {
1229  /* Unload symbols */
1232  }
1233 
1234  /* Attempt to break in the debugger (otherwise halt CPU) */
1236 
1237  /* Shouldn't get here */
1238  ASSERT(FALSE);
1239  while (TRUE);
1240 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
signed char * PCHAR
Definition: retypes.h:7
UCHAR DebuggerSavedIRQL
Definition: ketypes.h:739
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:29
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
LONG KeBugCheckOwnerRecursionCount
Definition: bug.c:25
VOID NTAPI KeRosDumpTriageForBugZillaReport(VOID)
Definition: bug.c:299
#define DbgPrint
Definition: loader.c:25
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:572
#define DBG_STATUS_BUGCHECK_FIRST
Definition: kdtypes.h:41
char CHAR
Definition: xmlstorage.h:175
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
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 KiDoBugCheckCallbacks(VOID)
Definition: bug.c:504
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
ULONG64 SavedContext
Definition: wdbgexts.h:182
ULONG KeBugCheckOwner
Definition: bug.c:24
VOID NTAPI KeRosDumpStackFrames(IN PULONG_PTR Frame OPTIONAL, IN ULONG FrameCount OPTIONAL)
Definition: bug.c:262
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:325
#define IPI_FREEZE
Definition: ketypes.h:234
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID NTAPI KiBugCheckDebugBreak(IN ULONG StatusCode)
Definition: bug.c:561
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
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:610
CONTEXT ContextFrame
Definition: ketypes.h:531
#define DBG_STATUS_BUGCHECK_SECOND
Definition: kdtypes.h:42
Definition: bl.h:892
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:48
#define ACPI_BIOS_ERROR(plist)
Definition: acoutput.h:243
void * PVOID
Definition: retypes.h:9
#define PCHAR
Definition: match.c:90
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: kdmain.c:361
PVOID NTAPI KiPcToFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:44
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:680
VOID NTAPI HalReturnToFirmware(IN FIRMWARE_REENTRY Action)
Definition: reboot.c:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:579
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:372
Definition: btrfs_drv.h:1853
#define KeGetTrapFramePc(TrapFrame)
Definition: ke.h:130
VOID FASTCALL KiIpiSend(KAFFINITY TargetSet, ULONG IpiRequest)
ULONG KeBugCheckActive
Definition: bug.c:24
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
#define InterlockedIncrement
Definition: armddk.h:53
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:586
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
USHORT Number
Definition: ketypes.h:559
void __cdecl _disable(void)
Definition: intrin_arm.h:365
struct tagContext Context
Definition: acpixf.h:1030
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:63
#define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE
Definition: ntstatus.h:815
signed int * PLONG
Definition: retypes.h:5
ULONG KiHardwareTrigger
Definition: bug.c:28
BOOLEAN NTAPI MmIsSpecialPoolAddress(IN PVOID P)
BOOLEAN KdDebuggerNotPresent
Definition: kdmain.c:50
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
ULONG KeBugCheckCount
Definition: bug.c:27

Referenced by KeBugCheck(), and KeBugCheckEx().

◆ KeDeregisterBugCheckCallback()

BOOLEAN NTAPI KeDeregisterBugCheckCallback ( IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)

Definition at line 1284 of file bug.c.

1285 {
1286  KIRQL OldIrql;
1287  BOOLEAN Status = FALSE;
1288 
1289  /* Raise IRQL to High */
1291 
1292  /* Check the Current State */
1293  if (CallbackRecord->State == BufferInserted)
1294  {
1295  /* Reset state and remove from list */
1296  CallbackRecord->State = BufferEmpty;
1297  RemoveEntryList(&CallbackRecord->Entry);
1298  Status = TRUE;
1299  }
1300 
1301  /* Lower IRQL and return */
1303  return Status;
1304 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
unsigned char BOOLEAN
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703

Referenced by NdisMDeregisterAdapterShutdownHandler().

◆ KeDeregisterBugCheckReasonCallback()

BOOLEAN NTAPI KeDeregisterBugCheckReasonCallback ( IN PKBUGCHECK_REASON_CALLBACK_RECORD  CallbackRecord)

Definition at line 1311 of file bug.c.

1313 {
1314  KIRQL OldIrql;
1315  BOOLEAN Status = FALSE;
1316 
1317  /* Raise IRQL to High */
1319 
1320  /* Check the Current State */
1321  if (CallbackRecord->State == BufferInserted)
1322  {
1323  /* Reset state and remove from list */
1324  CallbackRecord->State = BufferEmpty;
1325  RemoveEntryList(&CallbackRecord->Entry);
1326  Status = TRUE;
1327  }
1328 
1329  /* Lower IRQL and return */
1331  return Status;
1332 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
unsigned char BOOLEAN
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703

◆ KeDeregisterNmiCallback()

NTSTATUS NTAPI KeDeregisterNmiCallback ( IN PVOID  Handle)

Definition at line 1443 of file bug.c.

1444 {
1445  KIRQL OldIrql;
1446  PKNMI_HANDLER_CALLBACK NmiData;
1447  PKNMI_HANDLER_CALLBACK* Previous;
1449 
1450  /* Find in the list the NMI callback corresponding to the handle */
1452  Previous = &KiNmiCallbackListHead;
1453  NmiData = *Previous;
1454  while (NmiData)
1455  {
1456  if (NmiData->Handle == Handle)
1457  {
1458  /* The handle is the pointer to the callback itself */
1459  ASSERT(Handle == NmiData);
1460 
1461  /* Found it, remove from the list */
1462  *Previous = NmiData->Next;
1463  break;
1464  }
1465 
1466  /* Not found; try again */
1467  Previous = &NmiData->Next;
1468  NmiData = *Previous;
1469  }
1471 
1472  /* If we have found the entry, free it */
1473  if (NmiData)
1474  {
1475  ExFreePoolWithTag(NmiData, TAG_KNMI);
1476  return STATUS_SUCCESS;
1477  }
1478 
1479  return STATUS_INVALID_HANDLE;
1480 }
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1675
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:75
UCHAR KIRQL
Definition: env_spec_w32.h:591
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead
Definition: bug.c:32
_In_ HANDLE Handle
Definition: extypes.h:390
#define TAG_KNMI
Definition: bug.c:34
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1668
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ KeEnterKernelDebugger()

VOID NTAPI KeEnterKernelDebugger ( VOID  )

Definition at line 1518 of file bug.c.

1519 {
1520  /* Disable interrupts */
1521  KiHardwareTrigger = 1;
1522  _disable();
1523 
1524  /* Check the bugcheck count */
1526  {
1527  /* There was only one, is the debugger disabled? */
1528  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
1529  {
1530  /* Enable the debugger */
1531  KdInitSystem(0, NULL);
1532  }
1533  }
1534 
1535  /* Break in the debugger */
1537 }
BOOLEAN KdPitchDebugger
Definition: kdmain.c:52
#define DBG_STATUS_FATAL
Definition: kdtypes.h:43
VOID NTAPI KiBugCheckDebugBreak(IN ULONG StatusCode)
Definition: bug.c:561
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN KdDebuggerEnabled
Definition: kdmain.c:48
#define InterlockedDecrement
Definition: armddk.h:52
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kdinit.c:169
void __cdecl _disable(void)
Definition: intrin_arm.h:365
signed int * PLONG
Definition: retypes.h:5
ULONG KiHardwareTrigger
Definition: bug.c:28
ULONG KeBugCheckCount
Definition: bug.c:27

◆ KeGetBugMessageText()

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

Definition at line 406 of file bug.c.

408 {
409  ULONG i;
410  ULONG IdOffset;
411  PMESSAGE_RESOURCE_ENTRY MessageEntry;
412  PCHAR BugCode;
413  USHORT Length;
414  BOOLEAN Result = FALSE;
415 
416  /* Make sure we're not bugchecking too early */
417  if (!KiBugCodeMessages) return Result;
418 
419  /*
420  * Globally protect in SEH as we are trying to access data in
421  * dire situations, and potentially going to patch it (see below).
422  */
423  _SEH2_TRY
424  {
425 
426  /*
427  * Make the kernel resource section writable, as we are going to manually
428  * trim the trailing newlines in the bugcheck resource message in place,
429  * when OutputString is NULL and before displaying it on screen.
430  */
432 
433  /* Find the message. This code is based on RtlFindMesssage */
434  for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
435  {
436  /* Check if the ID matches */
437  if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
438  (BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
439  {
440  /* Get offset to entry */
441  MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
443  IdOffset = BugCheckCode - KiBugCodeMessages->Blocks[i].LowId;
444 
445  /* Advance in the entries until finding it */
446  while (IdOffset--)
447  {
448  MessageEntry = (PMESSAGE_RESOURCE_ENTRY)
449  ((ULONG_PTR)MessageEntry + MessageEntry->Length);
450  }
451 
452  /* Make sure it's not Unicode */
453  ASSERT(!(MessageEntry->Flags & MESSAGE_RESOURCE_UNICODE));
454 
455  /* Get the final code */
456  BugCode = (PCHAR)MessageEntry->Text;
457  Length = (USHORT)strlen(BugCode);
458 
459  /* Handle trailing newlines */
460  while ((Length > 0) && ((BugCode[Length - 1] == '\n') ||
461  (BugCode[Length - 1] == '\r') ||
462  (BugCode[Length - 1] == ANSI_NULL)))
463  {
464  /* Directly trim the newline in place if we don't return the string */
465  if (!OutputString) BugCode[Length - 1] = ANSI_NULL;
466 
467  /* Skip the trailing newline */
468  Length--;
469  }
470 
471  /* Check if caller wants an output string */
472  if (OutputString)
473  {
474  /* Return it in the OutputString */
475  OutputString->Buffer = BugCode;
476  OutputString->Length = Length;
477  OutputString->MaximumLength = Length;
478  }
479  else
480  {
481  /* Direct output to screen */
482  InbvDisplayString(BugCode);
483  InbvDisplayString("\r");
484  }
485 
486  /* We're done */
487  Result = TRUE;
488  break;
489  }
490  }
491 
492  }
494  {
495  }
496  _SEH2_END;
497 
498  /* Return the result */
499  return Result;
500 }
signed char * PCHAR
Definition: retypes.h:7
#define MESSAGE_RESOURCE_UNICODE
Definition: rtltypes.h:354
Definition: rtltypes.h:1827
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
Definition: bug.c:26
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:572
USHORT Flags
Definition: rtltypes.h:1830
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID NTAPI MmMakeKernelResourceSectionWritable(VOID)
Definition: sysldr.c:2317
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
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 ANSI_NULL
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
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:1831
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
USHORT Length
Definition: rtltypes.h:1829
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY]
Definition: rtltypes.h:1844
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

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 1269 of file bug.c.

1274 {
1275  UNIMPLEMENTED;
1276  return STATUS_UNSUCCESSFUL;
1277 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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 1339 of file bug.c.

1344 {
1345  KIRQL OldIrql;
1346  BOOLEAN Status = FALSE;
1347 
1348  /* Raise IRQL to High */
1350 
1351  /* Check the Current State first so we don't double-register */
1352  if (CallbackRecord->State == BufferEmpty)
1353  {
1354  /* Set the Callback Settings and insert into the list */
1355  CallbackRecord->Length = Length;
1356  CallbackRecord->Buffer = Buffer;
1357  CallbackRecord->Component = Component;
1358  CallbackRecord->CallbackRoutine = CallbackRoutine;
1359  CallbackRecord->State = BufferInserted;
1360  InsertTailList(&KeBugcheckCallbackListHead, &CallbackRecord->Entry);
1361  Status = TRUE;
1362  }
1363 
1364  /* Lower IRQL and return */
1366  return Status;
1367 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#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
unsigned char BOOLEAN
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:21
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

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 1374 of file bug.c.

1379 {
1380  KIRQL OldIrql;
1381  BOOLEAN Status = FALSE;
1382 
1383  /* Raise IRQL to High */
1385 
1386  /* Check the Current State first so we don't double-register */
1387  if (CallbackRecord->State == BufferEmpty)
1388  {
1389  /* Set the Callback Settings and insert into the list */
1390  CallbackRecord->Component = Component;
1391  CallbackRecord->CallbackRoutine = CallbackRoutine;
1392  CallbackRecord->State = BufferInserted;
1393  CallbackRecord->Reason = Reason;
1395  &CallbackRecord->Entry);
1396  Status = TRUE;
1397  }
1398 
1399  /* Lower IRQL and return */
1401  return Status;
1402 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#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
unsigned char BOOLEAN
LIST_ENTRY KeBugcheckReasonCallbackListHead
Definition: bug.c:22
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:45

◆ KeRegisterNmiCallback()

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

Definition at line 1409 of file bug.c.

1411 {
1412  KIRQL OldIrql;
1413  PKNMI_HANDLER_CALLBACK NmiData, Next;
1415 
1416  /* Allocate NMI callback data */
1417  NmiData = ExAllocatePoolWithTag(NonPagedPool, sizeof(*NmiData), TAG_KNMI);
1418  if (!NmiData) return NULL;
1419 
1420  /* Fill in the information */
1421  NmiData->Callback = CallbackRoutine;
1422  NmiData->Context = Context;
1423  NmiData->Handle = NmiData;
1424 
1425  /* Insert it into NMI callback list */
1427  NmiData->Next = KiNmiCallbackListHead;
1429  NmiData,
1430  NmiData->Next);
1431  ASSERT(Next == NmiData->Next);
1433 
1434  /* Return the opaque "handle" */
1435  return NmiData->Handle;
1436 }
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1675
PNMI_CALLBACK Callback
Definition: ke.h:76
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:75
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:32
smooth NULL
Definition: ftsmooth.c:416
#define TAG_KNMI
Definition: bug.c:34
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1668
struct tagContext Context
Definition: acpixf.h:1030

Referenced by DriverEntry().

◆ KeRosCaptureUserStackBackTrace()

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

Definition at line 158 of file bug.c.

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 }
static int Hash(const char *)
Definition: reader.c:2257
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 PtrToUlong(u)
Definition: config.h:107
#define RtlFillMemoryUlong(dst, len, val)
Definition: mkhive.h:55
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 201 of file bug.c.

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 }
BOOLEAN KdbSymPrintAddress(IN PVOID Address, IN PKTRAP_FRAME Context)
Print address...
Definition: kdb_symbols.c:148
#define DbgPrint
Definition: loader.c:25
char CHAR
Definition: xmlstorage.h:175
PVOID NTAPI KiRosPcToUserFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
Definition: bug.c:109
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DllBase
Definition: btrfs_drv.h:1857
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 char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI KiPcToFileHeader(IN PVOID Pc, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry, IN BOOLEAN DriversOnly, OUT PBOOLEAN InKernel)
Definition: bug.c:44
Definition: btrfs_drv.h:1853
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:586
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
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 262 of file bug.c.

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 }
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
USHORT NTAPI KeRosCaptureUserStackBackTrace(IN ULONG FramesToSkip, IN ULONG FramesToCapture, OUT PVOID *BackTrace, OUT PULONG BackTraceHash OPTIONAL)
Definition: bug.c:158
#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:201

Referenced by KeBugCheckWithTf().

◆ KeRosDumpTriageForBugZillaReport()

VOID NTAPI KeRosDumpTriageForBugZillaReport ( VOID  )

Definition at line 299 of file bug.c.

300 {
301 #if 0
305 
306  DbgPrint("ReactOS has crashed! Please go to http://jira.reactos.org/ to file a bug!\n");
307  DbgPrint("\nHardware Information\n");
308  DbgPrint("Processor Architecture: %d\n"
309  "Feature Bits: %d\n"
310  "System Call Disabled: %d\n"
311  "NPX Present: %d\n"
312  "MXCsr Mask: %d\n"
313  "MXCsr Feature Mask: %d\n"
314  "XMMI Present: %d\n"
315  "FXSR Present: %d\n"
316  "Machine Type: %d\n"
317  "PAE: %d\n"
318  "NX: %d\n"
319  "Processors: %d\n"
320  "Active Processors: %d\n"
321  "Pentium LOCK Bug: %d\n"
322  "Hyperthreading: %d\n"
323  "CPU Manufacturer: %s\n"
324  "CPU Name: %wZ\n"
325  "CPUID: %d\n"
326  "CPU Type: %d\n"
327  "CPU Stepping: %d\n"
328  "CPU Speed: %d\n"
329  "CPU L2 Cache: %d\n"
330  "BIOS Date: %wZ\n"
331  "BIOS Version: %wZ\n"
332  "Video BIOS Date: %wZ\n"
333  "Video BIOS Version: %wZ\n"
334  "Memory: %d\n",
339  KiMXCsrMask,
344  Ke386Pae,
350  KeGetCurrentPrcb()->VendorString,
352  KeGetCurrentPrcb()->CpuID,
353  KeGetCurrentPrcb()->CpuType,
355  KeGetCurrentPrcb()->MHz,
356  ((PKIPCR)KeGetPcr())->SecondLevelCacheSize,
357  &KeRosBiosDate,
362 #endif
363 }
BOOLEAN KiI386PentiumLockErrataPresent
Definition: cpu.c:40
ULONG Ke386NoExecute
Definition: cpu.c:34
#define DbgPrint
Definition: loader.c:25
ULONG KiFastSystemCallDisable
Definition: cpu.c:26
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
ULONG KeFeatureBits
Definition: krnlinit.c:22
ULONG KeI386NpxPresent
Definition: cpu.c:31
#define KeGetPcr()
Definition: ke.h:25
ULONG KeI386FxsrPresent
Definition: cpu.c:31
unsigned char BOOLEAN
ULONG KeI386XMMIPresent
Definition: cpu.c:30
ULONG KiMXCsrMask
Definition: cpu.c:28
USHORT KeProcessorArchitecture
Definition: krnlinit.c:19
ULONG KeI386MachineType
Definition: cpu.c:30
UNICODE_STRING KeRosBiosDate
Definition: bug.c:37
#define PAGE_SIZE
Definition: env_spec_w32.h:49
KAFFINITY KeActiveProcessors
Definition: krnlinit.c:23
UNICODE_STRING KeRosVideoBiosDate
Definition: bug.c:38
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
UNICODE_STRING KeRosVideoBiosVersion
Definition: bug.c:38
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
UNICODE_STRING KeRosProcessorName
Definition: bug.c:37
ULONG MxcsrFeatureMask
Definition: cpu.c:29
unsigned int ULONG
Definition: retypes.h:1
ULONG Ke386Pae
Definition: cpu.c:33
VOID CpuStep(VOID)
Definition: cpu.c:108
UNICODE_STRING KeRosBiosVersion
Definition: bug.c:37
BOOLEAN KiSMTProcessorsPresent
Definition: cpu.c:34

Referenced by KeBugCheckWithTf().

◆ KiBugCheckDebugBreak()

VOID NTAPI KiBugCheckDebugBreak ( IN ULONG  StatusCode)

Definition at line 561 of file bug.c.

562 {
563  /*
564  * Wrap this in SEH so we don't crash if
565  * there is no debugger or if it disconnected
566  */
567 DoBreak:
568  _SEH2_TRY
569  {
570  /* Breakpoint */
571  DbgBreakPointWithStatus(StatusCode);
572  }
574  {
575  /* No debugger, halt the CPU */
576  HalHaltSystem();
577  }
578  _SEH2_END;
579 
580  /* Break again if this wasn't first try */
581  if (StatusCode != DBG_STATUS_BUGCHECK_FIRST) goto DoBreak;
582 }
#define DBG_STATUS_BUGCHECK_FIRST
Definition: kdtypes.h:41
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define HalHaltSystem
Definition: halfuncs.h:43
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
__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 680 of file bug.c.

685 {
686  CHAR AnsiName[75];
687 
688  /* Check if bootvid is installed */
690  {
691  /* Acquire ownership and reset the display */
694 
695  /* Display blue screen */
696  InbvSolidColorFill(0, 0, 639, 479, 4);
697  InbvSetTextColor(15);
700  InbvSetScrollRegion(0, 0, 639, 479);
701  }
702 
703  /* Check if this is a hard error */
704  if (IsHardError)
705  {
706  /* Display caption and message */
707  if (HardErrCaption) InbvDisplayString(HardErrCaption);
708  if (HardErrMessage) InbvDisplayString(HardErrMessage);
709  }
710 
711  /* Begin the display */
712  InbvDisplayString("\r\n");
713 
714  /* Print out initial message */
715  KeGetBugMessageText(BUGCHECK_MESSAGE_INTRO, NULL);
716  InbvDisplayString("\r\n\r\n");
717 
718  /* Check if we have a driver */
719  if (KiBugCheckDriver)
720  {
721  /* Print out into to driver name */
722  KeGetBugMessageText(BUGCODE_ID_DRIVER, NULL);
723 
724  /* Convert and print out driver name */
725  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
726  InbvDisplayString(" ");
727  InbvDisplayString(AnsiName);
728  InbvDisplayString("\r\n\r\n");
729  }
730 
731  /* Check if this is the generic message */
732  if (MessageId == BUGCODE_PSS_MESSAGE)
733  {
734  /* It is, so get the bug code string as well */
736  InbvDisplayString("\r\n\r\n");
737  }
738 
739  /* Print second introduction message */
740  KeGetBugMessageText(PSS_MESSAGE_INTRO, NULL);
741  InbvDisplayString("\r\n\r\n");
742 
743  /* Get the bug code string */
744  KeGetBugMessageText(MessageId, NULL);
745  InbvDisplayString("\r\n\r\n");
746 
747  /* Print message for technical information */
748  KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
749 
750  /* Show the technical Data */
751  sprintf(AnsiName,
752  "\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
753  (ULONG)KiBugCheckData[0],
754  (PVOID)KiBugCheckData[1],
755  (PVOID)KiBugCheckData[2],
756  (PVOID)KiBugCheckData[3],
757  (PVOID)KiBugCheckData[4]);
758  InbvDisplayString(AnsiName);
759 
760  /* Check if we have a driver*/
761  if (KiBugCheckDriver)
762  {
763  /* Display technical driver data */
765  }
766  else
767  {
768  /* Dump parameter information */
770  (PVOID)&KiBugCheckData[1],
771  4,
773  }
774 }
BOOLEAN NTAPI KeGetBugMessageText(IN ULONG BugCheckCode, OUT PANSI_STRING OutputString OPTIONAL)
Definition: bug.c:406
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:29
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:572
char CHAR
Definition: xmlstorage.h:175
ULONG_PTR KiBugCheckData[5]
Definition: bug.c:30
VOID NTAPI InbvSolidColorFill(IN ULONG Left, IN ULONG Top, IN ULONG Right, IN ULONG Bottom, IN ULONG Color)
Definition: inbv.c:719
#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:610
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI InbvSetTextColor(IN ULONG Color)
Definition: inbv.c:695
CHAR Message[80]
Definition: alive.c:5
VOID NTAPI InbvAcquireDisplayOwnership(VOID)
Definition: inbv.c:531
BOOLEAN NTAPI InbvEnableDisplayString(IN BOOLEAN Enable)
Definition: inbv.c:609
BOOLEAN NTAPI InbvIsBootDriverInstalled(VOID)
Definition: inbv.c:633
BOOLEAN NTAPI InbvResetDisplay(VOID)
Definition: inbv.c:667
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:586
VOID NTAPI InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter)
Definition: inbv.c:625
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:684

Referenced by KeBugCheckWithTf().

◆ KiDoBugCheckCallbacks()

VOID NTAPI KiDoBugCheckCallbacks ( VOID  )

Definition at line 504 of file bug.c.

505 {
506  PKBUGCHECK_CALLBACK_RECORD CurrentRecord;
507  PLIST_ENTRY ListHead, NextEntry, LastEntry;
508  ULONG_PTR Checksum;
509 
510  /* First make sure that the list is initialized... it might not be */
511  ListHead = &KeBugcheckCallbackListHead;
512  if ((!ListHead->Flink) || (!ListHead->Blink))
513  return;
514 
515  /* Loop the list */
516  LastEntry = ListHead;
517  NextEntry = ListHead->Flink;
518  while (NextEntry != ListHead)
519  {
520  /* Get the reord */
521  CurrentRecord = CONTAINING_RECORD(NextEntry,
523  Entry);
524 
525  /* Validate it */
526  // TODO/FIXME: Check whether the memory CurrentRecord points to
527  // is still accessible and valid!
528  if (CurrentRecord->Entry.Blink != LastEntry) return;
529  Checksum = (ULONG_PTR)CurrentRecord->CallbackRoutine;
530  Checksum += (ULONG_PTR)CurrentRecord->Buffer;
531  Checksum += (ULONG_PTR)CurrentRecord->Length;
532  Checksum += (ULONG_PTR)CurrentRecord->Component;
533 
534  /* Make sure it's inserted and validated */
535  if ((CurrentRecord->State == BufferInserted) &&
536  (CurrentRecord->Checksum == Checksum))
537  {
538  /* Call the routine */
539  CurrentRecord->State = BufferStarted;
540  _SEH2_TRY
541  {
542  (CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer,
543  CurrentRecord->Length);
544  CurrentRecord->State = BufferFinished;
545  }
547  {
548  CurrentRecord->State = BufferIncomplete;
549  }
550  _SEH2_END;
551  }
552 
553  /* Go to the next entry */
554  LastEntry = NextEntry;
555  NextEntry = NextEntry->Flink;
556  }
557 }
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:324
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
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:119
Definition: typedefs.h:117
_SEH2_END
Definition: create.c:4424
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:21
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
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 610 of file bug.c.

614 {
615  ULONG i;
616  BOOLEAN InSystem;
617  PLDR_DATA_TABLE_ENTRY LdrEntry;
618  PVOID ImageBase;
619  PUNICODE_STRING DriverName;
620  CHAR AnsiName[32];
621  PIMAGE_NT_HEADERS NtHeader;
623  BOOLEAN FirstRun = TRUE;
624 
625  /* Loop parameters */
626  for (i = 0; i < ParameterCount; i++)
627  {
628  /* Get the base for this parameter */
629  ImageBase = KiPcToFileHeader((PVOID)Parameters[i],
630  &LdrEntry,
631  FALSE,
632  &InSystem);
633  if (!ImageBase)
634  {
635  /* FIXME: Add code to check for unloaded drivers */
636  DPRINT1("Potentially unloaded driver!\n");
637  continue;
638  }
639  else
640  {
641  /* Get the NT Headers and Timestamp */
642  NtHeader = RtlImageNtHeader(LdrEntry->DllBase);
643  TimeStamp = NtHeader->FileHeader.TimeDateStamp;
644 
645  /* Convert the driver name */
646  DriverName = &LdrEntry->BaseDllName;
647  ConversionRoutine(&LdrEntry->BaseDllName,
648  AnsiName,
649  sizeof(AnsiName));
650  }
651 
652  /* Format driver name */
654  "%s** %12s - Address %p base at %p, DateStamp %08lx\r\n",
655  FirstRun ? "\r\n*":"*",
656  AnsiName,
657  (PVOID)Parameters[i],
658  ImageBase,
659  TimeStamp);
660 
661  /* Check if we only had one parameter */
662  if (ParameterCount <= 1)
663  {
664  /* Then just save the name */
665  KiBugCheckDriver = DriverName;
666  }
667  else
668  {
669  /* Otherwise, display the message */
671  }
672 
673  /* Loop again */
674  FirstRun = FALSE;
675  }
676 }
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:29
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI InbvDisplayString(IN PCHAR String)
Definition: inbv.c:572
char CHAR
Definition: xmlstorage.h:175
PVOID DllBase
Definition: btrfs_drv.h:1857
#define sprintf(buf, format,...)
Definition: sprintf.c: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 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:44
CHAR Message[80]
Definition: alive.c:5
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
Definition: btrfs_drv.h:1853
SECURITY_INTEGER TimeStamp
Definition: sspi.h:78
UNICODE_STRING BaseDllName
Definition: ldrtypes.h:145
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:465
unsigned int ULONG
Definition: retypes.h:1

Referenced by KeBugCheckWithTf(), and KiDisplayBlueScreen().

◆ KiHandleNmi()

BOOLEAN NTAPI KiHandleNmi ( VOID  )

Definition at line 1244 of file bug.c.

1245 {
1246  BOOLEAN Handled = FALSE;
1247  PKNMI_HANDLER_CALLBACK NmiData;
1248 
1249  /* Parse the list of callbacks */
1250  NmiData = KiNmiCallbackListHead;
1251  while (NmiData)
1252  {
1253  /* Save if this callback has handled it -- all it takes is one */
1254  Handled |= NmiData->Callback(NmiData->Context, Handled);
1255  NmiData = NmiData->Next;
1256  }
1257 
1258  /* Has anyone handled this? */
1259  return Handled;
1260 }
PNMI_CALLBACK Callback
Definition: ke.h:76
struct _KNMI_HANDLER_CALLBACK * Next
Definition: ke.h:75
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead
Definition: bug.c:32
unsigned char BOOLEAN
_In_ BOOLEAN Handled
Definition: ketypes.h:337

Referenced by KiTrap02Handler().

◆ KiInitializeBugCheck()

VOID INIT_FUNCTION NTAPI KiInitializeBugCheck ( VOID  )

Definition at line 368 of file bug.c.

369 {
370  PMESSAGE_RESOURCE_DATA BugCheckData;
371  LDR_RESOURCE_INFO ResourceInfo;
372  PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
374  PLDR_DATA_TABLE_ENTRY LdrEntry;
375 
376  /* Get the kernel entry */
379  InLoadOrderLinks);
380 
381  /* Cache the Bugcheck Message Strings. Prepare the Lookup Data */
382  ResourceInfo.Type = 11;
383  ResourceInfo.Name = 1;
384  ResourceInfo.Language = 9;
385 
386  /* Do the lookup. */
387  Status = LdrFindResource_U(LdrEntry->DllBase,
388  &ResourceInfo,
390  &ResourceDataEntry);
391 
392  /* Make sure it worked */
393  if (NT_SUCCESS(Status))
394  {
395  /* Now actually get a pointer to it */
396  Status = LdrAccessResource(LdrEntry->DllBase,
397  ResourceDataEntry,
398  (PVOID*)&BugCheckData,
399  NULL);
400  if (NT_SUCCESS(Status)) KiBugCodeMessages = BugCheckData;
401  }
402 }
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
Definition: bug.c:26
LONG NTSTATUS
Definition: precomp.h:26
ULONG_PTR Type
Definition: ldrtypes.h:181
PVOID DllBase
Definition: btrfs_drv.h:1857
ULONG_PTR Name
Definition: ldrtypes.h:182
smooth NULL
Definition: ftsmooth.c:416
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)
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: btrfs_drv.h:1853
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
Status
Definition: gdiplustypes.h:24
#define RESOURCE_DATA_LEVEL
Definition: ldrtypes.h:33
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 44 of file bug.c.

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 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
smooth NULL
Definition: ftsmooth.c:416
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:119
if(!(yy_init))
Definition: macro.lex.yy.c:714
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
Definition: btrfs_drv.h:1853
Definition: typedefs.h:117
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
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 109 of file bug.c.

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 }
struct _Entry Entry
Definition: kefuncs.h:640
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
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:119
Definition: btrfs_drv.h:1853
Definition: typedefs.h:117
#define KeGetCurrentThread
Definition: hal.h:44
base of all file and directory entries
Definition: entries.h:82

Referenced by KeRosDumpStackFrameArray(), and RtlPcToFileHeader().

Variable Documentation

◆ BugCheckCallbackLock

KSPIN_LOCK BugCheckCallbackLock

Definition at line 23 of file bug.c.

Referenced by KiInitializeKernel(), and KiInitSystem().

◆ KeBugCheckActive

ULONG KeBugCheckActive

Definition at line 24 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugcheckCallbackListHead

LIST_ENTRY KeBugcheckCallbackListHead

◆ KeBugCheckCount

ULONG KeBugCheckCount = 1

Definition at line 27 of file bug.c.

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KeBugCheckOwner

ULONG KeBugCheckOwner

Definition at line 24 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugCheckOwnerRecursionCount

LONG KeBugCheckOwnerRecursionCount

Definition at line 25 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugcheckReasonCallbackListHead

LIST_ENTRY KeBugcheckReasonCallbackListHead

Definition at line 22 of file bug.c.

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

◆ KeRosBiosDate

UNICODE_STRING KeRosBiosDate

◆ KeRosBiosVersion

UNICODE_STRING KeRosBiosVersion

◆ KeRosProcessorName

UNICODE_STRING KeRosProcessorName

◆ KeRosVideoBiosDate

UNICODE_STRING KeRosVideoBiosDate

◆ KeRosVideoBiosVersion

UNICODE_STRING KeRosVideoBiosVersion

◆ KiBugCheckData

ULONG_PTR KiBugCheckData[5]

◆ KiBugCheckDriver

PUNICODE_STRING KiBugCheckDriver

Definition at line 29 of file bug.c.

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

◆ KiBugCodeMessages

PMESSAGE_RESOURCE_DATA KiBugCodeMessages

Definition at line 26 of file bug.c.

Referenced by KeGetBugMessageText(), and KiInitializeBugCheck().

◆ KiHardwareTrigger

ULONG KiHardwareTrigger

Definition at line 28 of file bug.c.

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KiNmiCallbackListHead

PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead = NULL

Definition at line 32 of file bug.c.

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

◆ KiNmiCallbackListLock

KSPIN_LOCK KiNmiCallbackListLock

Definition at line 33 of file bug.c.

Referenced by KiAcquireNmiListLock(), and KiReleaseNmiListLock().