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/usetup/inffile.c
23 * PURPOSE: .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
43 SetupCloseInfFile(HINF InfHandle
)
45 InfCloseFile(InfHandle
);
48 // #define SetupFindFirstLineW InfpFindFirstLineW
55 IN OUT PINFCONTEXT Context
)
60 ret
= InfFindFirstLine(InfHandle
, Section
, Key
, &pContext
);
64 memcpy(Context
, pContext
, sizeof(INFCONTEXT
));
65 InfFreeContext(pContext
);
69 extern BOOLEAN
InfFindNextLine(PINFCONTEXT ContextIn
,
70 PINFCONTEXT ContextOut
);
71 // #define SetupFindNextLine InfFindNextLine
74 SetupFindNextLine(PINFCONTEXT ContextIn
,
75 PINFCONTEXT ContextOut
)
77 return !!InfFindNextLine(ContextIn
, ContextOut
);
80 extern LONG
InfGetFieldCount(PINFCONTEXT Context
);
81 // #define SetupGetFieldCount InfGetFieldCount
84 SetupGetFieldCount(PINFCONTEXT Context
)
86 return InfGetFieldCount(Context
);
90 * This function corresponds to an undocumented but exported setupapi API
91 * that exists since WinNT4 and is still present in Win10.
92 * The returned string pointer is a read-only pointer to a string in the
93 * maintained INF cache, and is always in UNICODE (on NT systems).
95 extern BOOLEAN
InfGetDataField(PINFCONTEXT Context
,
100 pSetupGetField(PINFCONTEXT Context
,
104 if (!InfGetDataField(Context
, FieldIndex
, &Data
))
109 extern BOOLEAN
InfGetBinaryField(PINFCONTEXT Context
,
112 ULONG ReturnBufferSize
,
113 PULONG RequiredSize
);
114 // #define SetupGetBinaryField InfGetBinaryField
117 SetupGetBinaryField(PINFCONTEXT Context
,
120 ULONG ReturnBufferSize
,
123 return !!InfGetBinaryField(Context
,
130 extern BOOLEAN
InfGetIntField(PINFCONTEXT Context
,
133 // #define SetupGetIntField InfGetIntField
136 SetupGetIntField(PINFCONTEXT Context
,
138 INT
*IntegerValue
) // PINT
140 return !!InfGetIntField(Context
, FieldIndex
, IntegerValue
);
143 extern BOOLEAN
InfGetMultiSzField(PINFCONTEXT Context
,
146 ULONG ReturnBufferSize
,
147 PULONG RequiredSize
);
148 // #define SetupGetMultiSzFieldW InfGetMultiSzField
151 SetupGetMultiSzFieldW(PINFCONTEXT Context
,
154 ULONG ReturnBufferSize
,
157 return !!InfGetMultiSzField(Context
,
164 extern BOOLEAN
InfGetStringField(PINFCONTEXT Context
,
167 ULONG ReturnBufferSize
,
168 PULONG RequiredSize
);
169 // #define SetupGetStringFieldW InfGetStringField
172 SetupGetStringFieldW(PINFCONTEXT Context
,
175 ULONG ReturnBufferSize
,
178 return !!InfGetStringField(Context
,
186 /* SetupOpenInfFileW with support for a user-provided LCID */
187 // #define SetupOpenInfFileExW InfpOpenInfFileW
198 UNICODE_STRING FileNameU
;
202 RtlInitUnicodeString(&FileNameU
, FileName
);
203 Status
= InfOpenFile(&hInf
,
205 LANGIDFROMLCID(LocaleId
),
207 *ErrorLine
= (UINT
)ErrorLineUL
;
208 if (!NT_SUCCESS(Status
))
209 return INVALID_HANDLE_VALUE
;
215 /* HELPER FUNCTIONS **********************************************************/
218 INF_OpenBufferedFileA(
230 Status
= InfOpenBufferedFile(&hInf
,
233 LANGIDFROMLCID(LocaleId
),
235 *ErrorLine
= (UINT
)ErrorLineUL
;
236 if (!NT_SUCCESS(Status
))
237 return INVALID_HANDLE_VALUE
;