2005-03-12 16:01:30 +00:00
|
|
|
/*
|
2006-08-30 05:22:56 +00:00
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
1998-08-28 23:24:42 +00:00
|
|
|
* FILE: ntoskrnl/ke/bug.c
|
2006-08-30 05:22:56 +00:00
|
|
|
* PURPOSE: Bugcheck Support
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
1998-08-25 04:27:26 +00:00
|
|
|
*/
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* INCLUDES ******************************************************************/
|
1998-08-25 04:27:26 +00:00
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2005-03-12 16:01:30 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
2003-07-15 16:26:18 +00:00
|
|
|
|
2005-11-28 23:25:31 +00:00
|
|
|
#if defined (ALLOC_PRAGMA)
|
|
|
|
#pragma alloc_text(INIT, KiInitializeBugCheck)
|
|
|
|
#endif
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2007-02-19 18:52:23 +00:00
|
|
|
LIST_ENTRY KeBugcheckCallbackListHead;
|
|
|
|
LIST_ENTRY KeBugcheckReasonCallbackListHead;
|
2006-09-02 04:40:09 +00:00
|
|
|
KSPIN_LOCK BugCheckCallbackLock;
|
2006-08-30 05:22:56 +00:00
|
|
|
ULONG KeBugCheckActive, KeBugCheckOwner;
|
|
|
|
LONG KeBugCheckOwnerRecursionCount;
|
2010-06-27 19:56:57 +00:00
|
|
|
PMESSAGE_RESOURCE_DATA KiBugCodeMessages;
|
2006-08-30 05:22:56 +00:00
|
|
|
ULONG KeBugCheckCount = 1;
|
|
|
|
ULONG KiHardwareTrigger;
|
|
|
|
PUNICODE_STRING KiBugCheckDriver;
|
|
|
|
ULONG_PTR KiBugCheckData[5];
|
2015-09-23 23:52:03 +00:00
|
|
|
|
|
|
|
PKNMI_HANDLER_CALLBACK KiNmiCallbackListHead = NULL;
|
2010-01-02 04:48:22 +00:00
|
|
|
KSPIN_LOCK KiNmiCallbackListLock;
|
2015-09-23 23:52:03 +00:00
|
|
|
#define TAG_KNMI 'IMNK'
|
2006-08-30 05:22:56 +00:00
|
|
|
|
2007-09-21 20:14:34 +00:00
|
|
|
/* Bugzilla Reporting */
|
|
|
|
UNICODE_STRING KeRosProcessorName, KeRosBiosDate, KeRosBiosVersion;
|
|
|
|
UNICODE_STRING KeRosVideoBiosDate, KeRosVideoBiosVersion;
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
1998-08-25 04:27:26 +00:00
|
|
|
|
2007-05-09 16:15:22 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2009-10-04 16:53:15 +00:00
|
|
|
KiPcToFileHeader(IN PVOID Pc,
|
2007-05-09 16:15:22 +00:00
|
|
|
OUT PLDR_DATA_TABLE_ENTRY *LdrEntry,
|
|
|
|
IN BOOLEAN DriversOnly,
|
|
|
|
OUT PBOOLEAN InKernel)
|
|
|
|
{
|
|
|
|
ULONG i = 0;
|
2009-10-04 16:53:15 +00:00
|
|
|
PVOID ImageBase, PcBase = NULL;
|
2007-05-09 16:15:22 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY Entry;
|
|
|
|
PLIST_ENTRY ListHead, NextEntry;
|
|
|
|
|
|
|
|
/* Check which list we should use */
|
|
|
|
ListHead = (KeLoaderBlock) ? &KeLoaderBlock->LoadOrderListHead :
|
|
|
|
&PsLoadedModuleList;
|
|
|
|
|
|
|
|
/* Assume no */
|
|
|
|
*InKernel = FALSE;
|
|
|
|
|
|
|
|
/* Set list pointers and make sure it's valid */
|
|
|
|
NextEntry = ListHead->Flink;
|
|
|
|
if (NextEntry)
|
|
|
|
{
|
|
|
|
/* Start loop */
|
|
|
|
while (NextEntry != ListHead)
|
|
|
|
{
|
|
|
|
/* Increase entry */
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* Check if this is a kernel entry and we only want drivers */
|
2014-11-15 22:47:51 +00:00
|
|
|
if ((i <= 2) && (DriversOnly != FALSE))
|
2007-05-09 16:15:22 +00:00
|
|
|
{
|
|
|
|
/* Skip it */
|
|
|
|
NextEntry = NextEntry->Flink;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the loader entry */
|
|
|
|
Entry = CONTAINING_RECORD(NextEntry,
|
|
|
|
LDR_DATA_TABLE_ENTRY,
|
|
|
|
InLoadOrderLinks);
|
|
|
|
|
|
|
|
/* Move to the next entry */
|
|
|
|
NextEntry = NextEntry->Flink;
|
|
|
|
ImageBase = Entry->DllBase;
|
|
|
|
|
|
|
|
/* Check if this is the right one */
|
2009-10-04 16:53:15 +00:00
|
|
|
if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
|
|
|
|
((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
|
2007-05-09 16:15:22 +00:00
|
|
|
{
|
|
|
|
/* Return this entry */
|
|
|
|
*LdrEntry = Entry;
|
2009-10-04 16:53:15 +00:00
|
|
|
PcBase = ImageBase;
|
2007-05-09 16:15:22 +00:00
|
|
|
|
|
|
|
/* Check if this was a kernel or HAL entry */
|
|
|
|
if (i <= 2) *InKernel = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the base address */
|
2009-10-04 16:53:15 +00:00
|
|
|
return PcBase;
|
2007-05-09 16:15:22 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2009-10-04 16:53:15 +00:00
|
|
|
KiRosPcToUserFileHeader(IN PVOID Pc,
|
2007-10-01 17:58:49 +00:00
|
|
|
OUT PLDR_DATA_TABLE_ENTRY *LdrEntry)
|
|
|
|
{
|
2009-10-04 16:53:15 +00:00
|
|
|
PVOID ImageBase, PcBase = NULL;
|
2007-10-01 17:58:49 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY Entry;
|
|
|
|
PLIST_ENTRY ListHead, NextEntry;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/*
|
|
|
|
* We know this is valid because we should only be called after a
|
|
|
|
* succesfull address from RtlWalkFrameChain for UserMode, which
|
|
|
|
* validates everything for us.
|
|
|
|
*/
|
|
|
|
ListHead = &KeGetCurrentThread()->
|
|
|
|
Teb->ProcessEnvironmentBlock->Ldr->InLoadOrderModuleList;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Set list pointers and make sure it's valid */
|
|
|
|
NextEntry = ListHead->Flink;
|
|
|
|
if (NextEntry)
|
|
|
|
{
|
|
|
|
/* Start loop */
|
|
|
|
while (NextEntry != ListHead)
|
|
|
|
{
|
|
|
|
/* Get the loader entry */
|
|
|
|
Entry = CONTAINING_RECORD(NextEntry,
|
|
|
|
LDR_DATA_TABLE_ENTRY,
|
|
|
|
InLoadOrderLinks);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Move to the next entry */
|
|
|
|
NextEntry = NextEntry->Flink;
|
|
|
|
ImageBase = Entry->DllBase;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Check if this is the right one */
|
2009-10-04 16:53:15 +00:00
|
|
|
if (((ULONG_PTR)Pc >= (ULONG_PTR)Entry->DllBase) &&
|
|
|
|
((ULONG_PTR)Pc < ((ULONG_PTR)Entry->DllBase + Entry->SizeOfImage)))
|
2007-10-01 17:58:49 +00:00
|
|
|
{
|
|
|
|
/* Return this entry */
|
|
|
|
*LdrEntry = Entry;
|
2009-10-04 16:53:15 +00:00
|
|
|
PcBase = ImageBase;
|
2007-10-01 17:58:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Return the base address */
|
2009-10-04 16:53:15 +00:00
|
|
|
return PcBase;
|
2007-10-01 17:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
USHORT
|
|
|
|
NTAPI
|
|
|
|
KeRosCaptureUserStackBackTrace(IN ULONG FramesToSkip,
|
|
|
|
IN ULONG FramesToCapture,
|
|
|
|
OUT PVOID *BackTrace,
|
|
|
|
OUT PULONG BackTraceHash OPTIONAL)
|
|
|
|
{
|
|
|
|
PVOID Frames[2 * 64];
|
|
|
|
ULONG FrameCount;
|
|
|
|
ULONG Hash = 0, i;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Skip a frame for the caller */
|
|
|
|
FramesToSkip++;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Don't go past the limit */
|
|
|
|
if ((FramesToCapture + FramesToSkip) >= 128) return 0;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Do the back trace */
|
|
|
|
FrameCount = RtlWalkFrameChain(Frames, FramesToCapture + FramesToSkip, 1);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Make sure we're not skipping all of them */
|
|
|
|
if (FrameCount <= FramesToSkip) return 0;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Loop all the frames */
|
|
|
|
for (i = 0; i < FramesToCapture; i++)
|
|
|
|
{
|
|
|
|
/* Don't go past the limit */
|
|
|
|
if ((FramesToSkip + i) >= FrameCount) break;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Save this entry and hash it */
|
|
|
|
BackTrace[i] = Frames[FramesToSkip + i];
|
|
|
|
Hash += PtrToUlong(BackTrace[i]);
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Write the hash */
|
|
|
|
if (BackTraceHash) *BackTraceHash = Hash;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-10-01 17:58:49 +00:00
|
|
|
/* Clear the other entries and return count */
|
|
|
|
RtlFillMemoryUlong(Frames, 128, 0);
|
|
|
|
return (USHORT)i;
|
|
|
|
}
|
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
VOID
|
2008-03-14 23:51:27 +00:00
|
|
|
FASTCALL
|
2010-07-16 00:34:26 +00:00
|
|
|
KeRosDumpStackFrameArray(IN PULONG_PTR Frames,
|
2008-03-14 23:51:27 +00:00
|
|
|
IN ULONG FrameCount)
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
ULONG i;
|
|
|
|
ULONG_PTR Addr;
|
2007-05-09 16:15:22 +00:00
|
|
|
BOOLEAN InSystem;
|
2008-03-14 23:51:27 +00:00
|
|
|
PVOID p;
|
2008-12-03 17:38:56 +00:00
|
|
|
|
|
|
|
/* GCC complaints that it may be used uninitialized */
|
|
|
|
PLDR_DATA_TABLE_ENTRY LdrEntry = NULL;
|
2005-03-12 16:01:30 +00:00
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
/* Loop them */
|
2006-08-30 06:52:10 +00:00
|
|
|
for (i = 0; i < FrameCount; i++)
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
|
|
|
/* Get the EIP */
|
|
|
|
Addr = Frames[i];
|
2008-03-14 23:51:27 +00:00
|
|
|
if (!Addr)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
/* Get the base for this file */
|
|
|
|
if (Addr > (ULONG_PTR)MmHighestUserAddress)
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
2008-03-14 23:51:27 +00:00
|
|
|
/* We are in kernel */
|
|
|
|
p = KiPcToFileHeader((PVOID)Addr, &LdrEntry, FALSE, &InSystem);
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
2008-03-14 23:51:27 +00:00
|
|
|
else
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
2008-03-14 23:51:27 +00:00
|
|
|
/* We are in user land */
|
|
|
|
p = KiRosPcToUserFileHeader((PVOID)Addr, &LdrEntry);
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
2008-03-14 23:51:27 +00:00
|
|
|
if (p)
|
2007-05-09 16:15:22 +00:00
|
|
|
{
|
2007-11-27 12:51:08 +00:00
|
|
|
#ifdef KDBG
|
2011-06-01 20:36:40 +00:00
|
|
|
if (!KdbSymPrintAddress((PVOID)Addr, NULL))
|
2007-11-27 12:51:08 +00:00
|
|
|
#endif
|
|
|
|
{
|
2012-03-26 13:51:15 +00:00
|
|
|
CHAR AnsiName[64];
|
|
|
|
|
|
|
|
/* Convert module name to ANSI and print it */
|
|
|
|
KeBugCheckUnicodeToAnsi(&LdrEntry->BaseDllName,
|
|
|
|
AnsiName,
|
|
|
|
sizeof(AnsiName));
|
2007-11-27 12:51:08 +00:00
|
|
|
Addr -= (ULONG_PTR)LdrEntry->DllBase;
|
2012-03-26 13:51:15 +00:00
|
|
|
DbgPrint("<%s: %p>", AnsiName, (PVOID)Addr);
|
2007-11-27 12:51:08 +00:00
|
|
|
}
|
2007-05-09 16:15:22 +00:00
|
|
|
}
|
2008-03-14 23:51:27 +00:00
|
|
|
else
|
2007-10-01 17:58:49 +00:00
|
|
|
{
|
|
|
|
/* Print only the address */
|
2010-07-16 00:34:26 +00:00
|
|
|
DbgPrint("<%p>", (PVOID)Addr);
|
2007-10-01 17:58:49 +00:00
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Go to the next frame */
|
|
|
|
DbgPrint("\n");
|
2003-08-22 14:49:54 +00:00
|
|
|
}
|
2008-03-14 23:51:27 +00:00
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2010-07-16 00:34:26 +00:00
|
|
|
KeRosDumpStackFrames(IN PULONG_PTR Frame OPTIONAL,
|
2008-03-14 23:51:27 +00:00
|
|
|
IN ULONG FrameCount OPTIONAL)
|
|
|
|
{
|
2010-07-16 00:34:26 +00:00
|
|
|
ULONG_PTR Frames[32];
|
2008-03-14 23:51:27 +00:00
|
|
|
ULONG RealFrameCount;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
/* If the caller didn't ask, assume 32 frames */
|
|
|
|
if (!FrameCount || FrameCount > 32) FrameCount = 32;
|
|
|
|
|
|
|
|
if (Frame)
|
2007-10-01 17:58:49 +00:00
|
|
|
{
|
2008-03-14 23:51:27 +00:00
|
|
|
/* Dump them */
|
|
|
|
KeRosDumpStackFrameArray(Frame, FrameCount);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get the current frames (skip the two. One for the dumper, one for the caller) */
|
|
|
|
RealFrameCount = RtlCaptureStackBackTrace(2, FrameCount, (PVOID*)Frames, NULL);
|
2014-03-02 13:01:16 +00:00
|
|
|
DPRINT1("RealFrameCount =%lu\n", RealFrameCount);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
/* Dump them */
|
|
|
|
KeRosDumpStackFrameArray(Frames, RealFrameCount);
|
|
|
|
|
|
|
|
/* Count left for user mode? */
|
|
|
|
if (FrameCount - RealFrameCount > 0)
|
2007-10-01 17:58:49 +00:00
|
|
|
{
|
2008-03-14 23:51:27 +00:00
|
|
|
/* Get the current frames */
|
|
|
|
RealFrameCount = KeRosCaptureUserStackBackTrace(-1, FrameCount - RealFrameCount, (PVOID*)Frames, NULL);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2008-03-14 23:51:27 +00:00
|
|
|
/* Dump them */
|
|
|
|
KeRosDumpStackFrameArray(Frames, RealFrameCount);
|
|
|
|
}
|
2007-10-01 17:58:49 +00:00
|
|
|
}
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
2003-12-30 18:52:06 +00:00
|
|
|
|
2007-09-21 20:14:34 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KeRosDumpTriageForBugZillaReport(VOID)
|
|
|
|
{
|
2007-10-06 07:53:20 +00:00
|
|
|
#if 0
|
2007-09-21 20:14:34 +00:00
|
|
|
extern BOOLEAN KiFastSystemCallDisable, KiSMTProcessorsPresent;
|
|
|
|
extern ULONG KeI386MachineType, MxcsrFeatureMask;
|
|
|
|
extern BOOLEAN Ke386Pae, Ke386NoExecute;
|
|
|
|
|
2013-06-02 18:41:40 +00:00
|
|
|
DbgPrint("ReactOS has crashed! Please go to http://jira.reactos.org/ to file a bug!\n");
|
2007-09-21 20:14:34 +00:00
|
|
|
DbgPrint("\nHardware Information\n");
|
|
|
|
DbgPrint("Processor Architecture: %d\n"
|
|
|
|
"Feature Bits: %d\n"
|
|
|
|
"System Call Disabled: %d\n"
|
|
|
|
"NPX Present: %d\n"
|
|
|
|
"MXCsr Mask: %d\n"
|
|
|
|
"MXCsr Feature Mask: %d\n"
|
|
|
|
"XMMI Present: %d\n"
|
|
|
|
"FXSR Present: %d\n"
|
|
|
|
"Machine Type: %d\n"
|
|
|
|
"PAE: %d\n"
|
|
|
|
"NX: %d\n"
|
|
|
|
"Processors: %d\n"
|
|
|
|
"Active Processors: %d\n"
|
|
|
|
"Pentium LOCK Bug: %d\n"
|
|
|
|
"Hyperthreading: %d\n"
|
|
|
|
"CPU Manufacturer: %s\n"
|
|
|
|
"CPU Name: %wZ\n"
|
|
|
|
"CPUID: %d\n"
|
|
|
|
"CPU Type: %d\n"
|
|
|
|
"CPU Stepping: %d\n"
|
|
|
|
"CPU Speed: %d\n"
|
|
|
|
"CPU L2 Cache: %d\n"
|
|
|
|
"BIOS Date: %wZ\n"
|
|
|
|
"BIOS Version: %wZ\n"
|
|
|
|
"Video BIOS Date: %wZ\n"
|
|
|
|
"Video BIOS Version: %wZ\n"
|
2007-09-27 13:07:43 +00:00
|
|
|
"Memory: %d\n",
|
2007-09-21 20:14:34 +00:00
|
|
|
KeProcessorArchitecture,
|
|
|
|
KeFeatureBits,
|
|
|
|
KiFastSystemCallDisable,
|
|
|
|
KeI386NpxPresent,
|
|
|
|
KiMXCsrMask,
|
|
|
|
MxcsrFeatureMask,
|
|
|
|
KeI386XMMIPresent,
|
|
|
|
KeI386FxsrPresent,
|
|
|
|
KeI386MachineType,
|
|
|
|
Ke386Pae,
|
|
|
|
Ke386NoExecute,
|
|
|
|
KeNumberProcessors,
|
|
|
|
KeActiveProcessors,
|
|
|
|
KiI386PentiumLockErrataPresent,
|
|
|
|
KiSMTProcessorsPresent,
|
|
|
|
KeGetCurrentPrcb()->VendorString,
|
|
|
|
&KeRosProcessorName,
|
|
|
|
KeGetCurrentPrcb()->CpuID,
|
|
|
|
KeGetCurrentPrcb()->CpuType,
|
|
|
|
KeGetCurrentPrcb()->CpuStep,
|
|
|
|
KeGetCurrentPrcb()->MHz,
|
|
|
|
((PKIPCR)KeGetPcr())->SecondLevelCacheSize,
|
|
|
|
&KeRosBiosDate,
|
|
|
|
&KeRosBiosVersion,
|
|
|
|
&KeRosVideoBiosDate,
|
|
|
|
&KeRosVideoBiosVersion,
|
2007-09-27 18:07:44 +00:00
|
|
|
MmNumberOfPhysicalPages * PAGE_SIZE);
|
2007-09-21 20:14:34 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
VOID
|
|
|
|
INIT_FUNCTION
|
|
|
|
NTAPI
|
|
|
|
KiInitializeBugCheck(VOID)
|
2005-03-12 16:01:30 +00:00
|
|
|
{
|
2010-06-27 19:56:57 +00:00
|
|
|
PMESSAGE_RESOURCE_DATA BugCheckData;
|
2006-08-30 05:22:56 +00:00
|
|
|
LDR_RESOURCE_INFO ResourceInfo;
|
|
|
|
PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry;
|
|
|
|
NTSTATUS Status;
|
2006-10-07 22:23:35 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
|
|
|
|
|
|
|
/* Get the kernel entry */
|
|
|
|
LdrEntry = CONTAINING_RECORD(KeLoaderBlock->LoadOrderListHead.Flink,
|
|
|
|
LDR_DATA_TABLE_ENTRY,
|
|
|
|
InLoadOrderLinks);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Cache the Bugcheck Message Strings. Prepare the Lookup Data */
|
|
|
|
ResourceInfo.Type = 11;
|
|
|
|
ResourceInfo.Name = 1;
|
|
|
|
ResourceInfo.Language = 9;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Do the lookup. */
|
2006-10-07 22:23:35 +00:00
|
|
|
Status = LdrFindResource_U(LdrEntry->DllBase,
|
2006-08-30 05:22:56 +00:00
|
|
|
&ResourceInfo,
|
|
|
|
RESOURCE_DATA_LEVEL,
|
|
|
|
&ResourceDataEntry);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Make sure it worked */
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Now actually get a pointer to it */
|
2006-10-07 22:23:35 +00:00
|
|
|
Status = LdrAccessResource(LdrEntry->DllBase,
|
2006-08-30 05:22:56 +00:00
|
|
|
ResourceDataEntry,
|
|
|
|
(PVOID*)&BugCheckData,
|
|
|
|
NULL);
|
|
|
|
if (NT_SUCCESS(Status)) KiBugCodeMessages = BugCheckData;
|
2005-01-02 17:55:06 +00:00
|
|
|
}
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 01:35:43 +00:00
|
|
|
BOOLEAN
|
2006-08-30 05:22:56 +00:00
|
|
|
NTAPI
|
|
|
|
KeGetBugMessageText(IN ULONG BugCheckCode,
|
|
|
|
OUT PANSI_STRING OutputString OPTIONAL)
|
2005-03-12 16:01:30 +00:00
|
|
|
{
|
2012-01-14 11:14:40 +00:00
|
|
|
ULONG i, j;
|
2005-03-12 16:01:30 +00:00
|
|
|
ULONG IdOffset;
|
|
|
|
ULONG_PTR MessageEntry;
|
|
|
|
PCHAR BugCode;
|
2007-03-05 01:35:43 +00:00
|
|
|
BOOLEAN Result = FALSE;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
USHORT Length;
|
2007-03-05 01:35:43 +00:00
|
|
|
|
|
|
|
/* Make sure we're not bugchecking too early */
|
|
|
|
if (!KiBugCodeMessages) return Result;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Find the message. This code is based on RtlFindMesssage */
|
|
|
|
for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Check if the ID Matches */
|
|
|
|
if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
|
2006-08-30 05:22:56 +00:00
|
|
|
(BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
|
2007-03-05 01:35:43 +00:00
|
|
|
{
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Get Offset to Entry */
|
2006-08-30 05:22:56 +00:00
|
|
|
MessageEntry = KiBugCodeMessages->Blocks[i].OffsetToEntries +
|
|
|
|
(ULONG_PTR)KiBugCodeMessages;
|
2005-03-12 16:01:30 +00:00
|
|
|
IdOffset = BugCheckCode - KiBugCodeMessages->Blocks[i].LowId;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Get offset to ID */
|
2012-01-14 11:14:40 +00:00
|
|
|
for (j = 0; j < IdOffset; j++)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2005-05-09 01:38:29 +00:00
|
|
|
/* Advance in the Entries */
|
2010-06-27 20:38:12 +00:00
|
|
|
MessageEntry += ((PMESSAGE_RESOURCE_ENTRY)MessageEntry)->
|
2006-08-30 05:22:56 +00:00
|
|
|
Length;
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Get the final Code */
|
2010-06-27 20:45:15 +00:00
|
|
|
BugCode = (PCHAR)((PMESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
Length = (USHORT)strlen(BugCode);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
/* Handle trailing newlines */
|
|
|
|
while ((Length > 0) && ((BugCode[Length] == '\n') ||
|
|
|
|
(BugCode[Length] == '\r') ||
|
|
|
|
(BugCode[Length] == ANSI_NULL)))
|
2007-03-05 01:35:43 +00:00
|
|
|
{
|
|
|
|
/* Check if we have a string to return */
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
if (!OutputString) BugCode[Length] = ANSI_NULL;
|
|
|
|
Length--;
|
2007-03-05 01:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if caller wants an output string */
|
2006-08-30 05:22:56 +00:00
|
|
|
if (OutputString)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2007-03-05 01:35:43 +00:00
|
|
|
/* Return it in the OutputString */
|
2005-03-12 16:01:30 +00:00
|
|
|
OutputString->Buffer = BugCode;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
OutputString->Length = Length + 1;
|
|
|
|
OutputString->MaximumLength = Length + 1;
|
2005-06-04 00:25:04 +00:00
|
|
|
}
|
2006-11-05 21:00:42 +00:00
|
|
|
else
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Direct Output to Screen */
|
2006-08-30 05:22:56 +00:00
|
|
|
InbvDisplayString(BugCode);
|
|
|
|
InbvDisplayString("\r");
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
2007-03-05 01:35:43 +00:00
|
|
|
|
|
|
|
/* We're done */
|
|
|
|
Result = TRUE;
|
|
|
|
break;
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
2003-08-27 21:28:08 +00:00
|
|
|
}
|
2007-03-05 01:35:43 +00:00
|
|
|
|
|
|
|
/* Return the result */
|
|
|
|
return Result;
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
2006-08-30 05:22:56 +00:00
|
|
|
NTAPI
|
2005-03-12 16:01:30 +00:00
|
|
|
KiDoBugCheckCallbacks(VOID)
|
|
|
|
{
|
|
|
|
PKBUGCHECK_CALLBACK_RECORD CurrentRecord;
|
2006-08-30 05:22:56 +00:00
|
|
|
PLIST_ENTRY ListHead, NextEntry, LastEntry;
|
|
|
|
ULONG_PTR Checksum;
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2005-03-12 16:01:30 +00:00
|
|
|
/* First make sure that the list is Initialized... it might not be */
|
2007-02-19 18:52:23 +00:00
|
|
|
ListHead = &KeBugcheckCallbackListHead;
|
2006-08-30 05:22:56 +00:00
|
|
|
if ((ListHead->Flink) && (ListHead->Blink))
|
|
|
|
{
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Loop the list */
|
2006-08-30 05:22:56 +00:00
|
|
|
LastEntry = ListHead;
|
|
|
|
NextEntry = ListHead->Flink;
|
|
|
|
while (NextEntry != ListHead)
|
2005-09-26 22:57:48 +00:00
|
|
|
{
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Get the reord */
|
|
|
|
CurrentRecord = CONTAINING_RECORD(NextEntry,
|
|
|
|
KBUGCHECK_CALLBACK_RECORD,
|
|
|
|
Entry);
|
|
|
|
|
|
|
|
/* Validate it */
|
|
|
|
if (CurrentRecord->Entry.Blink != LastEntry) return;
|
|
|
|
Checksum = (ULONG_PTR)CurrentRecord->CallbackRoutine;
|
|
|
|
Checksum += (ULONG_PTR)CurrentRecord->Buffer;
|
|
|
|
Checksum += (ULONG_PTR)CurrentRecord->Length;
|
|
|
|
Checksum += (ULONG_PTR)CurrentRecord->Component;
|
|
|
|
|
|
|
|
/* Make sure it's inserted and valitdated */
|
|
|
|
if ((CurrentRecord->State == BufferInserted) &&
|
|
|
|
(CurrentRecord->Checksum == Checksum))
|
|
|
|
{
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Call the routine */
|
|
|
|
CurrentRecord->State = BufferStarted;
|
2005-05-09 01:38:29 +00:00
|
|
|
(CurrentRecord->CallbackRoutine)(CurrentRecord->Buffer,
|
2005-03-12 16:01:30 +00:00
|
|
|
CurrentRecord->Length);
|
|
|
|
CurrentRecord->State = BufferFinished;
|
|
|
|
}
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Go to the next entry */
|
|
|
|
LastEntry = NextEntry;
|
|
|
|
NextEntry = NextEntry->Flink;
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
2003-04-24 16:53:59 +00:00
|
|
|
}
|
2005-03-12 16:01:30 +00:00
|
|
|
}
|
|
|
|
|
2005-05-09 01:38:29 +00:00
|
|
|
VOID
|
2006-08-30 05:22:56 +00:00
|
|
|
NTAPI
|
|
|
|
KiBugCheckDebugBreak(IN ULONG StatusCode)
|
2005-03-12 16:01:30 +00:00
|
|
|
{
|
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly.
- Fail on physical memory write like we do for read too.
- Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows.
- Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics.
- Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely.
- Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again.
- Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code.
- Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example).
- Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers).
- Crashing and rebooting from KD now works properly.
svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
|
|
|
/*
|
|
|
|
* Wrap this in SEH so we don't crash if
|
|
|
|
* there is no debugger or if it disconnected
|
|
|
|
*/
|
|
|
|
DoBreak:
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
/* Breakpoint */
|
|
|
|
DbgBreakPointWithStatus(StatusCode);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
/* No debugger, halt the CPU */
|
|
|
|
HalHaltSystem();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
/* Break again if this wasn't first try */
|
|
|
|
if (StatusCode != DBG_STATUS_BUGCHECK_FIRST) goto DoBreak;
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PCHAR
|
|
|
|
NTAPI
|
|
|
|
KeBugCheckUnicodeToAnsi(IN PUNICODE_STRING Unicode,
|
|
|
|
OUT PCHAR Ansi,
|
|
|
|
IN ULONG Length)
|
|
|
|
{
|
|
|
|
PCHAR p;
|
|
|
|
PWCHAR pw;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
/* Set length and normalize it */
|
|
|
|
i = Unicode->Length / sizeof(WCHAR);
|
|
|
|
i = min(i, Length - 1);
|
|
|
|
|
|
|
|
/* Set source and destination, and copy */
|
|
|
|
pw = Unicode->Buffer;
|
|
|
|
p = Ansi;
|
|
|
|
while (i--) *p++ = (CHAR)*pw++;
|
|
|
|
|
|
|
|
/* Null terminate and return */
|
|
|
|
*p = ANSI_NULL;
|
|
|
|
return Ansi;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KiDumpParameterImages(IN PCHAR Message,
|
|
|
|
IN PULONG_PTR Parameters,
|
|
|
|
IN ULONG ParameterCount,
|
|
|
|
IN PKE_BUGCHECK_UNICODE_TO_ANSI ConversionRoutine)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
BOOLEAN InSystem;
|
|
|
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
|
|
|
PVOID ImageBase;
|
|
|
|
PUNICODE_STRING DriverName;
|
|
|
|
CHAR AnsiName[32];
|
|
|
|
PIMAGE_NT_HEADERS NtHeader;
|
|
|
|
ULONG TimeStamp;
|
|
|
|
BOOLEAN FirstRun = TRUE;
|
|
|
|
|
|
|
|
/* Loop parameters */
|
|
|
|
for (i = 0; i < ParameterCount; i++)
|
|
|
|
{
|
|
|
|
/* Get the base for this parameter */
|
|
|
|
ImageBase = KiPcToFileHeader((PVOID)Parameters[i],
|
|
|
|
&LdrEntry,
|
|
|
|
FALSE,
|
|
|
|
&InSystem);
|
|
|
|
if (!ImageBase)
|
|
|
|
{
|
2008-11-26 18:56:41 +00:00
|
|
|
/* FIXME: Add code to check for unloaded drivers */
|
|
|
|
DPRINT1("Potentially unloaded driver!\n");
|
|
|
|
continue;
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get the NT Headers and Timestamp */
|
|
|
|
NtHeader = RtlImageNtHeader(LdrEntry->DllBase);
|
|
|
|
TimeStamp = NtHeader->FileHeader.TimeDateStamp;
|
|
|
|
|
|
|
|
/* Convert the driver name */
|
|
|
|
DriverName = &LdrEntry->BaseDllName;
|
|
|
|
ConversionRoutine(&LdrEntry->BaseDllName,
|
|
|
|
AnsiName,
|
|
|
|
sizeof(AnsiName));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Format driver name */
|
|
|
|
sprintf(Message,
|
2013-10-13 23:04:13 +00:00
|
|
|
"%s** %12s - Address %p base at %p, DateStamp %08lx\r\n",
|
2006-08-30 05:22:56 +00:00
|
|
|
FirstRun ? "\r\n*":"*",
|
|
|
|
AnsiName,
|
|
|
|
(PVOID)Parameters[i],
|
|
|
|
ImageBase,
|
|
|
|
TimeStamp);
|
|
|
|
|
|
|
|
/* Check if we only had one parameter */
|
|
|
|
if (ParameterCount <= 1)
|
|
|
|
{
|
|
|
|
/* Then just save the name */
|
|
|
|
KiBugCheckDriver = DriverName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise, display the message */
|
|
|
|
InbvDisplayString(Message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop again */
|
|
|
|
FirstRun = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KiDisplayBlueScreen(IN ULONG MessageId,
|
|
|
|
IN BOOLEAN IsHardError,
|
|
|
|
IN PCHAR HardErrCaption OPTIONAL,
|
|
|
|
IN PCHAR HardErrMessage OPTIONAL,
|
|
|
|
IN PCHAR Message)
|
|
|
|
{
|
|
|
|
CHAR AnsiName[75];
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2007-02-18 20:47:04 +00:00
|
|
|
/* Check if bootvid is installed */
|
|
|
|
if (InbvIsBootDriverInstalled())
|
|
|
|
{
|
|
|
|
/* Acquire ownership and reset the display */
|
|
|
|
InbvAcquireDisplayOwnership();
|
|
|
|
InbvResetDisplay();
|
|
|
|
|
|
|
|
/* Display blue screen */
|
|
|
|
InbvSolidColorFill(0, 0, 639, 479, 4);
|
|
|
|
InbvSetTextColor(15);
|
|
|
|
InbvInstallDisplayStringFilter(NULL);
|
|
|
|
InbvEnableDisplayString(TRUE);
|
|
|
|
InbvSetScrollRegion(0, 0, 639, 479);
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Check if this is a hard error */
|
|
|
|
if (IsHardError)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Display caption and message */
|
|
|
|
if (HardErrCaption) InbvDisplayString(HardErrCaption);
|
|
|
|
if (HardErrMessage) InbvDisplayString(HardErrMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin the display */
|
|
|
|
InbvDisplayString("\r\n");
|
|
|
|
|
|
|
|
/* Print out initial message */
|
|
|
|
KeGetBugMessageText(BUGCHECK_MESSAGE_INTRO, NULL);
|
|
|
|
InbvDisplayString("\r\n\r\n");
|
|
|
|
|
|
|
|
/* Check if we have a driver */
|
|
|
|
if (KiBugCheckDriver)
|
|
|
|
{
|
|
|
|
/* Print out into to driver name */
|
|
|
|
KeGetBugMessageText(BUGCODE_ID_DRIVER, NULL);
|
|
|
|
|
|
|
|
/* Convert and print out driver name */
|
|
|
|
KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
|
|
|
|
InbvDisplayString(" ");
|
|
|
|
InbvDisplayString(AnsiName);
|
|
|
|
InbvDisplayString("\r\n\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if this is the generic message */
|
|
|
|
if (MessageId == BUGCODE_PSS_MESSAGE)
|
|
|
|
{
|
|
|
|
/* It is, so get the bug code string as well */
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
KeGetBugMessageText((ULONG)KiBugCheckData[0], NULL);
|
2006-08-30 05:22:56 +00:00
|
|
|
InbvDisplayString("\r\n\r\n");
|
2003-04-24 16:53:59 +00:00
|
|
|
}
|
2005-03-12 16:01:30 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Print second introduction message */
|
|
|
|
KeGetBugMessageText(PSS_MESSAGE_INTRO, NULL);
|
|
|
|
InbvDisplayString("\r\n\r\n");
|
|
|
|
|
|
|
|
/* Get the bug code string */
|
|
|
|
KeGetBugMessageText(MessageId, NULL);
|
|
|
|
InbvDisplayString("\r\n\r\n");
|
|
|
|
|
|
|
|
/* Print message for technical information */
|
|
|
|
KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
|
2005-03-12 16:01:30 +00:00
|
|
|
|
2007-03-05 01:35:43 +00:00
|
|
|
/* Show the technical Data */
|
2006-08-30 05:22:56 +00:00
|
|
|
sprintf(AnsiName,
|
|
|
|
"\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
|
|
|
|
KiBugCheckData[0],
|
|
|
|
(PVOID)KiBugCheckData[1],
|
|
|
|
(PVOID)KiBugCheckData[2],
|
|
|
|
(PVOID)KiBugCheckData[3],
|
|
|
|
(PVOID)KiBugCheckData[4]);
|
|
|
|
InbvDisplayString(AnsiName);
|
|
|
|
|
|
|
|
/* Check if we have a driver*/
|
|
|
|
if (KiBugCheckDriver)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Display technical driver data */
|
|
|
|
InbvDisplayString(Message);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Dump parameter information */
|
|
|
|
KiDumpParameterImages(Message,
|
|
|
|
(PVOID)&KiBugCheckData[1],
|
|
|
|
4,
|
|
|
|
KeBugCheckUnicodeToAnsi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
|
|
|
CONTEXT Context;
|
|
|
|
ULONG MessageId;
|
|
|
|
CHAR AnsiName[128];
|
2007-02-18 20:47:04 +00:00
|
|
|
BOOLEAN IsSystem, IsHardError = FALSE, Reboot = FALSE;
|
2006-08-30 05:22:56 +00:00
|
|
|
PCHAR HardErrCaption = NULL, HardErrMessage = NULL;
|
2009-10-04 16:53:15 +00:00
|
|
|
PVOID Pc = NULL, Memory;
|
2006-08-30 05:22:56 +00:00
|
|
|
PVOID DriverBase;
|
|
|
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
|
|
|
PULONG_PTR HardErrorParameters;
|
2008-02-07 07:10:13 +00:00
|
|
|
KIRQL OldIrql;
|
2006-11-05 21:00:42 +00:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
LONG i = 0;
|
|
|
|
#endif
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Set active bugcheck */
|
|
|
|
KeBugCheckActive = TRUE;
|
|
|
|
KiBugCheckDriver = NULL;
|
|
|
|
|
|
|
|
/* Check if this is power failure simulation */
|
|
|
|
if (BugCheckCode == POWER_FAILURE_SIMULATE)
|
|
|
|
{
|
2011-11-26 09:56:23 +00:00
|
|
|
/* Call the Callbacks and reboot */
|
2006-08-30 05:22:56 +00:00
|
|
|
KiDoBugCheckCallbacks();
|
|
|
|
HalReturnToFirmware(HalRebootRoutine);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the IRQL and set hardware trigger */
|
|
|
|
Prcb->DebuggerSavedIRQL = KeGetCurrentIrql();
|
2006-08-30 21:47:38 +00:00
|
|
|
InterlockedIncrement((PLONG)&KiHardwareTrigger);
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Capture the CPU Context */
|
|
|
|
RtlCaptureContext(&Prcb->ProcessorState.ContextFrame);
|
2007-02-18 20:47:04 +00:00
|
|
|
KiSaveProcessorControlState(&Prcb->ProcessorState);
|
2006-08-30 05:22:56 +00:00
|
|
|
Context = Prcb->ProcessorState.ContextFrame;
|
|
|
|
|
2007-02-18 20:47:04 +00:00
|
|
|
/* FIXME: Call the Watchdog if it's registered */
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Check which bugcode this is */
|
|
|
|
switch (BugCheckCode)
|
|
|
|
{
|
|
|
|
/* These bug checks already have detailed messages, keep them */
|
|
|
|
case UNEXPECTED_KERNEL_MODE_TRAP:
|
|
|
|
case DRIVER_CORRUPTED_EXPOOL:
|
|
|
|
case ACPI_BIOS_ERROR:
|
|
|
|
case ACPI_BIOS_FATAL_ERROR:
|
|
|
|
case THREAD_STUCK_IN_DEVICE_DRIVER:
|
|
|
|
case DATA_BUS_ERROR:
|
|
|
|
case FAT_FILE_SYSTEM:
|
|
|
|
case NO_MORE_SYSTEM_PTES:
|
|
|
|
case INACCESSIBLE_BOOT_DEVICE:
|
|
|
|
|
|
|
|
/* Keep the same code */
|
|
|
|
MessageId = BugCheckCode;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if this is a kernel-mode exception */
|
|
|
|
case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
|
2009-12-10 08:54:53 +00:00
|
|
|
case SYSTEM_THREAD_EXCEPTION_NOT_HANDLED:
|
2007-02-18 20:47:04 +00:00
|
|
|
case KMODE_EXCEPTION_NOT_HANDLED:
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Use the generic text message */
|
|
|
|
MessageId = KMODE_EXCEPTION_NOT_HANDLED;
|
2007-02-18 20:47:04 +00:00
|
|
|
break;
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* File-system errors */
|
|
|
|
case NTFS_FILE_SYSTEM:
|
|
|
|
|
|
|
|
/* Use the generic message for FAT */
|
|
|
|
MessageId = FAT_FILE_SYSTEM;
|
2007-02-18 20:47:04 +00:00
|
|
|
break;
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Check if this is a coruption of the Mm's Pool */
|
|
|
|
case DRIVER_CORRUPTED_MMPOOL:
|
|
|
|
|
|
|
|
/* Use generic corruption message */
|
|
|
|
MessageId = DRIVER_CORRUPTED_EXPOOL;
|
2007-02-18 20:47:04 +00:00
|
|
|
break;
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Check if this is a signature check failure */
|
|
|
|
case STATUS_SYSTEM_IMAGE_BAD_SIGNATURE:
|
|
|
|
|
|
|
|
/* Use the generic corruption message */
|
|
|
|
MessageId = BUGCODE_PSS_MESSAGE_SIGNATURE;
|
2007-02-18 20:47:04 +00:00
|
|
|
break;
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* All other codes */
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Use the default bugcheck message */
|
|
|
|
MessageId = BUGCODE_PSS_MESSAGE;
|
2007-02-18 20:47:04 +00:00
|
|
|
break;
|
2004-03-11 21:50:24 +00:00
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Save bugcheck data */
|
|
|
|
KiBugCheckData[0] = BugCheckCode;
|
|
|
|
KiBugCheckData[1] = BugCheckParameter1;
|
|
|
|
KiBugCheckData[2] = BugCheckParameter2;
|
|
|
|
KiBugCheckData[3] = BugCheckParameter3;
|
|
|
|
KiBugCheckData[4] = BugCheckParameter4;
|
|
|
|
|
|
|
|
/* Now check what bugcheck this is */
|
|
|
|
switch (BugCheckCode)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Invalid access to R/O memory or Unhandled KM Exception */
|
|
|
|
case KERNEL_MODE_EXCEPTION_NOT_HANDLED:
|
|
|
|
case ATTEMPTED_WRITE_TO_READONLY_MEMORY:
|
|
|
|
case ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY:
|
|
|
|
|
|
|
|
/* Check if we have a trap frame */
|
|
|
|
if (!TrapFrame)
|
|
|
|
{
|
|
|
|
/* Use parameter 3 as a trap frame, if it exists */
|
|
|
|
if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
|
|
|
|
}
|
|
|
|
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Check if we got one now and if we need to get the Program Counter */
|
2006-08-30 05:22:56 +00:00
|
|
|
if ((TrapFrame) &&
|
|
|
|
(BugCheckCode != KERNEL_MODE_EXCEPTION_NOT_HANDLED))
|
|
|
|
{
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Get the Program Counter */
|
|
|
|
Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Wrong IRQL */
|
|
|
|
case IRQL_NOT_LESS_OR_EQUAL:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The NT kernel has 3 special sections:
|
|
|
|
* MISYSPTE, POOLMI and POOLCODE. The bug check code can
|
|
|
|
* determine in which of these sections this bugcode happened
|
|
|
|
* and provide a more detailed analysis. For now, we don't.
|
|
|
|
*/
|
|
|
|
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Program Counter is in parameter 4 */
|
|
|
|
Pc = (PVOID)BugCheckParameter4;
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Get the driver base */
|
2009-10-04 16:53:15 +00:00
|
|
|
DriverBase = KiPcToFileHeader(Pc,
|
|
|
|
&LdrEntry,
|
|
|
|
FALSE,
|
|
|
|
&IsSystem);
|
2006-08-30 05:22:56 +00:00
|
|
|
if (IsSystem)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The error happened inside the kernel or HAL.
|
|
|
|
* Get the memory address that was being referenced.
|
|
|
|
*/
|
|
|
|
Memory = (PVOID)BugCheckParameter1;
|
|
|
|
|
|
|
|
/* Find to which driver it belongs */
|
|
|
|
DriverBase = KiPcToFileHeader(Memory,
|
|
|
|
&LdrEntry,
|
|
|
|
TRUE,
|
|
|
|
&IsSystem);
|
|
|
|
if (DriverBase)
|
|
|
|
{
|
|
|
|
/* Get the driver name and update the bug code */
|
|
|
|
KiBugCheckDriver = &LdrEntry->BaseDllName;
|
|
|
|
KiBugCheckData[0] = DRIVER_PORTION_MUST_BE_NONPAGED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Find the driver that unloaded at this address */
|
|
|
|
KiBugCheckDriver = NULL; // FIXME: ROS can't locate
|
|
|
|
|
|
|
|
/* Check if the cause was an unloaded driver */
|
|
|
|
if (KiBugCheckDriver)
|
|
|
|
{
|
|
|
|
/* Update bug check code */
|
|
|
|
KiBugCheckData[0] =
|
|
|
|
SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Update the bug check code */
|
|
|
|
KiBugCheckData[0] = DRIVER_IRQL_NOT_LESS_OR_EQUAL;
|
|
|
|
}
|
|
|
|
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Clear Pc so we don't look it up later */
|
|
|
|
Pc = NULL;
|
2006-08-30 05:22:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Hard error */
|
|
|
|
case FATAL_UNHANDLED_HARD_ERROR:
|
|
|
|
|
|
|
|
/* Copy bug check data from hard error */
|
|
|
|
HardErrorParameters = (PULONG_PTR)BugCheckParameter2;
|
|
|
|
KiBugCheckData[0] = BugCheckParameter1;
|
|
|
|
KiBugCheckData[1] = HardErrorParameters[0];
|
|
|
|
KiBugCheckData[2] = HardErrorParameters[1];
|
|
|
|
KiBugCheckData[3] = HardErrorParameters[2];
|
|
|
|
KiBugCheckData[4] = HardErrorParameters[3];
|
|
|
|
|
|
|
|
/* Remember that this is hard error and set the caption/message */
|
|
|
|
IsHardError = TRUE;
|
|
|
|
HardErrCaption = (PCHAR)BugCheckParameter3;
|
|
|
|
HardErrMessage = (PCHAR)BugCheckParameter4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Page fault */
|
|
|
|
case PAGE_FAULT_IN_NONPAGED_AREA:
|
|
|
|
|
|
|
|
/* Assume no driver */
|
|
|
|
DriverBase = NULL;
|
|
|
|
|
|
|
|
/* Check if we have a trap frame */
|
|
|
|
if (!TrapFrame)
|
|
|
|
{
|
|
|
|
/* We don't, use parameter 3 if possible */
|
|
|
|
if (BugCheckParameter3) TrapFrame = (PVOID)BugCheckParameter3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we have a frame now */
|
|
|
|
if (TrapFrame)
|
|
|
|
{
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Get the Program Counter */
|
|
|
|
Pc = (PVOID)KeGetTrapFramePc(TrapFrame);
|
|
|
|
KiBugCheckData[3] = (ULONG_PTR)Pc;
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Find out if was in the kernel or drivers */
|
2009-10-04 16:53:15 +00:00
|
|
|
DriverBase = KiPcToFileHeader(Pc,
|
2007-02-18 20:47:04 +00:00
|
|
|
&LdrEntry,
|
|
|
|
FALSE,
|
|
|
|
&IsSystem);
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
2014-10-22 13:13:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Can't blame a driver, assume system */
|
|
|
|
IsSystem = TRUE;
|
|
|
|
}
|
2006-08-30 05:22:56 +00:00
|
|
|
|
2014-10-22 13:13:31 +00:00
|
|
|
/* FIXME: Check for session pool in addition to special pool */
|
2006-08-30 05:22:56 +00:00
|
|
|
|
2014-10-22 13:13:31 +00:00
|
|
|
/* Special pool has its own bug check codes */
|
|
|
|
if (MmIsSpecialPoolAddress((PVOID)BugCheckParameter1))
|
|
|
|
{
|
|
|
|
if (MmIsSpecialPoolAddressFree((PVOID)BugCheckParameter1))
|
|
|
|
{
|
|
|
|
KiBugCheckData[0] = IsSystem
|
|
|
|
? PAGE_FAULT_IN_FREED_SPECIAL_POOL
|
|
|
|
: DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KiBugCheckData[0] = IsSystem
|
|
|
|
? PAGE_FAULT_BEYOND_END_OF_ALLOCATION
|
|
|
|
: DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!DriverBase)
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
|
|
|
/* Find the driver that unloaded at this address */
|
|
|
|
KiBugCheckDriver = NULL; // FIXME: ROS can't locate
|
|
|
|
|
|
|
|
/* Check if the cause was an unloaded driver */
|
|
|
|
if (KiBugCheckDriver)
|
|
|
|
{
|
|
|
|
KiBugCheckData[0] =
|
|
|
|
DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if the driver forgot to unlock pages */
|
|
|
|
case DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS:
|
|
|
|
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Program Counter is in parameter 1 */
|
|
|
|
Pc = (PVOID)BugCheckParameter1;
|
2006-08-30 05:22:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if the driver consumed too many PTEs */
|
|
|
|
case DRIVER_USED_EXCESSIVE_PTES:
|
|
|
|
|
2007-02-18 20:47:04 +00:00
|
|
|
/* Loader entry is in parameter 1 */
|
|
|
|
LdrEntry = (PVOID)BugCheckParameter1;
|
|
|
|
KiBugCheckDriver = &LdrEntry->BaseDllName;
|
2006-08-30 05:22:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if the driver has a stuck thread */
|
|
|
|
case THREAD_STUCK_IN_DEVICE_DRIVER:
|
|
|
|
|
|
|
|
/* The name is in Parameter 3 */
|
|
|
|
KiBugCheckDriver = (PVOID)BugCheckParameter3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Anything else */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do we have a driver name? */
|
|
|
|
if (KiBugCheckDriver)
|
|
|
|
{
|
|
|
|
/* Convert it to ANSI */
|
|
|
|
KeBugCheckUnicodeToAnsi(KiBugCheckDriver, AnsiName, sizeof(AnsiName));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-04 16:53:15 +00:00
|
|
|
/* Do we have a Program Counter? */
|
|
|
|
if (Pc)
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
|
|
|
/* Dump image name */
|
|
|
|
KiDumpParameterImages(AnsiName,
|
2009-10-04 16:53:15 +00:00
|
|
|
(PULONG_PTR)&Pc,
|
2006-08-30 05:22:56 +00:00
|
|
|
1,
|
|
|
|
KeBugCheckUnicodeToAnsi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:47:04 +00:00
|
|
|
/* Check if we need to save the context for KD */
|
2007-03-05 01:35:43 +00:00
|
|
|
#ifdef _WINKD_
|
2009-10-10 19:27:54 +00:00
|
|
|
if (!KdPitchDebugger) KdDebuggerDataBlock.SavedContext = (ULONG_PTR)&Context;
|
2007-03-05 01:35:43 +00:00
|
|
|
#endif
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Check if a debugger is connected */
|
|
|
|
if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
|
|
|
|
{
|
|
|
|
/* Crash on the debugger console */
|
|
|
|
DbgPrint("\n*** Fatal System Error: 0x%08lx\n"
|
|
|
|
" (0x%p,0x%p,0x%p,0x%p)\n\n",
|
|
|
|
KiBugCheckData[0],
|
|
|
|
KiBugCheckData[1],
|
|
|
|
KiBugCheckData[2],
|
|
|
|
KiBugCheckData[3],
|
|
|
|
KiBugCheckData[4]);
|
|
|
|
|
|
|
|
/* Check if the debugger isn't currently connected */
|
|
|
|
if (!KdDebuggerNotPresent)
|
|
|
|
{
|
|
|
|
/* Check if we have a driver to blame */
|
|
|
|
if (KiBugCheckDriver)
|
|
|
|
{
|
|
|
|
/* Dump it */
|
|
|
|
DbgPrint("Driver at fault: %s.\n", AnsiName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if this was a hard error */
|
|
|
|
if (IsHardError)
|
|
|
|
{
|
|
|
|
/* Print caption and message */
|
|
|
|
if (HardErrCaption) DbgPrint(HardErrCaption);
|
|
|
|
if (HardErrMessage) DbgPrint(HardErrMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Break in the debugger */
|
|
|
|
KiBugCheckDebugBreak(DBG_STATUS_BUGCHECK_FIRST);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* ROS HACK.
|
|
|
|
* Ok, so debugging is enabled, but KDBG isn't there.
|
|
|
|
* We'll manually dump the stack for the user.
|
|
|
|
*/
|
|
|
|
KeRosDumpStackFrames(NULL, 0);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-09-21 20:14:34 +00:00
|
|
|
/* ROS HACK 2: Generate something useful for Bugzilla */
|
|
|
|
KeRosDumpTriageForBugZillaReport();
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
/* Raise IRQL to HIGH_LEVEL */
|
2007-09-27 13:07:43 +00:00
|
|
|
_disable();
|
2008-02-07 07:10:13 +00:00
|
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Avoid recursion */
|
2006-08-30 21:47:38 +00:00
|
|
|
if (!InterlockedDecrement((PLONG)&KeBugCheckCount))
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
2007-02-18 20:47:04 +00:00
|
|
|
#ifdef CONFIG_SMP
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Set CPU that is bug checking now */
|
|
|
|
KeBugCheckOwner = Prcb->Number;
|
|
|
|
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Freeze the other CPUs */
|
2006-11-05 21:00:42 +00:00
|
|
|
for (i = 0; i < KeNumberProcessors; i++)
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2005-07-05 23:15:22 +00:00
|
|
|
if (i != (LONG)KeGetCurrentProcessorNumber())
|
2005-06-04 00:25:04 +00:00
|
|
|
{
|
2005-03-12 16:01:30 +00:00
|
|
|
/* Send the IPI and give them one second to catch up */
|
2008-11-01 11:44:04 +00:00
|
|
|
KiIpiSend(1 << i, IPI_FREEZE);
|
2005-03-12 16:01:30 +00:00
|
|
|
KeStallExecutionProcessor(1000000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Display the BSOD */
|
|
|
|
KiDisplayBlueScreen(MessageId,
|
|
|
|
IsHardError,
|
|
|
|
HardErrCaption,
|
|
|
|
HardErrMessage,
|
|
|
|
AnsiName);
|
2003-04-24 16:53:59 +00:00
|
|
|
|
2007-02-18 20:47:04 +00:00
|
|
|
/* Check if the debugger is disabled but we can enable it */
|
2007-03-05 01:35:43 +00:00
|
|
|
if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
|
2007-02-18 20:47:04 +00:00
|
|
|
{
|
|
|
|
/* Enable it */
|
2007-03-05 01:35:43 +00:00
|
|
|
#ifdef _WINKD_
|
|
|
|
KdEnableDebuggerWithLock(FALSE);
|
|
|
|
#endif
|
2007-02-18 20:47:04 +00:00
|
|
|
}
|
2007-03-05 01:35:43 +00:00
|
|
|
else
|
2007-02-18 20:47:04 +00:00
|
|
|
{
|
|
|
|
/* Otherwise, print the last line */
|
|
|
|
InbvDisplayString("\r\n");
|
|
|
|
}
|
2006-08-30 05:22:56 +00:00
|
|
|
|
|
|
|
/* Save the context */
|
|
|
|
Prcb->ProcessorState.ContextFrame = Context;
|
|
|
|
|
|
|
|
/* FIXME: Support Triage Dump */
|
|
|
|
|
2009-07-24 15:49:27 +00:00
|
|
|
/* FIXME: Write the crash dump */
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
2007-02-18 20:47:04 +00:00
|
|
|
else
|
2006-08-30 05:22:56 +00:00
|
|
|
{
|
2007-02-18 20:47:04 +00:00
|
|
|
/* Increase recursion count */
|
|
|
|
KeBugCheckOwnerRecursionCount++;
|
|
|
|
if (KeBugCheckOwnerRecursionCount == 2)
|
|
|
|
{
|
|
|
|
/* Break in the debugger */
|
|
|
|
KiBugCheckDebugBreak(DBG_STATUS_BUGCHECK_SECOND);
|
|
|
|
}
|
|
|
|
else if (KeBugCheckOwnerRecursionCount > 2)
|
|
|
|
{
|
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly.
- Fail on physical memory write like we do for read too.
- Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows.
- Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics.
- Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely.
- Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again.
- Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code.
- Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example).
- Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers).
- Crashing and rebooting from KD now works properly.
svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
|
|
|
/* Halt execution */
|
|
|
|
while (TRUE);
|
2007-02-18 20:47:04 +00:00
|
|
|
}
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the Callbacks */
|
|
|
|
KiDoBugCheckCallbacks();
|
|
|
|
|
|
|
|
/* FIXME: Call Watchdog if enabled */
|
|
|
|
|
2007-02-18 20:47:04 +00:00
|
|
|
/* Check if we have to reboot */
|
|
|
|
if (Reboot)
|
|
|
|
{
|
|
|
|
/* Unload symbols */
|
2009-10-25 15:56:38 +00:00
|
|
|
DbgUnLoadImageSymbols(NULL, (PVOID)MAXULONG_PTR, 0);
|
2007-02-18 20:47:04 +00:00
|
|
|
HalReturnToFirmware(HalRebootRoutine);
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Attempt to break in the debugger (otherwise halt CPU) */
|
|
|
|
KiBugCheckDebugBreak(DBG_STATUS_BUGCHECK_SECOND);
|
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly.
- Fail on physical memory write like we do for read too.
- Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows.
- Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics.
- Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely.
- Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again.
- Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code.
- Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example).
- Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers).
- Crashing and rebooting from KD now works properly.
svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
|
|
|
|
|
|
|
/* Shouldn't get here */
|
2013-01-04 12:31:46 +00:00
|
|
|
ASSERT(FALSE);
|
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly.
- Fail on physical memory write like we do for read too.
- Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows.
- Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics.
- Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely.
- Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again.
- Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code.
- Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example).
- Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers).
- Crashing and rebooting from KD now works properly.
svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
|
|
|
while (TRUE);
|
2006-08-30 05:22:56 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 04:48:22 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KiHandleNmi(VOID)
|
|
|
|
{
|
|
|
|
BOOLEAN Handled = FALSE;
|
|
|
|
PKNMI_HANDLER_CALLBACK NmiData;
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Parse the list of callbacks */
|
2010-01-02 04:48:22 +00:00
|
|
|
NmiData = KiNmiCallbackListHead;
|
|
|
|
while (NmiData)
|
|
|
|
{
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Save if this callback has handled it -- all it takes is one */
|
2010-01-02 04:48:22 +00:00
|
|
|
Handled |= NmiData->Callback(NmiData->Context, Handled);
|
|
|
|
NmiData = NmiData->Next;
|
|
|
|
}
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Has anyone handled this? */
|
2010-01-02 04:48:22 +00:00
|
|
|
return Handled;
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
|
- Export KeI386MachineType and KeInitializeThreadedDpc
- Stubplement and export IoEnumerateRegisteredFiltersList, IoGetPagingIoPriority, KdRefreshDebuggerNotPresent, KeAcquireInStackQueuedSpinLockForDpc, KeReleaseInStackQueuedSpinLockForDpc, KeAcquireSpinLockForDpc, KeReleaseSpinLockForDpc, KeRegisterNmiCallback, KeDeregisterNmiCallback, KeInitializeCrashDumpHeader, KeTestSpinLock and MmAllocatePagesForMdlEx
- Add IO_PAGING_PRIORITY enumeration and PNMI_CALLBACK prototype to headers
svn path=/trunk/; revision=35103
2008-08-04 15:48:46 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KeInitializeCrashDumpHeader(IN ULONG Type,
|
|
|
|
IN ULONG Flags,
|
|
|
|
OUT PVOID Buffer,
|
|
|
|
IN ULONG BufferSize,
|
|
|
|
OUT ULONG BufferNeeded OPTIONAL)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KeDeregisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
|
|
|
BOOLEAN Status = FALSE;
|
|
|
|
|
|
|
|
/* Raise IRQL to High */
|
|
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
|
|
|
|
|
|
|
/* Check the Current State */
|
|
|
|
if (CallbackRecord->State == BufferInserted)
|
|
|
|
{
|
|
|
|
/* Reset state and remove from list */
|
|
|
|
CallbackRecord->State = BufferEmpty;
|
|
|
|
RemoveEntryList(&CallbackRecord->Entry);
|
|
|
|
Status = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lower IRQL and return */
|
|
|
|
KeLowerIrql(OldIrql);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KeDeregisterBugCheckReasonCallback(
|
|
|
|
IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
|
|
|
BOOLEAN Status = FALSE;
|
|
|
|
|
|
|
|
/* Raise IRQL to High */
|
|
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
|
|
|
|
|
|
|
/* Check the Current State */
|
|
|
|
if (CallbackRecord->State == BufferInserted)
|
|
|
|
{
|
|
|
|
/* Reset state and remove from list */
|
|
|
|
CallbackRecord->State = BufferEmpty;
|
|
|
|
RemoveEntryList(&CallbackRecord->Entry);
|
|
|
|
Status = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lower IRQL and return */
|
|
|
|
KeLowerIrql(OldIrql);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KeRegisterBugCheckCallback(IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
|
|
|
|
IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine,
|
|
|
|
IN PVOID Buffer,
|
|
|
|
IN ULONG Length,
|
|
|
|
IN PUCHAR Component)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
|
|
|
BOOLEAN Status = FALSE;
|
|
|
|
|
|
|
|
/* Raise IRQL to High */
|
|
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
|
|
|
|
|
|
|
/* Check the Current State first so we don't double-register */
|
|
|
|
if (CallbackRecord->State == BufferEmpty)
|
|
|
|
{
|
|
|
|
/* Set the Callback Settings and insert into the list */
|
|
|
|
CallbackRecord->Length = Length;
|
|
|
|
CallbackRecord->Buffer = Buffer;
|
|
|
|
CallbackRecord->Component = Component;
|
|
|
|
CallbackRecord->CallbackRoutine = CallbackRoutine;
|
|
|
|
CallbackRecord->State = BufferInserted;
|
2007-02-19 18:52:23 +00:00
|
|
|
InsertTailList(&KeBugcheckCallbackListHead, &CallbackRecord->Entry);
|
2006-08-30 05:22:56 +00:00
|
|
|
Status = TRUE;
|
2003-04-24 16:53:59 +00:00
|
|
|
}
|
2005-03-12 16:01:30 +00:00
|
|
|
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Lower IRQL and return */
|
|
|
|
KeLowerIrql(OldIrql);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
KeRegisterBugCheckReasonCallback(
|
|
|
|
IN PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord,
|
|
|
|
IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine,
|
|
|
|
IN KBUGCHECK_CALLBACK_REASON Reason,
|
|
|
|
IN PUCHAR Component)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
|
|
|
BOOLEAN Status = FALSE;
|
|
|
|
|
|
|
|
/* Raise IRQL to High */
|
|
|
|
KeRaiseIrql(HIGH_LEVEL, &OldIrql);
|
|
|
|
|
|
|
|
/* Check the Current State first so we don't double-register */
|
|
|
|
if (CallbackRecord->State == BufferEmpty)
|
|
|
|
{
|
|
|
|
/* Set the Callback Settings and insert into the list */
|
|
|
|
CallbackRecord->Component = Component;
|
|
|
|
CallbackRecord->CallbackRoutine = CallbackRoutine;
|
|
|
|
CallbackRecord->State = BufferInserted;
|
|
|
|
CallbackRecord->Reason = Reason;
|
2007-02-19 18:52:23 +00:00
|
|
|
InsertTailList(&KeBugcheckReasonCallbackListHead,
|
2006-08-30 05:22:56 +00:00
|
|
|
&CallbackRecord->Entry);
|
|
|
|
Status = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Lower IRQL and return */
|
|
|
|
KeLowerIrql(OldIrql);
|
|
|
|
return Status;
|
2002-05-02 23:45:33 +00:00
|
|
|
}
|
|
|
|
|
- Export KeI386MachineType and KeInitializeThreadedDpc
- Stubplement and export IoEnumerateRegisteredFiltersList, IoGetPagingIoPriority, KdRefreshDebuggerNotPresent, KeAcquireInStackQueuedSpinLockForDpc, KeReleaseInStackQueuedSpinLockForDpc, KeAcquireSpinLockForDpc, KeReleaseSpinLockForDpc, KeRegisterNmiCallback, KeDeregisterNmiCallback, KeInitializeCrashDumpHeader, KeTestSpinLock and MmAllocatePagesForMdlEx
- Add IO_PAGING_PRIORITY enumeration and PNMI_CALLBACK prototype to headers
svn path=/trunk/; revision=35103
2008-08-04 15:48:46 +00:00
|
|
|
/*
|
2010-01-02 04:48:22 +00:00
|
|
|
* @implemented
|
- Export KeI386MachineType and KeInitializeThreadedDpc
- Stubplement and export IoEnumerateRegisteredFiltersList, IoGetPagingIoPriority, KdRefreshDebuggerNotPresent, KeAcquireInStackQueuedSpinLockForDpc, KeReleaseInStackQueuedSpinLockForDpc, KeAcquireSpinLockForDpc, KeReleaseSpinLockForDpc, KeRegisterNmiCallback, KeDeregisterNmiCallback, KeInitializeCrashDumpHeader, KeTestSpinLock and MmAllocatePagesForMdlEx
- Add IO_PAGING_PRIORITY enumeration and PNMI_CALLBACK prototype to headers
svn path=/trunk/; revision=35103
2008-08-04 15:48:46 +00:00
|
|
|
*/
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
KeRegisterNmiCallback(IN PNMI_CALLBACK CallbackRoutine,
|
|
|
|
IN PVOID Context)
|
|
|
|
{
|
2010-01-02 04:48:22 +00:00
|
|
|
KIRQL OldIrql;
|
|
|
|
PKNMI_HANDLER_CALLBACK NmiData, Next;
|
|
|
|
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Allocate NMI callback data */
|
2015-09-23 23:52:03 +00:00
|
|
|
NmiData = ExAllocatePoolWithTag(NonPagedPool, sizeof(*NmiData), TAG_KNMI);
|
2010-01-02 04:48:22 +00:00
|
|
|
if (!NmiData) return NULL;
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Fill in the information */
|
2010-01-02 04:48:22 +00:00
|
|
|
NmiData->Callback = CallbackRoutine;
|
|
|
|
NmiData->Context = Context;
|
|
|
|
NmiData->Handle = NmiData;
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Insert it into NMI callback list */
|
2010-01-02 04:48:22 +00:00
|
|
|
KiAcquireNmiListLock(&OldIrql);
|
|
|
|
NmiData->Next = KiNmiCallbackListHead;
|
2010-07-16 00:34:26 +00:00
|
|
|
Next = InterlockedCompareExchangePointer((PVOID*)&KiNmiCallbackListHead,
|
2010-01-02 04:48:22 +00:00
|
|
|
NmiData,
|
|
|
|
NmiData->Next);
|
|
|
|
ASSERT(Next == NmiData->Next);
|
|
|
|
KiReleaseNmiListLock(OldIrql);
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Return the opaque "handle" */
|
2010-01-02 04:48:22 +00:00
|
|
|
return NmiData->Handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2015-09-23 23:52:03 +00:00
|
|
|
KeDeregisterNmiCallback(IN PVOID Handle)
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
{
|
2015-09-23 23:52:03 +00:00
|
|
|
KIRQL OldIrql;
|
2015-09-23 23:55:04 +00:00
|
|
|
PKNMI_HANDLER_CALLBACK NmiData;
|
|
|
|
PKNMI_HANDLER_CALLBACK* Previous;
|
2015-09-23 23:52:03 +00:00
|
|
|
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
|
|
|
|
|
|
|
/* Find in the list the NMI callback corresponding to the handle */
|
|
|
|
KiAcquireNmiListLock(&OldIrql);
|
|
|
|
Previous = &KiNmiCallbackListHead;
|
|
|
|
NmiData = *Previous;
|
|
|
|
while (NmiData)
|
|
|
|
{
|
|
|
|
if (NmiData->Handle == Handle)
|
|
|
|
{
|
|
|
|
/* The handle is the pointer to the callback itself */
|
|
|
|
ASSERT(Handle == NmiData);
|
|
|
|
|
|
|
|
/* Found it, remove from the list */
|
|
|
|
*Previous = NmiData->Next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Not found; try again */
|
|
|
|
Previous = &NmiData->Next;
|
|
|
|
NmiData = *Previous;
|
|
|
|
}
|
|
|
|
KiReleaseNmiListLock(OldIrql);
|
|
|
|
|
|
|
|
/* If we have found the entry, free it */
|
|
|
|
if (NmiData)
|
|
|
|
{
|
|
|
|
ExFreePoolWithTag(NmiData, TAG_KNMI);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_INVALID_HANDLE;
|
- Export KeI386MachineType and KeInitializeThreadedDpc
- Stubplement and export IoEnumerateRegisteredFiltersList, IoGetPagingIoPriority, KdRefreshDebuggerNotPresent, KeAcquireInStackQueuedSpinLockForDpc, KeReleaseInStackQueuedSpinLockForDpc, KeAcquireSpinLockForDpc, KeReleaseSpinLockForDpc, KeRegisterNmiCallback, KeDeregisterNmiCallback, KeInitializeCrashDumpHeader, KeTestSpinLock and MmAllocatePagesForMdlEx
- Add IO_PAGING_PRIORITY enumeration and PNMI_CALLBACK prototype to headers
svn path=/trunk/; revision=35103
2008-08-04 15:48:46 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 17:44:06 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
1998-08-25 04:27:26 +00:00
|
|
|
*/
|
2005-05-09 01:38:29 +00:00
|
|
|
VOID
|
2006-08-30 05:22:56 +00:00
|
|
|
NTAPI
|
|
|
|
KeBugCheckEx(IN ULONG BugCheckCode,
|
|
|
|
IN ULONG_PTR BugCheckParameter1,
|
|
|
|
IN ULONG_PTR BugCheckParameter2,
|
|
|
|
IN ULONG_PTR BugCheckParameter3,
|
|
|
|
IN ULONG_PTR BugCheckParameter4)
|
1998-08-25 04:27:26 +00:00
|
|
|
{
|
2012-02-24 13:51:52 +00:00
|
|
|
/* Call the internal API */
|
|
|
|
KeBugCheckWithTf(BugCheckCode,
|
|
|
|
BugCheckParameter1,
|
|
|
|
BugCheckParameter2,
|
|
|
|
BugCheckParameter3,
|
|
|
|
BugCheckParameter4,
|
|
|
|
NULL);
|
1998-08-25 04:27:26 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 17:44:06 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
1998-08-25 04:27:26 +00:00
|
|
|
*/
|
2005-06-04 00:25:04 +00:00
|
|
|
VOID
|
2006-08-30 05:22:56 +00:00
|
|
|
NTAPI
|
2005-03-12 16:01:30 +00:00
|
|
|
KeBugCheck(ULONG BugCheckCode)
|
1998-08-25 04:27:26 +00:00
|
|
|
{
|
2006-08-30 05:22:56 +00:00
|
|
|
/* Call the internal API */
|
|
|
|
KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
|
1998-08-25 04:27:26 +00:00
|
|
|
}
|
|
|
|
|
2007-03-05 01:35:43 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KeEnterKernelDebugger(VOID)
|
|
|
|
{
|
|
|
|
/* Disable interrupts */
|
|
|
|
KiHardwareTrigger = 1;
|
|
|
|
_disable();
|
|
|
|
|
|
|
|
/* Check the bugcheck count */
|
2007-03-05 17:35:37 +00:00
|
|
|
if (!InterlockedDecrement((PLONG)&KeBugCheckCount))
|
2007-03-05 01:35:43 +00:00
|
|
|
{
|
|
|
|
/* There was only one, is the debugger disabled? */
|
|
|
|
if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
|
|
|
|
{
|
|
|
|
/* Enable the debugger */
|
|
|
|
KdInitSystem(0, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- Stub out DbgKdWriteVirtualMemoryApi, DbgKdReadPhysicalMemoryApi, DbgKdWritePhysicalMemoryApi, DbgKdWriteBreakPointExApi, DbgKdRestoreBreakPointExApi, DbgKdSearchMemoryApi and DbgKdFillMemoryApi cases more properly.
- Fail on physical memory write like we do for read too.
- Don't handle OldVlm1/2 as they appear to be deprecated and unhandled in Windows.
- Implement HalHaltSystem to halt execution in a portable way. Default to xHalHaltSystem, a simple infinite loop, if we get called before HAL has initialized. Use this in KiBugCheckDebugBreak and the system shutdown handler instead of x86/AMD64/ARM intrinsics.
- Don't try to halt the CPU if KeBugCheck has been called 3 times or more -- if this happens, something has gone very wrong, and we shouldn't try to do anything special. Just loop infinitely.
- Fix KiBugCheckDebugBreak -- it shouldn't halt execution when called for the first chance as bugcheck callbacks have not been invoked at this point (nor has the BSOD been displayed). Use SEH to protect against a crash instead of checking KdDebuggerNotPresent as the debugger, if it is present, *could* disconnect while the trap is being handled. Also, don't halt execution if the debugger handled the breakpoint, just break again.
- Don't call MmMapIoSpace from HalpReboot! The reboot might take place at elevated IRQL (as high as HIGH_LEVEL if called from KeBugCheck), and thus can't use any Mm support routines. Use a PTE from the reserved HAL region and map it ourselves instead as done in the BIOS call code.
- Acquire the display ownership in HalReturnToFirmware in case the caller hasn't done so (as done in the KD reboot routine, for example).
- Just include ntndk.h in hal.h instead of including 6 NDK headers (which turns into more than half of the NDK anyway since those headers include other NDK headers).
- Crashing and rebooting from KD now works properly.
svn path=/trunk/; revision=43380
2009-10-11 20:16:45 +00:00
|
|
|
/* Break in the debugger */
|
2007-03-05 01:35:43 +00:00
|
|
|
KiBugCheckDebugBreak(DBG_STATUS_FATAL);
|
|
|
|
}
|
|
|
|
|
2000-06-04 19:51:05 +00:00
|
|
|
/* EOF */
|