3 * Copyright (C) 2002 ReactOS Team
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.
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.
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.
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)
28 /* INCLUDES ******************************************************************/
35 /* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
37 /* Functions from the INFLIB library */
39 extern VOID
InfCloseFile(HINF InfHandle
);
40 // #define SetupCloseInfFile InfCloseFile
46 InfCloseFile(InfHandle
);
49 // #define SetupFindFirstLineW InfpFindFirstLineW
56 IN OUT PINFCONTEXT Context
)
61 ret
= InfFindFirstLine(InfHandle
, Section
, Key
, &pContext
);
65 memcpy(Context
, pContext
, sizeof(INFCONTEXT
));
66 InfFreeContext(pContext
);
70 extern BOOLEAN
InfFindNextLine(PINFCONTEXT ContextIn
,
71 PINFCONTEXT ContextOut
);
72 // #define SetupFindNextLine InfFindNextLine
76 IN PINFCONTEXT ContextIn
,
77 OUT PINFCONTEXT ContextOut
)
79 return !!InfFindNextLine(ContextIn
, ContextOut
);
82 extern LONG
InfGetFieldCount(PINFCONTEXT Context
);
83 // #define SetupGetFieldCount InfGetFieldCount
87 IN PINFCONTEXT Context
)
89 return (ULONG
)InfGetFieldCount(Context
);
93 * This function corresponds to an undocumented but exported SetupAPI function
94 * that exists since WinNT4 and is still present in Win10.
95 * The returned string pointer is a read-only pointer to a string in the
96 * maintained INF cache, and is always in UNICODE (on NT systems).
98 extern BOOLEAN
InfGetDataField(PINFCONTEXT Context
,
104 IN PINFCONTEXT Context
,
108 if (!InfGetDataField(Context
, FieldIndex
, &Data
))
113 extern BOOLEAN
InfGetBinaryField(PINFCONTEXT Context
,
116 ULONG ReturnBufferSize
,
117 PULONG RequiredSize
);
118 // #define SetupGetBinaryField InfGetBinaryField
122 IN PINFCONTEXT Context
,
124 OUT PUCHAR ReturnBuffer
,
125 IN ULONG ReturnBufferSize
,
126 OUT PULONG RequiredSize
)
128 return !!InfGetBinaryField(Context
,
135 extern BOOLEAN
InfGetIntField(PINFCONTEXT Context
,
138 // #define SetupGetIntField InfGetIntField
142 IN PINFCONTEXT Context
,
144 OUT INT
*IntegerValue
) // PINT
146 return !!InfGetIntField(Context
, FieldIndex
, IntegerValue
);
149 extern BOOLEAN
InfGetMultiSzField(PINFCONTEXT Context
,
152 ULONG ReturnBufferSize
,
153 PULONG RequiredSize
);
154 // #define SetupGetMultiSzFieldW InfGetMultiSzField
157 SetupGetMultiSzFieldW(
158 IN PINFCONTEXT Context
,
160 OUT PWSTR ReturnBuffer
,
161 IN ULONG ReturnBufferSize
,
162 OUT PULONG RequiredSize
)
164 return !!InfGetMultiSzField(Context
,
171 extern BOOLEAN
InfGetStringField(PINFCONTEXT Context
,
174 ULONG ReturnBufferSize
,
175 PULONG RequiredSize
);
176 // #define SetupGetStringFieldW InfGetStringField
179 SetupGetStringFieldW(
180 IN PINFCONTEXT Context
,
182 OUT PWSTR ReturnBuffer
,
183 IN ULONG ReturnBufferSize
,
184 OUT PULONG RequiredSize
)
186 return !!InfGetStringField(Context
,
193 /* SetupOpenInfFileW with support for a user-provided LCID */
194 // #define SetupOpenInfFileExW InfpOpenInfFileW
205 UNICODE_STRING FileNameU
;
209 RtlInitUnicodeString(&FileNameU
, FileName
);
210 Status
= InfOpenFile(&hInf
,
212 LANGIDFROMLCID(LocaleId
),
214 *ErrorLine
= (UINT
)ErrorLineUL
;
215 if (!NT_SUCCESS(Status
))
216 return INVALID_HANDLE_VALUE
;
222 /* GLOBALS *******************************************************************/
224 pSpInfCloseInfFile SpInfCloseInfFile
= SetupCloseInfFile
;
225 pSpInfFindFirstLine SpInfFindFirstLine
= SetupFindFirstLineW
;
226 pSpInfFindNextLine SpInfFindNextLine
= SetupFindNextLine
;
227 pSpInfGetFieldCount SpInfGetFieldCount
= SetupGetFieldCount
;
228 pSpInfGetBinaryField SpInfGetBinaryField
= SetupGetBinaryField
;
229 pSpInfGetIntField SpInfGetIntField
= SetupGetIntField
;
230 pSpInfGetMultiSzField SpInfGetMultiSzField
= SetupGetMultiSzFieldW
;
231 pSpInfGetStringField SpInfGetStringField
= SetupGetStringFieldW
;
232 pSpInfGetField SpInfGetField
= pSetupGetField
;
233 pSpInfOpenInfFile SpInfOpenInfFile
= SetupOpenInfFileExW
;
236 /* HELPER FUNCTIONS **********************************************************/
239 INF_OpenBufferedFileA(
251 Status
= InfOpenBufferedFile(&hInf
,
254 LANGIDFROMLCID(LocaleId
),
256 *ErrorLine
= (UINT
)ErrorLineUL
;
257 if (!NT_SUCCESS(Status
))
258 return INVALID_HANDLE_VALUE
;