1. a few previous mode fixes
2. implemented NtSetDefaultHardErrorPort() with help of pseudo code from
windowsitlibrary.com
Modified: trunk/reactos/ntoskrnl/ke/alert.c
Modified: trunk/reactos/ntoskrnl/ke/apc.c
Modified: trunk/reactos/ntoskrnl/ke/error.c
_____
Modified: trunk/reactos/ntoskrnl/ke/alert.c
--- trunk/reactos/ntoskrnl/ke/alert.c 2005-02-14 18:45:17 UTC (rev
13575)
+++ trunk/reactos/ntoskrnl/ke/alert.c 2005-02-14 21:00:05 UTC (rev
13576)
@@ -107,13 +107,16 @@
NTSTATUS STDCALL
NtAlertThread (IN HANDLE ThreadHandle)
{
+ KPROCESSOR_MODE PreviousMode;
PETHREAD Thread;
NTSTATUS Status;
+
+ PreviousMode = ExGetPreviousMode();
Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SUSPEND_RESUME,
PsThreadType,
- ExGetPreviousMode(),
+ PreviousMode,
(PVOID*)&Thread,
NULL);
if (!NT_SUCCESS(Status))
@@ -125,7 +128,7 @@
* ZwAlertThread was called?
* -Gunnar
*/
- KeAlertThread((PKTHREAD)Thread, UserMode);
+ KeAlertThread((PKTHREAD)Thread, PreviousMode);
ObDereferenceObject(Thread);
return(STATUS_SUCCESS);
_____
Modified: trunk/reactos/ntoskrnl/ke/apc.c
--- trunk/reactos/ntoskrnl/ke/apc.c 2005-02-14 18:45:17 UTC (rev
13575)
+++ trunk/reactos/ntoskrnl/ke/apc.c 2005-02-14 21:00:05 UTC (rev
13576)
@@ -1,4 +1,4 @@
-/* $Id:$
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -517,13 +517,16 @@
PKAPC Apc;
PETHREAD Thread;
+ KPROCESSOR_MODE PreviousMode;
NTSTATUS Status;
+
+ PreviousMode = ExGetPreviousMode();
/* Get ETHREAD from Handle */
Status = ObReferenceObjectByHandle(ThreadHandle,
THREAD_SET_CONTEXT,
PsThreadType,
- KeGetPreviousMode(),
+ PreviousMode,
(PVOID)&Thread,
NULL);
@@ -552,7 +555,7 @@
KiFreeApcRoutine,
NULL,
ApcRoutine,
- UserMode,
+ PreviousMode,
NormalContext);
if (!KeInsertQueueApc(Apc, SystemArgument1, SystemArgument2,
IO_NO_INCREMENT)) {
Status = STATUS_UNSUCCESSFUL;
_____
Modified: trunk/reactos/ntoskrnl/ke/error.c
--- trunk/reactos/ntoskrnl/ke/error.c 2005-02-14 18:45:17 UTC (rev
13575)
+++ trunk/reactos/ntoskrnl/ke/error.c 2005-02-14 21:00:05 UTC (rev
13576)
@@ -1,4 +1,4 @@
-/* $Id:$
+/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -15,6 +15,10 @@
/* FUNCTIONS
***************************************************************/
+BOOLEAN ExReadyForErrors = FALSE;
+PEPORT ExpDefaultErrorPort = NULL;
+PEPROCESS ExpDefaultErrorPortProcess = NULL;
+
/*
* @unimplemented
*/
@@ -54,8 +58,41 @@
NTSTATUS STDCALL
NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
{
- UNIMPLEMENTED;
- return(STATUS_NOT_IMPLEMENTED);
+ KPROCESSOR_MODE PreviousMode;
+ 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 */