reactos/base/setup/lib/infsupp.h
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

165 lines
3.8 KiB
C

/*
* 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_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 */