ReactOS  0.4.15-dev-321-g2d9b385
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)
 
INIT_FUNCTION 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)
 
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 13 of file bug.c.

◆ TAG_KNMI

#define TAG_KNMI   'IMNK'

Definition at line 35 of file bug.c.

Function Documentation

◆ KeBugCheck()

VOID NTAPI KeBugCheck ( ULONG  BugCheckCode)

Definition at line 1428 of file bug.c.

1429 {
1430  /* Call the internal API */
1431  KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
1432 }
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:711
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 1408 of file bug.c.

1413 {
1414  /* Call the internal API */
1415  KeBugCheckWithTf(BugCheckCode,
1416  BugCheckParameter1,
1417  BugCheckParameter2,
1418  BugCheckParameter3,
1419  BugCheckParameter4,
1420  NULL);
1421 }
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:711
smooth NULL
Definition: ftsmooth.c:416

◆ KeBugCheckUnicodeToAnsi()

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

Definition at line 519 of file bug.c.

522 {
523  PCHAR p;
524  PWCHAR pw;
525  ULONG i;
526 
527  /* Set length and normalize it */
528  i = Unicode->Length / sizeof(WCHAR);
529  i = min(i, Length - 1);
530 
531  /* Set source and destination, and copy */
532  pw = Unicode->Buffer;
533  p = Ansi;
534  while (i--) *p++ = (CHAR)*pw++;
535 
536  /* Null terminate and return */
537  *p = ANSI_NULL;
538  return Ansi;
539 }
signed char * PCHAR
Definition: retypes.h:7
uint16_t * PWCHAR
Definition: typedefs.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
#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 711 of file bug.c.

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

Referenced by KeBugCheck(), and KeBugCheckEx().

◆ KeDeregisterBugCheckCallback()

BOOLEAN NTAPI KeDeregisterBugCheckCallback ( IN PKBUGCHECK_CALLBACK_RECORD  CallbackRecord)

Definition at line 1205 of file bug.c.

1206 {
1207  KIRQL OldIrql;
1208  BOOLEAN Status = FALSE;
1209 
1210  /* Raise IRQL to High */
1212 
1213  /* Check the Current State */
1215  {
1216  /* Reset state and remove from list */
1219  Status = TRUE;
1220  }
1221 
1222  /* Lower IRQL and return */
1224  return Status;
1225 }
#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
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
unsigned char BOOLEAN
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
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 1232 of file bug.c.

1234 {
1235  KIRQL OldIrql;
1236  BOOLEAN Status = FALSE;
1237 
1238  /* Raise IRQL to High */
1240 
1241  /* Check the Current State */
1243  {
1244  /* Reset state and remove from list */
1247  Status = TRUE;
1248  }
1249 
1250  /* Lower IRQL and return */
1252  return Status;
1253 }
#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
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
unsigned char BOOLEAN
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703

◆ KeDeregisterNmiCallback()

NTSTATUS NTAPI KeDeregisterNmiCallback ( IN PVOID  Handle)

Definition at line 1364 of file bug.c.

1365 {
1366  KIRQL OldIrql;
1367  PKNMI_HANDLER_CALLBACK NmiData;
1368  PKNMI_HANDLER_CALLBACK* Previous;
1370 
1371  /* Find in the list the NMI callback corresponding to the handle */
1373  Previous = &KiNmiCallbackListHead;
1374  NmiData = *Previous;
1375  while (NmiData)
1376  {
1377  if (NmiData->Handle == Handle)
1378  {
1379  /* The handle is the pointer to the callback itself */
1380  ASSERT(Handle == NmiData);
1381 
1382  /* Found it, remove from the list */
1383  *Previous = NmiData->Next;
1384  break;
1385  }
1386 
1387  /* Not found; try again */
1388  Previous = &NmiData->Next;
1389  NmiData = *Previous;
1390  }
1392 
1393  /* If we have found the entry, free it */
1394  if (NmiData)
1395  {
1396  ExFreePoolWithTag(NmiData, TAG_KNMI);
1397  return STATUS_SUCCESS;
1398  }
1399 
1400  return STATUS_INVALID_HANDLE;
1401 }
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1679
#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:33
_In_ HANDLE Handle
Definition: extypes.h:390
#define TAG_KNMI
Definition: bug.c:35
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1672
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ KeEnterKernelDebugger()

VOID NTAPI KeEnterKernelDebugger ( VOID  )

Definition at line 1439 of file bug.c.

1440 {
1441  /* Disable interrupts */
1442  KiHardwareTrigger = 1;
1443  _disable();
1444 
1445  /* Check the bugcheck count */
1447  {
1448  /* There was only one, is the debugger disabled? */
1449  if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
1450  {
1451  /* Enable the debugger */
1452  KdInitSystem(0, NULL);
1453  }
1454  }
1455 
1456  /* Break in the debugger */
1458 }
BOOLEAN KdPitchDebugger
Definition: kdmain.c:52
#define DBG_STATUS_FATAL
Definition: kdtypes.h:43
VOID NTAPI KiBugCheckDebugBreak(IN ULONG StatusCode)
Definition: bug.c:494
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:29
ULONG KeBugCheckCount
Definition: bug.c:28

◆ KeGetBugMessageText()

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

Definition at line 339 of file bug.c.

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

1195 {
1196  UNIMPLEMENTED;
1197  return STATUS_UNSUCCESSFUL;
1198 }
#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 1260 of file bug.c.

1265 {
1266  KIRQL OldIrql;
1267  BOOLEAN Status = FALSE;
1268 
1269  /* Raise IRQL to High */
1271 
1272  /* Check the Current State first so we don't double-register */
1274  {
1275  /* Set the Callback Settings and insert into the list */
1276  CallbackRecord->Length = Length;
1277  CallbackRecord->Buffer = Buffer;
1278  CallbackRecord->Component = Component;
1282  Status = TRUE;
1283  }
1284 
1285  /* Lower IRQL and return */
1287  return Status;
1288 }
#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
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
unsigned char BOOLEAN
PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:299
_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:790
Status
Definition: gdiplustypes.h:24
#define HIGH_LEVEL
Definition: env_spec_w32.h:703
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:22
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 1295 of file bug.c.

1300 {
1301  KIRQL OldIrql;
1302  BOOLEAN Status = FALSE;
1303 
1304  /* Raise IRQL to High */
1306 
1307  /* Check the Current State first so we don't double-register */
1309  {
1310  /* Set the Callback Settings and insert into the list */
1311  CallbackRecord->Component = Component;
1316  &CallbackRecord->Entry);
1317  Status = TRUE;
1318  }
1319 
1320  /* Lower IRQL and return */
1322  return Status;
1323 }
KBUGCHECK_CALLBACK_REASON Reason
Definition: ketypes.h:302
#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
KBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord
unsigned char BOOLEAN
PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:299
LIST_ENTRY KeBugcheckReasonCallbackListHead
Definition: bug.c:23
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
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 1330 of file bug.c.

1332 {
1333  KIRQL OldIrql;
1334  PKNMI_HANDLER_CALLBACK NmiData, Next;
1336 
1337  /* Allocate NMI callback data */
1338  NmiData = ExAllocatePoolWithTag(NonPagedPool, sizeof(*NmiData), TAG_KNMI);
1339  if (!NmiData) return NULL;
1340 
1341  /* Fill in the information */
1342  NmiData->Callback = CallbackRoutine;
1343  NmiData->Context = Context;
1344  NmiData->Handle = NmiData;
1345 
1346  /* Insert it into NMI callback list */
1348  NmiData->Next = KiNmiCallbackListHead;
1350  NmiData,
1351  NmiData->Next);
1352  ASSERT(Next == NmiData->Next);
1354 
1355  /* Return the opaque "handle" */
1356  return NmiData->Handle;
1357 }
#define ASSERT_IRQL_LESS_OR_EQUAL(x)
Definition: debug.h:251
FORCEINLINE VOID KiReleaseNmiListLock(IN KIRQL OldIrql)
Definition: ke_x.h:1679
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:33
smooth NULL
Definition: ftsmooth.c:416
#define TAG_KNMI
Definition: bug.c:35
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:790
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
FORCEINLINE VOID KiAcquireNmiListLock(OUT PKIRQL OldIrql)
Definition: ke_x.h:1672
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 159 of file bug.c.

163 {
164  PVOID Frames[2 * 64];
165  ULONG FrameCount;
166  ULONG Hash = 0, i;
167 
168  /* Skip a frame for the caller */
169  FramesToSkip++;
170 
171  /* Don't go past the limit */
172  if ((FramesToCapture + FramesToSkip) >= 128) return 0;
173 
174  /* Do the back trace */
175  FrameCount = RtlWalkFrameChain(Frames, FramesToCapture + FramesToSkip, 1);
176 
177  /* Make sure we're not skipping all of them */
178  if (FrameCount <= FramesToSkip) return 0;
179 
180  /* Loop all the frames */
181  for (i = 0; i < FramesToCapture; i++)
182  {
183  /* Don't go past the limit */
184  if ((FramesToSkip + i) >= FrameCount) break;
185 
186  /* Save this entry and hash it */
187  BackTrace[i] = Frames[FramesToSkip + i];
188  Hash += PtrToUlong(BackTrace[i]);
189  }
190 
191  /* Write the hash */
192  if (BackTraceHash) *BackTraceHash = Hash;
193 
194  /* Clear the other entries and return count */
195  RtlFillMemoryUlong(Frames, 128, 0);
196  return (USHORT)i;
197 }
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 202 of file bug.c.

204 {
205  ULONG i;
206  ULONG_PTR Addr;
207  BOOLEAN InSystem;
208  PVOID p;
209 
210  /* GCC complaints that it may be used uninitialized */
211  PLDR_DATA_TABLE_ENTRY LdrEntry = NULL;
212 
213  /* Loop them */
214  for (i = 0; i < FrameCount; i++)
215  {
216  /* Get the EIP */
217  Addr = Frames[i];
218  if (!Addr)
219  {
220  break;
221  }
222 
223  /* Get the base for this file */
224  if (Addr > (ULONG_PTR)MmHighestUserAddress)
225  {
226  /* We are in kernel */
227  p = KiPcToFileHeader((PVOID)Addr, &LdrEntry, FALSE, &InSystem);
228  }
229  else
230  {
231  /* We are in user land */
232  p = KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry);
233  }
234  if (p)
235  {
236 #ifdef KDBG
237  if (!KdbSymPrintAddress((PVOID)Addr, NULL))
238 #endif
239  {
240  CHAR AnsiName[64];
241 
242  /* Convert module name to ANSI and print it */
244  AnsiName,
245  sizeof(AnsiName));
246  Addr -= (ULONG_PTR)LdrEntry->DllBase;
247  DbgPrint("<%s: %p>", AnsiName, (PVOID)Addr);
248  }
249  }
250  else
251  {
252  /* Print only the address */
253  DbgPrint("<%p>", (PVOID)Addr);
254  }
255 
256  /* Go to the next frame */
257  DbgPrint("\n");
258  }
259 }
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:110
uint32_t ULONG_PTR
Definition: typedefs.h:64
PVOID DllBase
Definition: btrfs_drv.h:1926
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:45
Definition: btrfs_drv.h:1922
PCHAR NTAPI KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode, OUT PCHAR Ansi, IN ULONG Length)
Definition: bug.c:519
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 263 of file bug.c.

265 {
266  ULONG_PTR Frames[32];
267  ULONG RealFrameCount;
268 
269  /* If the caller didn't ask, assume 32 frames */
270  if (!FrameCount || FrameCount > 32) FrameCount = 32;
271 
272  if (Frame)
273  {
274  /* Dump them */
275  KeRosDumpStackFrameArray(Frame, FrameCount);
276  }
277  else
278  {
279  /* Get the current frames (skip the two. One for the dumper, one for the caller) */
280  RealFrameCount = RtlCaptureStackBackTrace(2, FrameCount, (PVOID*)Frames, NULL);
281  DPRINT1("RealFrameCount =%lu\n", RealFrameCount);
282 
283  /* Dump them */
284  KeRosDumpStackFrameArray(Frames, RealFrameCount);
285 
286  /* Count left for user mode? */
287  if (FrameCount - RealFrameCount > 0)
288  {
289  /* Get the current frames */
290  RealFrameCount = KeRosCaptureUserStackBackTrace(-1, FrameCount - RealFrameCount, (PVOID*)Frames, NULL);
291 
292  /* Dump them */
293  KeRosDumpStackFrameArray(Frames, RealFrameCount);
294  }
295  }
296 }
uint32_t ULONG_PTR
Definition: typedefs.h:64
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:159
#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:202

◆ KiBugCheckDebugBreak()

VOID NTAPI KiBugCheckDebugBreak ( IN ULONG  StatusCode)

Definition at line 494 of file bug.c.

495 {
496  /*
497  * Wrap this in SEH so we don't crash if
498  * there is no debugger or if it disconnected
499  */
500 DoBreak:
501  _SEH2_TRY
502  {
503  /* Breakpoint */
504  DbgBreakPointWithStatus(StatusCode);
505  }
507  {
508  /* No debugger, halt the CPU */
509  HalHaltSystem();
510  }
511  _SEH2_END;
512 
513  /* Break again if this wasn't first try */
514  if (StatusCode != DBG_STATUS_BUGCHECK_FIRST) goto DoBreak;
515 }
#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 613 of file bug.c.

618 {
619  CHAR AnsiName[75];
620 
621  /* Check if bootvid is installed */
623  {
624  /* Acquire ownership and reset the display */
627 
628  /* Display blue screen */
634  }
635 
636  /* Check if this is a hard error */
637  if (IsHardError)
638  {
639  /* Display caption and message */
640  if (HardErrCaption) InbvDisplayString(HardErrCaption);
641  if (HardErrMessage) InbvDisplayString(HardErrMessage);
642  }
643 
644  /* Begin the display */
645  InbvDisplayString("\r\n");
646 
647  /* Print out initial message */
648  KeGetBugMessageText(BUGCHECK_MESSAGE_INTRO, NULL);
649  InbvDisplayString("\r\n\r\n");
650 
651  /* Check if we have a driver */
652  if (KiBugCheckDriver)
653  {
654  /* Print out into to driver name */
655  KeGetBugMessageText(BUGCODE_ID_DRIVER, NULL);
656 
657  /* Convert and print out driver name */
658  KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
659  InbvDisplayString(" ");
660  InbvDisplayString(AnsiName);
661  InbvDisplayString("\r\n\r\n");
662  }
663 
664  /* Check if this is the generic message */
665  if (MessageId == BUGCODE_PSS_MESSAGE)
666  {
667  /* It is, so get the bug code string as well */
669  InbvDisplayString("\r\n\r\n");
670  }
671 
672  /* Print second introduction message */
673  KeGetBugMessageText(PSS_MESSAGE_INTRO, NULL);
674  InbvDisplayString("\r\n\r\n");
675 
676  /* Get the bug code string */
677  KeGetBugMessageText(MessageId, NULL);
678  InbvDisplayString("\r\n\r\n");
679 
680  /* Print message for technical information */
681  KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
682 
683  /* Show the technical Data */
684  sprintf(AnsiName,
685  "\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
686  (ULONG)KiBugCheckData[0],
687  (PVOID)KiBugCheckData[1],
688  (PVOID)KiBugCheckData[2],
689  (PVOID)KiBugCheckData[3],
690  (PVOID)KiBugCheckData[4]);
691  InbvDisplayString(AnsiName);
692 
693  /* Check if we have a driver*/
694  if (KiBugCheckDriver)
695  {
696  /* Display technical driver data */
698  }
699  else
700  {
701  /* Dump parameter information */
703  (PVOID)&KiBugCheckData[1],
704  4,
706  }
707 }
BOOLEAN NTAPI KeGetBugMessageText(IN ULONG BugCheckCode, OUT PANSI_STRING OutputString OPTIONAL)
Definition: bug.c:339
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:30
#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:31
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:543
smooth NULL
Definition: ftsmooth.c:416
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:519
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 437 of file bug.c.

438 {
439  PKBUGCHECK_CALLBACK_RECORD CurrentRecord;
440  PLIST_ENTRY ListHead, NextEntry, LastEntry;
441  ULONG_PTR Checksum;
442 
443  /* First make sure that the list is initialized... it might not be */
444  ListHead = &KeBugcheckCallbackListHead;
445  if ((!ListHead->Flink) || (!ListHead->Blink))
446  return;
447 
448  /* Loop the list */
449  LastEntry = ListHead;
450  NextEntry = ListHead->Flink;
451  while (NextEntry != ListHead)
452  {
453  /* Get the reord */
454  CurrentRecord = CONTAINING_RECORD(NextEntry,
456  Entry);
457 
458  /* Validate it */
459  // TODO/FIXME: Check whether the memory CurrentRecord points to
460  // is still accessible and valid!
461  if (CurrentRecord->Entry.Blink != LastEntry) return;
462  Checksum = (ULONG_PTR)CurrentRecord->CallbackRoutine;
463  Checksum += (ULONG_PTR)CurrentRecord->Buffer;
464  Checksum += (ULONG_PTR)CurrentRecord->Length;
465  Checksum += (ULONG_PTR)CurrentRecord->Component;
466 
467  /* Make sure it's inserted and validated */
468  if ((CurrentRecord->State == BufferInserted) &&
469  (CurrentRecord->Checksum == Checksum))
470  {
471  /* Call the routine */
472  CurrentRecord->State = BufferStarted;
473  _SEH2_TRY
474  {
475  (CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer,
476  CurrentRecord->Length);
477  CurrentRecord->State = BufferFinished;
478  }
480  {
481  CurrentRecord->State = BufferIncomplete;
482  }
483  _SEH2_END;
484  }
485 
486  /* Go to the next entry */
487  LastEntry = NextEntry;
488  NextEntry = NextEntry->Flink;
489  }
490 }
PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine
Definition: ketypes.h:324
struct _LIST_ENTRY * Blink
Definition: typedefs.h:121
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:64
#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:120
Definition: typedefs.h:118
_SEH2_END
Definition: create.c:4424
LIST_ENTRY KeBugcheckCallbackListHead
Definition: bug.c:22
#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 543 of file bug.c.

547 {
548  ULONG i;
549  BOOLEAN InSystem;
550  PLDR_DATA_TABLE_ENTRY LdrEntry;
551  PVOID ImageBase;
552  PUNICODE_STRING DriverName;
553  CHAR AnsiName[32];
554  PIMAGE_NT_HEADERS NtHeader;
556  BOOLEAN FirstRun = TRUE;
557 
558  /* Loop parameters */
559  for (i = 0; i < ParameterCount; i++)
560  {
561  /* Get the base for this parameter */
562  ImageBase = KiPcToFileHeader((PVOID)Parameters[i],
563  &LdrEntry,
564  FALSE,
565  &InSystem);
566  if (!ImageBase)
567  {
568  /* FIXME: Add code to check for unloaded drivers */
569  DPRINT1("Potentially unloaded driver!\n");
570  continue;
571  }
572  else
573  {
574  /* Get the NT Headers and Timestamp */
575  NtHeader = RtlImageNtHeader(LdrEntry->DllBase);
576  TimeStamp = NtHeader->FileHeader.TimeDateStamp;
577 
578  /* Convert the driver name */
579  DriverName = &LdrEntry->BaseDllName;
580  ConversionRoutine(&LdrEntry->BaseDllName,
581  AnsiName,
582  sizeof(AnsiName));
583  }
584 
585  /* Format driver name */
587  "%s** %12s - Address %p base at %p, DateStamp %08lx\r\n",
588  FirstRun ? "\r\n*":"*",
589  AnsiName,
590  (PVOID)Parameters[i],
591  ImageBase,
592  TimeStamp);
593 
594  /* Check if we only had one parameter */
595  if (ParameterCount <= 1)
596  {
597  /* Then just save the name */
598  KiBugCheckDriver = DriverName;
599  }
600  else
601  {
602  /* Otherwise, display the message */
604  }
605 
606  /* Loop again */
607  FirstRun = FALSE;
608  }
609 }
PUNICODE_STRING KiBugCheckDriver
Definition: bug.c:30
#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
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:45
CHAR Message[80]
Definition: alive.c:5
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
Definition: btrfs_drv.h:1922
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:466
unsigned int ULONG
Definition: retypes.h:1

Referenced by KeBugCheckWithTf(), and KiDisplayBlueScreen().

◆ KiHandleNmi()

BOOLEAN NTAPI KiHandleNmi ( VOID  )

Definition at line 1165 of file bug.c.

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

Referenced by KiTrap02Handler().

◆ KiInitializeBugCheck()

INIT_FUNCTION VOID NTAPI KiInitializeBugCheck ( VOID  )

Definition at line 301 of file bug.c.

302 {
304  LDR_RESOURCE_INFO ResourceInfo;
305  PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
307  PLDR_DATA_TABLE_ENTRY LdrEntry;
308 
309  /* Get the kernel entry */
312  InLoadOrderLinks);
313 
314  /* Cache the Bugcheck Message Strings. Prepare the Lookup Data */
315  ResourceInfo.Type = 11;
316  ResourceInfo.Name = 1;
317  ResourceInfo.Language = 9;
318 
319  /* Do the lookup. */
320  Status = LdrFindResource_U(LdrEntry->DllBase,
321  &ResourceInfo,
323  &ResourceDataEntry);
324 
325  /* Make sure it worked */
326  if (NT_SUCCESS(Status))
327  {
328  /* Now actually get a pointer to it */
329  Status = LdrAccessResource(LdrEntry->DllBase,
330  ResourceDataEntry,
331  (PVOID*)&BugCheckData,
332  NULL);
334  }
335 }
PMESSAGE_RESOURCE_DATA KiBugCodeMessages
Definition: bug.c:27
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
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:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static tBugCheckData BugCheckData
Definition: btrfs_drv.h:1922
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 45 of file bug.c.

49 {
50  ULONG i = 0;
51  PVOID ImageBase, PcBase = NULL;
53  PLIST_ENTRY ListHead, NextEntry;
54 
55  /* Check which list we should use */
58 
59  /* Assume no */
60  *InKernel = FALSE;
61 
62  /* Set list pointers and make sure it's valid */
63  NextEntry = ListHead->Flink;
64  if (NextEntry)
65  {
66  /* Start loop */
67  while (NextEntry != ListHead)
68  {
69  /* Increase entry */
70  i++;
71 
72  /* Check if this is a kernel entry and we only want drivers */
73  if ((i <= 2) && (DriversOnly != FALSE))
74  {
75  /* Skip it */
76  NextEntry = NextEntry->Flink;
77  continue;
78  }
79 
80  /* Get the loader entry */
81  Entry = CONTAINING_RECORD(NextEntry,
83  InLoadOrderLinks);
84 
85  /* Move to the next entry */
86  NextEntry = NextEntry->Flink;
87  ImageBase = Entry->DllBase;
88 
89  /* Check if this is the right one */
90  if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
91  ((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
92  {
93  /* Return this entry */
94  *LdrEntry = Entry;
95  PcBase = ImageBase;
96 
97  /* Check if this was a kernel or HAL entry */
98  if (i <= 2) *InKernel = TRUE;
99  break;
100  }
101  }
102  }
103 
104  /* Return the base address */
105  return PcBase;
106 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:627
uint32_t ULONG_PTR
Definition: typedefs.h:64
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:120
if(!(yy_init))
Definition: macro.lex.yy.c:714
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
Definition: btrfs_drv.h:1922
Definition: typedefs.h:118
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 110 of file bug.c.

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

Referenced by KiInitializeKernel(), and KiInitSystem().

◆ KeBugCheckActive

ULONG KeBugCheckActive

Definition at line 25 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugcheckCallbackListHead

LIST_ENTRY KeBugcheckCallbackListHead

◆ KeBugCheckCount

ULONG KeBugCheckCount = 1

Definition at line 28 of file bug.c.

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KeBugCheckOwner

ULONG KeBugCheckOwner

Definition at line 25 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugCheckOwnerRecursionCount

LONG KeBugCheckOwnerRecursionCount

Definition at line 26 of file bug.c.

Referenced by KeBugCheckWithTf().

◆ KeBugcheckReasonCallbackListHead

LIST_ENTRY KeBugcheckReasonCallbackListHead

Definition at line 23 of file bug.c.

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

◆ KeRosBiosDate

UNICODE_STRING KeRosBiosDate

Definition at line 38 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosBiosVersion

UNICODE_STRING KeRosBiosVersion

Definition at line 38 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosProcessorName

UNICODE_STRING KeRosProcessorName

Definition at line 38 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosVideoBiosDate

UNICODE_STRING KeRosVideoBiosDate

Definition at line 39 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KeRosVideoBiosVersion

UNICODE_STRING KeRosVideoBiosVersion

Definition at line 39 of file bug.c.

Referenced by CmpInitializeMachineDependentConfiguration().

◆ KiBugCheckData

ULONG_PTR KiBugCheckData[5]

◆ KiBugCheckDriver

PUNICODE_STRING KiBugCheckDriver

Definition at line 30 of file bug.c.

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

◆ KiBugCodeMessages

PMESSAGE_RESOURCE_DATA KiBugCodeMessages

Definition at line 27 of file bug.c.

Referenced by KeGetBugMessageText(), and KiInitializeBugCheck().

◆ KiHardwareTrigger

ULONG KiHardwareTrigger

Definition at line 29 of file bug.c.

Referenced by KeBugCheckWithTf(), and KeEnterKernelDebugger().

◆ KiNmiCallbackListHead

PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead = NULL

Definition at line 33 of file bug.c.

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

◆ KiNmiCallbackListLock

KSPIN_LOCK KiNmiCallbackListLock

Definition at line 34 of file bug.c.

Referenced by KiAcquireNmiListLock(), and KiReleaseNmiListLock().