Author: ion
Date: Mon Oct 30 17:20:45 2006
New Revision: 24665
URL:
http://svn.reactos.org/svn/reactos?rev=24665&view=rev
Log:
- Implement the rest of Hard Error support.
- Kernel support is complete (except temporary LPC hack), and CSRSS properly receives the
event and sends it off to win32csr's hard error handler (much like on NT). However,
the handler doesn't call NtUserHardErrorControl nor do much of the complex sequence of
events that NT does, instead, we only display a hello-world style message box. Anyone up
for implementing the rest is welcome.
Modified:
trunk/reactos/ntoskrnl/ex/error.c
trunk/reactos/ntoskrnl/lpc/reply.c
trunk/reactos/ntoskrnl/lpc/send.c
trunk/reactos/subsystems/win32/csrss/api/wapi.c
trunk/reactos/subsystems/win32/csrss/include/csrplugin.h
trunk/reactos/subsystems/win32/csrss/init.c
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.def
Modified: trunk/reactos/ntoskrnl/ex/error.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/error.c?rev=24…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/error.c (original)
+++ trunk/reactos/ntoskrnl/ex/error.c Mon Oct 30 17:20:45 2006
@@ -112,11 +112,6 @@
HANDLE PortHandle;
KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
PAGED_CODE();
- DPRINT1("Hard error, baby!: %lx, %lx, %lx %p\n",
- ErrorStatus,
- NumberOfParameters,
- UnicodeStringParameterMask,
- Parameters);
/* Check if this error will shutdown the system */
if (ValidResponseOptions == OptionShutdownSystem)
@@ -235,15 +230,42 @@
Parameters,
sizeof(ULONG_PTR) * NumberOfParameters);
- /* Send the message */
+ /* Send the LPC Message */
Status = LpcRequestWaitReplyPort(PortHandle,
(PVOID)Message,
(PVOID)Message);
- DPRINT1("Checkpoint 2: %lx\n", Status);
- }
-
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ if (NT_SUCCESS(Status))
+ {
+ /* Check what kind of response we got */
+ if ((Message->Response != ResponseReturnToCaller) &&
+ (Message->Response != ResponseNotHandled) &&
+ (Message->Response != ResponseAbort) &&
+ (Message->Response != ResponseCancel) &&
+ (Message->Response != ResponseIgnore) &&
+ (Message->Response != ResponseNo) &&
+ (Message->Response != ResponseOk) &&
+ (Message->Response != ResponseRetry) &&
+ (Message->Response != ResponseYes) &&
+ (Message->Response != ResponseTryAgain) &&
+ (Message->Response != ResponseContinue))
+ {
+ /* Reset to a default one */
+ Message->Response = ResponseReturnToCaller;
+ }
+
+ /* Set the response */
+ *Response = Message->Response;
+ }
+ }
+ else
+ {
+ /* Set defaults */
+ *Response = ResponseReturnToCaller;
+ Status = STATUS_SUCCESS;
+ }
+
+ /* Return status */
+ return Status;
}
/*++
Modified: trunk/reactos/ntoskrnl/lpc/reply.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/lpc/reply.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/reply.c (original)
+++ trunk/reactos/ntoskrnl/lpc/reply.c Mon Oct 30 17:20:45 2006
@@ -429,22 +429,26 @@
{
HANDLE PortHandle;
NTSTATUS Status;
-
- /* This is a SICK hack */
- Status = ObOpenObjectByPointer(Port,
- 0,
- NULL,
- PORT_ALL_ACCESS,
- LpcPortObjectType,
- KernelMode,
- &PortHandle);
- DPRINT1("LPC Hack active: %lx %lx\n", Status, PortHandle);
-
- /* Call the Nt function. Do a ring transition to get Kmode. */
+ UNICODE_STRING PortName;
+ ULONG ConnectInfoLength;
+
+ //
+ // OMG HAXX!
+ //
+ RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
+ ConnectInfoLength = 0;
+ Status = ZwConnectPort(&PortHandle,
+ &PortName,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &ConnectInfoLength);
+
Status = ZwRequestWaitReplyPort(PortHandle,
LpcMessageRequest,
LpcMessageReply);
- DPRINT1("LPC Hack active: %lx %lx\n", Status, PortHandle);
/* Close the handle */
ObCloseHandle(PortHandle, KernelMode);
Modified: trunk/reactos/ntoskrnl/lpc/send.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/lpc/send.c?rev=24…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/send.c (original)
+++ trunk/reactos/ntoskrnl/lpc/send.c Mon Oct 30 17:20:45 2006
@@ -288,7 +288,7 @@
Status = EiReplyOrRequestPort(Port->OtherPort,
LpcRequest,
- LPC_REQUEST,
+ LpcRequest->u2.s2.Type == LPC_ERROR_EVENT ? LPC_ERROR_EVENT :
LPC_REQUEST,
Port);
if (!NT_SUCCESS(Status))
{
Modified: trunk/reactos/subsystems/win32/csrss/api/wapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/api…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/wapi.c (original)
+++ trunk/reactos/subsystems/win32/csrss/api/wapi.c Mon Oct 30 17:20:45 2006
@@ -104,6 +104,20 @@
}
}
+BOOL FASTCALL CallHardError(void);
+
+static
+VOID
+NTAPI
+CsrHandleHardError(IN PCSRSS_PROCESS_DATA ProcessData,
+ IN OUT PHARDERROR_MSG Message)
+{
+ DPRINT1("CSR: received hard error %lx\n", Message->Status);
+
+ /* Call the hard error handler in win32csr */
+ CallHardError();
+}
+
static
VOID
STDCALL
@@ -133,7 +147,7 @@
DPRINT1("NtReplyWaitReceivePort failed\n");
break;
}
-
+
/* If the connection was closed, handle that */
if (Request->Header.u2.s2.Type == LPC_PORT_CLOSED)
{
@@ -161,9 +175,18 @@
continue;
}
- /* Call the Handler */
- CsrApiCallHandler(ProcessData, Request);
-
+ /* Check if we got a hard error */
+ if (Request->Header.u2.s2.Type == LPC_ERROR_EVENT)
+ {
+ /* Call the Handler */
+ CsrHandleHardError(ProcessData, (PHARDERROR_MSG)Request);
+ }
+ else
+ {
+ /* Call the Handler */
+ CsrApiCallHandler(ProcessData, Request);
+ }
+
/* Send back the reply */
Reply = Request;
}
Modified: trunk/reactos/subsystems/win32/csrss/include/csrplugin.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/csrplugin.h (original)
+++ trunk/reactos/subsystems/win32/csrss/include/csrplugin.h Mon Oct 30 17:20:45 2006
@@ -43,9 +43,12 @@
typedef BOOL (STDCALL *CSRPLUGIN_INIT_COMPLETE_PROC)(void);
+typedef BOOL (STDCALL *CSRPLUGIN_HARDERROR_PROC)(void);
+
typedef BOOL (STDCALL *CSRPLUGIN_INITIALIZE_PROC)(PCSRSS_API_DEFINITION *ApiDefinitions,
PCSRSS_OBJECT_DEFINITION
*ObjectDefinitions,
CSRPLUGIN_INIT_COMPLETE_PROC
*InitCompleteProc,
+ CSRPLUGIN_HARDERROR_PROC
*HardErrorProc,
PCSRSS_EXPORTED_FUNCS Exports,
HANDLE CsrssApiHeap);
Modified: trunk/reactos/subsystems/win32/csrss/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/ini…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/init.c (original)
+++ trunk/reactos/subsystems/win32/csrss/init.c Mon Oct 30 17:20:45 2006
@@ -27,6 +27,9 @@
static unsigned InitCompleteProcCount;
static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
+
+static unsigned HardErrorProcCount;
+static CSRPLUGIN_HARDERROR_PROC *HardErrorProcs = NULL;
HANDLE hSbApiPort = (HANDLE) 0;
@@ -64,6 +67,34 @@
InitCompleteProcCount++;
return STATUS_SUCCESS;
+}
+
+static NTSTATUS FASTCALL
+CsrpAddHardErrorProc(CSRPLUGIN_HARDERROR_PROC Proc)
+{
+ CSRPLUGIN_HARDERROR_PROC *NewProcs;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
+ (HardErrorProcCount + 1)
+ * sizeof(CSRPLUGIN_HARDERROR_PROC));
+ if (NULL == NewProcs)
+ {
+ return STATUS_NO_MEMORY;
+ }
+ if (0 != HardErrorProcCount)
+ {
+ RtlCopyMemory(NewProcs, HardErrorProcs,
+ HardErrorProcCount * sizeof(CSRPLUGIN_HARDERROR_PROC));
+ RtlFreeHeap(CsrssApiHeap, 0, HardErrorProcs);
+ }
+
+ NewProcs[HardErrorProcCount] = Proc;
+ HardErrorProcs = NewProcs;
+ HardErrorProcCount++;
+
+ return STATUS_SUCCESS;
}
/**********************************************************************
@@ -88,6 +119,27 @@
}
return Ok;
+}
+
+BOOL
+FASTCALL
+CallHardError(void)
+{
+ BOOL Ok;
+ unsigned i;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ Ok = TRUE;
+ if (0 != HardErrorProcCount)
+ {
+ for (i = 0; i < HardErrorProcCount && Ok; i++)
+ {
+ Ok = (*(HardErrorProcs[i]))();
+ }
+ }
+
+ return Ok;
}
ULONG
@@ -182,6 +234,7 @@
PCSRSS_API_DEFINITION ApiDefinitions;
PCSRSS_OBJECT_DEFINITION ObjectDefinitions;
CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc;
+ CSRPLUGIN_HARDERROR_PROC HardErrorProc;
DPRINT("CSR: %s called\n", __FUNCTION__);
@@ -202,7 +255,7 @@
Exports.CsrReleaseObjectProc = CsrReleaseObject;
Exports.CsrEnumProcessesProc = CsrEnumProcesses;
if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
- &Exports, CsrssApiHeap))
+ &HardErrorProc, &Exports, CsrssApiHeap))
{
return STATUS_UNSUCCESSFUL;
}
@@ -221,6 +274,7 @@
{
Status = CsrpAddInitCompleteProc(InitCompleteProc);
}
+ if (HardErrorProc) Status = CsrpAddHardErrorProc(HardErrorProc);
return Status;
}
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c Mon Oct 30 17:20:45 2006
@@ -163,10 +163,19 @@
return TRUE;
}
+static BOOL STDCALL
+Win32CsrHardError(void)
+{
+ MessageBox(0, "Hard Error", "TODO", 0);
+ return TRUE;
+}
+
+
BOOL STDCALL
Win32CsrInitialization(PCSRSS_API_DEFINITION *ApiDefinitions,
PCSRSS_OBJECT_DEFINITION *ObjectDefinitions,
CSRPLUGIN_INIT_COMPLETE_PROC *InitComplete,
+ CSRPLUGIN_HARDERROR_PROC *HardError,
PCSRSS_EXPORTED_FUNCS Exports,
HANDLE CsrssApiHeap)
{
@@ -179,6 +188,7 @@
*ApiDefinitions = Win32CsrApiDefinitions;
*ObjectDefinitions = Win32CsrObjectDefinitions;
*InitComplete = Win32CsrInitComplete;
+ *HardError = Win32CsrHardError;
return TRUE;
}
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.def
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.def (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.def Mon Oct 30 17:20:45 2006
@@ -5,4 +5,4 @@
EXPORTS
-Win32CsrInitialization@20
+Win32CsrInitialization@24