mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 05:26:58 +00:00
[NTOSKRNL] Simplify NtRaiseHardError() by merging the terminating blocks.
- Return the status codes provided by the Ex(p)RaiseHardError() calls. - Fix the return values in case of failure.
This commit is contained in:
parent
ea390c2b3f
commit
6cefd1242d
|
@ -394,7 +394,7 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
PVOID UserData = NULL;
|
PVOID UserData = NULL;
|
||||||
PHARDERROR_USER_PARAMETERS UserParams;
|
PHARDERROR_USER_PARAMETERS UserParams;
|
||||||
PWSTR BufferBase;
|
PWSTR BufferBase;
|
||||||
ULONG SafeResponse;
|
ULONG SafeResponse = ResponseNotHandled;
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
@ -430,7 +430,12 @@ ExRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
&Size,
|
&Size,
|
||||||
MEM_COMMIT,
|
MEM_COMMIT,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
if (!NT_SUCCESS(Status)) return Status;
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Return failure */
|
||||||
|
*Response = ResponseNotHandled;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the pointers to our data */
|
/* Set the pointers to our data */
|
||||||
UserParams = UserData;
|
UserParams = UserData;
|
||||||
|
@ -551,12 +556,14 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PULONG_PTR SafeParams = NULL;
|
PULONG_PTR SafeParams = NULL;
|
||||||
ULONG SafeResponse;
|
ULONG SafeResponse = ResponseNotHandled;
|
||||||
UNICODE_STRING SafeString;
|
UNICODE_STRING SafeString;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG ParamSize = 0;
|
ULONG ParamSize = 0;
|
||||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||||
|
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Validate parameter count */
|
/* Validate parameter count */
|
||||||
if (NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
|
if (NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
|
||||||
{
|
{
|
||||||
|
@ -662,37 +669,17 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
/* Call the system function directly, because we probed */
|
/* Call the system function directly, because we probed */
|
||||||
ExpRaiseHardError(ErrorStatus,
|
Status = ExpRaiseHardError(ErrorStatus,
|
||||||
NumberOfParameters,
|
NumberOfParameters,
|
||||||
UnicodeStringParameterMask,
|
UnicodeStringParameterMask,
|
||||||
SafeParams,
|
SafeParams,
|
||||||
ValidResponseOptions,
|
ValidResponseOptions,
|
||||||
&SafeResponse);
|
&SafeResponse);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Reuse variable */
|
|
||||||
SafeParams = Parameters;
|
|
||||||
|
|
||||||
/*
|
/* Free captured buffer */
|
||||||
* Call the Executive Function. It will probe and copy pointers to
|
|
||||||
* user-mode
|
|
||||||
*/
|
|
||||||
ExRaiseHardError(ErrorStatus,
|
|
||||||
NumberOfParameters,
|
|
||||||
UnicodeStringParameterMask,
|
|
||||||
SafeParams,
|
|
||||||
ValidResponseOptions,
|
|
||||||
&SafeResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we were called in user-mode */
|
|
||||||
if (PreviousMode != KernelMode)
|
|
||||||
{
|
|
||||||
/* That means we have a buffer to free */
|
|
||||||
if (SafeParams) ExFreePoolWithTag(SafeParams, TAG_ERR);
|
if (SafeParams) ExFreePoolWithTag(SafeParams, TAG_ERR);
|
||||||
|
|
||||||
/* Enter SEH Block for return */
|
/* Enter SEH Block to return the response */
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
/* Return the response */
|
/* Return the response */
|
||||||
|
@ -707,6 +694,20 @@ NtRaiseHardError(IN NTSTATUS ErrorStatus,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Reuse variable */
|
||||||
|
SafeParams = Parameters;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call the Executive Function. It will probe
|
||||||
|
* and copy pointers to user-mode.
|
||||||
|
*/
|
||||||
|
Status = ExRaiseHardError(ErrorStatus,
|
||||||
|
NumberOfParameters,
|
||||||
|
UnicodeStringParameterMask,
|
||||||
|
SafeParams,
|
||||||
|
ValidResponseOptions,
|
||||||
|
&SafeResponse);
|
||||||
|
|
||||||
/* Return the response */
|
/* Return the response */
|
||||||
*Response = SafeResponse;
|
*Response = SafeResponse;
|
||||||
}
|
}
|
||||||
|
@ -740,6 +741,8 @@ NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
|
||||||
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
|
||||||
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Check if we have the privileges */
|
/* Check if we have the privileges */
|
||||||
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue