Author: tfaber
Date: Thu Sep 29 06:48:19 2011
New Revision: 53888
URL:
http://svn.reactos.org/svn/reactos?rev=53888&view=rev
Log:
[NTOSKRNL]
- Fix handling of hard error string parameters from kernel mode
- Some simplification
Modified:
trunk/reactos/ntoskrnl/ex/harderr.c
trunk/reactos/ntoskrnl/include/internal/ex.h
Modified: trunk/reactos/ntoskrnl/ex/harderr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/harderr.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/harderr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/harderr.c [iso-8859-1] Thu Sep 29 06:48:19 2011
@@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS Kernel
* 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
* PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net)
*/
@@ -158,52 +158,27 @@
}
}
- /* Check if we have an exception port */
- if (Process->ExceptionPort)
- {
- /* Check if hard errors should be processed */
- if (Process->DefaultHardErrorProcessing & 1)
+ /* 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 */
+ if (Process->ExceptionPort)
{
/* Use the port */
PortHandle = Process->ExceptionPort;
}
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 */
PortHandle = ExpDefaultErrorPort;
}
- else
- {
- /* It's disabled, check if the error overrides it */
- if (ErrorStatus & 0x10000000)
- {
- /* Use the port anyway */
- PortHandle = ExpDefaultErrorPort;
- }
- else
- {
- /* No such luck */
- PortHandle = NULL;
- }
- }
+ }
+ else
+ {
+ /* Don't process the error */
+ PortHandle = NULL;
}
/* If hard errors are disabled, do nothing */
@@ -390,8 +365,8 @@
SIZE_T Size;
UNICODE_STRING CapturedParams[MAXIMUM_HARDERROR_PARAMETERS];
ULONG i;
- PULONG_PTR UserData = NULL, ParameterBase;
- PUNICODE_STRING StringBase;
+ PVOID UserData = NULL;
+ PHARDERROR_USER_PARAMETERS UserParams;
PWSTR BufferBase;
ULONG SafeResponse;
NTSTATUS Status;
@@ -403,9 +378,8 @@
/* Check if we have strings */
if (UnicodeStringParameterMask)
{
- /* Add the maximum possible size */
- Size = (sizeof(ULONG_PTR) + sizeof(UNICODE_STRING)) *
- MAXIMUM_HARDERROR_PARAMETERS + sizeof(UNICODE_STRING);
+ /* Calculate the required size */
+ Size = FIELD_OFFSET(HARDERROR_USER_PARAMETERS, Buffer[0]);
/* Loop each parameter */
for (i = 0; i < NumberOfParameters; i++)
@@ -415,7 +389,7 @@
{
/* Copy it */
RtlMoveMemory(&CapturedParams[i],
- &Parameters[i],
+ (PVOID)Parameters[i],
sizeof(UNICODE_STRING));
/* Increase the size */
@@ -425,21 +399,16 @@
/* Allocate the user data region */
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
- (PVOID*)&UserData,
+ &UserData,
0,
&Size,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status)) return Status;
- /* Set the pointers to our various data */
- ParameterBase = UserData;
- StringBase = (PVOID)((ULONG_PTR)UserData +
- sizeof(ULONG_PTR) *
- MAXIMUM_HARDERROR_PARAMETERS);
- BufferBase = (PVOID)((ULONG_PTR)StringBase +
- sizeof(UNICODE_STRING) *
- MAXIMUM_HARDERROR_PARAMETERS);
+ /* Set the pointers to our data */
+ UserParams = UserData;
+ BufferBase = UserParams->Buffer;
/* Loop parameters again */
for (i = 0; i < NumberOfParameters; i++)
@@ -448,7 +417,7 @@
if (UnicodeStringParameterMask & (1 << i))
{
/* Update the base */
- ParameterBase[i] = (ULONG_PTR)&StringBase[i];
+ UserParams->Parameters[i] =
(ULONG_PTR)&UserParams->Strings[i];
/* Copy the string buffer */
RtlMoveMemory(BufferBase,
@@ -459,9 +428,7 @@
CapturedParams[i].Buffer = BufferBase;
/* Copy the string structure */
- RtlMoveMemory(&StringBase[i],
- &CapturedParams[i],
- sizeof(UNICODE_STRING));
+ UserParams->Strings[i] = CapturedParams[i];
/* Update the pointer */
BufferBase += CapturedParams[i].MaximumLength;
@@ -469,7 +436,7 @@
else
{
/* No need to copy any strings */
- ParameterBase[i] = Parameters[i];
+ UserParams->Parameters[i] = Parameters[i];
}
}
}
@@ -494,7 +461,7 @@
/* We did! Delete it */
Size = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
- (PVOID*)&UserData,
+ &UserData,
&Size,
MEM_RELEASE);
}
@@ -609,7 +576,7 @@
/* Copy them */
RtlCopyMemory(SafeParams, Parameters, ParamSize);
- /* Nowo check if there's strings in it */
+ /* Now check if there's strings in it */
if (UnicodeStringParameterMask)
{
/* Loop every string */
Modified: trunk/reactos/ntoskrnl/include/internal/ex.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ex.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ex.h [iso-8859-1] Thu Sep 29 06:48:19 2011
@@ -61,6 +61,13 @@
PWSTR Name;
} 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 ExAcquireRundownProtection _ExAcquireRundownProtection