ReactOS 0.4.15-dev-7958-gcd0bb1a
infsupp.c
Go to the documentation of this file.
1/*
2 * ReactOS kernel
3 * Copyright (C) 2002 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19/*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: base/setup/lib/infsupp.c
23 * PURPOSE: Interfacing with Setup* API .INF Files support functions
24 * PROGRAMMERS: Hervé Poussineau
25 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
26 */
27
28/* INCLUDES ******************************************************************/
29
30#ifndef _USETUP_PCH_
31#include "usetup.h"
32#endif
33
34#define NDEBUG
35#include <debug.h>
36
37/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
38
39/* Functions from the INFLIB library */
40
41extern VOID InfCloseFile(HINF InfHandle);
42// #define SetupCloseInfFile InfCloseFile
43VOID
46 IN HINF InfHandle)
47{
48 if (InfHandle == INVALID_HANDLE_VALUE)
49 return;
50 InfCloseFile(InfHandle);
51}
52
53// #define SetupFindFirstLineW InfpFindFirstLineW
54BOOL
57 IN HINF InfHandle,
58 IN PCWSTR Section,
61{
62 PINFCONTEXT pContext;
63 BOOL ret;
64
65 if (InfHandle == INVALID_HANDLE_VALUE)
66 return FALSE;
67
68 ret = InfFindFirstLine(InfHandle, Section, Key, &pContext);
69 if (!ret)
70 return FALSE;
71
72 memcpy(Context, pContext, sizeof(INFCONTEXT));
73 InfFreeContext(pContext);
74 return TRUE;
75}
76
77extern BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn,
78 PINFCONTEXT ContextOut);
79// #define SetupFindNextLine InfFindNextLine
80BOOL
83 IN PINFCONTEXT ContextIn,
84 OUT PINFCONTEXT ContextOut)
85{
86 return !!InfFindNextLine(ContextIn, ContextOut);
87}
88
90// #define SetupGetFieldCount InfGetFieldCount
95{
97}
98
99/*
100 * This function corresponds to an undocumented but exported SetupAPI function
101 * that exists since WinNT4 and is still present in Win10.
102 * The returned string pointer is a read-only pointer to a string in the
103 * maintained INF cache, and is always in UNICODE (on NT systems).
104 */
107 PWCHAR *Data);
108PCWSTR
109WINAPI
113{
114 PWCHAR Data = NULL;
116 return NULL;
117 return Data;
118}
119
122 PUCHAR ReturnBuffer,
125// #define SetupGetBinaryField InfGetBinaryField
126BOOL
127WINAPI
131 OUT PUCHAR ReturnBuffer,
134{
135 return !!InfGetBinaryField(Context,
137 ReturnBuffer,
140}
141
144 INT *IntegerValue);
145// #define SetupGetIntField InfGetIntField
146BOOL
147WINAPI
151 OUT INT *IntegerValue) // PINT
152{
153 return !!InfGetIntField(Context, FieldIndex, IntegerValue);
154}
155
158 PWSTR ReturnBuffer,
161// #define SetupGetMultiSzFieldW InfGetMultiSzField
162BOOL
163WINAPI
167 OUT PWSTR ReturnBuffer,
170{
173 ReturnBuffer,
176}
177
180 PWSTR ReturnBuffer,
183// #define SetupGetStringFieldW InfGetStringField
184BOOL
185WINAPI
189 OUT PWSTR ReturnBuffer,
192{
193 return !!InfGetStringField(Context,
195 ReturnBuffer,
198}
199
200/* SetupOpenInfFileW with support for a user-provided LCID */
201// #define SetupOpenInfFileExW InfpOpenInfFileW
202HINF
203WINAPI
206 IN PCWSTR InfClass,
207 IN DWORD InfStyle,
209 OUT PUINT ErrorLine)
210{
211 HINF hInf = NULL;
212 UNICODE_STRING FileNameU;
213 ULONG ErrorLineUL;
215
216 RtlInitUnicodeString(&FileNameU, FileName);
217 Status = InfOpenFile(&hInf,
218 &FileNameU,
220 &ErrorLineUL);
221 *ErrorLine = (UINT)ErrorLineUL;
222 if (!NT_SUCCESS(Status))
224
225 return hInf;
226}
227
228
229/* GLOBALS *******************************************************************/
230
241
242
243/* HELPER FUNCTIONS **********************************************************/
244
247 IN PSTR FileBuffer,
249 IN PCSTR InfClass,
250 IN DWORD InfStyle,
252 OUT PUINT ErrorLine)
253{
254 HINF hInf = NULL;
255 ULONG ErrorLineUL;
257
259 FileBuffer,
260 FileSize,
262 &ErrorLineUL);
263 *ErrorLine = (UINT)ErrorLineUL;
264 if (!NT_SUCCESS(Status))
266
267 return hInf;
268}
269
270/* EOF */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
HINF WINAPI INF_OpenBufferedFileA(IN PSTR FileBuffer, IN ULONG FileSize, IN PCSTR InfClass, IN DWORD InfStyle, IN LCID LocaleId, OUT PUINT ErrorLine)
Definition: infsupp.c:246
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
BOOLEAN InfFindFirstLine(HINF InfHandle, PCSTR Section, PCSTR Key, PINFCONTEXT Context)
Definition: inffile.c:1050
BOOLEAN InfOpenFile(PHINF InfHandle, PCSTR FileName, PULONG ErrorLine)
Definition: inffile.c:918
VOID InfFreeContext(PINFCONTEXT Context)
Definition: infrosget.c:135
NTSTATUS InfOpenBufferedFile(PHINF InfHandle, PVOID Buffer, ULONG BufferSize, LANGID LanguageId, PULONG ErrorLine)
Definition: infrosgen.c:51
ULONG(WINAPI * pSpInfGetFieldCount)(IN PINFCONTEXT Context)
Definition: infsupp.h:85
pSpInfGetBinaryField SpInfGetBinaryField
Definition: infsupp.c:90
HINF(WINAPI * pSpInfOpenInfFile)(IN PCWSTR FileName, IN PCWSTR InfClass, IN DWORD InfStyle, IN LCID LocaleId, OUT PUINT ErrorLine)
Definition: infsupp.h:143
pSpInfGetMultiSzField SpInfGetMultiSzField
Definition: infsupp.c:92
BOOL(WINAPI * pSpInfGetStringField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.h:123
BOOL(WINAPI * pSpInfGetMultiSzField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.h:112
pSpInfGetStringField SpInfGetStringField
Definition: infsupp.c:93
BOOL(WINAPI * pSpInfFindFirstLine)(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.h:67
BOOL(WINAPI * pSpInfGetIntField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.h:103
pSpInfGetFieldCount SpInfGetFieldCount
Definition: infsupp.c:89
pSpInfFindNextLine SpInfFindNextLine
Definition: infsupp.c:88
pSpInfGetIntField SpInfGetIntField
Definition: infsupp.c:91
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
VOID(WINAPI * pSpInfCloseInfFile)(IN HINF InfHandle)
Definition: infsupp.h:60
pSpInfOpenInfFile SpInfOpenInfFile
Definition: infsupp.c:95
pSpInfCloseInfFile SpInfCloseInfFile
Definition: infsupp.c:86
pSpInfGetField SpInfGetField
Definition: infsupp.c:94
PCWSTR(WINAPI * pSpInfGetField)(IN PINFCONTEXT Context, IN ULONG FieldIndex)
Definition: infsupp.h:134
BOOL(WINAPI * pSpInfGetBinaryField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PUCHAR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.h:92
BOOL(WINAPI * pSpInfFindNextLine)(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
long LONG
Definition: pedump.c:60
PCWSTR WINAPI pSetupGetField(IN PINFCONTEXT Context, IN ULONG FieldIndex)
Definition: infsupp.c:110
HINF WINAPI SetupOpenInfFileExW(IN PCWSTR FileName, IN PCWSTR InfClass, IN DWORD InfStyle, IN LCID LocaleId, OUT PUINT ErrorLine)
Definition: infsupp.c:35
#define LANGIDFROMLCID(l)
Definition: nls.h:18
DWORD LCID
Definition: nls.h:13
_In_ DWORD FieldIndex
Definition: setupapi.h:1895
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1897
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:186
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:56
BOOLEAN InfGetIntField(PINFCONTEXT Context, ULONG FieldIndex, INT *IntegerValue)
Definition: infrosget.c:85
BOOL WINAPI SetupGetMultiSzFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:164
BOOL WINAPI SetupGetIntField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.c:148
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:93
BOOLEAN InfGetDataField(PINFCONTEXT Context, ULONG FieldIndex, PWCHAR *Data)
Definition: infrosget.c:127
VOID InfCloseFile(HINF InfHandle)
Definition: inffile.c:1028
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:82
BOOLEAN InfFindNextLine(PINFCONTEXT ContextIn, PINFCONTEXT ContextOut)
Definition: inffile.c:1107
BOOLEAN InfGetBinaryField(PINFCONTEXT Context, ULONG FieldIndex, PUCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: inffile.c:1260
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
LONG InfGetFieldCount(PINFCONTEXT Context)
Definition: inffile.c:1250
BOOLEAN InfGetMultiSzField(PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: infrosget.c:94
BOOL WINAPI SetupGetBinaryField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PUCHAR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:128
BOOLEAN InfGetStringField(PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: infrosget.c:106
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING _In_ LCID LocaleId
Definition: wdfpdo.h:437
#define WINAPI
Definition: msvc.h:6