2 * Copyright 2001 Andreas Mohr
3 * Copyright 2005-2006 Hervé Poussineau
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.
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.
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
20 #ifndef __SETUPAPI_PRIVATE_H
21 #define __SETUPAPI_PRIVATE_H
25 #define WIN32_NO_STATUS
27 #define COM_NO_WINDOWS_H
50 #include <wine/unicode.h>
51 #define NTOS_MODE_USER
52 #include <ndk/rtlfuncs.h>
54 #include <wine/debug.h>
55 WINE_DEFAULT_DEBUG_CHANNEL(setupapi
);
63 #define SETUP_DEVICE_INFO_SET_MAGIC 0xd00ff057
64 #define SETUP_CLASS_IMAGE_LIST_MAGIC 0xd00ff058
66 #define CMP_MAGIC 0x01234567
68 struct DeviceInterface
/* Element of DeviceInfo.InterfaceListHead */
72 /* Link to is parent device */
73 struct DeviceInfo
*DeviceInfo
;
74 GUID InterfaceClassGuid
;
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
83 /* Contains the symbolic link of this interface, for example
84 * \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */
85 WCHAR SymbolicLink
[ANYSIZE_ARRAY
];
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 */
92 /* Handle to the .inf file */
94 /* Reference count to this object. Once it raises 0, the .inf file is
95 * automatically closed and this memory structure is deleted */
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 */
105 /* Variable size array (contains data for DirectoryName and FileName) */
106 WCHAR szData
[ANYSIZE_ARRAY
];
109 struct DriverInfoElement
/* Element of DeviceInfoSet.DriverListHead and DeviceInfo.DriverListHead */
111 LIST_ENTRY ListEntry
;
113 SP_DRVINSTALL_PARAMS Params
;
114 ULARGE_INTEGER DriverDate
;
115 SP_DRVINFO_DATA_V2_W Info
;
116 SP_DRVINFO_DETAIL_DATA_W Details
;
119 struct InfFileDetails
*InfFileDetails
;
122 struct ClassInstallParams
124 PSP_PROPCHANGE_PARAMS PropChangeParams
;
125 PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData
;
128 struct DeviceInfo
/* Element of DeviceInfoSet.ListHead */
130 LIST_ENTRY ListEntry
;
131 /* Used when dealing with CM_* functions */
134 /* Link to parent DeviceInfoSet */
135 struct DeviceInfoSet
*set
;
137 /* Reserved Field of SP_DEVINSTALL_PARAMS_W structure
138 * points to a struct DriverInfoElement */
139 SP_DEVINSTALL_PARAMS_W InstallParams
;
141 /* Information about devnode:
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
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
157 * Identifies the class of this device. It is GUID_NULL if the
158 * device has not been installed
160 * Is a combination of:
162 * the unique ID needs to be generated
163 * - DICD_INHERIT_CLASSDRVS
164 * inherit driver of the device info set (== same pointer)
168 PCWSTR DeviceDescription
;
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 */
176 /* List of interfaces implemented by this device */
177 LIST_ENTRY InterfaceListHead
; /* List of struct DeviceInterface */
179 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
180 struct ClassInstallParams ClassInstallParams
;
182 /* Device property page provider data */
183 HMODULE hmodDevicePropPageProvider
;
184 PVOID pDevicePropPageProvider
;
186 /* Variable size array (contains data for instanceId, UniqueId, DeviceDescription) */
187 WCHAR Data
[ANYSIZE_ARRAY
];
190 struct DeviceInfoSet
/* HDEVINFO */
192 DWORD magic
; /* SETUP_DEVICE_INFO_SET_MAGIC */
193 /* If != GUID_NULL, only devices of this class can be in the device info set */
195 /* Local or distant HKEY_LOCAL_MACHINE registry key */
197 /* Used when dealing with CM_* functions */
200 /* Reserved Field points to a struct DriverInfoElement */
201 SP_DEVINSTALL_PARAMS_W InstallParams
;
203 /* List of struct DriverInfoElement (if no driver has been
204 * searched/detected, this list is empty) */
205 LIST_ENTRY DriverListHead
;
207 /* List of struct DeviceInfo */
209 struct DeviceInfo
*SelectedDevice
;
211 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
212 struct ClassInstallParams ClassInstallParams
;
214 /* Class property page provider data */
215 HMODULE hmodClassPropPageProvider
;
216 PVOID pClassPropPageProvider
;
218 /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
219 * or NULL if related to local machine. Points into szData field at the
220 * end of the structure */
223 /* Variable size array (contains data for MachineName) */
224 WCHAR szData
[ANYSIZE_ARRAY
];
227 struct ClassImageList
229 DWORD magic
; /* SETUP_CLASS_IMAGE_LIST_MAGIC */
231 /* Number of GUIDs contained in Guids and IconIndexes arrays */
233 /* Array of GUIDs associated to icons of the image list. Its size
234 * is NumberOfGuids and is pointing after the end this structure */
236 /* Array of corresponding icons index in the image list. Its size
237 * is NumberOfGuids and is pointing after the end this structure */
241 struct FileLog
/* HSPFILELOG */
248 extern HINSTANCE hInstance
;
249 extern OSVERSIONINFOEXW OsVersionInfo
;
252 * See: https://msdn.microsoft.com/en-us/library/bb432397(v=vs.85).aspx
253 * for more information.
255 extern DWORD GlobalSetupFlags
;
256 #define PSPGF_NO_BACKUP 0x0002
257 #define PSPGF_NONINTERACTIVE 0x0004
259 #define RC_STRING_MAX_SIZE 256
261 #define REG_INSTALLEDFILES "System\\CurrentControlSet\\Control\\InstalledFiles"
262 #define REGPART_RENAME "\\Rename"
263 #define REG_VERSIONCONFLICT "Software\\Microsoft\\VersionConflictManager"
265 inline static WCHAR
*strdupAtoW( const char *str
)
270 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
271 if ((ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )))
272 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
277 /* string substitutions */
280 extern const WCHAR
*DIRID_get_string( int dirid
);
281 extern const WCHAR
*PARSER_get_inf_filename( HINF hinf
) DECLSPEC_HIDDEN
;
282 extern WCHAR
*PARSER_get_src_root( HINF hinf
) DECLSPEC_HIDDEN
;
283 extern WCHAR
*PARSER_get_dest_dir( INFCONTEXT
*context
) DECLSPEC_HIDDEN
;
285 /* support for Ascii queue callback functions */
287 struct callback_WtoA_context
290 PSP_FILE_CALLBACK_A orig_handler
;
293 UINT CALLBACK
QUEUE_callback_WtoA( void *context
, UINT notification
, UINT_PTR
, UINT_PTR
);
295 /* from msvcrt/sys/stat.h */
296 #define _S_IWRITE 0x0080
297 #define _S_IREAD 0x0100
303 IN
struct DeviceInfoSet
*list
,
304 IN LPCWSTR InstancePath
,
305 IN LPCGUID pClassGuid
,
306 OUT
struct DeviceInfo
**pDeviceInfo
);
309 SETUP_CreateDevicesList(
310 IN OUT
struct DeviceInfoSet
*list
,
311 IN PCWSTR MachineName OPTIONAL
,
312 IN CONST GUID
*Class OPTIONAL
,
313 IN PCWSTR Enumerator OPTIONAL
);
315 HKEY
SETUPDI_OpenDevKey(HKEY RootKey
, struct DeviceInfo
*devInfo
, REGSAM samDesired
);
316 HKEY
SETUPDI_OpenDrvKey(HKEY RootKey
, struct DeviceInfo
*devInfo
, REGSAM samDesired
);
320 struct InfFileDetails
*
321 CreateInfFileDetails(
322 IN LPCWSTR FullInfFileName
);
325 DereferenceInfFile(struct InfFileDetails
* infFile
);
328 DestroyDriverInfoElement(struct DriverInfoElement
* driverInfo
);
333 GetStringField( PINFCONTEXT context
, DWORD index
, PWSTR
*value
);
338 DestroyDeviceInterface(
339 struct DeviceInterface
* deviceInterface
);
342 SETUP_CreateInterfaceList(
343 struct DeviceInfoSet
*list
,
345 CONST GUID
*InterfaceGuid
,
346 PCWSTR DeviceInstanceW
/* OPTIONAL */,
347 BOOL OnlyPresentInterfaces
);
353 IN PWSTR InstallerName
,
354 OUT HMODULE
* ModulePointer
,
355 OUT PVOID
* FunctionPointer
);
359 IN HMODULE ModulePointer
,
360 IN PVOID FunctionPointer
);
364 pSetupStringFromGuid(LPGUID lpGUID
, PWSTR pString
, DWORD dwStringLen
);
366 DWORD WINAPI
CaptureAndConvertAnsiArg(LPCSTR pSrc
, LPWSTR
*pDst
);
368 VOID WINAPI
MyFree(LPVOID lpMem
);
369 LPVOID WINAPI
MyMalloc(DWORD dwSize
);
370 LPVOID WINAPI
MyRealloc(LPVOID lpSrc
, DWORD dwSize
);
371 LPWSTR WINAPI
DuplicateString(LPCWSTR lpSrc
);
372 BOOL WINAPI
IsUserAdmin(VOID
);
373 LPWSTR WINAPI
MultiByteToUnicode(LPCSTR lpMultiByteStr
, UINT uCodePage
);
374 LPSTR WINAPI
UnicodeToMultiByte(LPCWSTR lpUnicodeStr
, UINT uCodePage
);
378 typedef BOOL (*FIND_CALLBACK
)(LPCWSTR SectionName
, PVOID Context
);
379 BOOL
EnumerateSectionsStartingWith(HINF hInf
, LPCWSTR pStr
, FIND_CALLBACK Callback
, PVOID Context
);
381 #endif /* __SETUPAPI_PRIVATE_H */