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