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