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