- Return the status codes provided by the Ex(p)RaiseHardError() calls.
- Fix the return values in case of failure.
PVOID UserData = NULL;
PHARDERROR_USER_PARAMETERS UserParams;
PWSTR BufferBase;
PVOID UserData = NULL;
PHARDERROR_USER_PARAMETERS UserParams;
PWSTR BufferBase;
+ ULONG SafeResponse = ResponseNotHandled;
&Size,
MEM_COMMIT,
PAGE_READWRITE);
&Size,
MEM_COMMIT,
PAGE_READWRITE);
- if (!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status))
+ {
+ /* Return failure */
+ *Response = ResponseNotHandled;
+ return Status;
+ }
/* Set the pointers to our data */
UserParams = UserData;
/* Set the pointers to our data */
UserParams = UserData;
{
NTSTATUS Status = STATUS_SUCCESS;
PULONG_PTR SafeParams = NULL;
{
NTSTATUS Status = STATUS_SUCCESS;
PULONG_PTR SafeParams = NULL;
+ ULONG SafeResponse = ResponseNotHandled;
UNICODE_STRING SafeString;
ULONG i;
ULONG ParamSize = 0;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
UNICODE_STRING SafeString;
ULONG i;
ULONG ParamSize = 0;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
/* Validate parameter count */
if (NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
{
/* Validate parameter count */
if (NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
{
_SEH2_END;
/* Call the system function directly, because we probed */
_SEH2_END;
/* Call the system function directly, because we probed */
- ExpRaiseHardError(ErrorStatus,
- NumberOfParameters,
- UnicodeStringParameterMask,
- SafeParams,
- ValidResponseOptions,
- &SafeResponse);
- }
- else
- {
- /* Reuse variable */
- SafeParams = Parameters;
-
- /*
- * 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 */
+ Status = ExpRaiseHardError(ErrorStatus,
+ NumberOfParameters,
+ UnicodeStringParameterMask,
+ SafeParams,
+ ValidResponseOptions,
+ &SafeResponse);
+
+ /* Free captured buffer */
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
{
/* Return the response */
_SEH2_TRY
{
/* Return the response */
+ /* 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 */
*Response = SafeResponse;
}
/* Return the response */
*Response = SafeResponse;
}
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_UNSUCCESSFUL;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
NTSTATUS Status = STATUS_UNSUCCESSFUL;
/* Check if we have the privileges */
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
{
/* Check if we have the privileges */
if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode))
{