https://git.reactos.org/?p=reactos.git;a=commitdiff;h=842605e3ef6c3673d8846…
commit 842605e3ef6c3673d8846181787c1f671a2e8c24
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Apr 1 15:53:49 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Apr 1 22:50:33 2018 +0200
[NTOSKRNL] Don't emit hard errors for the calling thread if hard errors have been disabled for this thread on user-mode side.
---
ntoskrnl/ex/harderr.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/ex/harderr.c b/ntoskrnl/ex/harderr.c
index 82d22f4926..185d43537e 100644
--- a/ntoskrnl/ex/harderr.c
+++ b/ntoskrnl/ex/harderr.c
@@ -105,13 +105,14 @@ ExpRaiseHardError(IN NTSTATUS ErrorStatus,
IN ULONG ValidResponseOptions,
OUT PULONG Response)
{
+ NTSTATUS Status;
PEPROCESS Process = PsGetCurrentProcess();
PETHREAD Thread = PsGetCurrentThread();
UCHAR Buffer[PORT_MAXIMUM_MESSAGE_LENGTH];
PHARDERROR_MSG Message = (PHARDERROR_MSG)Buffer;
- NTSTATUS Status;
HANDLE PortHandle;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
+
PAGED_CODE();
/* Check if this error will shutdown the system */
@@ -182,6 +183,31 @@ ExpRaiseHardError(IN NTSTATUS ErrorStatus,
/* If hard errors are disabled, do nothing */
if (Thread->HardErrorsAreDisabled) PortHandle = NULL;
+ /*
+ * If this is not the system thread, check whether hard errors are
+ * disabled for this thread on user-mode side, and if so, do nothing.
+ */
+ if (!Thread->SystemThread && (PortHandle != NULL))
+ {
+ /* Check if we have a TEB */
+ PTEB Teb = PsGetCurrentThread()->Tcb.Teb;
+ if (Teb)
+ {
+ _SEH2_TRY
+ {
+ if (Teb->HardErrorMode & RTL_SEM_FAILCRITICALERRORS)
+ {
+ PortHandle = NULL;
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ NOTHING;
+ }
+ _SEH2_END;
+ }
+ }
+
/* Now check if we have a port */
if (PortHandle == NULL)
{