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
27 #define WIN32_NO_STATUS
29 #define COM_NO_WINDOWS_H
46 #include <wine/debug.h>
47 #include <wine/unicode.h>
48 #define NTOS_MODE_USER
49 #include <ndk/cmfuncs.h>
50 #include <ndk/obfuncs.h>
51 #include <ndk/rtlfuncs.h>
53 //#include <pseh/pseh2.h>
57 #include "rpc_private.h"
58 //#include "resource.h"
64 #define SETUP_DEVICE_INFO_SET_MAGIC 0xd00ff057
65 #define SETUP_CLASS_IMAGE_LIST_MAGIC 0xd00ff058
67 #define CMP_MAGIC 0x01234567
69 struct DeviceInterface
/* Element of DeviceInfo.InterfaceListHead */
73 /* Link to is parent device */
74 struct DeviceInfo
*DeviceInfo
;
75 GUID InterfaceClassGuid
;
78 /* SPINT_ACTIVE : the interface is active/enabled
79 * SPINT_DEFAULT: the interface is the default interface for the device class
80 * SPINT_REMOVED: the interface is removed
84 /* Contains the symbolic link of this interface, for example
85 * \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */
86 WCHAR SymbolicLink
[ANYSIZE_ARRAY
];
89 /* We don't want to open the .inf file to read only one information in it, so keep a handle to it once it
90 * has been already loaded once. Keep also a reference counter */
93 /* Handle to the .inf file */
95 /* Reference count to this object. Once it raises 0, the .inf file is
96 * automatically closed and this memory structure is deleted */
99 /* Contains the directory name of the .inf file.
100 * Points into szData at then end of the structure */
101 PCWSTR DirectoryName
;
102 /* Contains the .inf file name (without directory name).
103 * Points into szData at then end of the structure */
106 /* Variable size array (contains data for DirectoryName and FileName) */
107 WCHAR szData
[ANYSIZE_ARRAY
];
110 struct DriverInfoElement
/* Element of DeviceInfoSet.DriverListHead and DeviceInfo.DriverListHead */
112 LIST_ENTRY ListEntry
;
114 SP_DRVINSTALL_PARAMS Params
;
115 ULARGE_INTEGER DriverDate
;
116 SP_DRVINFO_DATA_V2_W Info
;
117 SP_DRVINFO_DETAIL_DATA_W Details
;
120 struct InfFileDetails
*InfFileDetails
;
123 struct ClassInstallParams
125 PSP_PROPCHANGE_PARAMS PropChangeParams
;
126 PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData
;
129 struct DeviceInfo
/* Element of DeviceInfoSet.ListHead */
131 LIST_ENTRY ListEntry
;
132 /* Used when dealing with CM_* functions */
135 /* Link to parent DeviceInfoSet */
136 struct DeviceInfoSet
*set
;
138 /* Reserved Field of SP_DEVINSTALL_PARAMS_W structure
139 * points to a struct DriverInfoElement */
140 SP_DEVINSTALL_PARAMS_W InstallParams
;
142 /* Information about devnode:
144 * "Root\*PNP0501" for example.
145 * It doesn't contain the unique ID for the device
146 * (points into the Data field at the end of the structure)
147 * WARNING: no NULL char exist between instanceId and UniqueId
150 * "5&1be2108e&0" or "0000"
151 * If DICD_GENERATE_ID is specified in creation flags,
152 * this unique ID is autogenerated using 4 digits, base 10
153 * (points into the Data field at the end of the structure)
154 * - DeviceDescription
155 * String which identifies the device. Can be NULL. If not NULL,
156 * points into the Data field at the end of the structure
158 * Identifies the class of this device. It is GUID_NULL if the
159 * device has not been installed
161 * Is a combination of:
163 * the unique ID needs to be generated
164 * - DICD_INHERIT_CLASSDRVS
165 * inherit driver of the device info set (== same pointer)
169 PCWSTR DeviceDescription
;
173 /* If CreationFlags contains DICD_INHERIT_CLASSDRVS, this list is invalid */
174 /* If the driver is not searched/detected, this list is empty */
175 LIST_ENTRY DriverListHead
; /* List of struct DriverInfoElement */
177 /* List of interfaces implemented by this device */
178 LIST_ENTRY InterfaceListHead
; /* List of struct DeviceInterface */
180 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
181 struct ClassInstallParams ClassInstallParams
;
183 /* Variable size array (contains data for instanceId, UniqueId, DeviceDescription) */
184 WCHAR Data
[ANYSIZE_ARRAY
];
187 struct DeviceInfoSet
/* HDEVINFO */
189 DWORD magic
; /* SETUP_DEVICE_INFO_SET_MAGIC */
190 /* If != GUID_NULL, only devices of this class can be in the device info set */
192 /* Local or distant HKEY_LOCAL_MACHINE registry key */
194 /* Used when dealing with CM_* functions */
197 /* Reserved Field points to a struct DriverInfoElement */
198 SP_DEVINSTALL_PARAMS_W InstallParams
;
200 /* List of struct DriverInfoElement (if no driver has been
201 * searched/detected, this list is empty) */
202 LIST_ENTRY DriverListHead
;
204 /* List of struct DeviceInfo */
206 struct DeviceInfo
*SelectedDevice
;
208 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
209 struct ClassInstallParams ClassInstallParams
;
211 /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
212 * or NULL if related to local machine. Points into szData field at the
213 * end of the structure */
216 /* Variable size array (contains data for MachineName) */
217 WCHAR szData
[ANYSIZE_ARRAY
];
220 struct ClassImageList
222 DWORD magic
; /* SETUP_CLASS_IMAGE_LIST_MAGIC */
224 /* Number of GUIDs contained in Guids and IconIndexes arrays */
226 /* Array of GUIDs associated to icons of the image list. Its size
227 * is NumberOfGuids and is pointing after the end this structure */
229 /* Array of corresponding icons index in the image list. Its size
230 * is NumberOfGuids and is pointing after the end this structure */
234 struct FileLog
/* HSPFILELOG */
241 extern HINSTANCE hInstance
;
242 #define RC_STRING_MAX_SIZE 256
244 #define REG_INSTALLEDFILES "System\\CurrentControlSet\\Control\\InstalledFiles"
245 #define REGPART_RENAME "\\Rename"
246 #define REG_VERSIONCONFLICT "Software\\Microsoft\\VersionConflictManager"
248 inline static WCHAR
*strdupAtoW( const char *str
)
253 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
254 if ((ret
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )))
255 MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
260 /* string substitutions */
263 extern const WCHAR
*DIRID_get_string( int dirid
);
264 extern unsigned int PARSER_string_substA( const struct inf_file
*file
, const WCHAR
*text
,
265 char *buffer
, unsigned int size
);
266 extern unsigned int PARSER_string_substW( const struct inf_file
*file
, const WCHAR
*text
,
267 WCHAR
*buffer
, unsigned int size
);
268 extern const WCHAR
*PARSER_get_inf_filename( HINF hinf
);
269 extern WCHAR
*PARSER_get_src_root( HINF hinf
);
270 extern WCHAR
*PARSER_get_dest_dir( INFCONTEXT
*context
);
272 /* support for Ascii queue callback functions */
274 struct callback_WtoA_context
277 PSP_FILE_CALLBACK_A orig_handler
;
280 UINT CALLBACK
QUEUE_callback_WtoA( void *context
, UINT notification
, UINT_PTR
, UINT_PTR
);
282 /* from msvcrt/sys/stat.h */
283 #define _S_IWRITE 0x0080
284 #define _S_IREAD 0x0100
286 extern HINSTANCE hInstance
;
287 extern OSVERSIONINFOW OsVersionInfo
;
293 IN
struct DeviceInfoSet
*list
,
294 IN LPCWSTR InstancePath
,
295 IN LPCGUID pClassGuid
,
296 OUT
struct DeviceInfo
**pDeviceInfo
);
299 SETUP_CreateDevicesList(
300 IN OUT
struct DeviceInfoSet
*list
,
301 IN PCWSTR MachineName OPTIONAL
,
302 IN CONST GUID
*Class OPTIONAL
,
303 IN PCWSTR Enumerator OPTIONAL
);
307 struct InfFileDetails
*
308 CreateInfFileDetails(
309 IN LPCWSTR FullInfFileName
);
312 DereferenceInfFile(struct InfFileDetails
* infFile
);
315 DestroyDriverInfoElement(struct DriverInfoElement
* driverInfo
);
320 GetStringField( PINFCONTEXT context
, DWORD index
, PWSTR
*value
);
325 DestroyDeviceInterface(
326 struct DeviceInterface
* deviceInterface
);
329 SETUP_CreateInterfaceList(
330 struct DeviceInfoSet
*list
,
332 CONST GUID
*InterfaceGuid
,
333 PCWSTR DeviceInstanceW
/* OPTIONAL */,
334 BOOL OnlyPresentInterfaces
);
340 IN PWSTR InstallerName
,
341 OUT HMODULE
* ModulePointer
,
342 OUT PVOID
* FunctionPointer
);
346 IN HMODULE ModulePointer
,
347 IN PVOID FunctionPointer
);
351 pSetupStringFromGuid(LPGUID lpGUID
, PWSTR pString
, DWORD dwStringLen
);
353 DWORD WINAPI
CaptureAndConvertAnsiArg(LPCSTR pSrc
, LPWSTR
*pDst
);
355 VOID WINAPI
MyFree(LPVOID lpMem
);
356 LPVOID WINAPI
MyMalloc(DWORD dwSize
);
357 LPVOID WINAPI
MyRealloc(LPVOID lpSrc
, DWORD dwSize
);
358 LPWSTR WINAPI
DuplicateString(LPCWSTR lpSrc
);
359 BOOL WINAPI
IsUserAdmin(VOID
);
360 LPWSTR WINAPI
MultiByteToUnicode(LPCSTR lpMultiByteStr
, UINT uCodePage
);
361 LPSTR WINAPI
UnicodeToMultiByte(LPCWSTR lpUnicodeStr
, UINT uCodePage
);
365 typedef BOOL (*FIND_CALLBACK
)(LPCWSTR SectionName
, PVOID Context
);
366 BOOL
EnumerateSectionsStartingWith(HINF hInf
, LPCWSTR pStr
, FIND_CALLBACK Callback
, PVOID Context
);
368 #endif /* __SETUPAPI_PRIVATE_H */