[NTOS:KE/MM] Some bug-fixes in the bugcheck code.

- Introduce the MmMakeKernelResourceSectionWritable() helper for
  making the kernel resource memory section writable, and use it
  in KeGetBugMessageText(). Indeed, this latter function patches
  in place the bugcheck resource message to trim any trailing
  newlines before displaying the message on screen.

  See also 83bad53/dm/introspection-win7.c (L286)
  that mentions it too.

  This fixes bugcheck text display (e.g. the MANUALLY_INITIATED_CRASH one)
  when using (at least) MSVC-built ReactOS, avoiding a Page-Fault
  exception during the bugcheck.

- Cover KeGetBugMessageText() in SEH since we are accessing kernel
  resources that could also be corrupted in bugcheck scenarii, and we
  don't want to further bugcheck.

- Fix newline trimming loop.

- KiDoBugCheckCallbacks():
  * Wrap the bugcheck CallbackRoutine call in SEH.
  * Add a FIXME concerning the need of further memory validation of CurrentRecord.

- Add a FIXME concerning the need to run the bugcheck-reason callbacks
  with the KbCallbackReserved1 reason, in KeBugCheckWithTf().
  Mentioned in http://blog.ptsecurity.com/2012/06/customizing-blue-screen-of-death.html
This commit is contained in:
Hermès Bélusca-Maïto 2019-06-25 20:45:23 +02:00
parent 35f800c6e2
commit f694d12f0c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 108 additions and 26 deletions

View file

@ -794,7 +794,7 @@ NTAPI
MmDeleteKernelStack(PVOID Stack,
BOOLEAN GuiStack);
/* balace.c ******************************************************************/
/* balance.c *****************************************************************/
INIT_FUNCTION
VOID
@ -1370,6 +1370,10 @@ MiInitializeLoadedModuleList(
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
VOID
NTAPI
MmMakeKernelResourceSectionWritable(VOID);
NTSTATUS
NTAPI
MmLoadSystemImage(