ReactOS 0.4.15-dev-8413-gc1c91f2
infsupp.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS GUI first stage setup application
4 * FILE: base/setup/lib/infsupp.c
5 * PURPOSE: Interfacing with Setup* API .INF Files support functions
6 * PROGRAMMERS: Hervé Poussineau
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10/* INCLUDES ******************************************************************/
11
12#include "reactos.h"
13#include <winnls.h>
14
15#define NDEBUG
16#include <debug.h>
17
18/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/
19
20/*
21 * This function corresponds to an undocumented but exported SetupAPI function
22 * that exists since WinNT4 and is still present in Win10.
23 * The returned string pointer is a read-only pointer to a string in the
24 * maintained INF cache, and is always in UNICODE (on NT systems).
25 */
31
32/* SetupOpenInfFileW with support for a user-provided LCID */
33HINF
37 IN PCWSTR InfClass,
38 IN DWORD InfStyle,
40 OUT PUINT ErrorLine)
41{
42 HINF InfHandle;
43 LCID OldLocaleId;
44 WCHAR Win32FileName[MAX_PATH];
45
46 /*
47 * SetupOpenInfFileExW is called within setuplib with NT paths, however
48 * the Win32 SetupOpenInfFileW API only takes Win32 paths. We therefore
49 * map the NT path to Win32 path and then call the Win32 API.
50 */
52 Win32FileName,
53 _countof(Win32FileName),
54 FileName))
55 {
57 }
58
59 /*
60 * Because SetupAPI's SetupOpenInfFileW() function does not allow the user
61 * to specify a given LCID to use to load localized string substitutions,
62 * we temporarily change the current thread locale before calling
63 * SetupOpenInfFileW(). When we have finished we restore the original
64 * thread locale.
65 */
66 OldLocaleId = GetThreadLocale();
67 if (OldLocaleId != LocaleId)
69
70 /* Load the INF file */
71 InfHandle = SetupOpenInfFileW(Win32FileName,
72 InfClass,
73 InfStyle,
74 ErrorLine);
75
76 /* Restore the original thread locale */
77 if (OldLocaleId != LocaleId)
78 SetThreadLocale(OldLocaleId);
79
80 return InfHandle;
81}
82
83
84/* GLOBALS *******************************************************************/
85
96
97
98/* HELPER FUNCTIONS **********************************************************/
99
100#if 0
101
104 IN PSTR FileBuffer,
106 IN PCSTR InfClass,
107 IN DWORD InfStyle,
109 OUT PUINT ErrorLine)
110{
111#ifdef __REACTOS__
112 HINF hInf = NULL;
113 ULONG ErrorLineUL;
115
117 FileBuffer,
118 FileSize,
120 &ErrorLineUL);
121 *ErrorLine = (UINT)ErrorLineUL;
122 if (!NT_SUCCESS(Status))
124
125 return hInf;
126#else
128#endif /* !__REACTOS__ */
129}
130
131#endif
132
133/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
BOOL ConvertNtPathToWin32Path(IN OUT PNT_WIN32_PATH_MAPPING_LIST MappingList, OUT PWSTR pwszPath, IN DWORD cchPathMax, IN PCWSTR pwszNTPath)
Definition: reactos.c:1523
SETUPDATA SetupData
Definition: reactos.c:42
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 NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
LCID WINAPI GetThreadLocale(void)
Definition: locale.c:2800
BOOL WINAPI SetThreadLocale(LCID lcid)
Definition: locale.c:2819
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
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
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
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
#define _countof(array)
Definition: sndvol32.h:70
NT_WIN32_PATH_MAPPING_LIST MappingList
Definition: reactos.h:126
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
const char * PCSTR
Definition: typedefs.h:52
#define IN
Definition: typedefs.h:39
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
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
BOOL WINAPI SetupFindNextLine(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.c:82
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:45
BOOL WINAPI SetupGetBinaryField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PUCHAR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:128
_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
__wchar_t WCHAR
Definition: xmlstorage.h:180