[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".
This commit is contained in:
Hermès Bélusca-Maïto 2018-01-06 16:47:37 +01:00
parent 44c101c9dc
commit 8f1ab791fa
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
22 changed files with 702 additions and 396 deletions

View file

@ -1,119 +0,0 @@
/*
* 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 */

View file

@ -1,168 +0,0 @@
/*
* 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@sfr.fr)
*/
#pragma once
/* Make setupapi.h to not define the API as exports to the DLL */
#ifdef __REACTOS__
#define _SETUPAPI_
#endif
// 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
typedef PVOID HINF;
typedef struct _INFCONTEXT
{
HINF Inf;
HINF CurrentInf;
UINT Section;
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 */
#undef MAX_INF_STRING_LENGTH
#define MAX_INF_STRING_LENGTH 1024 // Still larger than in infcommon.h
#ifndef INF_STYLE_OLDNT
#define INF_STYLE_OLDNT 0x00000001
#endif
#ifndef INF_STYLE_WIN4
#define INF_STYLE_WIN4 0x00000002
#endif
#if 0
typedef PVOID HINF;
typedef struct _INFCONTEXT
{
HINF Inf;
HINF CurrentInf;
UINT Section;
UINT Line;
} INFCONTEXT, *PINFCONTEXT;
#endif
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);
/* A version of SetupOpenInfFileW with support for a user-provided LCID */
// #define SetupOpenInfFileExW InfpOpenInfFileW
HINF
WINAPI
SetupOpenInfFileExW(
IN PCWSTR FileName,
IN PCWSTR InfClass,
IN DWORD InfStyle,
IN LCID LocaleId,
OUT PUINT ErrorLine);
/* HELPER FUNCTIONS **********************************************************/
FORCEINLINE VOID
INF_FreeData(IN PWCHAR InfData)
{
#if 0
if (InfData)
RtlFreeHeap(ProcessHeap, 0, InfData);
#else
UNREFERENCED_PARAMETER(InfData);
#endif
}
BOOLEAN
INF_GetDataField(
IN PINFCONTEXT Context,
IN ULONG FieldIndex,
OUT PWCHAR *Data);
BOOLEAN
INF_GetData(
IN PINFCONTEXT Context,
OUT PWCHAR *Key,
OUT PWCHAR *Data);
/* EOF */