cf86101583ee6c105d43c8c3caf702bf48e17443
[reactos.git] / reactos / dll / win32 / setupapi / setupapi_private.h
1 /*
2 * Copyright 2001 Andreas Mohr
3 * Copyright 2005-2006 Hervé Poussineau
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #ifndef __SETUPAPI_PRIVATE_H
21 #define __SETUPAPI_PRIVATE_H
22
23 #include <wchar.h>
24
25 #define WIN32_NO_STATUS
26 #define _INC_WINDOWS
27 #define COM_NO_WINDOWS_H
28
29 #define COBJMACROS
30
31 #include <windef.h>
32 #include <winbase.h>
33 #include <winreg.h>
34 #include <wingdi.h>
35 #include <winspool.h>
36 #include <wincon.h>
37 #include <objbase.h>
38 #include <cfgmgr32.h>
39 #include <regstr.h>
40 #include <sddl.h>
41 #include <setupapi.h>
42 #include <softpub.h>
43 #include <mscat.h>
44 #include <lzexpand.h>
45 #include <shlobj.h>
46 #include <wine/unicode.h>
47 #define NTOS_MODE_USER
48 #include <ndk/rtlfuncs.h>
49
50 #include <wine/debug.h>
51 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
52
53 #ifdef __REACTOS__
54 #undef __WINESRC__
55 #endif
56
57 #define SETUP_DEVICE_INFO_SET_MAGIC 0xd00ff057
58 #define SETUP_CLASS_IMAGE_LIST_MAGIC 0xd00ff058
59
60 #define CMP_MAGIC 0x01234567
61
62 struct DeviceInterface /* Element of DeviceInfo.InterfaceListHead */
63 {
64 LIST_ENTRY ListEntry;
65
66 /* Link to is parent device */
67 struct DeviceInfo *DeviceInfo;
68 GUID InterfaceClassGuid;
69
70
71 /* SPINT_ACTIVE : the interface is active/enabled
72 * SPINT_DEFAULT: the interface is the default interface for the device class
73 * SPINT_REMOVED: the interface is removed
74 */
75 DWORD Flags;
76
77 /* Contains the symbolic link of this interface, for example
78 * \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */
79 WCHAR SymbolicLink[ANYSIZE_ARRAY];
80 };
81
82 /* We don't want to open the .inf file to read only one information in it, so keep a handle to it once it
83 * has been already loaded once. Keep also a reference counter */
84 struct InfFileDetails
85 {
86 /* Handle to the .inf file */
87 HINF hInf;
88 /* Reference count to this object. Once it raises 0, the .inf file is
89 * automatically closed and this memory structure is deleted */
90 LONG References;
91
92 /* Contains the directory name of the .inf file.
93 * Points into szData at then end of the structure */
94 PCWSTR DirectoryName;
95 /* Contains the .inf file name (without directory name).
96 * Points into szData at then end of the structure */
97 PCWSTR FileName;
98
99 /* Variable size array (contains data for DirectoryName and FileName) */
100 WCHAR szData[ANYSIZE_ARRAY];
101 };
102
103 struct DriverInfoElement /* Element of DeviceInfoSet.DriverListHead and DeviceInfo.DriverListHead */
104 {
105 LIST_ENTRY ListEntry;
106
107 SP_DRVINSTALL_PARAMS Params;
108 ULARGE_INTEGER DriverDate;
109 SP_DRVINFO_DATA_V2_W Info;
110 SP_DRVINFO_DETAIL_DATA_W Details;
111 GUID ClassGuid;
112 LPWSTR MatchingId;
113 struct InfFileDetails *InfFileDetails;
114 };
115
116 struct ClassInstallParams
117 {
118 PSP_PROPCHANGE_PARAMS PropChangeParams;
119 PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData;
120 };
121
122 struct DeviceInfo /* Element of DeviceInfoSet.ListHead */
123 {
124 LIST_ENTRY ListEntry;
125 /* Used when dealing with CM_* functions */
126 DEVINST dnDevInst;
127
128 /* Link to parent DeviceInfoSet */
129 struct DeviceInfoSet *set;
130
131 /* Reserved Field of SP_DEVINSTALL_PARAMS_W structure
132 * points to a struct DriverInfoElement */
133 SP_DEVINSTALL_PARAMS_W InstallParams;
134
135 /* Information about devnode:
136 * - instanceId:
137 * "Root\*PNP0501" for example.
138 * It doesn't contain the unique ID for the device
139 * (points into the Data field at the end of the structure)
140 * WARNING: no NULL char exist between instanceId and UniqueId
141 * in Data field!
142 * - UniqueId
143 * "5&1be2108e&0" or "0000"
144 * If DICD_GENERATE_ID is specified in creation flags,
145 * this unique ID is autogenerated using 4 digits, base 10
146 * (points into the Data field at the end of the structure)
147 * - DeviceDescription
148 * String which identifies the device. Can be NULL. If not NULL,
149 * points into the Data field at the end of the structure
150 * - ClassGuid
151 * Identifies the class of this device. It is GUID_NULL if the
152 * device has not been installed
153 * - CreationFlags
154 * Is a combination of:
155 * - DICD_GENERATE_ID
156 * the unique ID needs to be generated
157 * - DICD_INHERIT_CLASSDRVS
158 * inherit driver of the device info set (== same pointer)
159 */
160 PCWSTR instanceId;
161 PCWSTR UniqueId;
162 PCWSTR DeviceDescription;
163 GUID ClassGuid;
164 DWORD CreationFlags;
165
166 /* If CreationFlags contains DICD_INHERIT_CLASSDRVS, this list is invalid */
167 /* If the driver is not searched/detected, this list is empty */
168 LIST_ENTRY DriverListHead; /* List of struct DriverInfoElement */
169
170 /* List of interfaces implemented by this device */
171 LIST_ENTRY InterfaceListHead; /* List of struct DeviceInterface */
172
173 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
174 struct ClassInstallParams ClassInstallParams;
175
176 /* Device property page provider data */
177 HMODULE hmodDevicePropPageProvider;
178 PVOID pDevicePropPageProvider;
179
180 /* Variable size array (contains data for instanceId, UniqueId, DeviceDescription) */
181 WCHAR Data[ANYSIZE_ARRAY];
182 };
183
184 struct DeviceInfoSet /* HDEVINFO */
185 {
186 DWORD magic; /* SETUP_DEVICE_INFO_SET_MAGIC */
187 /* If != GUID_NULL, only devices of this class can be in the device info set */
188 GUID ClassGuid;
189 /* Local or distant HKEY_LOCAL_MACHINE registry key */
190 HKEY HKLM;
191 /* Used when dealing with CM_* functions */
192 HMACHINE hMachine;
193
194 /* Reserved Field points to a struct DriverInfoElement */
195 SP_DEVINSTALL_PARAMS_W InstallParams;
196
197 /* List of struct DriverInfoElement (if no driver has been
198 * searched/detected, this list is empty) */
199 LIST_ENTRY DriverListHead;
200
201 /* List of struct DeviceInfo */
202 LIST_ENTRY ListHead;
203 struct DeviceInfo *SelectedDevice;
204
205 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
206 struct ClassInstallParams ClassInstallParams;
207
208 /* Class property page provider data */
209 HMODULE hmodClassPropPageProvider;
210 PVOID pClassPropPageProvider;
211
212 /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
213 * or NULL if related to local machine. Points into szData field at the
214 * end of the structure */
215 PCWSTR MachineName;
216
217 /* Variable size array (contains data for MachineName) */
218 WCHAR szData[ANYSIZE_ARRAY];
219 };
220
221 struct ClassImageList
222 {
223 DWORD magic; /* SETUP_CLASS_IMAGE_LIST_MAGIC */
224
225 /* Number of GUIDs contained in Guids and IconIndexes arrays */
226 DWORD NumberOfGuids;
227 /* Array of GUIDs associated to icons of the image list. Its size
228 * is NumberOfGuids and is pointing after the end this structure */
229 GUID* Guids;
230 /* Array of corresponding icons index in the image list. Its size
231 * is NumberOfGuids and is pointing after the end this structure */
232 INT* IconIndexes;
233 };
234
235 struct FileLog /* HSPFILELOG */
236 {
237 DWORD ReadOnly;
238 DWORD SystemLog;
239 LPWSTR LogName;
240 };
241
242 extern HINSTANCE hInstance;
243 #define RC_STRING_MAX_SIZE 256
244
245 #define REG_INSTALLEDFILES "System\\CurrentControlSet\\Control\\InstalledFiles"
246 #define REGPART_RENAME "\\Rename"
247 #define REG_VERSIONCONFLICT "Software\\Microsoft\\VersionConflictManager"
248
249 inline static WCHAR *strdupAtoW( const char *str )
250 {
251 WCHAR *ret = NULL;
252 if (str)
253 {
254 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
255 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
256 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
257 }
258 return ret;
259 }
260
261 /* string substitutions */
262
263 struct inf_file;
264 extern const WCHAR *DIRID_get_string( int dirid );
265 extern const WCHAR *PARSER_get_inf_filename( HINF hinf ) DECLSPEC_HIDDEN;
266 extern WCHAR *PARSER_get_src_root( HINF hinf ) DECLSPEC_HIDDEN;
267 extern WCHAR *PARSER_get_dest_dir( INFCONTEXT *context ) DECLSPEC_HIDDEN;
268
269 /* support for Ascii queue callback functions */
270
271 struct callback_WtoA_context
272 {
273 void *orig_context;
274 PSP_FILE_CALLBACK_A orig_handler;
275 };
276
277 UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, UINT_PTR, UINT_PTR );
278
279 /* from msvcrt/sys/stat.h */
280 #define _S_IWRITE 0x0080
281 #define _S_IREAD 0x0100
282
283 extern HINSTANCE hInstance;
284 extern OSVERSIONINFOW OsVersionInfo;
285
286 /* devinst.c */
287
288 BOOL
289 CreateDeviceInfo(
290 IN struct DeviceInfoSet *list,
291 IN LPCWSTR InstancePath,
292 IN LPCGUID pClassGuid,
293 OUT struct DeviceInfo **pDeviceInfo);
294
295 LONG
296 SETUP_CreateDevicesList(
297 IN OUT struct DeviceInfoSet *list,
298 IN PCWSTR MachineName OPTIONAL,
299 IN CONST GUID *Class OPTIONAL,
300 IN PCWSTR Enumerator OPTIONAL);
301
302 /* driver.c */
303
304 struct InfFileDetails *
305 CreateInfFileDetails(
306 IN LPCWSTR FullInfFileName);
307
308 VOID
309 DereferenceInfFile(struct InfFileDetails* infFile);
310
311 BOOL
312 DestroyDriverInfoElement(struct DriverInfoElement* driverInfo);
313
314 /* install.c */
315
316 BOOL
317 GetStringField( PINFCONTEXT context, DWORD index, PWSTR *value);
318
319 /* interface.c */
320
321 BOOL
322 DestroyDeviceInterface(
323 struct DeviceInterface* deviceInterface);
324
325 LONG
326 SETUP_CreateInterfaceList(
327 struct DeviceInfoSet *list,
328 PCWSTR MachineName,
329 CONST GUID *InterfaceGuid,
330 PCWSTR DeviceInstanceW /* OPTIONAL */,
331 BOOL OnlyPresentInterfaces);
332
333 /* misc.c */
334
335 DWORD
336 GetFunctionPointer(
337 IN PWSTR InstallerName,
338 OUT HMODULE* ModulePointer,
339 OUT PVOID* FunctionPointer);
340
341 DWORD
342 FreeFunctionPointer(
343 IN HMODULE ModulePointer,
344 IN PVOID FunctionPointer);
345
346 DWORD
347 WINAPI
348 pSetupStringFromGuid(LPGUID lpGUID, PWSTR pString, DWORD dwStringLen);
349
350 DWORD WINAPI CaptureAndConvertAnsiArg(LPCSTR pSrc, LPWSTR *pDst);
351
352 VOID WINAPI MyFree(LPVOID lpMem);
353 LPVOID WINAPI MyMalloc(DWORD dwSize);
354 LPVOID WINAPI MyRealloc(LPVOID lpSrc, DWORD dwSize);
355 LPWSTR WINAPI DuplicateString(LPCWSTR lpSrc);
356 BOOL WINAPI IsUserAdmin(VOID);
357 LPWSTR WINAPI MultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage);
358 LPSTR WINAPI UnicodeToMultiByte(LPCWSTR lpUnicodeStr, UINT uCodePage);
359
360 /* parser.c */
361
362 typedef BOOL (*FIND_CALLBACK)(LPCWSTR SectionName, PVOID Context);
363 BOOL EnumerateSectionsStartingWith(HINF hInf, LPCWSTR pStr, FIND_CALLBACK Callback, PVOID Context);
364
365 #endif /* __SETUPAPI_PRIVATE_H */