https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8f1ab791faa1ca06ecfe1…
commit 8f1ab791faa1ca06ecfe1abac2a2ea5ab86c9353
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Jan 6 16:47:37 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Nov 1 18:55:43 2018 +0100
[SETUPLIB][REACTOS][USETUP] Further improve the interfacing with INF and File-Queue
APIs.
This allows using some of the SetupApi.dll functions when SETUPLIB is
used in the (Win32) GUI 1st-stage installer "REACTOS", while using the
custom implemented NT-aware functions in "USETUP".
---
base/setup/lib/CMakeLists.txt | 5 +-
base/setup/lib/registry.c | 60 +++----
base/setup/lib/settings.c | 44 ++---
base/setup/lib/setuplib.c | 102 ++++++------
base/setup/lib/setuplib.h | 3 +-
base/setup/lib/spapisup/fileqsup.c | 34 ++++
.../filequeue.h => lib/spapisup/fileqsup.h} | 108 ++++++-------
base/setup/lib/{utils => spapisup}/infsupp.c | 59 ++++---
base/setup/lib/{utils => spapisup}/infsupp.h | 178 +++++++++++----------
base/setup/lib/spapisup/spapisup.h | 29 ++++
base/setup/reactos/CMakeLists.txt | 3 +-
base/setup/reactos/spapisup/fileqsup.c | 155 ++++++++++++++++++
.../reactos/{inffile.c => spapisup/infsupp.c} | 34 +++-
base/setup/usetup/CMakeLists.txt | 6 +-
base/setup/usetup/devinst.c | 19 +--
base/setup/usetup/{ => spapisup}/cabinet.c | 0
base/setup/usetup/{ => spapisup}/cabinet.h | 0
.../usetup/{filequeue.c => spapisup/fileqsup.c} | 37 +++--
base/setup/usetup/{ => spapisup}/inffile.h | 14 +-
.../setup/usetup/{inffile.c => spapisup/infsupp.c} | 93 ++++++-----
base/setup/usetup/usetup.c | 108 +++++++------
base/setup/usetup/usetup.h | 7 +-
22 files changed, 702 insertions(+), 396 deletions(-)
diff --git a/base/setup/lib/CMakeLists.txt b/base/setup/lib/CMakeLists.txt
index 199dffd86b..7c23e24045 100644
--- a/base/setup/lib/CMakeLists.txt
+++ b/base/setup/lib/CMakeLists.txt
@@ -1,14 +1,15 @@
add_definitions(${I18N_DEFS})
-include_directories(utils)
+include_directories(spapisup utils)
list(APPEND SOURCE
+ spapisup/fileqsup.c
+ spapisup/infsupp.c
utils/arcname.c
utils/bldrsup.c
utils/filesup.c
utils/genlist.c
- utils/infsupp.c
utils/inicache.c
utils/ntverrsrc.c
utils/osdetect.c
diff --git a/base/setup/lib/registry.c b/base/setup/lib/registry.c
index 810002d840..bc97489da0 100644
--- a/base/setup/lib/registry.c
+++ b/base/setup/lib/registry.c
@@ -55,18 +55,6 @@
#define FLG_ADDREG_TYPE_MASK (0xFFFF0000 | FLG_ADDREG_BINVALUETYPE)
#endif
-#ifdef _M_IX86
-#define Architecture L"x86"
-#elif defined(_M_AMD64)
-#define Architecture L"amd64"
-#elif defined(_M_IA64)
-#define Architecture L"ia64"
-#elif defined(_M_ARM)
-#define Architecture L"arm"
-#elif defined(_M_PPC)
-#define Architecture L"ppc"
-#endif
-
/* GLOBALS ******************************************************************/
#define REGISTRY_SETUP_MACHINE
L"\\Registry\\Machine\\SYSTEM\\USetup_Machine\\"
@@ -301,13 +289,13 @@ do_reg_operation(HANDLE KeyHandle,
}
if (!(Flags & FLG_ADDREG_BINVALUETYPE) ||
- (Type == REG_DWORD && SetupGetFieldCount (Context) == 5))
+ (Type == REG_DWORD && SpInfGetFieldCount(Context) == 5))
{
PWCHAR Str = NULL;
if (Type == REG_MULTI_SZ)
{
- if (!SetupGetMultiSzFieldW (Context, 5, NULL, 0, &Size))
+ if (!SpInfGetMultiSzField(Context, 5, NULL, 0, &Size))
Size = 0;
if (Size)
@@ -316,7 +304,7 @@ do_reg_operation(HANDLE KeyHandle,
if (Str == NULL)
return FALSE;
- SetupGetMultiSzFieldW (Context, 5, Str, Size, NULL);
+ SpInfGetMultiSzField(Context, 5, Str, Size, NULL);
}
if (Flags & FLG_ADDREG_APPEND)
@@ -334,7 +322,7 @@ do_reg_operation(HANDLE KeyHandle,
}
else
{
- if (!SetupGetStringFieldW(Context, 5, NULL, 0, &Size))
+ if (!SpInfGetStringField(Context, 5, NULL, 0, &Size))
Size = 0;
if (Size)
@@ -343,7 +331,7 @@ do_reg_operation(HANDLE KeyHandle,
if (Str == NULL)
return FALSE;
- SetupGetStringFieldW(Context, 5, Str, Size, NULL);
+ SpInfGetStringField(Context, 5, Str, Size, NULL);
}
}
@@ -389,7 +377,7 @@ do_reg_operation(HANDLE KeyHandle,
{
PUCHAR Data = NULL;
- if (!SetupGetBinaryField (Context, 5, NULL, 0, &Size))
+ if (!SpInfGetBinaryField(Context, 5, NULL, 0, &Size))
Size = 0;
if (Size)
@@ -399,7 +387,7 @@ do_reg_operation(HANDLE KeyHandle,
return FALSE;
DPRINT("setting binary data %wZ len %lu\n", ValueName, Size);
- SetupGetBinaryField (Context, 5, Data, Size, NULL);
+ SpInfGetBinaryField(Context, 5, Data, Size, NULL);
}
NtSetValueKey (KeyHandle,
@@ -435,27 +423,27 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
HANDLE RootKeyHandle, KeyHandle;
BOOLEAN Ok;
- Ok = SetupFindFirstLineW(hInf, Section, NULL, &Context);
+ Ok = SpInfFindFirstLine(hInf, Section, NULL, &Context);
if (!Ok)
return TRUE; /* Don't fail if the section isn't present */
- for (;Ok; Ok = SetupFindNextLine(&Context, &Context))
+ for (;Ok; Ok = SpInfFindNextLine(&Context, &Context))
{
/* get root */
- if (!SetupGetStringFieldW(&Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR),
NULL))
+ if (!SpInfGetStringField(&Context, 1, Buffer, sizeof(Buffer)/sizeof(WCHAR),
NULL))
continue;
RootKeyHandle = GetRootKeyByName(Buffer, &RootKeyName);
if (!RootKeyHandle)
continue;
/* get key */
- if (!SetupGetStringFieldW(&Context, 2, Buffer, sizeof(Buffer)/sizeof(WCHAR),
NULL))
+ if (!SpInfGetStringField(&Context, 2, Buffer, sizeof(Buffer)/sizeof(WCHAR),
NULL))
*Buffer = 0;
DPRINT("KeyName: <%S\\%S>\n", RootKeyName, Buffer);
/* get flags */
- if (!SetupGetIntField(&Context, 4, (PINT)&Flags))
+ if (!SpInfGetIntField(&Context, 4, (PINT)&Flags))
Flags = 0;
DPRINT("Flags: %lx\n", Flags);
@@ -492,7 +480,7 @@ registry_callback(HINF hInf, PCWSTR Section, BOOLEAN Delete)
}
/* get value name */
- if (SetupGetStringFieldW(&Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR),
NULL))
+ if (SpInfGetStringField(&Context, 3, Buffer, sizeof(Buffer)/sizeof(WCHAR),
NULL))
{
RtlInitUnicodeString(&Value, Buffer);
ValuePtr = &Value;
@@ -531,14 +519,14 @@ ImportRegistryFile(
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2,
SourcePath, FileName);
- hInf = SetupOpenInfFileExW(FileNameBuffer,
- NULL,
- INF_STYLE_WIN4,
- LocaleId,
- &ErrorLine);
+ hInf = SpInfOpenInfFile(FileNameBuffer,
+ NULL,
+ INF_STYLE_WIN4,
+ LocaleId,
+ &ErrorLine);
if (hInf == INVALID_HANDLE_VALUE)
{
- DPRINT1("SetupOpenInfFileEx() failed\n");
+ DPRINT1("SpInfOpenInfFile() failed\n");
return FALSE;
}
@@ -546,7 +534,7 @@ ImportRegistryFile(
if (!registry_callback(hInf, L"DelReg", FALSE))
{
DPRINT1("registry_callback() failed\n");
- SetupCloseInfFile(hInf);
+ SpInfCloseInfFile(hInf);
return FALSE;
}
#endif
@@ -554,18 +542,18 @@ ImportRegistryFile(
if (!registry_callback(hInf, L"AddReg", FALSE))
{
DPRINT1("registry_callback() failed\n");
- SetupCloseInfFile(hInf);
+ SpInfCloseInfFile(hInf);
return FALSE;
}
- if (!registry_callback(hInf, L"AddReg.NT" Architecture, FALSE))
+ if (!registry_callback(hInf, L"AddReg.NT" INF_ARCH, FALSE))
{
DPRINT1("registry_callback() failed\n");
- SetupCloseInfFile(hInf);
+ SpInfCloseInfFile(hInf);
return FALSE;
}
- SetupCloseInfFile(hInf);
+ SpInfCloseInfFile(hInf);
return TRUE;
}
diff --git a/base/setup/lib/settings.c b/base/setup/lib/settings.c
index 93de42a31d..20a6bd4b8d 100644
--- a/base/setup/lib/settings.c
+++ b/base/setup/lib/settings.c
@@ -337,13 +337,13 @@ AddEntriesFromInfSection(
IN PVOID Parameter OPTIONAL)
{
LONG TotalCount = 0;
- PWCHAR KeyName;
- PWCHAR KeyValue;
+ PCWSTR KeyName;
+ PCWSTR KeyValue;
PVOID UserData;
BOOLEAN Current;
UCHAR RetVal;
- if (!SetupFindFirstLineW(InfFile, SectionName, NULL, pContext))
+ if (!SpInfFindFirstLine(InfFile, SectionName, NULL, pContext))
return -1;
do
@@ -389,7 +389,7 @@ AddEntriesFromInfSection(
}
// else if (RetVal == 2), skip the entry.
- } while (SetupFindNextLine(pContext, pContext));
+ } while (SpInfFindNextLine(pContext, pContext));
return TotalCount;
}
@@ -439,8 +439,8 @@ CreateComputerTypeList(
{
PGENERIC_LIST List;
INFCONTEXT Context;
- PWCHAR KeyName;
- PWCHAR KeyValue;
+ PCWSTR KeyName;
+ PCWSTR KeyValue;
WCHAR ComputerIdentifier[128];
WCHAR ComputerKey[32];
@@ -453,7 +453,7 @@ CreateComputerTypeList(
DPRINT("Computer identifier: '%S'\n", ComputerIdentifier);
/* Search for matching device identifier */
- if (!SetupFindFirstLineW(InfFile, L"Map.Computer", NULL, &Context))
+ if (!SpInfFindFirstLine(InfFile, L"Map.Computer", NULL, &Context))
{
/* FIXME: error message */
return NULL;
@@ -487,7 +487,7 @@ CreateComputerTypeList(
DPRINT("Computer key: %S\n", KeyName);
RtlStringCchCopyW(ComputerKey, ARRAYSIZE(ComputerKey), KeyName);
INF_FreeData(KeyName);
- } while (SetupFindNextLine(&Context, &Context));
+ } while (SpInfFindNextLine(&Context, &Context));
List = CreateGenericList();
if (List == NULL)
@@ -675,8 +675,8 @@ CreateDisplayDriverList(
{
PGENERIC_LIST List;
INFCONTEXT Context;
- PWCHAR KeyName;
- PWCHAR KeyValue;
+ PCWSTR KeyName;
+ PCWSTR KeyValue;
WCHAR DisplayIdentifier[128];
WCHAR DisplayKey[32];
@@ -689,7 +689,7 @@ CreateDisplayDriverList(
DPRINT("Display identifier: '%S'\n", DisplayIdentifier);
/* Search for matching device identifier */
- if (!SetupFindFirstLineW(InfFile, L"Map.Display", NULL, &Context))
+ if (!SpInfFindFirstLine(InfFile, L"Map.Display", NULL, &Context))
{
/* FIXME: error message */
return NULL;
@@ -723,7 +723,7 @@ CreateDisplayDriverList(
DPRINT("Display key: %S\n", KeyName);
RtlStringCchCopyW(DisplayKey, ARRAYSIZE(DisplayKey), KeyName);
INF_FreeData(KeyName);
- } while (SetupFindNextLine(&Context, &Context));
+ } while (SpInfFindNextLine(&Context, &Context));
List = CreateGenericList();
if (List == NULL)
@@ -778,8 +778,8 @@ ProcessDisplayRegistry(
NTSTATUS Status;
PGENERIC_LIST_ENTRY Entry;
INFCONTEXT Context;
- PWCHAR Buffer;
- PWCHAR ServiceName;
+ PCWSTR Buffer;
+ PCWSTR ServiceName;
ULONG StartValue;
ULONG Width, Height, Bpp;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -793,11 +793,11 @@ ProcessDisplayRegistry(
if (Entry == NULL)
return FALSE;
- if (!SetupFindFirstLineW(InfFile, L"Display",
- ((PGENENTRY)GetListEntryData(Entry))->Id,
- &Context))
+ if (!SpInfFindFirstLine(InfFile, L"Display",
+ ((PGENENTRY)GetListEntryData(Entry))->Id,
+ &Context))
{
- DPRINT1("SetupFindFirstLineW() failed\n");
+ DPRINT1("SpInfFindFirstLine() failed\n");
return FALSE;
}
@@ -1137,7 +1137,7 @@ CreateLanguageList(
{
PGENERIC_LIST List;
INFCONTEXT Context;
- PWCHAR KeyValue;
+ PCWSTR KeyValue;
LANG_ENTRY_PARAM LangEntryParam;
@@ -1145,7 +1145,7 @@ CreateLanguageList(
LangEntryParam.DefaultLanguage = DefaultLanguage;
/* Get default language id */
- if (!SetupFindFirstLineW(InfFile, L"NLS", L"DefaultLanguage",
&Context))
+ if (!SpInfFindFirstLine(InfFile, L"NLS", L"DefaultLanguage",
&Context))
return NULL;
if (!INF_GetData(&Context, NULL, &KeyValue))
@@ -1188,12 +1188,12 @@ CreateKeyboardLayoutList(
{
PGENERIC_LIST List;
INFCONTEXT Context;
- PWCHAR KeyValue;
+ PCWSTR KeyValue;
const MUI_LAYOUTS* LayoutsList;
ULONG uIndex = 0;
/* Get default layout id */
- if (!SetupFindFirstLineW(InfFile, L"NLS", L"DefaultLayout",
&Context))
+ if (!SpInfFindFirstLine(InfFile, L"NLS", L"DefaultLayout",
&Context))
return NULL;
if (!INF_GetData(&Context, NULL, &KeyValue))
diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c
index cb48fd3fa3..34eb2283bb 100644
--- a/base/setup/lib/setuplib.c
+++ b/base/setup/lib/setuplib.c
@@ -32,7 +32,7 @@ CheckUnattendedSetup(
HINF UnattendInf;
UINT ErrorLine;
INT IntValue;
- PWCHAR Value;
+ PCWSTR Value;
WCHAR UnattendInfPath[MAX_PATH];
CombinePaths(UnattendInfPath, ARRAYSIZE(UnattendInfPath), 2,
@@ -47,22 +47,21 @@ CheckUnattendedSetup(
}
/* Load 'unattend.inf' from installation media */
- UnattendInf = SetupOpenInfFileExW(UnattendInfPath,
- NULL,
- INF_STYLE_OLDNT,
- pSetupData->LanguageId,
- &ErrorLine);
-
+ UnattendInf = SpInfOpenInfFile(UnattendInfPath,
+ NULL,
+ INF_STYLE_OLDNT,
+ pSetupData->LanguageId,
+ &ErrorLine);
if (UnattendInf == INVALID_HANDLE_VALUE)
{
- DPRINT("SetupOpenInfFileExW() failed\n");
+ DPRINT("SpInfOpenInfFile() failed\n");
return;
}
/* Open 'Unattend' section */
- if (!SetupFindFirstLineW(UnattendInf, L"Unattend", L"Signature",
&Context))
+ if (!SpInfFindFirstLine(UnattendInf, L"Unattend", L"Signature",
&Context))
{
- DPRINT("SetupFindFirstLineW() failed for section
'Unattend'\n");
+ DPRINT("SpInfFindFirstLine() failed for section
'Unattend'\n");
goto Quit;
}
@@ -84,7 +83,7 @@ CheckUnattendedSetup(
INF_FreeData(Value);
/* Check if Unattend setup is enabled */
- if (!SetupFindFirstLineW(UnattendInf, L"Unattend",
L"UnattendSetupEnabled", &Context))
+ if (!SpInfFindFirstLine(UnattendInf, L"Unattend",
L"UnattendSetupEnabled", &Context))
{
DPRINT("Can't find key 'UnattendSetupEnabled'\n");
goto Quit;
@@ -106,37 +105,37 @@ CheckUnattendedSetup(
INF_FreeData(Value);
/* Search for 'DestinationDiskNumber' in the 'Unattend' section */
- if (!SetupFindFirstLineW(UnattendInf, L"Unattend",
L"DestinationDiskNumber", &Context))
+ if (!SpInfFindFirstLine(UnattendInf, L"Unattend",
L"DestinationDiskNumber", &Context))
{
- DPRINT("SetupFindFirstLine() failed for key
'DestinationDiskNumber'\n");
+ DPRINT("SpInfFindFirstLine() failed for key
'DestinationDiskNumber'\n");
goto Quit;
}
- if (!SetupGetIntField(&Context, 1, &IntValue))
+ if (!SpInfGetIntField(&Context, 1, &IntValue))
{
- DPRINT("SetupGetIntField() failed for key
'DestinationDiskNumber'\n");
+ DPRINT("SpInfGetIntField() failed for key
'DestinationDiskNumber'\n");
goto Quit;
}
pSetupData->DestinationDiskNumber = (LONG)IntValue;
/* Search for 'DestinationPartitionNumber' in the 'Unattend' section
*/
- if (!SetupFindFirstLineW(UnattendInf, L"Unattend",
L"DestinationPartitionNumber", &Context))
+ if (!SpInfFindFirstLine(UnattendInf, L"Unattend",
L"DestinationPartitionNumber", &Context))
{
- DPRINT("SetupFindFirstLine() failed for key
'DestinationPartitionNumber'\n");
+ DPRINT("SpInfFindFirstLine() failed for key
'DestinationPartitionNumber'\n");
goto Quit;
}
- if (!SetupGetIntField(&Context, 1, &IntValue))
+ if (!SpInfGetIntField(&Context, 1, &IntValue))
{
- DPRINT("SetupGetIntField() failed for key
'DestinationPartitionNumber'\n");
+ DPRINT("SpInfGetIntField() failed for key
'DestinationPartitionNumber'\n");
goto Quit;
}
pSetupData->DestinationPartitionNumber = (LONG)IntValue;
/* Search for 'InstallationDirectory' in the 'Unattend' section
(optional) */
- if (SetupFindFirstLineW(UnattendInf, L"Unattend",
L"InstallationDirectory", &Context))
+ if (SpInfFindFirstLine(UnattendInf, L"Unattend",
L"InstallationDirectory", &Context))
{
/* Get pointer 'InstallationDirectory' key */
if (!INF_GetData(&Context, NULL, &Value))
@@ -157,9 +156,9 @@ CheckUnattendedSetup(
/* Search for 'MBRInstallType' in the 'Unattend' section */
pSetupData->MBRInstallType = -1;
- if (SetupFindFirstLineW(UnattendInf, L"Unattend",
L"MBRInstallType", &Context))
+ if (SpInfFindFirstLine(UnattendInf, L"Unattend",
L"MBRInstallType", &Context))
{
- if (SetupGetIntField(&Context, 1, &IntValue))
+ if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->MBRInstallType = IntValue;
}
@@ -167,25 +166,25 @@ CheckUnattendedSetup(
/* Search for 'FormatPartition' in the 'Unattend' section */
pSetupData->FormatPartition = 0;
- if (SetupFindFirstLineW(UnattendInf, L"Unattend",
L"FormatPartition", &Context))
+ if (SpInfFindFirstLine(UnattendInf, L"Unattend",
L"FormatPartition", &Context))
{
- if (SetupGetIntField(&Context, 1, &IntValue))
+ if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->FormatPartition = IntValue;
}
}
pSetupData->AutoPartition = 0;
- if (SetupFindFirstLineW(UnattendInf, L"Unattend",
L"AutoPartition", &Context))
+ if (SpInfFindFirstLine(UnattendInf, L"Unattend",
L"AutoPartition", &Context))
{
- if (SetupGetIntField(&Context, 1, &IntValue))
+ if (SpInfGetIntField(&Context, 1, &IntValue))
{
pSetupData->AutoPartition = IntValue;
}
}
/* Search for LocaleID in the 'Unattend' section */
- if (SetupFindFirstLineW(UnattendInf, L"Unattend", L"LocaleID",
&Context))
+ if (SpInfFindFirstLine(UnattendInf, L"Unattend", L"LocaleID",
&Context))
{
if (INF_GetData(&Context, NULL, &Value))
{
@@ -198,7 +197,7 @@ CheckUnattendedSetup(
}
Quit:
- SetupCloseInfFile(UnattendInf);
+ SpInfCloseInfFile(UnattendInf);
}
VOID
@@ -505,7 +504,7 @@ LoadSetupInf(
INFCONTEXT Context;
UINT ErrorLine;
INT IntValue;
- PWCHAR Value;
+ PCWSTR Value;
WCHAR FileNameBuffer[MAX_PATH];
CombinePaths(FileNameBuffer, ARRAYSIZE(FileNameBuffer), 2,
@@ -514,17 +513,16 @@ LoadSetupInf(
DPRINT("SetupInf path: '%S'\n", FileNameBuffer);
pSetupData->SetupInf =
- SetupOpenInfFileExW(FileNameBuffer,
- NULL,
- /* INF_STYLE_WIN4 | */ INF_STYLE_OLDNT,
- pSetupData->LanguageId,
- &ErrorLine);
-
+ SpInfOpenInfFile(FileNameBuffer,
+ NULL,
+ /* INF_STYLE_WIN4 | */ INF_STYLE_OLDNT,
+ pSetupData->LanguageId,
+ &ErrorLine);
if (pSetupData->SetupInf == INVALID_HANDLE_VALUE)
return ERROR_LOAD_TXTSETUPSIF;
/* Open 'Version' section */
- if (!SetupFindFirstLineW(pSetupData->SetupInf, L"Version",
L"Signature", &Context))
+ if (!SpInfFindFirstLine(pSetupData->SetupInf, L"Version",
L"Signature", &Context))
return ERROR_CORRUPT_TXTSETUPSIF;
/* Get pointer 'Signature' key */
@@ -541,13 +539,13 @@ LoadSetupInf(
INF_FreeData(Value);
/* Open 'DiskSpaceRequirements' section */
- if (!SetupFindFirstLineW(pSetupData->SetupInf, L"DiskSpaceRequirements",
L"FreeSysPartDiskSpace", &Context))
+ if (!SpInfFindFirstLine(pSetupData->SetupInf, L"DiskSpaceRequirements",
L"FreeSysPartDiskSpace", &Context))
return ERROR_CORRUPT_TXTSETUPSIF;
pSetupData->RequiredPartitionDiskSpace = ~0;
/* Get the 'FreeSysPartDiskSpace' value */
- if (!SetupGetIntField(&Context, 1, &IntValue))
+ if (!SpInfGetIntField(&Context, 1, &IntValue))
return ERROR_CORRUPT_TXTSETUPSIF;
pSetupData->RequiredPartitionDiskSpace = (ULONG)IntValue;
@@ -559,7 +557,7 @@ LoadSetupInf(
//
/* Update the Setup Source paths */
- if (SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData",
L"SetupSourceDevice", &Context))
+ if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData",
L"SetupSourceDevice", &Context))
{
/*
* Get optional pointer 'SetupSourceDevice' key, its presence
@@ -572,7 +570,7 @@ LoadSetupInf(
RtlCreateUnicodeString(&pSetupData->SourceRootPath, Value);
INF_FreeData(Value);
- if (!SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData",
L"SetupSourcePath", &Context))
+ if (!SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData",
L"SetupSourcePath", &Context))
{
/* The 'SetupSourcePath' value is mandatory! */
return ERROR_CORRUPT_TXTSETUPSIF;
@@ -594,7 +592,7 @@ LoadSetupInf(
/* Search for 'DefaultPath' in the 'SetupData' section */
pSetupData->InstallationDirectory[0] = 0;
- if (SetupFindFirstLineW(pSetupData->SetupInf, L"SetupData",
L"DefaultPath", &Context))
+ if (SpInfFindFirstLine(pSetupData->SetupInf, L"SetupData",
L"DefaultPath", &Context))
{
/* Get pointer 'DefaultPath' key */
if (!INF_GetData(&Context, NULL, &Value))
@@ -632,6 +630,10 @@ InitDestinationPaths(
RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer);
DPRINT("DestinationRootPath: %wZ\n",
&pSetupData->DestinationRootPath);
+ // FIXME! Which variable to choose?
+ if (!InstallationDir)
+ InstallationDir = pSetupData->InstallationDirectory;
+
/** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
/* Create 'pSetupData->DestinationArcPath' */
RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
@@ -776,7 +778,7 @@ FinishSetup(
}
/* Close the Setup INF */
- SetupCloseInfFile(pSetupData->SetupInf);
+ SpInfCloseInfFile(pSetupData->SetupInf);
}
/*
@@ -802,9 +804,9 @@ UpdateRegistry(
ERROR_NUMBER ErrorNumber;
NTSTATUS Status;
INFCONTEXT InfContext;
- PWSTR Action;
- PWSTR File;
- PWSTR Section;
+ PCWSTR Action;
+ PCWSTR File;
+ PCWSTR Section;
BOOLEAN Success;
BOOLEAN ShouldRepairRegistry = FALSE;
BOOLEAN Delete;
@@ -858,13 +860,13 @@ DoUpdate:
* "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
*/
- Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Fresh", NULL,
&InfContext); // Windows-compatible
+ Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Fresh", NULL,
&InfContext); // Windows-compatible
if (!Success)
- Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Install", NULL,
&InfContext); // ReactOS-specific
+ Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Install", NULL,
&InfContext); // ReactOS-specific
if (!Success)
{
- DPRINT1("SetupFindFirstLine() failed\n");
+ DPRINT1("SpInfFindFirstLine() failed\n");
ErrorNumber = ERROR_FIND_REGISTRY;
goto Cleanup;
}
@@ -877,7 +879,7 @@ DoUpdate:
* we only update the hives.
*/
- Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Upgrade", NULL,
&InfContext);
+ Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Upgrade", NULL,
&InfContext);
if (!Success)
{
/* Nothing to do for update! */
@@ -929,7 +931,7 @@ DoUpdate:
ErrorNumber = ERROR_IMPORT_HIVE;
goto Cleanup;
}
- } while (SetupFindNextLine(&InfContext, &InfContext));
+ } while (SpInfFindNextLine(&InfContext, &InfContext));
if (!RepairUpdateFlag || ShouldRepairRegistry)
{
diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h
index a885d6d09d..0686b00d58 100644
--- a/base/setup/lib/setuplib.h
+++ b/base/setup/lib/setuplib.h
@@ -25,6 +25,8 @@
extern HANDLE ProcessHeap;
#include "errorcode.h"
+#include "spapisup/fileqsup.h"
+#include "spapisup/infsupp.h"
#include "utils/linklist.h"
#include "utils/ntverrsrc.h"
// #include "utils/arcname.h"
@@ -33,7 +35,6 @@ extern HANDLE ProcessHeap;
#include "utils/filesup.h"
#include "fsutil.h"
#include "utils/genlist.h"
-#include "utils/infsupp.h"
#include "utils/inicache.h"
#include "utils/partlist.h"
#include "utils/arcname.h"
diff --git a/base/setup/lib/spapisup/fileqsup.c b/base/setup/lib/spapisup/fileqsup.c
new file mode 100644
index 0000000000..34da6a4580
--- /dev/null
+++ b/base/setup/lib/spapisup/fileqsup.c
@@ -0,0 +1,34 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Setup Library
+ * FILE: base/setup/lib/fileqsup.c
+ * PURPOSE: Interfacing with Setup* API File Queue support functions
+ * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "precomp.h"
+#include "fileqsup.h"
+
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS *******************************************************************/
+
+/*
+ * These externs should be defined by the user of this library.
+ * They are kept there for reference and ease of usage.
+ */
+#if 0
+
+pSpFileQueueOpen SpFileQueueOpen = NULL;
+pSpFileQueueClose SpFileQueueClose = NULL;
+pSpFileQueueCopy SpFileQueueCopy = NULL;
+pSpFileQueueDelete SpFileQueueDelete = NULL;
+pSpFileQueueRename SpFileQueueRename = NULL;
+pSpFileQueueCommit SpFileQueueCommit = NULL;
+
+#endif
+
+/* EOF */
diff --git a/base/setup/usetup/filequeue.h b/base/setup/lib/spapisup/fileqsup.h
similarity index 58%
rename from base/setup/usetup/filequeue.h
rename to base/setup/lib/spapisup/fileqsup.h
index cf608377e1..c6cc3839c1 100644
--- a/base/setup/usetup/filequeue.h
+++ b/base/setup/lib/spapisup/fileqsup.h
@@ -1,31 +1,24 @@
-/*
- * ReactOS kernel
- * Copyright (C) 2002 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/filequeue.h
- * PURPOSE: File queue functions
- * PROGRAMMER:
+ * PROJECT: ReactOS Setup Library
+ * FILE: base/setup/lib/fileqsup.h
+ * PURPOSE: Interfacing with Setup* API File Queue support functions
+ * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
#pragma once
+#include "spapisup.h"
+
+// FIXME: Temporary measure until all the users of this header
+// (usetup...) use or define SetupAPI-conforming APIs.
+#if defined(_SETUPAPI_H_) || defined(_INC_SETUPAPI)
+
+#include <setupapi.h>
+
+#else
+
#define SPFILENOTIFY_STARTQUEUE 0x00000001
#define SPFILENOTIFY_ENDQUEUE 0x00000002
#define SPFILENOTIFY_STARTSUBQUEUE 0x00000003
@@ -76,67 +69,68 @@ typedef UINT (CALLBACK* PSP_FILE_CALLBACK_W)(
IN UINT_PTR Param1,
IN UINT_PTR Param2);
+#endif
+
/* FUNCTIONS ****************************************************************/
-HSPFILEQ
-WINAPI
-SetupOpenFileQueue(VOID);
+// #define SetupOpenFileQueue
+typedef HSPFILEQ
+(WINAPI* pSpFileQueueOpen)(VOID);
+
+extern pSpFileQueueOpen SpFileQueueOpen;
-VOID
-WINAPI
-SetupCloseFileQueue(
+// #define SetupCloseFileQueue
+typedef BOOL
+(WINAPI* pSpFileQueueClose)(
IN HSPFILEQ QueueHandle);
-#if 0 // This is the API that is declared in setupapi.h and exported by setupapi.dll
-BOOL
-WINAPI
-SetupQueueCopyWNew(
- IN HSPFILEQ QueueHandle,
- IN PCWSTR SourceRootPath,
- IN PCWSTR SourcePath,
- IN PCWSTR SourceFileName,
- IN PCWSTR SourceDescription,
- IN PCWSTR SourceTagFile,
- IN PCWSTR TargetDirectory,
- IN PCWSTR TargetFileName,
- IN DWORD CopyStyle);
-#endif
+extern pSpFileQueueClose SpFileQueueClose;
-/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */
-BOOL
-WINAPI
-SetupQueueCopyWithCab( // SetupQueueCopyW
+// #define SetupQueueCopyW
+typedef BOOL
+(WINAPI* pSpFileQueueCopy)(
IN HSPFILEQ QueueHandle,
- IN PCWSTR SourceCabinet OPTIONAL,
IN PCWSTR SourceRootPath,
IN PCWSTR SourcePath OPTIONAL,
IN PCWSTR SourceFileName,
+ IN PCWSTR SourceDescription OPTIONAL,
+ IN PCWSTR SourceCabinet OPTIONAL,
+ IN PCWSTR SourceTagFile OPTIONAL,
IN PCWSTR TargetDirectory,
- IN PCWSTR TargetFileName OPTIONAL);
+ IN PCWSTR TargetFileName OPTIONAL,
+ IN ULONG CopyStyle);
+
+extern pSpFileQueueCopy SpFileQueueCopy;
-BOOL
-WINAPI
-SetupQueueDeleteW(
+// #define SetupQueueDeleteW
+typedef BOOL
+(WINAPI* pSpFileQueueDelete)(
IN HSPFILEQ QueueHandle,
IN PCWSTR PathPart1,
IN PCWSTR PathPart2 OPTIONAL);
-BOOL
-WINAPI
-SetupQueueRenameW(
+extern pSpFileQueueDelete SpFileQueueDelete;
+
+// #define SetupQueueRenameW
+typedef BOOL
+(WINAPI* pSpFileQueueRename)(
IN HSPFILEQ QueueHandle,
IN PCWSTR SourcePath,
IN PCWSTR SourceFileName OPTIONAL,
IN PCWSTR TargetPath OPTIONAL,
IN PCWSTR TargetFileName);
-BOOL
-WINAPI
-SetupCommitFileQueueW(
+extern pSpFileQueueRename SpFileQueueRename;
+
+// #define SetupCommitFileQueueW
+typedef BOOL
+(WINAPI* pSpFileQueueCommit)(
IN HWND Owner,
IN HSPFILEQ QueueHandle,
IN PSP_FILE_CALLBACK_W MsgHandler,
IN PVOID Context OPTIONAL);
+extern pSpFileQueueCommit SpFileQueueCommit;
+
/* EOF */
diff --git a/base/setup/lib/utils/infsupp.c b/base/setup/lib/spapisup/infsupp.c
similarity index 53%
rename from base/setup/lib/utils/infsupp.c
rename to base/setup/lib/spapisup/infsupp.c
index 265585712e..65bdbd23e6 100644
--- a/base/setup/lib/utils/infsupp.c
+++ b/base/setup/lib/spapisup/infsupp.c
@@ -2,7 +2,7 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Setup Library
* FILE: base/setup/lib/infsupp.c
- * PURPOSE: Interfacing with Setup* API .inf files support functions
+ * PURPOSE: Interfacing with Setup* API .INF Files support functions
* PROGRAMMERS: Hervé Poussineau
* Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
@@ -15,13 +15,34 @@
#define NDEBUG
#include <debug.h>
+/* GLOBALS *******************************************************************/
+
+/*
+ * These externs should be defined by the user of this library.
+ * They are kept there for reference and ease of usage.
+ */
+#if 0
+
+pSpInfCloseInfFile SpInfCloseInfFile = NULL;
+pSpInfFindFirstLine SpInfFindFirstLine = NULL;
+pSpInfFindNextLine SpInfFindNextLine = NULL;
+pSpInfGetFieldCount SpInfGetFieldCount = NULL;
+pSpInfGetBinaryField SpInfGetBinaryField = NULL;
+pSpInfGetIntField SpInfGetIntField = NULL;
+pSpInfGetMultiSzField SpInfGetMultiSzField = NULL;
+pSpInfGetStringField SpInfGetStringField = NULL;
+pSpInfGetField SpInfGetField = NULL;
+pSpInfOpenInfFile SpInfOpenInfFile = NULL;
+
+#endif
+
/* HELPER FUNCTIONS **********************************************************/
BOOLEAN
INF_GetDataField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
- OUT PWCHAR *Data)
+ OUT PCWSTR* Data)
{
#if 0
@@ -31,11 +52,11 @@ INF_GetDataField(
*Data = NULL;
- Success = SetupGetStringFieldW(Context,
- FieldIndex,
- NULL,
- 0,
- &dwSize);
+ Success = SpInfGetStringField(Context,
+ FieldIndex,
+ NULL,
+ 0,
+ &dwSize);
if (!Success)
return FALSE;
@@ -43,11 +64,11 @@ INF_GetDataField(
if (!InfData)
return FALSE;
- Success = SetupGetStringFieldW(Context,
- FieldIndex,
- InfData,
- dwSize,
- NULL);
+ Success = SpInfGetStringField(Context,
+ FieldIndex,
+ InfData,
+ dwSize,
+ NULL);
if (!Success)
{
RtlFreeHeap(ProcessHeap, 0, InfData);
@@ -59,7 +80,7 @@ INF_GetDataField(
#else
- *Data = (PWCHAR)pSetupGetField(Context, FieldIndex);
+ *Data = SpInfGetField(Context, FieldIndex);
return !!*Data;
#endif
@@ -68,11 +89,11 @@ INF_GetDataField(
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,
- OUT PWCHAR *Key,
- OUT PWCHAR *Data)
+ OUT PCWSTR* Key,
+ OUT PCWSTR* Data)
{
BOOL Success;
- PWCHAR InfData[2] = {NULL, NULL};
+ PCWSTR InfData[2] = {NULL, NULL};
if (Key)
*Key = NULL;
@@ -82,11 +103,11 @@ INF_GetData(
/*
* Verify that the INF file has only one value field, in addition to its key name.
- * Note that SetupGetFieldCount() does not count the key name as a field.
+ * Note that SpInfGetFieldCount() does not count the key name as a field.
*/
- if (SetupGetFieldCount(Context) != 1)
+ if (SpInfGetFieldCount(Context) != 1)
{
- DPRINT1("SetupGetFieldCount != 1\n");
+ DPRINT1("SpInfGetFieldCount != 1\n");
return FALSE;
}
diff --git a/base/setup/lib/utils/infsupp.h b/base/setup/lib/spapisup/infsupp.h
similarity index 53%
rename from base/setup/lib/utils/infsupp.h
rename to base/setup/lib/spapisup/infsupp.h
index db6043c03f..c5d24ca6b7 100644
--- a/base/setup/lib/utils/infsupp.h
+++ b/base/setup/lib/spapisup/infsupp.h
@@ -2,16 +2,13 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Setup Library
* FILE: base/setup/lib/infsupp.h
- * PURPOSE: Interfacing with Setup* API .inf files support functions
- * PROGRAMMER: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
+ * PURPOSE: Interfacing with Setup* API .INF Files support functions
+ * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
#pragma once
-/* Make setupapi.h to not define the API as exports to the DLL */
-#ifdef __REACTOS__
-#define _SETUPAPI_
-#endif
+#include "spapisup.h"
// FIXME: Temporary measure until all the users of this header
// (usetup...) use or define SetupAPI-conforming APIs.
@@ -30,65 +27,6 @@ typedef struct _INFCONTEXT
UINT Line;
} INFCONTEXT, *PINFCONTEXT;
-// #define SetupCloseInfFile InfCloseFile
-VOID
-WINAPI
-SetupCloseInfFile(HINF InfHandle);
-
-// #define SetupFindFirstLineW InfpFindFirstLineW
-BOOL
-WINAPI
-SetupFindFirstLineW(
- IN HINF InfHandle,
- IN PCWSTR Section,
- IN PCWSTR Key,
- IN OUT PINFCONTEXT Context);
-
-// #define SetupFindNextLine InfFindNextLine
-BOOL
-WINAPI
-SetupFindNextLine(PINFCONTEXT ContextIn,
- PINFCONTEXT ContextOut);
-
-// #define SetupGetFieldCount InfGetFieldCount
-LONG
-WINAPI
-SetupGetFieldCount(PINFCONTEXT Context);
-
-// #define SetupGetBinaryField InfGetBinaryField
-BOOL
-WINAPI
-SetupGetBinaryField(PINFCONTEXT Context,
- ULONG FieldIndex,
- PUCHAR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize);
-
-// #define SetupGetIntField InfGetIntField
-BOOL
-WINAPI
-SetupGetIntField(PINFCONTEXT Context,
- ULONG FieldIndex,
- INT *IntegerValue); // PINT
-
-// #define SetupGetMultiSzFieldW InfGetMultiSzField
-BOOL
-WINAPI
-SetupGetMultiSzFieldW(PINFCONTEXT Context,
- ULONG FieldIndex,
- PWSTR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize);
-
-// #define SetupGetStringFieldW InfGetStringField
-BOOL
-WINAPI
-SetupGetStringFieldW(PINFCONTEXT Context,
- ULONG FieldIndex,
- PWSTR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize);
-
#endif
/* Lower the MAX_INF_STRING_LENGTH value in order to avoid too much stack usage */
@@ -117,33 +55,107 @@ typedef struct _INFCONTEXT
C_ASSERT(sizeof(INFCONTEXT) == 2 * sizeof(HINF) + 2 * sizeof(UINT));
-/*
- * This function corresponds to an undocumented but exported SetupAPI function
- * that exists since WinNT4 and is still present in Win10.
- * The returned string pointer is a read-only pointer to a string in the
- * maintained INF cache, and is always in UNICODE (on NT systems).
- */
-PCWSTR
-WINAPI
-pSetupGetField(PINFCONTEXT Context,
- ULONG FieldIndex);
+// #define SetupCloseInfFile InfCloseFile
+typedef VOID
+(WINAPI* pSpInfCloseInfFile)(
+ IN HINF InfHandle);
+
+extern pSpInfCloseInfFile SpInfCloseInfFile;
+
+// #define SetupFindFirstLineW InfpFindFirstLineW
+typedef BOOL
+(WINAPI* pSpInfFindFirstLine)(
+ IN HINF InfHandle,
+ IN PCWSTR Section,
+ IN PCWSTR Key,
+ IN OUT PINFCONTEXT Context);
+
+extern pSpInfFindFirstLine SpInfFindFirstLine;
+
+// #define SetupFindNextLine InfFindNextLine
+typedef BOOL
+(WINAPI* pSpInfFindNextLine)(
+ IN PINFCONTEXT ContextIn,
+ OUT PINFCONTEXT ContextOut);
+
+extern pSpInfFindNextLine SpInfFindNextLine;
+
+// #define SetupGetFieldCount InfGetFieldCount
+typedef ULONG
+(WINAPI* pSpInfGetFieldCount)(
+ IN PINFCONTEXT Context);
+
+extern pSpInfGetFieldCount SpInfGetFieldCount;
+
+// #define SetupGetBinaryField InfGetBinaryField
+typedef BOOL
+(WINAPI* pSpInfGetBinaryField)(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PUCHAR ReturnBuffer,
+ IN ULONG ReturnBufferSize,
+ OUT PULONG RequiredSize);
+
+extern pSpInfGetBinaryField SpInfGetBinaryField;
+
+// #define SetupGetIntField InfGetIntField
+typedef BOOL
+(WINAPI* pSpInfGetIntField)(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT INT *IntegerValue); // PINT
+
+extern pSpInfGetIntField SpInfGetIntField;
+
+// #define SetupGetMultiSzFieldW InfGetMultiSzField
+typedef BOOL
+(WINAPI* pSpInfGetMultiSzField)(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PWSTR ReturnBuffer,
+ IN ULONG ReturnBufferSize,
+ OUT PULONG RequiredSize);
+
+extern pSpInfGetMultiSzField SpInfGetMultiSzField;
+
+// #define SetupGetStringFieldW InfGetStringField
+typedef BOOL
+(WINAPI* pSpInfGetStringField)(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PWSTR ReturnBuffer,
+ IN ULONG ReturnBufferSize,
+ OUT PULONG RequiredSize);
+
+extern pSpInfGetStringField SpInfGetStringField;
+
+// #define pSetupGetField
+typedef PCWSTR
+(WINAPI* pSpInfGetField)(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex);
+
+extern pSpInfGetField SpInfGetField;
/* A version of SetupOpenInfFileW with support for a user-provided LCID */
// #define SetupOpenInfFileExW InfpOpenInfFileW
-HINF
-WINAPI
-SetupOpenInfFileExW(
+typedef HINF
+(WINAPI* pSpInfOpenInfFile)(
IN PCWSTR FileName,
IN PCWSTR InfClass,
IN DWORD InfStyle,
IN LCID LocaleId,
OUT PUINT ErrorLine);
+extern pSpInfOpenInfFile SpInfOpenInfFile;
+
/* HELPER FUNCTIONS **********************************************************/
-FORCEINLINE VOID
-INF_FreeData(IN PWCHAR InfData)
+FORCEINLINE
+VOID
+INF_FreeData(
+ IN PCWSTR InfData)
{
#if 0
if (InfData)
@@ -157,12 +169,12 @@ BOOLEAN
INF_GetDataField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
- OUT PWCHAR *Data);
+ OUT PCWSTR* Data);
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,
- OUT PWCHAR *Key,
- OUT PWCHAR *Data);
+ OUT PCWSTR* Key,
+ OUT PCWSTR* Data);
/* EOF */
diff --git a/base/setup/lib/spapisup/spapisup.h b/base/setup/lib/spapisup/spapisup.h
new file mode 100644
index 0000000000..7733b78473
--- /dev/null
+++ b/base/setup/lib/spapisup/spapisup.h
@@ -0,0 +1,29 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Setup Library
+ * FILE: base/setup/lib/spapisup.h
+ * PURPOSE: Interfacing with Setup* API support functions
+ * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
+ */
+
+#pragma once
+
+/* Make setupapi.h to not define the API as exports to the DLL */
+#ifdef __REACTOS__
+#define _SETUPAPI_
+#endif
+
+/* Architecture names to be used for architecture-specific INF sections */
+#ifdef _M_IX86
+#define INF_ARCH L"x86"
+#elif defined(_M_AMD64)
+#define INF_ARCH L"amd64"
+#elif defined(_M_IA64)
+#define INF_ARCH L"ia64"
+#elif defined(_M_ARM)
+#define INF_ARCH L"arm"
+#elif defined(_M_PPC)
+#define INF_ARCH L"ppc"
+#endif
+
+/* EOF */
diff --git a/base/setup/reactos/CMakeLists.txt b/base/setup/reactos/CMakeLists.txt
index 0f08c1f252..39225e758e 100644
--- a/base/setup/reactos/CMakeLists.txt
+++ b/base/setup/reactos/CMakeLists.txt
@@ -7,8 +7,9 @@ include_directories(
${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers)
list(APPEND SOURCE
+ spapisup/fileqsup.c
+ spapisup/infsupp.c
drivepage.c
- inffile.c
reactos.c
reactos.h)
diff --git a/base/setup/reactos/spapisup/fileqsup.c
b/base/setup/reactos/spapisup/fileqsup.c
new file mode 100644
index 0000000000..ad31c38ee1
--- /dev/null
+++ b/base/setup/reactos/spapisup/fileqsup.c
@@ -0,0 +1,155 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS GUI first stage setup application
+ * FILE: base/setup/lib/fileqsup.c
+ * PURPOSE: Interfacing with Setup* API File Queue support functions
+ * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include "precomp.h"
+
+#define NDEBUG
+#include <debug.h>
+
+/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
+
+/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */
+BOOL
+WINAPI
+SpFileQueueCopy_NtToWin32(
+ IN HSPFILEQ QueueHandle,
+ IN PCWSTR SourceRootPath,
+ IN PCWSTR SourcePath OPTIONAL,
+ IN PCWSTR SourceFileName,
+ IN PCWSTR SourceDescription OPTIONAL,
+ IN PCWSTR SourceCabinet OPTIONAL,
+ IN PCWSTR SourceTagFile OPTIONAL,
+ IN PCWSTR TargetDirectory,
+ IN PCWSTR TargetFileName OPTIONAL,
+ IN ULONG CopyStyle)
+{
+ WCHAR Win32SourceRootPath[MAX_PATH];
+ WCHAR Win32TargetDirectory[MAX_PATH];
+
+ /*
+ * SpFileQueueCopy is called within setuplib with NT paths, however
+ * the Win32 SetupQueueCopyW API only takes Win32 paths. We therefore
+ * map the NT path to Win32 path and then call the Win32 API.
+ */
+ if (!ConvertNtPathToWin32Path(Win32SourceRootPath,
+ _countof(Win32SourceRootPath),
+ SourceRootPath))
+ {
+ return FALSE;
+ }
+ /* SourcePath, SourceFileName and SourceCabinet are appended to SourceRootPath by the
SetupApi function */
+
+ if (!ConvertNtPathToWin32Path(Win32TargetDirectory,
+ _countof(Win32TargetDirectory),
+ TargetDirectory))
+ {
+ return FALSE;
+ }
+ /* TargetFileName is appended to TargetDirectory by the SetupApi function */
+
+ /*
+ * Use the undocumented way of copying files from within a given cabinet file
+ * *ONLY IF* the files do not already exist in the same directory where
+ * the cabinet file resides!!
+ */
+ return SetupQueueCopyW(QueueHandle,
+ Win32SourceRootPath,
+ SourcePath,
+ SourceFileName,
+ // Undocumented on MSDN is the fact that this parameter is mandatory *IF* one wants
to take the TagFile into account!
+ L"foobar",
+ // SourceTagFile -- Special behaviour: use cabinet file present in ArchiveDir path!
The API does not check for a ".cab" extension.
+ SourceCabinet,
+ Win32TargetDirectory,
+ TargetFileName,
+ // We choose to decompress the archive, so do NOT specify SP_COPY_NODECOMP !
+ SP_COPY_NOOVERWRITE /* | SP_COPY_SOURCE_ABSOLUTE |
SP_COPY_SOURCEPATH_ABSOLUTE */
+ );
+}
+
+BOOL
+WINAPI
+SpFileQueueDelete_NtToWin32(
+ IN HSPFILEQ QueueHandle,
+ IN PCWSTR PathPart1,
+ IN PCWSTR PathPart2 OPTIONAL)
+{
+ WCHAR Win32PathPart1[MAX_PATH];
+
+ /*
+ * SpFileQueueDelete is called within setuplib with NT paths, however
+ * the Win32 SetupQueueDeleteW API only takes Win32 paths. We therefore
+ * map the NT path to Win32 path and then call the Win32 API.
+ */
+ if (!ConvertNtPathToWin32Path(Win32PathPart1,
+ _countof(Win32PathPart1),
+ PathPart1))
+ {
+ return FALSE;
+ }
+ /* PathPart2 is appended to PathPart1 by the SetupApi function */
+
+ return SetupQueueDeleteW(QueueHandle, Win32PathPart1, PathPart2);
+}
+
+BOOL
+WINAPI
+SpFileQueueRename_NtToWin32(
+ IN HSPFILEQ QueueHandle,
+ IN PCWSTR SourcePath,
+ IN PCWSTR SourceFileName OPTIONAL,
+ IN PCWSTR TargetPath OPTIONAL,
+ IN PCWSTR TargetFileName)
+{
+ WCHAR Win32SourcePath[MAX_PATH];
+ WCHAR Win32TargetPath[MAX_PATH];
+
+ /*
+ * SpFileQueueRename is called within setuplib with NT paths, however
+ * the Win32 SetupQueueRenameW API only takes Win32 paths. We therefore
+ * map the NT path to Win32 path and then call the Win32 API.
+ */
+ if (!ConvertNtPathToWin32Path(Win32SourcePath,
+ _countof(Win32SourcePath),
+ SourcePath))
+ {
+ return FALSE;
+ }
+ /* SourceFileName is appended to SourcePath by the SetupApi function */
+
+ if (TargetPath)
+ {
+ if (!ConvertNtPathToWin32Path(Win32TargetPath,
+ _countof(Win32TargetPath),
+ TargetPath))
+ {
+ return FALSE;
+ }
+ }
+ /* TargetFileName is appended to TargetPath by the SetupApi function */
+
+ return SetupQueueRenameW(QueueHandle,
+ Win32SourcePath,
+ SourceFileName,
+ TargetPath ? Win32TargetPath : NULL,
+ TargetFileName);
+}
+
+
+/* GLOBALS *******************************************************************/
+
+pSpFileQueueOpen SpFileQueueOpen = SetupOpenFileQueue;
+pSpFileQueueClose SpFileQueueClose = SetupCloseFileQueue;
+pSpFileQueueCopy SpFileQueueCopy = SpFileQueueCopy_NtToWin32;
+pSpFileQueueDelete SpFileQueueDelete = SpFileQueueDelete_NtToWin32;
+pSpFileQueueRename SpFileQueueRename = SpFileQueueRename_NtToWin32;
+pSpFileQueueCommit SpFileQueueCommit = SetupCommitFileQueueW;
+
+/* EOF */
diff --git a/base/setup/reactos/inffile.c b/base/setup/reactos/spapisup/infsupp.c
similarity index 61%
rename from base/setup/reactos/inffile.c
rename to base/setup/reactos/spapisup/infsupp.c
index db25b07b08..c95aad8e6e 100644
--- a/base/setup/reactos/inffile.c
+++ b/base/setup/reactos/spapisup/infsupp.c
@@ -1,9 +1,9 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/inffile.c
- * PURPOSE: .inf files support functions
- * PROGRAMMERS: Herv� Poussineau
+ * PROJECT: ReactOS GUI first stage setup application
+ * FILE: base/setup/lib/infsupp.c
+ * PURPOSE: Interfacing with Setup* API .INF Files support functions
+ * PROGRAMMERS: Hervé Poussineau
* Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
@@ -16,7 +16,17 @@
/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
-/* Functions from the INFLIB library */
+/*
+ * This function corresponds to an undocumented but exported SetupAPI function
+ * that exists since WinNT4 and is still present in Win10.
+ * The returned string pointer is a read-only pointer to a string in the
+ * maintained INF cache, and is always in UNICODE (on NT systems).
+ */
+PCWSTR
+WINAPI
+pSetupGetField(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex);
/* SetupOpenInfFileW with support for a user-provided LCID */
HINF
@@ -51,6 +61,20 @@ SetupOpenInfFileExW(
}
+/* GLOBALS *******************************************************************/
+
+pSpInfCloseInfFile SpInfCloseInfFile = SetupCloseInfFile;
+pSpInfFindFirstLine SpInfFindFirstLine = SetupFindFirstLineW;
+pSpInfFindNextLine SpInfFindNextLine = SetupFindNextLine;
+pSpInfGetFieldCount SpInfGetFieldCount = SetupGetFieldCount;
+pSpInfGetBinaryField SpInfGetBinaryField = SetupGetBinaryField;
+pSpInfGetIntField SpInfGetIntField = SetupGetIntField;
+pSpInfGetMultiSzField SpInfGetMultiSzField = SetupGetMultiSzFieldW;
+pSpInfGetStringField SpInfGetStringField = SetupGetStringFieldW;
+pSpInfGetField SpInfGetField = pSetupGetField;
+pSpInfOpenInfFile SpInfOpenInfFile = SetupOpenInfFileExW;
+
+
/* HELPER FUNCTIONS **********************************************************/
#if 0
diff --git a/base/setup/usetup/CMakeLists.txt b/base/setup/usetup/CMakeLists.txt
index 19314bfe7a..89891713ff 100644
--- a/base/setup/usetup/CMakeLists.txt
+++ b/base/setup/usetup/CMakeLists.txt
@@ -10,17 +10,17 @@ include_directories(
${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers)
list(APPEND SOURCE
- cabinet.c
+ spapisup/cabinet.c
+ spapisup/fileqsup.c
+ spapisup/infsupp.c
chkdsk.c
cmdcons.c
console.c
consup.c
devinst.c
- filequeue.c
format.c
fslist.c
genlist.c
- inffile.c
keytrans.c
mui.c
partlist.c
diff --git a/base/setup/usetup/devinst.c b/base/setup/usetup/devinst.c
index 15483a31d0..2c067d72a0 100644
--- a/base/setup/usetup/devinst.c
+++ b/base/setup/usetup/devinst.c
@@ -53,14 +53,15 @@ InstallDriver(
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE hService;
INFCONTEXT Context;
- PWSTR Driver, ClassGuid, ImagePath, FullImagePath;
+ PCWSTR Driver, ClassGuid, ImagePath;
+ PWSTR FullImagePath;
ULONG dwValue;
ULONG Disposition;
NTSTATUS Status;
BOOLEAN deviceInstalled = FALSE;
/* Check if we know the hardware */
- if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId,
&Context))
+ if (!SpInfFindFirstLine(hInf, L"HardwareIdsDatabase", HardwareId,
&Context))
return FALSE;
if (!INF_GetDataField(&Context, 1, &Driver))
return FALSE;
@@ -71,11 +72,11 @@ InstallDriver(
/* Find associated driver name */
/* FIXME: check in other sections too! */
- if (!SetupFindFirstLineW(hInf, L"BootBusExtenders.Load", Driver,
&Context)
- && !SetupFindFirstLineW(hInf, L"BusExtenders.Load", Driver,
&Context)
- && !SetupFindFirstLineW(hInf, L"SCSI.Load", Driver, &Context)
- && !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver,
&Context)
- && !SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver,
&Context))
+ if (!SpInfFindFirstLine(hInf, L"BootBusExtenders.Load", Driver,
&Context)
+ && !SpInfFindFirstLine(hInf, L"BusExtenders.Load", Driver,
&Context)
+ && !SpInfFindFirstLine(hInf, L"SCSI.Load", Driver, &Context)
+ && !SpInfFindFirstLine(hInf, L"InputDevicesSupport.Load", Driver,
&Context)
+ && !SpInfFindFirstLine(hInf, L"Keyboard.Load", Driver,
&Context))
{
INF_FreeData(ClassGuid);
INF_FreeData(Driver);
@@ -151,7 +152,7 @@ InstallDriver(
&ImagePathU,
0,
REG_SZ,
- ImagePath,
+ (PVOID)ImagePath,
(wcslen(ImagePath) + 1) * sizeof(WCHAR));
INF_FreeData(ImagePath);
@@ -174,7 +175,7 @@ InstallDriver(
&ServiceU,
0,
REG_SZ,
- Driver,
+ (PVOID)Driver,
(wcslen(Driver) + 1) * sizeof(WCHAR));
if (NT_SUCCESS(Status))
{
diff --git a/base/setup/usetup/cabinet.c b/base/setup/usetup/spapisup/cabinet.c
similarity index 100%
rename from base/setup/usetup/cabinet.c
rename to base/setup/usetup/spapisup/cabinet.c
diff --git a/base/setup/usetup/cabinet.h b/base/setup/usetup/spapisup/cabinet.h
similarity index 100%
rename from base/setup/usetup/cabinet.h
rename to base/setup/usetup/spapisup/cabinet.h
diff --git a/base/setup/usetup/filequeue.c b/base/setup/usetup/spapisup/fileqsup.c
similarity index 96%
rename from base/setup/usetup/filequeue.c
rename to base/setup/usetup/spapisup/fileqsup.c
index c50203c361..75f6b36d41 100644
--- a/base/setup/usetup/filequeue.c
+++ b/base/setup/usetup/spapisup/fileqsup.c
@@ -16,11 +16,13 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/* COPYRIGHT: See COPYING in the top level directory
+/*
+ * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/filequeue.c
- * PURPOSE: File queue functions
- * PROGRAMMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * FILE: base/setup/lib/fileqsup.c
+ * PURPOSE: Interfacing with Setup* API File Queue support functions
+ * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
/* INCLUDES *****************************************************************/
@@ -30,7 +32,7 @@
#define NDEBUG
#include <debug.h>
-/* INCLUDES *****************************************************************/
+/* DEFINITIONS **************************************************************/
typedef struct _QUEUEENTRY
{
@@ -210,7 +212,7 @@ SetupDeleteQueueEntry(
RtlFreeHeap(ProcessHeap, 0, Entry);
}
-VOID
+BOOL
WINAPI
SetupCloseFileQueue(
IN HSPFILEQ QueueHandle)
@@ -220,7 +222,7 @@ SetupCloseFileQueue(
PQUEUEENTRY Entry;
if (QueueHandle == NULL)
- return;
+ return FALSE;
QueueHeader = (PFILEQUEUEHEADER)QueueHandle;
@@ -250,19 +252,24 @@ SetupCloseFileQueue(
/* Delete queue header */
RtlFreeHeap(ProcessHeap, 0, QueueHeader);
+
+ return TRUE;
}
/* A simplified version of SetupQueueCopyW that wraps Cabinet support around */
BOOL
WINAPI
-SetupQueueCopyWithCab( // SetupQueueCopyW
+SetupQueueCopyWithCab(
IN HSPFILEQ QueueHandle,
- IN PCWSTR SourceCabinet OPTIONAL,
IN PCWSTR SourceRootPath,
IN PCWSTR SourcePath OPTIONAL,
IN PCWSTR SourceFileName,
+ IN PCWSTR SourceDescription OPTIONAL,
+ IN PCWSTR SourceCabinet OPTIONAL,
+ IN PCWSTR SourceTagFile OPTIONAL,
IN PCWSTR TargetDirectory,
- IN PCWSTR TargetFileName OPTIONAL)
+ IN PCWSTR TargetFileName OPTIONAL,
+ IN ULONG CopyStyle)
{
PFILEQUEUEHEADER QueueHeader;
PQUEUEENTRY Entry;
@@ -868,4 +875,14 @@ SetupCommitFileQueueW(
return Success;
}
+
+/* GLOBALS *******************************************************************/
+
+pSpFileQueueOpen SpFileQueueOpen = SetupOpenFileQueue;
+pSpFileQueueClose SpFileQueueClose = SetupCloseFileQueue;
+pSpFileQueueCopy SpFileQueueCopy = SetupQueueCopyWithCab;
+pSpFileQueueDelete SpFileQueueDelete = SetupQueueDeleteW;
+pSpFileQueueRename SpFileQueueRename = SetupQueueRenameW;
+pSpFileQueueCommit SpFileQueueCommit = SetupCommitFileQueueW;
+
/* EOF */
diff --git a/base/setup/usetup/inffile.h b/base/setup/usetup/spapisup/inffile.h
similarity index 86%
rename from base/setup/usetup/inffile.h
rename to base/setup/usetup/spapisup/inffile.h
index 9d33563a88..4ee020c7b9 100644
--- a/base/setup/usetup/inffile.h
+++ b/base/setup/usetup/spapisup/inffile.h
@@ -20,8 +20,8 @@
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/inffile.h
- * PURPOSE: .inf files support functions
- * PROGRAMMERS: Herv� Poussineau
+ * PURPOSE: Interfacing with Setup* API .INF Files support functions
+ * PROGRAMMERS: Hervé Poussineau
* Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
@@ -50,11 +50,11 @@ extern VOID InfSetHeap(PVOID Heap);
HINF WINAPI
INF_OpenBufferedFileA(
- IN PSTR FileBuffer,
- IN ULONG FileSize,
- IN PCSTR InfClass,
- IN DWORD InfStyle,
- IN LCID LocaleId,
+ IN PSTR FileBuffer,
+ IN ULONG FileSize,
+ IN PCSTR InfClass,
+ IN DWORD InfStyle,
+ IN LCID LocaleId,
OUT PUINT ErrorLine);
/* EOF */
diff --git a/base/setup/usetup/inffile.c b/base/setup/usetup/spapisup/infsupp.c
similarity index 74%
rename from base/setup/usetup/inffile.c
rename to base/setup/usetup/spapisup/infsupp.c
index 47edb34a58..af18c491c1 100644
--- a/base/setup/usetup/inffile.c
+++ b/base/setup/usetup/spapisup/infsupp.c
@@ -19,9 +19,9 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
- * FILE: base/setup/usetup/inffile.c
- * PURPOSE: .inf files support functions
- * PROGRAMMERS: Herv� Poussineau
+ * FILE: base/setup/lib/infsupp.c
+ * PURPOSE: Interfacing with Setup* API .INF Files support functions
+ * PROGRAMMERS: Hervé Poussineau
* Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
*/
@@ -40,7 +40,8 @@ extern VOID InfCloseFile(HINF InfHandle);
// #define SetupCloseInfFile InfCloseFile
VOID
WINAPI
-SetupCloseInfFile(HINF InfHandle)
+SetupCloseInfFile(
+ IN HINF InfHandle)
{
InfCloseFile(InfHandle);
}
@@ -71,23 +72,25 @@ extern BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn,
// #define SetupFindNextLine InfFindNextLine
BOOL
WINAPI
-SetupFindNextLine(PINFCONTEXT ContextIn,
- PINFCONTEXT ContextOut)
+SetupFindNextLine(
+ IN PINFCONTEXT ContextIn,
+ OUT PINFCONTEXT ContextOut)
{
return !!InfFindNextLine(ContextIn, ContextOut);
}
extern LONG InfGetFieldCount(PINFCONTEXT Context);
// #define SetupGetFieldCount InfGetFieldCount
-LONG
+ULONG
WINAPI
-SetupGetFieldCount(PINFCONTEXT Context)
+SetupGetFieldCount(
+ IN PINFCONTEXT Context)
{
- return InfGetFieldCount(Context);
+ return (ULONG)InfGetFieldCount(Context);
}
/*
- * This function corresponds to an undocumented but exported setupapi API
+ * This function corresponds to an undocumented but exported SetupAPI function
* that exists since WinNT4 and is still present in Win10.
* The returned string pointer is a read-only pointer to a string in the
* maintained INF cache, and is always in UNICODE (on NT systems).
@@ -97,8 +100,9 @@ extern BOOLEAN InfGetDataField(PINFCONTEXT Context,
PWCHAR *Data);
PCWSTR
WINAPI
-pSetupGetField(PINFCONTEXT Context,
- ULONG FieldIndex)
+pSetupGetField(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex)
{
PWCHAR Data = NULL;
if (!InfGetDataField(Context, FieldIndex, &Data))
@@ -114,11 +118,12 @@ extern BOOLEAN InfGetBinaryField(PINFCONTEXT Context,
// #define SetupGetBinaryField InfGetBinaryField
BOOL
WINAPI
-SetupGetBinaryField(PINFCONTEXT Context,
- ULONG FieldIndex,
- PUCHAR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize)
+SetupGetBinaryField(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PUCHAR ReturnBuffer,
+ IN ULONG ReturnBufferSize,
+ OUT PULONG RequiredSize)
{
return !!InfGetBinaryField(Context,
FieldIndex,
@@ -133,9 +138,10 @@ extern BOOLEAN InfGetIntField(PINFCONTEXT Context,
// #define SetupGetIntField InfGetIntField
BOOL
WINAPI
-SetupGetIntField(PINFCONTEXT Context,
- ULONG FieldIndex,
- INT *IntegerValue) // PINT
+SetupGetIntField(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT INT *IntegerValue) // PINT
{
return !!InfGetIntField(Context, FieldIndex, IntegerValue);
}
@@ -148,11 +154,12 @@ extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context,
// #define SetupGetMultiSzFieldW InfGetMultiSzField
BOOL
WINAPI
-SetupGetMultiSzFieldW(PINFCONTEXT Context,
- ULONG FieldIndex,
- PWSTR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize)
+SetupGetMultiSzFieldW(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PWSTR ReturnBuffer,
+ IN ULONG ReturnBufferSize,
+ OUT PULONG RequiredSize)
{
return !!InfGetMultiSzField(Context,
FieldIndex,
@@ -169,11 +176,12 @@ extern BOOLEAN InfGetStringField(PINFCONTEXT Context,
// #define SetupGetStringFieldW InfGetStringField
BOOL
WINAPI
-SetupGetStringFieldW(PINFCONTEXT Context,
- ULONG FieldIndex,
- PWSTR ReturnBuffer,
- ULONG ReturnBufferSize,
- PULONG RequiredSize)
+SetupGetStringFieldW(
+ IN PINFCONTEXT Context,
+ IN ULONG FieldIndex,
+ OUT PWSTR ReturnBuffer,
+ IN ULONG ReturnBufferSize,
+ OUT PULONG RequiredSize)
{
return !!InfGetStringField(Context,
FieldIndex,
@@ -182,7 +190,6 @@ SetupGetStringFieldW(PINFCONTEXT Context,
RequiredSize);
}
-
/* SetupOpenInfFileW with support for a user-provided LCID */
// #define SetupOpenInfFileExW InfpOpenInfFileW
HINF
@@ -212,15 +219,29 @@ SetupOpenInfFileExW(
}
+/* GLOBALS *******************************************************************/
+
+pSpInfCloseInfFile SpInfCloseInfFile = SetupCloseInfFile;
+pSpInfFindFirstLine SpInfFindFirstLine = SetupFindFirstLineW;
+pSpInfFindNextLine SpInfFindNextLine = SetupFindNextLine;
+pSpInfGetFieldCount SpInfGetFieldCount = SetupGetFieldCount;
+pSpInfGetBinaryField SpInfGetBinaryField = SetupGetBinaryField;
+pSpInfGetIntField SpInfGetIntField = SetupGetIntField;
+pSpInfGetMultiSzField SpInfGetMultiSzField = SetupGetMultiSzFieldW;
+pSpInfGetStringField SpInfGetStringField = SetupGetStringFieldW;
+pSpInfGetField SpInfGetField = pSetupGetField;
+pSpInfOpenInfFile SpInfOpenInfFile = SetupOpenInfFileExW;
+
+
/* HELPER FUNCTIONS **********************************************************/
HINF WINAPI
INF_OpenBufferedFileA(
- IN PSTR FileBuffer,
- IN ULONG FileSize,
- IN PCSTR InfClass,
- IN DWORD InfStyle,
- IN LCID LocaleId,
+ IN PSTR FileBuffer,
+ IN ULONG FileSize,
+ IN PCSTR InfClass,
+ IN DWORD InfStyle,
+ IN LCID LocaleId,
OUT PUINT ErrorLine)
{
HINF hInf = NULL;
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index 929a4dca9a..7fe24fcf2d 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -71,8 +71,6 @@ static PGENERIC_LIST NtOsInstallsList = NULL;
// HACK: Temporary compatibility code.
#if 1
- #define SetupQueueCopy SetupQueueCopyWithCab
-
static CABINET_CONTEXT CabinetContext;
#define CabinetInitialize() (CabinetInitialize(&CabinetContext))
#define CabinetSetEventHandlers(a,b,c)
(CabinetSetEventHandlers(&CabinetContext,(a),(b),(c)))
@@ -3485,17 +3483,17 @@ InstallDirectoryPage(PINPUT_RECORD Ir)
static BOOLEAN
AddSectionToCopyQueueCab(HINF InfFile,
- PWCHAR SectionName,
- PWCHAR SourceCabinet,
+ PCWSTR SectionName,
+ PCWSTR SourceCabinet,
PCUNICODE_STRING DestinationPath,
PINPUT_RECORD Ir)
{
INFCONTEXT FilesContext;
INFCONTEXT DirContext;
- PWCHAR FileKeyName;
- PWCHAR FileKeyValue;
- PWCHAR DirKeyValue;
- PWCHAR TargetFileName;
+ PCWSTR FileKeyName;
+ PCWSTR FileKeyValue;
+ PCWSTR DirKeyValue;
+ PCWSTR TargetFileName;
WCHAR FileDstPath[MAX_PATH];
/*
@@ -3505,7 +3503,7 @@ AddSectionToCopyQueueCab(HINF InfFile,
*/
/* Search for the SectionName section */
- if (!SetupFindFirstLineW(InfFile, SectionName, NULL, &FilesContext))
+ if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &FilesContext))
{
MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, SectionName);
return FALSE;
@@ -3531,7 +3529,7 @@ AddSectionToCopyQueueCab(HINF InfFile,
DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n",
FileKeyName, FileKeyValue);
/* Lookup target directory */
- if (!SetupFindFirstLineW(InfFile, L"Directories", FileKeyValue,
&DirContext))
+ if (!SpInfFindFirstLine(InfFile, L"Directories", FileKeyValue,
&DirContext))
{
/* FIXME: Handle error! */
DPRINT1("SetupFindFirstLine() failed\n");
@@ -3557,7 +3555,7 @@ AddSectionToCopyQueueCab(HINF InfFile,
ULONG Length = wcslen(DirKeyValue);
if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\'))
Length--;
- DirKeyValue[Length] = UNICODE_NULL;
+ *((PWSTR)DirKeyValue + Length) = UNICODE_NULL;
}
/* Build the full target path */
@@ -3586,22 +3584,25 @@ AddSectionToCopyQueueCab(HINF InfFile,
}
#endif
- if (!SetupQueueCopy(USetupData.SetupFileQueue,
- SourceCabinet,
- USetupData.SourceRootPath.Buffer,
- USetupData.SourceRootDir.Buffer,
- FileKeyName,
- FileDstPath,
- TargetFileName))
+ if (!SpFileQueueCopy((HSPFILEQ)USetupData.SetupFileQueue,
+ USetupData.SourceRootPath.Buffer,
+ USetupData.SourceRootDir.Buffer,
+ FileKeyName,
+ NULL,
+ SourceCabinet,
+ NULL,
+ FileDstPath,
+ TargetFileName,
+ 0 /* FIXME */))
{
/* FIXME: Handle error! */
- DPRINT1("SetupQueueCopy() failed\n");
+ DPRINT1("SpFileQueueCopy() failed\n");
}
INF_FreeData(FileKeyName);
INF_FreeData(TargetFileName);
INF_FreeData(DirKeyValue);
- } while (SetupFindNextLine(&FilesContext, &FilesContext));
+ } while (SpInfFindNextLine(&FilesContext, &FilesContext));
return TRUE;
}
@@ -3609,17 +3610,17 @@ AddSectionToCopyQueueCab(HINF InfFile,
static BOOLEAN
AddSectionToCopyQueue(HINF InfFile,
- PWCHAR SectionName,
- PWCHAR SourceCabinet,
+ PCWSTR SectionName,
+ PCWSTR SourceCabinet,
PCUNICODE_STRING DestinationPath,
PINPUT_RECORD Ir)
{
INFCONTEXT FilesContext;
INFCONTEXT DirContext;
- PWCHAR FileKeyName;
- PWCHAR FileKeyValue;
- PWCHAR DirKeyValue;
- PWCHAR TargetFileName;
+ PCWSTR FileKeyName;
+ PCWSTR FileKeyValue;
+ PCWSTR DirKeyValue;
+ PCWSTR TargetFileName;
WCHAR CompleteOrigDirName[512]; // FIXME: MAX_PATH is not enough?
WCHAR FileDstPath[MAX_PATH];
@@ -3632,7 +3633,7 @@ AddSectionToCopyQueue(HINF InfFile,
*/
/* Search for the SectionName section */
- if (!SetupFindFirstLineW(InfFile, SectionName, NULL, &FilesContext))
+ if (!SpInfFindFirstLine(InfFile, SectionName, NULL, &FilesContext))
{
MUIDisplayError(ERROR_TXTSETUP_SECTION, Ir, POPUP_WAIT_ENTER, SectionName);
return FALSE;
@@ -3669,7 +3670,7 @@ AddSectionToCopyQueue(HINF InfFile,
DPRINT("FileKeyName: '%S' FileKeyValue: '%S'\n",
FileKeyName, FileKeyValue);
/* Lookup target directory */
- if (!SetupFindFirstLineW(InfFile, L"Directories", FileKeyValue,
&DirContext))
+ if (!SpInfFindFirstLine(InfFile, L"Directories", FileKeyValue,
&DirContext))
{
/* FIXME: Handle error! */
DPRINT1("SetupFindFirstLine() failed\n");
@@ -3726,7 +3727,7 @@ AddSectionToCopyQueue(HINF InfFile,
ULONG Length = wcslen(DirKeyValue);
if ((Length > 0) && (DirKeyValue[Length - 1] == L'\\'))
Length--;
- DirKeyValue[Length] = UNICODE_NULL;
+ *((PWSTR)DirKeyValue + Length) = UNICODE_NULL;
}
/* Build the full target path */
@@ -3755,22 +3756,25 @@ AddSectionToCopyQueue(HINF InfFile,
}
#endif
- if (!SetupQueueCopy(USetupData.SetupFileQueue,
- SourceCabinet,
- USetupData.SourceRootPath.Buffer,
- CompleteOrigDirName,
- FileKeyName,
- FileDstPath,
- TargetFileName))
+ if (!SpFileQueueCopy((HSPFILEQ)USetupData.SetupFileQueue,
+ USetupData.SourceRootPath.Buffer,
+ CompleteOrigDirName,
+ FileKeyName,
+ NULL,
+ SourceCabinet,
+ NULL,
+ FileDstPath,
+ TargetFileName,
+ 0 /* FIXME */))
{
/* FIXME: Handle error! */
- DPRINT1("SetupQueueCopy() failed\n");
+ DPRINT1("SpFileQueueCopy() failed\n");
}
INF_FreeData(FileKeyName);
INF_FreeData(TargetFileName);
INF_FreeData(DirKeyValue);
- } while (SetupFindNextLine(&FilesContext, &FilesContext));
+ } while (SpInfFindNextLine(&FilesContext, &FilesContext));
return TRUE;
}
@@ -3778,13 +3782,13 @@ AddSectionToCopyQueue(HINF InfFile,
static BOOLEAN
PrepareCopyPageInfFile(HINF InfFile,
- PWCHAR SourceCabinet,
+ PCWSTR SourceCabinet,
PINPUT_RECORD Ir)
{
NTSTATUS Status;
INFCONTEXT DirContext;
PWCHAR AdditionalSectionName = NULL;
- PWCHAR DirKeyValue;
+ PCWSTR DirKeyValue;
WCHAR PathBuffer[MAX_PATH];
/* Add common files */
@@ -3829,7 +3833,7 @@ PrepareCopyPageInfFile(HINF InfFile,
}
/* Search for the 'Directories' section */
- if (!SetupFindFirstLineW(InfFile, L"Directories", NULL, &DirContext))
+ if (!SpInfFindFirstLine(InfFile, L"Directories", NULL, &DirContext))
{
if (SourceCabinet)
MUIDisplayError(ERROR_CABINET_SECTION, Ir, POPUP_WAIT_ENTER,
L"Directories");
@@ -3898,7 +3902,7 @@ PrepareCopyPageInfFile(HINF InfFile,
}
INF_FreeData(DirKeyValue);
- } while (SetupFindNextLine(&DirContext, &DirContext));
+ } while (SpInfFindNextLine(&DirContext, &DirContext));
return TRUE;
}
@@ -3925,14 +3929,14 @@ PrepareCopyPage(PINPUT_RECORD Ir)
WCHAR PathBuffer[MAX_PATH];
INFCONTEXT CabinetsContext;
ULONG InfFileSize;
- PWCHAR KeyValue;
+ PCWSTR KeyValue;
UINT ErrorLine;
PVOID InfFileData;
MUIDisplayPage(PREPARE_COPY_PAGE);
/* Create the file queue */
- USetupData.SetupFileQueue = SetupOpenFileQueue();
+ USetupData.SetupFileQueue = SpFileQueueOpen();
if (USetupData.SetupFileQueue == NULL)
{
MUIDisplayError(ERROR_COPY_QUEUE, Ir, POPUP_WAIT_ENTER);
@@ -3946,7 +3950,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
}
/* Search for the 'Cabinets' section */
- if (!SetupFindFirstLineW(USetupData.SetupInf, L"Cabinets", NULL,
&CabinetsContext))
+ if (!SpInfFindFirstLine(USetupData.SetupInf, L"Cabinets", NULL,
&CabinetsContext))
{
return FILE_COPY_PAGE;
}
@@ -4005,7 +4009,7 @@ PrepareCopyPage(PINPUT_RECORD Ir)
/* FIXME: show an error dialog */
return QUIT_PAGE;
}
- } while (SetupFindNextLine(&CabinetsContext, &CabinetsContext));
+ } while (SpInfFindNextLine(&CabinetsContext, &CabinetsContext));
return FILE_COPY_PAGE;
}
@@ -4148,7 +4152,7 @@ FileCopyCallback(PVOID Context,
*
* SIDEEFFECTS
* Calls SetupCommitFileQueueW
- * Calls SetupCloseFileQueue
+ * Calls SpFileQueueClose
*
* RETURNS
* Number of the next page.
@@ -4210,13 +4214,13 @@ FileCopyPage(PINPUT_RECORD Ir)
"Free Memory");
/* Do the file copying */
- SetupCommitFileQueueW(NULL,
- USetupData.SetupFileQueue,
- FileCopyCallback,
- &CopyContext);
+ SpFileQueueCommit(NULL,
+ USetupData.SetupFileQueue,
+ FileCopyCallback,
+ &CopyContext);
/* If we get here, we're done, so cleanup the queue and progress bar */
- SetupCloseFileQueue(USetupData.SetupFileQueue);
+ SpFileQueueClose(USetupData.SetupFileQueue);
DestroyProgressBar(CopyContext.ProgressBar);
DestroyProgressBar(CopyContext.MemoryBars[0]);
DestroyProgressBar(CopyContext.MemoryBars[1]);
diff --git a/base/setup/usetup/usetup.h b/base/setup/usetup/usetup.h
index 39a5c6a168..ef2fc1e553 100644
--- a/base/setup/usetup/usetup.h
+++ b/base/setup/usetup/usetup.h
@@ -59,15 +59,16 @@
/* Internal Headers */
#include "consup.h"
-#include "inffile.h"
#include "progress.h"
-#include "filequeue.h"
#include "fslist.h"
#include "partlist.h"
-#include "cabinet.h"
#include "genlist.h"
#include "mui.h"
+#include "spapisup/inffile.h"
+#include "spapisup/cabinet.h"
+
+
extern HANDLE ProcessHeap;
extern BOOLEAN IsUnattendedSetup;
extern PCWSTR SelectedLanguageId;