2 * PROJECT: ReactOS system libraries
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/syssetup/classinst.c
5 * PURPOSE: Class installers
6 * PROGRAMMERS: Copyright 2006 Hervé Poussineau (hpoussin@reactos.org)
19 ComputerClassInstaller(
20 IN DI_FUNCTION InstallFunction
,
21 IN HDEVINFO DeviceInfoSet
,
22 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
24 switch (InstallFunction
)
27 DPRINT1("Install function %u ignored\n", InstallFunction
);
28 return ERROR_DI_DO_DEFAULT
;
38 CriticalDeviceCoInstaller(
39 IN DI_FUNCTION InstallFunction
,
40 IN HDEVINFO DeviceInfoSet
,
41 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
,
42 IN OUT PCOINSTALLER_CONTEXT_DATA Context
)
44 WCHAR szDeviceId
[256];
45 WCHAR szServiceName
[256];
46 WCHAR szClassGUID
[64];
48 HKEY hDriverKey
= NULL
;
49 HKEY hDatabaseKey
= NULL
, hDeviceKey
= NULL
;
52 DWORD dwError
= ERROR_SUCCESS
;
54 DPRINT("CriticalDeviceCoInstaller(%lu %p %p %p)\n",
55 InstallFunction
, DeviceInfoSet
, DeviceInfoData
, Context
);
57 if (InstallFunction
!= DIF_INSTALLDEVICE
)
60 /* Get the MatchingDeviceId property */
61 hDriverKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
67 if (hDriverKey
== INVALID_HANDLE_VALUE
)
69 if (Context
->PostProcessing
)
71 dwError
= GetLastError();
72 DPRINT1("Failed to open the driver key! (Error %lu)\n", dwError
);
77 DPRINT("Failed to open the driver key! Postprocessing required!\n");
78 return ERROR_DI_POSTPROCESSING_REQUIRED
;
82 dwRequiredSize
= sizeof(szDeviceId
);
83 dwError
= RegQueryValueExW(hDriverKey
,
89 RegCloseKey(hDriverKey
);
90 if (dwError
!= ERROR_SUCCESS
)
92 if (Context
->PostProcessing
)
94 dwError
= GetLastError();
95 DPRINT1("Failed to read the MatchingDeviceId value! (Error %lu)\n", dwError
);
100 DPRINT("Failed to read the MatchingDeviceId value! Postprocessing required!\n");
101 return ERROR_DI_POSTPROCESSING_REQUIRED
;
105 DPRINT("MatchingDeviceId: %S\n", szDeviceId
);
107 /* Get the ClassGUID property */
109 if (!SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet
,
117 if (Context
->PostProcessing
)
119 dwError
= GetLastError();
120 DPRINT1("Failed to read the ClassGUID! (Error %lu)\n", dwError
);
125 DPRINT("Failed to read the ClassGUID! Postprocessing required!\n");
126 return ERROR_DI_POSTPROCESSING_REQUIRED
;
130 DPRINT("ClassGUID %S\n", szClassGUID
);
132 /* Get the Service property (optional) */
134 if (!SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet
,
138 (PBYTE
)szServiceName
,
139 sizeof(szServiceName
),
142 if (Context
->PostProcessing
)
144 dwError
= GetLastError();
145 if (dwError
!= ERROR_FILE_NOT_FOUND
)
147 DPRINT1("Failed to read the Service name! (Error %lu)\n", dwError
);
152 szServiceName
[0] = UNICODE_NULL
;
153 dwError
= ERROR_SUCCESS
;
158 DPRINT("Failed to read the Service name! Postprocessing required!\n");
159 return ERROR_DI_POSTPROCESSING_REQUIRED
;
163 DPRINT("Service %S\n", szServiceName
);
165 /* Replace the first backslash by a number sign */
166 Ptr
= wcschr(szDeviceId
, L
'\\');
171 /* Terminate the device id at the second backslash */
172 Ptr
= wcschr(Ptr
, L
'\\');
177 DPRINT("DeviceId: %S\n", szDeviceId
);
179 /* Open the critical device database key */
180 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
181 L
"SYSTEM\\CurrentControlSet\\Control\\CriticalDeviceDatabase",
185 if (dwError
!= ERROR_SUCCESS
)
187 DPRINT1("RegOpenKeyExW failed (Error %lu)\n", dwError
);
191 /* Create a new key for the device */
192 dwError
= RegCreateKeyExW(hDatabaseKey
,
196 REG_OPTION_NON_VOLATILE
,
201 if (dwError
!= ERROR_SUCCESS
)
203 DPRINT1("RegCreateKeyExW failed (Error %lu)\n", dwError
);
207 /* Set the ClassGUID value */
208 dwError
= RegSetValueExW(hDeviceKey
,
213 (wcslen(szClassGUID
) + 1) * sizeof(WCHAR
));
214 if (dwError
!= ERROR_SUCCESS
)
216 DPRINT1("RegSetValueExW failed (Error %lu)\n", dwError
);
220 /* If available, set the Service value */
221 if (szServiceName
[0] != UNICODE_NULL
)
223 dwError
= RegSetValueExW(hDeviceKey
,
227 (PBYTE
)szServiceName
,
228 (wcslen(szServiceName
) + 1) * sizeof(WCHAR
));
229 if (dwError
!= ERROR_SUCCESS
)
231 DPRINT1("RegSetValueExW failed (Error %lu)\n", dwError
);
237 if (hDeviceKey
!= NULL
)
238 RegCloseKey(hDeviceKey
);
240 if (hDatabaseKey
!= NULL
)
241 RegCloseKey(hDatabaseKey
);
243 DPRINT("CriticalDeviceCoInstaller() done (Error %lu)\n", dwError
);
254 DeviceBayClassInstaller(
255 IN DI_FUNCTION InstallFunction
,
256 IN HDEVINFO DeviceInfoSet
,
257 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
259 switch (InstallFunction
)
262 DPRINT("Install function %u ignored\n", InstallFunction
);
263 return ERROR_DI_DO_DEFAULT
;
273 EisaUpHalCoInstaller(
274 IN DI_FUNCTION InstallFunction
,
275 IN HDEVINFO DeviceInfoSet
,
276 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
,
277 IN OUT PCOINSTALLER_CONTEXT_DATA Context
)
279 switch (InstallFunction
)
282 DPRINT1("Install function %u ignored\n", InstallFunction
);
283 return ERROR_SUCCESS
;
294 IN DI_FUNCTION InstallFunction
,
295 IN HDEVINFO DeviceInfoSet
,
296 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
298 DPRINT("HdcClassInstaller()\n");
299 return ERROR_DI_DO_DEFAULT
;
308 KeyboardClassInstaller(
309 IN DI_FUNCTION InstallFunction
,
310 IN HDEVINFO DeviceInfoSet
,
311 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
313 switch (InstallFunction
)
316 DPRINT("Install function %u ignored\n", InstallFunction
);
317 return ERROR_DI_DO_DEFAULT
;
328 IN DI_FUNCTION InstallFunction
,
329 IN HDEVINFO DeviceInfoSet
,
330 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
332 switch (InstallFunction
)
335 DPRINT("Install function %u ignored\n", InstallFunction
);
336 return ERROR_DI_DO_DEFAULT
;
347 IN DI_FUNCTION InstallFunction
,
348 IN HDEVINFO DeviceInfoSet
,
349 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
351 switch (InstallFunction
)
354 DPRINT("Install function %u ignored\n", InstallFunction
);
355 return ERROR_DI_DO_DEFAULT
;
366 IN DI_FUNCTION InstallFunction
,
367 IN HDEVINFO DeviceInfoSet
,
368 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
370 switch (InstallFunction
)
373 DPRINT("Install function %u ignored\n", InstallFunction
);
374 return ERROR_DI_DO_DEFAULT
;
385 IN DI_FUNCTION InstallFunction
,
386 IN HDEVINFO DeviceInfoSet
,
387 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
,
388 IN OUT PCOINSTALLER_CONTEXT_DATA Context
)
390 switch (InstallFunction
)
393 DPRINT1("Install function %u ignored\n", InstallFunction
);
394 return ERROR_SUCCESS
;
405 IN DI_FUNCTION InstallFunction
,
406 IN HDEVINFO DeviceInfoSet
,
407 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
409 DPRINT("TapeClassInstaller()\n");
410 return ERROR_DI_DO_DEFAULT
;
419 VolumeClassInstaller(
420 IN DI_FUNCTION InstallFunction
,
421 IN HDEVINFO DeviceInfoSet
,
422 IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
424 DPRINT("VolumeClassInstaller()\n");
425 return ERROR_DI_DO_DEFAULT
;