[SETUPLIB][USETUP] Add support for setup error handling.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 28 Oct 2018 21:51:33 +0000 (22:51 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 5 Nov 2018 11:03:19 +0000 (12:03 +0100)
base/setup/lib/setuplib.c
base/setup/lib/setuplib.h
base/setup/usetup/usetup.c

index 915acd5..9a7ea88 100644 (file)
@@ -675,6 +675,10 @@ InitializeSetup(
         // pSetupData->LayoutList   = NULL;
         // pSetupData->LanguageList = NULL;
 
+        /* Initialize error handling */
+        pSetupData->LastErrorNumber = ERROR_SUCCESS;
+        pSetupData->ErrorRoutine = NULL;
+
         /* Initialize global unicode strings */
         RtlInitUnicodeString(&pSetupData->SourcePath, NULL);
         RtlInitUnicodeString(&pSetupData->SourceRootPath, NULL);
index 585808f..837633a 100644 (file)
@@ -58,8 +58,15 @@ extern HANDLE ProcessHeap;
 
 struct _USETUP_DATA;
 
+typedef VOID
+(__cdecl *PSETUP_ERROR_ROUTINE)(IN struct _USETUP_DATA*, ...);
+
 typedef struct _USETUP_DATA
 {
+/* Error handling *****/
+    ERROR_NUMBER LastErrorNumber;
+    PSETUP_ERROR_ROUTINE ErrorRoutine;
+
 /* Setup INFs *****/
     HINF SetupInf;
 
index d951a65..4dbf388 100644 (file)
@@ -3481,6 +3481,29 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
 }
 
 
+// PSETUP_ERROR_ROUTINE
+static VOID
+__cdecl
+USetupErrorRoutine(
+    IN PUSETUP_DATA pSetupData,
+    ...)
+{
+    INPUT_RECORD Ir;
+    va_list arg_ptr;
+
+    va_start(arg_ptr, pSetupData);
+
+    if (pSetupData->LastErrorNumber >= ERROR_SUCCESS &&
+        pSetupData->LastErrorNumber <  ERROR_LAST_ERROR_CODE)
+    {
+        // Note: the "POPUP_WAIT_ENTER" actually depends on the LastErrorNumber...
+        MUIDisplayErrorV(pSetupData->LastErrorNumber, &Ir, POPUP_WAIT_ENTER, arg_ptr);
+    }
+
+    va_end(arg_ptr);
+}
+
+
 static BOOLEAN
 AddSectionToCopyQueueCab(HINF InfFile,
                          PCWSTR SectionName,
@@ -5001,6 +5024,7 @@ RunUSetup(VOID)
 
     /* Initialize Setup, phase 0 */
     InitializeSetup(&USetupData, 0);
+    USetupData.ErrorRoutine = USetupErrorRoutine;
 
     /* Hide the cursor */
     CONSOLE_SetCursorType(TRUE, FALSE);