[SETUPLIB][USETUP] Make the GENERIC_LIST store the items display text in UNICODE...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 3 Sep 2017 19:46:26 +0000 (19:46 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 27 Oct 2018 22:30:54 +0000 (00:30 +0200)
Only convert to ANSI when needed (e.g. in the display code for usetup).
The 1st-stage GUI setup will however use the UNICODE strings directly.

svn path=/branches/setup_improvements/; revision=75753

base/setup/lib/settings.c
base/setup/lib/utils/genlist.c
base/setup/lib/utils/genlist.h
base/setup/lib/utils/osdetect.c
base/setup/usetup/genlist.c
base/setup/usetup/genlist.h
base/setup/usetup/usetup.c

index bf9a804..4e27d03 100644 (file)
@@ -323,7 +323,7 @@ typedef UCHAR
 (NTAPI *PPROCESS_ENTRY_ROUTINE)(
     IN PWCHAR KeyName,
     IN PWCHAR KeyValue,
 (NTAPI *PPROCESS_ENTRY_ROUTINE)(
     IN PWCHAR KeyName,
     IN PWCHAR KeyValue,
-    IN PCHAR DisplayText,
+    OUT PWCHAR DisplayText,
     IN SIZE_T DisplayTextSize,
     OUT PVOID* UserData,
     OUT PBOOLEAN Current,
     IN SIZE_T DisplayTextSize,
     OUT PVOID* UserData,
     OUT PBOOLEAN Current,
@@ -344,7 +344,7 @@ AddEntriesFromInfSection(
     PVOID UserData;
     BOOLEAN Current;
     UCHAR RetVal;
     PVOID UserData;
     BOOLEAN Current;
     UCHAR RetVal;
-    CHAR DisplayText[128];
+    WCHAR DisplayText[128];
 
     if (!SetupFindFirstLineW(InfFile, SectionName, NULL, pContext))
         return -1;
 
     if (!SetupFindFirstLineW(InfFile, SectionName, NULL, pContext))
         return -1;
@@ -404,7 +404,7 @@ NTAPI
 DefaultProcessEntry(
     IN PWCHAR KeyName,
     IN PWCHAR KeyValue,
 DefaultProcessEntry(
     IN PWCHAR KeyName,
     IN PWCHAR KeyValue,
-    IN PCHAR DisplayText,
+    OUT PWCHAR DisplayText,
     IN SIZE_T DisplayTextSize,
     OUT PVOID* UserData,
     OUT PBOOLEAN Current,
     IN SIZE_T DisplayTextSize,
     OUT PVOID* UserData,
     OUT PBOOLEAN Current,
@@ -422,7 +422,7 @@ DefaultProcessEntry(
     }
 
     wcscpy((PWCHAR)*UserData, KeyName);
     }
 
     wcscpy((PWCHAR)*UserData, KeyName);
-    sprintf(DisplayText, "%S", KeyValue);
+    wcscpy(DisplayText, KeyValue);
 
     *Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
 
 
     *Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE);
 
@@ -739,7 +739,7 @@ CreateDisplayDriverList(
     }
 
 #if 0
     }
 
 #if 0
-    AppendGenericListEntry(List, "Other display driver", NULL, TRUE);
+    AppendGenericListEntry(List, L"Other display driver", NULL, TRUE);
 #endif
 
     return List;
 #endif
 
     return List;
@@ -1086,7 +1086,7 @@ NTAPI
 ProcessLangEntry(
     IN PWCHAR KeyName,
     IN PWCHAR KeyValue,
 ProcessLangEntry(
     IN PWCHAR KeyName,
     IN PWCHAR KeyValue,
-    IN PCHAR DisplayText,
+    OUT PWCHAR DisplayText,
     IN SIZE_T DisplayTextSize,
     OUT PVOID* UserData,
     OUT PBOOLEAN Current,
     IN SIZE_T DisplayTextSize,
     OUT PVOID* UserData,
     OUT PBOOLEAN Current,
@@ -1110,7 +1110,7 @@ ProcessLangEntry(
     }
 
     wcscpy((PWCHAR)*UserData, KeyName);
     }
 
     wcscpy((PWCHAR)*UserData, KeyName);
-    sprintf(DisplayText, "%S", KeyValue);
+    wcscpy(DisplayText, KeyValue);
 
     *Current = FALSE;
 
 
     *Current = FALSE;
 
index 1795895..919b524 100644 (file)
@@ -65,7 +65,7 @@ DestroyGenericList(
 BOOLEAN
 AppendGenericListEntry(
     IN OUT PGENERIC_LIST List,
 BOOLEAN
 AppendGenericListEntry(
     IN OUT PGENERIC_LIST List,
-    IN PCHAR Text,
+    IN PCWSTR Text,
     IN PVOID UserData,
     IN BOOLEAN Current)
 {
     IN PVOID UserData,
     IN BOOLEAN Current)
 {
@@ -73,11 +73,12 @@ AppendGenericListEntry(
 
     Entry = (PGENERIC_LIST_ENTRY)RtlAllocateHeap(ProcessHeap,
                                                  0,
 
     Entry = (PGENERIC_LIST_ENTRY)RtlAllocateHeap(ProcessHeap,
                                                  0,
-                                                 sizeof(GENERIC_LIST_ENTRY) + strlen(Text));
+                                                 sizeof(GENERIC_LIST_ENTRY) +
+                                                    (wcslen(Text) + 1) * sizeof(WCHAR));
     if (Entry == NULL)
         return FALSE;
 
     if (Entry == NULL)
         return FALSE;
 
-    strcpy (Entry->Text, Text);
+    wcscpy(Entry->Text, Text);
     Entry->List = List;
     Entry->UserData = UserData;
 
     Entry->List = List;
     Entry->UserData = UserData;
 
@@ -138,7 +139,7 @@ GetListEntryUserData(
     return Entry->UserData;
 }
 
     return Entry->UserData;
 }
 
-LPCSTR
+PCWSTR
 GetListEntryText(
     IN PGENERIC_LIST_ENTRY Entry)
 {
 GetListEntryText(
     IN PGENERIC_LIST_ENTRY Entry)
 {
index 5621089..ca8696d 100644 (file)
@@ -12,7 +12,7 @@ typedef struct _GENERIC_LIST_ENTRY
     LIST_ENTRY Entry;
     struct _GENERIC_LIST* List;
     PVOID UserData;
     LIST_ENTRY Entry;
     struct _GENERIC_LIST* List;
     PVOID UserData;
-    CHAR Text[1];       // FIXME: UI stuff
+    WCHAR Text[1];      // FIXME: UI stuff
 
 } GENERIC_LIST_ENTRY, *PGENERIC_LIST_ENTRY;
 
 
 } GENERIC_LIST_ENTRY, *PGENERIC_LIST_ENTRY;
 
@@ -38,7 +38,7 @@ DestroyGenericList(
 BOOLEAN
 AppendGenericListEntry(
     IN OUT PGENERIC_LIST List,
 BOOLEAN
 AppendGenericListEntry(
     IN OUT PGENERIC_LIST List,
-    IN PCHAR Text,
+    IN PCWSTR Text,
     IN PVOID UserData,
     IN BOOLEAN Current);
 
     IN PVOID UserData,
     IN BOOLEAN Current);
 
@@ -63,7 +63,7 @@ PVOID
 GetListEntryUserData(
     IN PGENERIC_LIST_ENTRY Entry);
 
 GetListEntryUserData(
     IN PGENERIC_LIST_ENTRY Entry);
 
-LPCSTR
+PCWSTR
 GetListEntryText(
     IN PGENERIC_LIST_ENTRY Entry);
 
 GetListEntryText(
     IN PGENERIC_LIST_ENTRY Entry);
 
index a82b04c..fdfd5ba 100644 (file)
@@ -575,7 +575,6 @@ AddNTOSInstallation(
 {
     PNTOS_INSTALLATION NtOsInstall;
     SIZE_T ArcPathLength, NtPathLength;
 {
     PNTOS_INSTALLATION NtOsInstall;
     SIZE_T ArcPathLength, NtPathLength;
-    CHAR InstallNameA[MAX_PATH];
 
     /* Is there already any installation with these settings? */
     NtOsInstall = FindExistingNTOSInstall(List, SystemRootArcPath, SystemRootNtPath);
 
     /* Is there already any installation with these settings? */
     NtOsInstall = FindExistingNTOSInstall(List, SystemRootArcPath, SystemRootNtPath);
@@ -623,8 +622,7 @@ AddNTOSInstallation(
                       InstallationName);
 
     // Having the GENERIC_LIST storing the display item string plainly sucks...
                       InstallationName);
 
     // Having the GENERIC_LIST storing the display item string plainly sucks...
-    RtlStringCchPrintfA(InstallNameA, ARRAYSIZE(InstallNameA), "%S", InstallationName);
-    AppendGenericListEntry(List, InstallNameA, NtOsInstall, FALSE);
+    AppendGenericListEntry(List, InstallationName, NtOsInstall, FALSE);
 
     return NtOsInstall;
 }
 
     return NtOsInstall;
 }
index 773dd1b..d0b7a63 100644 (file)
@@ -47,6 +47,8 @@ InitGenericListUi(
     ListUi->Right = 0;
     ListUi->Bottom = 0;
     ListUi->Redraw = TRUE;
     ListUi->Right = 0;
     ListUi->Bottom = 0;
     ListUi->Redraw = TRUE;
+
+    ListUi->CurrentItemText[0] = ANSI_NULL;
 }
 
 static
 }
 
 static
@@ -157,6 +159,8 @@ DrawListEntries(
             break;
         ListUi->LastShown = Entry;
 
             break;
         ListUi->LastShown = Entry;
 
+        sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text);
+
         FillConsoleOutputAttribute(StdOutput,
                                    (List->CurrentEntry == ListEntry) ?
                                    FOREGROUND_BLUE | BACKGROUND_WHITE :
         FillConsoleOutputAttribute(StdOutput,
                                    (List->CurrentEntry == ListEntry) ?
                                    FOREGROUND_BLUE | BACKGROUND_WHITE :
@@ -173,8 +177,8 @@ DrawListEntries(
 
         coPos.X++;
         WriteConsoleOutputCharacterA(StdOutput,
 
         coPos.X++;
         WriteConsoleOutputCharacterA(StdOutput,
-                                     ListEntry->Text,
-                                     min(strlen(ListEntry->Text), (SIZE_T)Width - 2),
+                                     ListUi->CurrentItemText,
+                                     min(strlen(ListUi->CurrentItemText), (SIZE_T)Width - 2),
                                      coPos,
                                      &Written);
         coPos.X--;
                                      coPos,
                                      &Written);
         coPos.X--;
@@ -414,7 +418,7 @@ ScrollPageUpGenericList(
 
     for (i = ListUi->Bottom - 1; i > ListUi->Top + 1; i--)
     {
 
     for (i = ListUi->Bottom - 1; i > ListUi->Top + 1; i--)
     {
-         ScrollUpGenericList(ListUi);
+        ScrollUpGenericList(ListUi);
     }
 
     /* Update user interface */
     }
 
     /* Update user interface */
@@ -489,13 +493,17 @@ GenericListKeyPress(
 
     ListUi->Redraw = FALSE;
 
 
     ListUi->Redraw = FALSE;
 
-    if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar) &&
+    sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text);
+
+    if ((strlen(ListUi->CurrentItemText) > 0) && (tolower(ListUi->CurrentItemText[0]) == AsciiChar) &&
          (List->CurrentEntry->Entry.Flink != &List->ListHead))
     {
         ScrollDownGenericList(ListUi);
         ListEntry = List->CurrentEntry;
 
          (List->CurrentEntry->Entry.Flink != &List->ListHead))
     {
         ScrollDownGenericList(ListUi);
         ListEntry = List->CurrentEntry;
 
-        if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar))
+        sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text);
+
+        if ((strlen(ListUi->CurrentItemText) > 0) && (tolower(ListUi->CurrentItemText[0]) == AsciiChar))
             goto End;
     }
 
             goto End;
     }
 
@@ -506,7 +514,9 @@ GenericListKeyPress(
 
     for (;;)
     {
 
     for (;;)
     {
-        if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar))
+        sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text);
+
+        if ((strlen(ListUi->CurrentItemText) > 0) && (tolower(ListUi->CurrentItemText[0]) == AsciiChar))
         {
             Flag = TRUE;
             break;
         {
             Flag = TRUE;
             break;
index 0799a63..5e85800 100644 (file)
@@ -40,6 +40,9 @@ typedef struct _GENERIC_LIST_UI
     SHORT Right;
     SHORT Bottom;
     BOOL Redraw;
     SHORT Right;
     SHORT Bottom;
     BOOL Redraw;
+
+    CHAR CurrentItemText[256];
+
 } GENERIC_LIST_UI, *PGENERIC_LIST_UI;
 
 VOID
 } GENERIC_LIST_UI, *PGENERIC_LIST_UI;
 
 VOID
index a576458..9106d0d 100644 (file)
@@ -1093,6 +1093,7 @@ static PAGE_NUMBER
 DeviceSettingsPage(PINPUT_RECORD Ir)
 {
     static ULONG Line = 16;
 DeviceSettingsPage(PINPUT_RECORD Ir)
 {
     static ULONG Line = 16;
+    CHAR CurrentItemText[256];
 
     /* Initialize the computer settings list */
     if (ComputerList == NULL)
 
     /* Initialize the computer settings list */
     if (ComputerList == NULL)
@@ -1147,10 +1148,14 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
 
     MUIDisplayPage(DEVICE_SETTINGS_PAGE);
 
 
     MUIDisplayPage(DEVICE_SETTINGS_PAGE);
 
-    CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry(ComputerList)));
-    CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry(DisplayList)));
-    CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry(KeyboardList)));
-    CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry(LayoutList)));
+    sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(ComputerList)));
+    CONSOLE_SetTextXY(25, 11, CurrentItemText);
+    sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(DisplayList)));
+    CONSOLE_SetTextXY(25, 12, CurrentItemText);
+    sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(KeyboardList)));
+    CONSOLE_SetTextXY(25, 13, CurrentItemText);
+    sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(LayoutList)));
+    CONSOLE_SetTextXY(25, 14, CurrentItemText);
 
     CONSOLE_InvertTextXY(24, Line, 48, 1);
 
 
     CONSOLE_InvertTextXY(24, Line, 48, 1);