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