mirror of
https://github.com/reactos/reactos.git
synced 2025-06-22 22:40:19 +00:00
[NTOSKRNL]
- Fix handling of hard error string parameters from kernel mode - Some simplification svn path=/trunk/; revision=53888
This commit is contained in:
parent
2779f4ccdd
commit
05616211a0
2 changed files with 32 additions and 58 deletions
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS Kernel
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: ntoskrnl/ex/error.c
|
* FILE: ntoskrnl/ex/harderr.c
|
||||||
* PURPOSE: Error Functions and Status/Exception Dispatching/Raising
|
* PURPOSE: Error Functions and Status/Exception Dispatching/Raising
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
||||||
*/
|
*/
|
||||||
|
@ -158,53 +158,28 @@ ExpRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Enable hard error processing if it is enabled for the process
|
||||||
|
* or if the exception status forces it */
|
||||||
|
if ((Process->DefaultHardErrorProcessing & 1) ||
|
||||||
|
(ErrorStatus & 0x10000000))
|
||||||
|
{
|
||||||
/* Check if we have an exception port */
|
/* Check if we have an exception port */
|
||||||
if (Process->ExceptionPort)
|
if (Process->ExceptionPort)
|
||||||
{
|
|
||||||
/* Check if hard errors should be processed */
|
|
||||||
if (Process->DefaultHardErrorProcessing & 1)
|
|
||||||
{
|
{
|
||||||
/* Use the port */
|
/* Use the port */
|
||||||
PortHandle = Process->ExceptionPort;
|
PortHandle = Process->ExceptionPort;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
/* It's disabled, check if the error overrides it */
|
|
||||||
if (ErrorStatus & 0x10000000)
|
|
||||||
{
|
|
||||||
/* Use the port anyway */
|
|
||||||
PortHandle = Process->ExceptionPort;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* No such luck */
|
|
||||||
PortHandle = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Check if hard errors are enabled */
|
|
||||||
if (Process->DefaultHardErrorProcessing & 1)
|
|
||||||
{
|
{
|
||||||
/* Use our default system port */
|
/* Use our default system port */
|
||||||
PortHandle = ExpDefaultErrorPort;
|
PortHandle = ExpDefaultErrorPort;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* It's disabled, check if the error overrides it */
|
|
||||||
if (ErrorStatus & 0x10000000)
|
|
||||||
{
|
|
||||||
/* Use the port anyway */
|
|
||||||
PortHandle = ExpDefaultErrorPort;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* No such luck */
|
/* Don't process the error */
|
||||||
PortHandle = NULL;
|
PortHandle = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If hard errors are disabled, do nothing */
|
/* If hard errors are disabled, do nothing */
|
||||||
if (Thread->HardErrorsAreDisabled) PortHandle = NULL;
|
if (Thread->HardErrorsAreDisabled) PortHandle = NULL;
|
||||||
|
@ -390,8 +365,8 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
SIZE_T Size;
|
SIZE_T Size;
|
||||||
UNICODE_STRING CapturedParams[MAXIMUM_HARDERROR_PARAMETERS];
|
UNICODE_STRING CapturedParams[MAXIMUM_HARDERROR_PARAMETERS];
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PULONG_PTR UserData = NULL, ParameterBase;
|
PVOID UserData = NULL;
|
||||||
PUNICODE_STRING StringBase;
|
PHARDERROR_USER_PARAMETERS UserParams;
|
||||||
PWSTR BufferBase;
|
PWSTR BufferBase;
|
||||||
ULONG SafeResponse;
|
ULONG SafeResponse;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -403,9 +378,8 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
/* Check if we have strings */
|
/* Check if we have strings */
|
||||||
if (UnicodeStringParameterMask)
|
if (UnicodeStringParameterMask)
|
||||||
{
|
{
|
||||||
/* Add the maximum possible size */
|
/* Calculate the required size */
|
||||||
Size = (sizeof(ULONG_PTR) + sizeof(UNICODE_STRING)) *
|
Size = FIELD_OFFSET(HARDERROR_USER_PARAMETERS, Buffer[0]);
|
||||||
MAXIMUM_HARDERROR_PARAMETERS + sizeof(UNICODE_STRING);
|
|
||||||
|
|
||||||
/* Loop each parameter */
|
/* Loop each parameter */
|
||||||
for (i = 0; i < NumberOfParameters; i++)
|
for (i = 0; i < NumberOfParameters; i++)
|
||||||
|
@ -415,7 +389,7 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
{
|
{
|
||||||
/* Copy it */
|
/* Copy it */
|
||||||
RtlMoveMemory(&CapturedParams[i],
|
RtlMoveMemory(&CapturedParams[i],
|
||||||
&Parameters[i],
|
(PVOID)Parameters[i],
|
||||||
sizeof(UNICODE_STRING));
|
sizeof(UNICODE_STRING));
|
||||||
|
|
||||||
/* Increase the size */
|
/* Increase the size */
|
||||||
|
@ -425,21 +399,16 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
|
|
||||||
/* Allocate the user data region */
|
/* Allocate the user data region */
|
||||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||||
(PVOID*)&UserData,
|
&UserData,
|
||||||
0,
|
0,
|
||||||
&Size,
|
&Size,
|
||||||
MEM_COMMIT,
|
MEM_COMMIT,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
|
|
||||||
/* Set the pointers to our various data */
|
/* Set the pointers to our data */
|
||||||
ParameterBase = UserData;
|
UserParams = UserData;
|
||||||
StringBase = (PVOID)((ULONG_PTR)UserData +
|
BufferBase = UserParams->Buffer;
|
||||||
sizeof(ULONG_PTR) *
|
|
||||||
MAXIMUM_HARDERROR_PARAMETERS);
|
|
||||||
BufferBase = (PVOID)((ULONG_PTR)StringBase +
|
|
||||||
sizeof(UNICODE_STRING) *
|
|
||||||
MAXIMUM_HARDERROR_PARAMETERS);
|
|
||||||
|
|
||||||
/* Loop parameters again */
|
/* Loop parameters again */
|
||||||
for (i = 0; i < NumberOfParameters; i++)
|
for (i = 0; i < NumberOfParameters; i++)
|
||||||
|
@ -448,7 +417,7 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
if (UnicodeStringParameterMask & (1 << i))
|
if (UnicodeStringParameterMask & (1 << i))
|
||||||
{
|
{
|
||||||
/* Update the base */
|
/* Update the base */
|
||||||
ParameterBase[i] = (ULONG_PTR)&StringBase[i];
|
UserParams->Parameters[i] = (ULONG_PTR)&UserParams->Strings[i];
|
||||||
|
|
||||||
/* Copy the string buffer */
|
/* Copy the string buffer */
|
||||||
RtlMoveMemory(BufferBase,
|
RtlMoveMemory(BufferBase,
|
||||||
|
@ -459,9 +428,7 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
CapturedParams[i].Buffer = BufferBase;
|
CapturedParams[i].Buffer = BufferBase;
|
||||||
|
|
||||||
/* Copy the string structure */
|
/* Copy the string structure */
|
||||||
RtlMoveMemory(&StringBase[i],
|
UserParams->Strings[i] = CapturedParams[i];
|
||||||
&CapturedParams[i],
|
|
||||||
sizeof(UNICODE_STRING));
|
|
||||||
|
|
||||||
/* Update the pointer */
|
/* Update the pointer */
|
||||||
BufferBase += CapturedParams[i].MaximumLength;
|
BufferBase += CapturedParams[i].MaximumLength;
|
||||||
|
@ -469,7 +436,7 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* No need to copy any strings */
|
/* No need to copy any strings */
|
||||||
ParameterBase[i] = Parameters[i];
|
UserParams->Parameters[i] = Parameters[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,7 +461,7 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
/* We did! Delete it */
|
/* We did! Delete it */
|
||||||
Size = 0;
|
Size = 0;
|
||||||
ZwFreeVirtualMemory(NtCurrentProcess(),
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
||||||
(PVOID*)&UserData,
|
&UserData,
|
||||||
&Size,
|
&Size,
|
||||||
MEM_RELEASE);
|
MEM_RELEASE);
|
||||||
}
|
}
|
||||||
|
@ -609,7 +576,7 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
/* Copy them */
|
/* Copy them */
|
||||||
RtlCopyMemory(SafeParams, Parameters, ParamSize);
|
RtlCopyMemory(SafeParams, Parameters, ParamSize);
|
||||||
|
|
||||||
/* Nowo check if there's strings in it */
|
/* Now check if there's strings in it */
|
||||||
if (UnicodeStringParameterMask)
|
if (UnicodeStringParameterMask)
|
||||||
{
|
{
|
||||||
/* Loop every string */
|
/* Loop every string */
|
||||||
|
|
|
@ -61,6 +61,13 @@ typedef struct
|
||||||
PWSTR Name;
|
PWSTR Name;
|
||||||
} SYSTEM_CALLBACKS;
|
} SYSTEM_CALLBACKS;
|
||||||
|
|
||||||
|
typedef struct _HARDERROR_USER_PARAMETERS
|
||||||
|
{
|
||||||
|
ULONG_PTR Parameters[MAXIMUM_HARDERROR_PARAMETERS];
|
||||||
|
UNICODE_STRING Strings[MAXIMUM_HARDERROR_PARAMETERS];
|
||||||
|
WCHAR Buffer[ANYSIZE_ARRAY];
|
||||||
|
} HARDERROR_USER_PARAMETERS, *PHARDERROR_USER_PARAMETERS;
|
||||||
|
|
||||||
#define MAX_FAST_REFS 7
|
#define MAX_FAST_REFS 7
|
||||||
|
|
||||||
#define ExAcquireRundownProtection _ExAcquireRundownProtection
|
#define ExAcquireRundownProtection _ExAcquireRundownProtection
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue