0e8386cc1036b8c877e65bf6e7a746b80d1c4718
[reactos.git] / reactos / dll / win32 / setupapi / setupapi_private.h
1 /*
2 * Copyright 2001 Andreas Mohr
3 * Copyright 2005 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 <assert.h>
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <limits.h>
27 #include <share.h>
28 #include <wchar.h>
29
30 #define WIN32_NO_STATUS
31 #include <windows.h>
32 #include <cfgmgr32.h>
33 #include <fdi.h>
34 #include <regstr.h>
35 #include <setupapi.h>
36 #include <shlobj.h>
37 #include <wine/debug.h>
38 #include <wine/unicode.h>
39 #define NTOS_MODE_USER
40 #include <ndk/ntndk.h>
41
42 #include <pnp_c.h>
43 #include "rpc_private.h"
44 #include "resource.h"
45
46 #ifdef __REACTOS__
47 #undef __WINESRC__
48 #endif
49
50 #define SETUP_DEV_INFO_SET_MAGIC 0xd00ff057
51 #define SETUP_CLASS_IMAGE_LIST_MAGIC 0xd00ff058
52
53 struct DeviceInterface /* Element of DeviceInfoElement.InterfaceListHead */
54 {
55 LIST_ENTRY ListEntry;
56
57 struct DeviceInfoElement* DeviceInfo;
58 GUID InterfaceClassGuid;
59
60
61 /* SPINT_ACTIVE : the interface is active/enabled
62 * SPINT_DEFAULT: the interface is the default interface for the device class
63 * SPINT_REMOVED: the interface is removed
64 */
65 DWORD Flags;
66
67 WCHAR SymbolicLink[ANYSIZE_ARRAY]; /* \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */
68 };
69
70 /* We don't want to open the .inf file to read only one information in it, so keep a handle to it once it
71 * has been already loaded once. Keep also a reference counter */
72 struct InfFileDetails
73 {
74 HINF hInf;
75 LONG References;
76
77 /* Contains the directory name of the .inf file. This field may
78 * be NULL if the file is already in %SYSTEMROOT%\Inf.
79 * Points into szData at then end of the structure */
80 PCWSTR DirectoryName;
81 /* Contains the full file name of the .inf file. However, the directory
82 * part may be missing if the file is already in %SYSTEMROOT%\Inf.
83 * Points into szData at then end of the structure */
84 PCWSTR FullInfFileName;
85
86 WCHAR szData[ANYSIZE_ARRAY];
87 };
88
89 struct DriverInfoElement /* Element of DeviceInfoSet.DriverListHead and DeviceInfoElement.DriverListHead */
90 {
91 LIST_ENTRY ListEntry;
92
93 DWORD DriverRank;
94 ULARGE_INTEGER DriverDate;
95 SP_DRVINFO_DATA_V2_W Info;
96 SP_DRVINFO_DETAIL_DATA_W Details;
97 GUID ClassGuid;
98 LPWSTR MatchingId;
99 struct InfFileDetails *InfFileDetails;
100 };
101
102 struct ClassInstallParams
103 {
104 PSP_PROPCHANGE_PARAMS PropChange;
105 };
106
107 struct DeviceInfoElement /* Element of DeviceInfoSet.ListHead */
108 {
109 LIST_ENTRY ListEntry;
110 DEVINST dnDevInst; /* Used in CM_* functions */
111
112 /* Reserved Field points to a struct DriverInfoElement */
113 SP_DEVINSTALL_PARAMS_W InstallParams;
114
115 /* Information about devnode:
116 * - DeviceName:
117 * "Root\*PNP0501" for example.
118 * It doesn't contain the unique ID for the device
119 * (points into the Data field at the end of the structure)
120 * WARNING: no NULL char exist between DeviceName and UniqueId
121 * in Data field!
122 * - UniqueId
123 * "5&1be2108e&0" or "0000"
124 * If DICD_GENERATE_ID is specified in creation flags,
125 * this unique ID is autogenerated using 4 digits, base 10
126 * (points into the Data field at the end of the structure)
127 * - DeviceDescription
128 * String which identifies the device. Can be NULL. If not NULL,
129 * points into the Data field at the end of the structure
130 * - ClassGuid
131 * Identifies the class of this device. It is GUID_NULL if the
132 * device has not been installed
133 * - CreationFlags
134 * Is a combination of:
135 * - DICD_GENERATE_ID
136 * the unique ID needs to be generated
137 * - DICD_INHERIT_CLASSDRVS
138 * inherit driver of the device info set (== same pointer)
139 */
140 PCWSTR DeviceName;
141 PCWSTR UniqueId;
142 PCWSTR DeviceDescription;
143 GUID ClassGuid;
144 DWORD CreationFlags;
145
146 /* If CreationFlags contains DICD_INHERIT_CLASSDRVS, this list is invalid */
147 /* If the driver is not searched/detected, this list is empty */
148 LIST_ENTRY DriverListHead; /* List of struct DriverInfoElement */
149
150 /* List of interfaces implemented by this device */
151 LIST_ENTRY InterfaceListHead; /* List of struct DeviceInterface */
152
153 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
154 struct ClassInstallParams ClassInstallParams;
155
156 WCHAR Data[ANYSIZE_ARRAY];
157 };
158
159 struct DeviceInfoSet /* HDEVINFO */
160 {
161 DWORD magic; /* SETUP_DEV_INFO_SET_MAGIC */
162 GUID ClassGuid; /* If != GUID_NULL, only devices of this class can be in the device info set */
163 HKEY HKLM; /* Local or distant HKEY_LOCAL_MACHINE registry key */
164 HMACHINE hMachine; /* Used in CM_* functions */
165
166 /* Reserved Field points to a struct DriverInfoElement */
167 SP_DEVINSTALL_PARAMS_W InstallParams;
168
169 /* If the driver is not searched/detected, this list is empty */
170 LIST_ENTRY DriverListHead; /* List of struct DriverInfoElement */
171
172 LIST_ENTRY ListHead; /* List of struct DeviceInfoElement */
173 struct DeviceInfoElement *SelectedDevice;
174
175 /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */
176 struct ClassInstallParams ClassInstallParams;
177
178 /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
179 * or NULL if related to local machine. Points into szData field at the
180 * end of the structure */
181 PCWSTR MachineName;
182 WCHAR szData[ANYSIZE_ARRAY];
183 };
184
185 struct ClassImageList
186 {
187 DWORD magic; /* SETUP_CLASS_IMAGE_LIST_MAGIC */
188
189 /* Contains the name of the remote computer ('\\COMPUTERNAME' for example),
190 * or NULL if related to local machine. Points into szData field at the
191 * end of the structure */
192 PCWSTR MachineName;
193 WCHAR szData[ANYSIZE_ARRAY];
194 };
195
196 extern HINSTANCE hInstance;
197 #define RC_STRING_MAX_SIZE 256
198
199 #define REG_INSTALLEDFILES "System\\CurrentControlSet\\Control\\InstalledFiles"
200 #define REGPART_RENAME "\\Rename"
201 #define REG_VERSIONCONFLICT "Software\\Microsoft\\VersionConflictManager"
202
203 /* string substitutions */
204
205 struct inf_file;
206 extern const WCHAR *DIRID_get_string( int dirid );
207 extern const WCHAR *PARSER_get_inf_filename( HINF hinf );
208 extern unsigned int PARSER_string_substA( struct inf_file *file, const WCHAR *text,
209 char *buffer, unsigned int size );
210 extern unsigned int PARSER_string_substW( struct inf_file *file, const WCHAR *text,
211 WCHAR *buffer, unsigned int size );
212 extern WCHAR *PARSER_get_src_root( HINF hinf );
213 extern WCHAR *PARSER_get_dest_dir( INFCONTEXT *context );
214
215 /* support for Ascii queue callback functions */
216
217 struct callback_WtoA_context
218 {
219 void *orig_context;
220 PSP_FILE_CALLBACK_A orig_handler;
221 };
222
223 UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, UINT_PTR, UINT_PTR );
224
225 /* from msvcrt/sys/stat.h */
226 #define _S_IWRITE 0x0080
227 #define _S_IREAD 0x0100
228
229 extern HINSTANCE hInstance;
230 extern OSVERSIONINFOW OsVersionInfo;
231
232 DWORD WINAPI CaptureAndConvertAnsiArg(LPCSTR pSrc, LPWSTR *pDst);
233
234 BOOL GetStringField( PINFCONTEXT context, DWORD index, PWSTR *value);
235
236 typedef BOOL (*FIND_CALLBACK)(LPCWSTR SectionName, PVOID Context);
237 BOOL EnumerateSectionsStartingWith(HINF hInf, LPCWSTR pStr, FIND_CALLBACK Callback, PVOID Context);
238
239 #endif /* __SETUPAPI_PRIVATE_H */