1. a few previous mode fixes

2. implemented NtSetDefaultHardErrorPort() with help of pseudo code from windowsitlibrary.com

svn path=/trunk/; revision=13576
This commit is contained in:
Thomas Bluemel 2005-02-14 21:00:05 +00:00
parent 36e7b406b5
commit f0222daf5d
3 changed files with 51 additions and 8 deletions

View file

@ -107,13 +107,16 @@ NtAlertResumeThread(IN HANDLE ThreadHandle,
NTSTATUS STDCALL NTSTATUS STDCALL
NtAlertThread (IN HANDLE ThreadHandle) NtAlertThread (IN HANDLE ThreadHandle)
{ {
KPROCESSOR_MODE PreviousMode;
PETHREAD Thread; PETHREAD Thread;
NTSTATUS Status; NTSTATUS Status;
PreviousMode = ExGetPreviousMode();
Status = ObReferenceObjectByHandle(ThreadHandle, Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SUSPEND_RESUME, THREAD_SUSPEND_RESUME,
PsThreadType, PsThreadType,
ExGetPreviousMode(), PreviousMode,
(PVOID*)&Thread, (PVOID*)&Thread,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -125,7 +128,7 @@ NtAlertThread (IN HANDLE ThreadHandle)
* ZwAlertThread was called? * ZwAlertThread was called?
* -Gunnar * -Gunnar
*/ */
KeAlertThread((PKTHREAD)Thread, UserMode); KeAlertThread((PKTHREAD)Thread, PreviousMode);
ObDereferenceObject(Thread); ObDereferenceObject(Thread);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);

View file

@ -1,4 +1,4 @@
/* $Id:$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -517,13 +517,16 @@ NtQueueApcThread(HANDLE ThreadHandle,
PKAPC Apc; PKAPC Apc;
PETHREAD Thread; PETHREAD Thread;
KPROCESSOR_MODE PreviousMode;
NTSTATUS Status; NTSTATUS Status;
PreviousMode = ExGetPreviousMode();
/* Get ETHREAD from Handle */ /* Get ETHREAD from Handle */
Status = ObReferenceObjectByHandle(ThreadHandle, Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SET_CONTEXT, THREAD_SET_CONTEXT,
PsThreadType, PsThreadType,
KeGetPreviousMode(), PreviousMode,
(PVOID)&Thread, (PVOID)&Thread,
NULL); NULL);
@ -552,7 +555,7 @@ NtQueueApcThread(HANDLE ThreadHandle,
KiFreeApcRoutine, KiFreeApcRoutine,
NULL, NULL,
ApcRoutine, ApcRoutine,
UserMode, PreviousMode,
NormalContext); NormalContext);
if (!KeInsertQueueApc(Apc, SystemArgument1, SystemArgument2, IO_NO_INCREMENT)) { if (!KeInsertQueueApc(Apc, SystemArgument1, SystemArgument2, IO_NO_INCREMENT)) {
Status = STATUS_UNSUCCESSFUL; Status = STATUS_UNSUCCESSFUL;

View file

@ -1,4 +1,4 @@
/* $Id:$ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -15,6 +15,10 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
BOOLEAN ExReadyForErrors = FALSE;
PEPORT ExpDefaultErrorPort = NULL;
PEPROCESS ExpDefaultErrorPortProcess = NULL;
/* /*
* @unimplemented * @unimplemented
*/ */
@ -54,8 +58,41 @@ NtRaiseHardError(IN NTSTATUS Status,
NTSTATUS STDCALL NTSTATUS STDCALL
NtSetDefaultHardErrorPort(IN HANDLE PortHandle) NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
{ {
UNIMPLEMENTED; KPROCESSOR_MODE PreviousMode;
return(STATUS_NOT_IMPLEMENTED); NTSTATUS Status;
PreviousMode = ExGetPreviousMode();
if(!SeSinglePrivilegeCheck(SeTcbPrivilege,
PreviousMode))
{
DPRINT1("NtSetDefaultHardErrorPort: Caller requires the SeTcbPrivilege privilege!\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
/* serialization shouldn't be required here as it usually is just called once
during startup */
if(!ExReadyForErrors)
{
Status = ObReferenceObjectByHandle(PortHandle,
0,
LpcPortObjectType,
PreviousMode,
(PVOID*)&ExpDefaultErrorPort,
NULL);
if(NT_SUCCESS(Status))
{
ExpDefaultErrorPortProcess = PsGetCurrentProcess();
ExReadyForErrors = TRUE;
}
}
else
{
Status = STATUS_UNSUCCESSFUL;
}
return Status;
} }
/* EOF */ /* EOF */