https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f894631472a436f02f1b8…
commit f894631472a436f02f1b80c31b2a6a04a215f10f
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Oct 28 22:51:33 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Nov 5 12:03:19 2018 +0100
[SETUPLIB][USETUP] Add support for setup error handling.
---
base/setup/lib/setuplib.c | 4 ++++
base/setup/lib/setuplib.h | 7 +++++++
base/setup/usetup/usetup.c | 24 ++++++++++++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c
index 915acd5a36..9a7ea88a9a 100644
--- a/base/setup/lib/setuplib.c
+++ b/base/setup/lib/setuplib.c
@@ -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);
diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h
index 585808f6fa..837633a7e7 100644
--- a/base/setup/lib/setuplib.h
+++ b/base/setup/lib/setuplib.h
@@ -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;
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index d951a65a86..4dbf3885c3 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -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);