db6043c03f6cd079decb8c27b74e572dd192285e
[reactos.git] / base / setup / lib / infsupp.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Setup Library
4 * FILE: base/setup/lib/infsupp.h
5 * PURPOSE: Interfacing with Setup* API .inf files support functions
6 * PROGRAMMER: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 #pragma once
10
11 /* Make setupapi.h to not define the API as exports to the DLL */
12 #ifdef __REACTOS__
13 #define _SETUPAPI_
14 #endif
15
16 // FIXME: Temporary measure until all the users of this header
17 // (usetup...) use or define SetupAPI-conforming APIs.
18 #if defined(_SETUPAPI_H_) || defined(_INC_SETUPAPI)
19
20 #include <setupapi.h>
21
22 #else
23
24 typedef PVOID HINF;
25 typedef struct _INFCONTEXT
26 {
27 HINF Inf;
28 HINF CurrentInf;
29 UINT Section;
30 UINT Line;
31 } INFCONTEXT, *PINFCONTEXT;
32
33 // #define SetupCloseInfFile InfCloseFile
34 VOID
35 WINAPI
36 SetupCloseInfFile(HINF InfHandle);
37
38 // #define SetupFindFirstLineW InfpFindFirstLineW
39 BOOL
40 WINAPI
41 SetupFindFirstLineW(
42 IN HINF InfHandle,
43 IN PCWSTR Section,
44 IN PCWSTR Key,
45 IN OUT PINFCONTEXT Context);
46
47 // #define SetupFindNextLine InfFindNextLine
48 BOOL
49 WINAPI
50 SetupFindNextLine(PINFCONTEXT ContextIn,
51 PINFCONTEXT ContextOut);
52
53 // #define SetupGetFieldCount InfGetFieldCount
54 LONG
55 WINAPI
56 SetupGetFieldCount(PINFCONTEXT Context);
57
58 // #define SetupGetBinaryField InfGetBinaryField
59 BOOL
60 WINAPI
61 SetupGetBinaryField(PINFCONTEXT Context,
62 ULONG FieldIndex,
63 PUCHAR ReturnBuffer,
64 ULONG ReturnBufferSize,
65 PULONG RequiredSize);
66
67 // #define SetupGetIntField InfGetIntField
68 BOOL
69 WINAPI
70 SetupGetIntField(PINFCONTEXT Context,
71 ULONG FieldIndex,
72 INT *IntegerValue); // PINT
73
74 // #define SetupGetMultiSzFieldW InfGetMultiSzField
75 BOOL
76 WINAPI
77 SetupGetMultiSzFieldW(PINFCONTEXT Context,
78 ULONG FieldIndex,
79 PWSTR ReturnBuffer,
80 ULONG ReturnBufferSize,
81 PULONG RequiredSize);
82
83 // #define SetupGetStringFieldW InfGetStringField
84 BOOL
85 WINAPI
86 SetupGetStringFieldW(PINFCONTEXT Context,
87 ULONG FieldIndex,
88 PWSTR ReturnBuffer,
89 ULONG ReturnBufferSize,
90 PULONG RequiredSize);
91
92 #endif
93
94 /* Lower the MAX_INF_STRING_LENGTH value in order to avoid too much stack usage */
95 #undef MAX_INF_STRING_LENGTH
96 #define MAX_INF_STRING_LENGTH 1024 // Still larger than in infcommon.h
97
98 #ifndef INF_STYLE_OLDNT
99 #define INF_STYLE_OLDNT 0x00000001
100 #endif
101
102 #ifndef INF_STYLE_WIN4
103 #define INF_STYLE_WIN4 0x00000002
104 #endif
105
106 #if 0
107 typedef PVOID HINF;
108 typedef struct _INFCONTEXT
109 {
110 HINF Inf;
111 HINF CurrentInf;
112 UINT Section;
113 UINT Line;
114 } INFCONTEXT, *PINFCONTEXT;
115 #endif
116
117 C_ASSERT(sizeof(INFCONTEXT) == 2 * sizeof(HINF) + 2 * sizeof(UINT));
118
119
120 /*
121 * This function corresponds to an undocumented but exported SetupAPI function
122 * that exists since WinNT4 and is still present in Win10.
123 * The returned string pointer is a read-only pointer to a string in the
124 * maintained INF cache, and is always in UNICODE (on NT systems).
125 */
126 PCWSTR
127 WINAPI
128 pSetupGetField(PINFCONTEXT Context,
129 ULONG FieldIndex);
130
131 /* A version of SetupOpenInfFileW with support for a user-provided LCID */
132 // #define SetupOpenInfFileExW InfpOpenInfFileW
133 HINF
134 WINAPI
135 SetupOpenInfFileExW(
136 IN PCWSTR FileName,
137 IN PCWSTR InfClass,
138 IN DWORD InfStyle,
139 IN LCID LocaleId,
140 OUT PUINT ErrorLine);
141
142
143 /* HELPER FUNCTIONS **********************************************************/
144
145 FORCEINLINE VOID
146 INF_FreeData(IN PWCHAR InfData)
147 {
148 #if 0
149 if (InfData)
150 RtlFreeHeap(ProcessHeap, 0, InfData);
151 #else
152 UNREFERENCED_PARAMETER(InfData);
153 #endif
154 }
155
156 BOOLEAN
157 INF_GetDataField(
158 IN PINFCONTEXT Context,
159 IN ULONG FieldIndex,
160 OUT PWCHAR *Data);
161
162 BOOLEAN
163 INF_GetData(
164 IN PINFCONTEXT Context,
165 OUT PWCHAR *Key,
166 OUT PWCHAR *Data);
167
168 /* EOF */