From 0fa49018cd071e037fad697749c438248ddc40d2 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Mollazadeh Date: Wed, 14 May 2025 23:45:11 +0330 Subject: [PATCH] [FREELDR] Show a notice message when booting in debug mode (#7967) Make FreeLoader print a notice message before it passes the control to the kernel, if kernel-mode debugging is enabled via boot options. This can be helpful for people who may forget that they're booting in debug mode (the default boot option also for the bootcd) and they need to attach a debugger for the boot process to continue. --- boot/freeldr/freeldr/ntldr/winldr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/boot/freeldr/freeldr/ntldr/winldr.c b/boot/freeldr/freeldr/ntldr/winldr.c index 807cf6c73e4..37672fcf6a8 100644 --- a/boot/freeldr/freeldr/ntldr/winldr.c +++ b/boot/freeldr/freeldr/ntldr/winldr.c @@ -1251,6 +1251,33 @@ LoadAndBootWindowsCommon( /* "Stop all motors", change videomode */ MachPrepareForReactOS(); + /* Show the "debug mode" notice if needed */ + /* Match KdInitSystem() conditions */ + if (!NtLdrGetOption(BootOptions, "CRASHDEBUG") && + !NtLdrGetOption(BootOptions, "NODEBUG") && + !!NtLdrGetOption(BootOptions, "DEBUG")) + { + /* Check whether there is a DEBUGPORT option */ + PCSTR DebugPort; + ULONG DebugPortLength = 0; + DebugPort = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &DebugPortLength); + if (DebugPort != NULL && DebugPortLength > 10) + { + /* Move to the debug port name */ + DebugPort += 10; DebugPortLength -= 10; + } + else + { + /* Default to COM */ + DebugPort = "COM"; DebugPortLength = 3; + } + + /* It is booting in debug mode, show the banner */ + TuiPrintf("You need to connect a debugger on port %.*s\n" + "For more information, visit https://reactos.org/wiki/Debugging.\n", + DebugPortLength, DebugPort); + } + /* Debugging... */ //DumpMemoryAllocMap();