[FREELDR] Make ASSERT bugcheck on failure (#8730)

Show a bugcheck with message showing where and why the ASSERT failed.
This commit is contained in:
Daniel Victor
2026-03-17 12:24:14 -03:00
committed by GitHub
parent b3ff1ff98f
commit b0bd092c0d
4 changed files with 28 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ FrLdrBugCheckWithMessage(
ULONG BugCode,
PCHAR File,
ULONG Line,
PSTR Format,
PCSTR Format,
...)
{
}

View File

@@ -203,7 +203,7 @@ FrLdrBugCheckWithMessage(
ULONG BugCode,
PCHAR File,
ULONG Line,
PSTR Format,
PCSTR Format,
...)
{
va_list argptr;

View File

@@ -146,7 +146,7 @@ FrLdrBugCheckWithMessage(
ULONG BugCode,
PCHAR File,
ULONG Line,
PSTR Format,
PCSTR Format,
...);
/* Bugcheck codes */
@@ -156,6 +156,7 @@ enum _FRLDR_BUGCHECK_CODES
MISSING_HARDWARE_REQUIREMENTS,
FREELDR_IMAGE_CORRUPTION,
MEMORY_INIT_FAILURE,
ASSERT_FAILURE,
#ifdef UEFIBOOT
EXIT_BOOTSERVICES_FAILURE,
#endif

View File

@@ -524,9 +524,21 @@ RtlAssert(IN PVOID FailedAssertion,
IN ULONG LineNumber,
IN PCHAR Message OPTIONAL)
{
PCSTR Format;
if (Message)
{
DbgPrint("Assertion \'%s\' failed at %s line %lu: %s\n",
Format = "Assertion \'%s\' failed at %s line %lu: %s\n";
DbgPrint(Format,
(PCHAR)FailedAssertion,
(PCHAR)FileName,
LineNumber,
Message);
FrLdrBugCheckWithMessage(
ASSERT_FAILURE, FileName, LineNumber,
Format,
(PCHAR)FailedAssertion,
(PCHAR)FileName,
LineNumber,
@@ -534,7 +546,16 @@ RtlAssert(IN PVOID FailedAssertion,
}
else
{
DbgPrint("Assertion \'%s\' failed at %s line %lu\n",
Format = "Assertion \'%s\' failed at %s line %lu\n";
DbgPrint(Format,
(PCHAR)FailedAssertion,
(PCHAR)FileName,
LineNumber);
FrLdrBugCheckWithMessage(
ASSERT_FAILURE, FileName, LineNumber,
Format,
(PCHAR)FailedAssertion,
(PCHAR)FileName,
LineNumber);
@@ -549,6 +570,7 @@ char *BugCodeStrings[] =
"MISSING_HARDWARE_REQUIREMENTS",
"FREELDR_IMAGE_CORRUPTION",
"MEMORY_INIT_FAILURE",
"ASSERT_FAILURE",
#ifdef UEFIBOOT
"EXIT_BOOTSERVICES_FAILURE",
#endif