reactos/base/setup/lib/infsupp.c
Hermès Bélusca-Maïto 60d9ea76d1
[USETUP][SETUPLIB] Split the registry helper code.
Split the registry helper code into registry utility functions
(create/mount/unmount/verify hives) and registry creation code
(the rest: initializing the system hives) and move it in the
setup library.

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

[USETUP][SETUPLIB] Improve how the Setup* INF APIs are interfaced in the code.

Define prototypes compatible (including their calling convention)
with the ones defined by setupapi (.h/.dll) so that it can be possible
to either use an internal implementation of these functions (via the
INFLIB library) as currently being done, or using imported setupapi
functions, as would be done by the future 1st-stage GUI installer.

[SETUPLIB] Cleanup the registry.c file and use the infsupp.h header.

svn path=/branches/setup_improvements/; revision=75345
svn path=/branches/setup_improvements/; revision=75346

[USETUP][SETUPLIB] Move some INF-related code from usetup to the setuplib.

- Move the generic INF_GetDataField() and INF_GetData() helpers to
  setuplib, and rework them a bit so that they explicitly call setupapi
  functions (or implementations thereof when being used in usetup);

- Rework the headers in accordance;
- Fix compilation in lib/registry.c .

- Fix compilation when these headers are used withing usetup (who
  doesn't use setupapi.dll) and "reactos" (the 1st-stage GUI installer
  that uses setupapi.dll).

svn path=/branches/setup_improvements/; revision=75515
svn path=/branches/setup_improvements/; revision=75537
svn path=/branches/setup_improvements/; revision=75538
2018-10-27 03:16:47 +02:00

119 lines
2.5 KiB
C

/*
* 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
* PROGRAMMERS: Hervé Poussineau
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
#include "infsupp.h"
#define NDEBUG
#include <debug.h>
/* HELPER FUNCTIONS **********************************************************/
BOOLEAN
INF_GetDataField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
OUT PWCHAR *Data)
{
#if 0
BOOL Success;
PWCHAR InfData;
DWORD dwSize;
*Data = NULL;
Success = SetupGetStringFieldW(Context,
FieldIndex,
NULL,
0,
&dwSize);
if (!Success)
return FALSE;
InfData = RtlAllocateHeap(ProcessHeap, 0, dwSize * sizeof(WCHAR));
if (!InfData)
return FALSE;
Success = SetupGetStringFieldW(Context,
FieldIndex,
InfData,
dwSize,
NULL);
if (!Success)
{
RtlFreeHeap(ProcessHeap, 0, InfData);
return FALSE;
}
*Data = InfData;
return TRUE;
#else
*Data = (PWCHAR)pSetupGetField(Context, FieldIndex);
return !!*Data;
#endif
}
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,
OUT PWCHAR *Key,
OUT PWCHAR *Data)
{
BOOL Success;
PWCHAR InfData[2] = {NULL, NULL};
if (Key)
*Key = NULL;
if (Data)
*Data = NULL;
/*
* 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.
*/
if (SetupGetFieldCount(Context) != 1)
{
DPRINT1("SetupGetFieldCount != 1\n");
return FALSE;
}
if (Key)
{
Success = INF_GetDataField(Context, 0, &InfData[0]);
if (!Success)
return FALSE;
}
if (Data)
{
Success = INF_GetDataField(Context, 1, &InfData[1]);
if (!Success)
{
INF_FreeData(InfData[0]);
return FALSE;
}
}
if (Key)
*Key = InfData[0];
if (Data)
*Data = InfData[1];
return TRUE;
}
/* EOF */