mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
In DevInstallW:
- Shut up debug messages - First steps to display messages to the user (retrieve device description before and after device installation) - Change to only one exit point svn path=/trunk/; revision=18412
This commit is contained in:
parent
71552e4e2f
commit
15afaf3715
3 changed files with 99 additions and 66 deletions
|
@ -7,28 +7,34 @@
|
||||||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
|
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#include "newdev.h"
|
#include "newdev.h"
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
DevInstallW(
|
DevInstallW(
|
||||||
IN HWND Hwnd,
|
IN HWND hWndParent,
|
||||||
IN HINSTANCE Handle,
|
IN HINSTANCE hInstance,
|
||||||
IN LPCWSTR InstanceId,
|
IN LPCWSTR InstanceId,
|
||||||
IN INT Show)
|
IN INT Show)
|
||||||
{
|
{
|
||||||
HDEVINFO hDevInfo;
|
HDEVINFO hDevInfo;
|
||||||
SP_DEVINFO_DATA devInfoData;
|
SP_DEVINFO_DATA devInfoData;
|
||||||
SP_DRVINFO_DATA_W drvInfoData;
|
DWORD requiredSize;
|
||||||
DWORD index;
|
DWORD regDataType;
|
||||||
|
PTSTR buffer = NULL;
|
||||||
|
SP_DRVINFO_DATA drvInfoData;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
DPRINT1("Installing device %S\n", InstanceId);
|
devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
|
||||||
|
|
||||||
hDevInfo = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
|
hDevInfo = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
|
||||||
if (hDevInfo == INVALID_HANDLE_VALUE)
|
if (hDevInfo == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
ret = FALSE;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||||
|
@ -40,42 +46,66 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
devInfoData.cbSize = 0;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetLastError(ERROR_GEN_FAILURE);
|
||||||
|
ret = SetupDiGetDeviceRegistryProperty(
|
||||||
|
hDevInfo,
|
||||||
|
&devInfoData,
|
||||||
|
SPDRP_DEVICEDESC,
|
||||||
|
®DataType,
|
||||||
|
NULL, 0,
|
||||||
|
&requiredSize);
|
||||||
|
if (!ret && GetLastError() == ERROR_MORE_DATA && regDataType == REG_SZ)
|
||||||
|
{
|
||||||
|
buffer = HeapAlloc(GetProcessHeap(), 0, requiredSize);
|
||||||
|
if (!buffer)
|
||||||
|
{
|
||||||
|
DPRINT("HeapAlloc() failed\n");
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = SetupDiGetDeviceRegistryProperty(
|
||||||
|
hDevInfo,
|
||||||
|
&devInfoData,
|
||||||
|
SPDRP_DEVICEDESC,
|
||||||
|
®DataType,
|
||||||
|
buffer, requiredSize,
|
||||||
|
&requiredSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
DPRINT("SetupDiGetDeviceRegistryProperty() failed with error 0x%lx\n", GetLastError());
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Installing %s (%S)\n", buffer, InstanceId);
|
||||||
|
|
||||||
ret = SetupDiBuildDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER);
|
ret = SetupDiBuildDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
|
||||||
ret = TRUE;
|
ret = SetupDiEnumDriverInfo(
|
||||||
index = 0;
|
hDevInfo,
|
||||||
drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W);
|
&devInfoData,
|
||||||
while (ret)
|
SPDIT_COMPATDRIVER,
|
||||||
|
0,
|
||||||
|
&drvInfoData);
|
||||||
|
if (!ret)
|
||||||
{
|
{
|
||||||
ret = SetupDiEnumDriverInfoW(
|
DPRINT("SetupDiEnumDriverInfo() failed with error 0x%lx\n", GetLastError());
|
||||||
hDevInfo,
|
goto cleanup;
|
||||||
&devInfoData,
|
|
||||||
SPDIT_COMPATDRIVER,
|
|
||||||
index,
|
|
||||||
&drvInfoData);
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
if (GetLastError() != ERROR_NO_MORE_ITEMS)
|
|
||||||
{
|
|
||||||
DPRINT1("SetupDiEnumDriverInfoW() failed with error 0x%lx\n", GetLastError());
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
DPRINT1("- %S: %S\n", drvInfoData.MfgName, drvInfoData.Description);
|
|
||||||
}
|
}
|
||||||
#endif
|
DPRINT("Installing driver %s: %s\n", drvInfoData.MfgName, drvInfoData.Description);
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
DIF_SELECTBESTCOMPATDRV,
|
DIF_SELECTBESTCOMPATDRV,
|
||||||
|
@ -83,8 +113,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -93,8 +123,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -103,8 +133,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -113,8 +143,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -123,8 +153,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -133,8 +163,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -143,8 +173,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -153,8 +183,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -163,8 +193,8 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiCallClassInstaller(
|
ret = SetupDiCallClassInstaller(
|
||||||
|
@ -173,23 +203,25 @@ DevInstallW(
|
||||||
&devInfoData);
|
&devInfoData);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
|
DPRINT("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiDestroyDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER);
|
cleanup:
|
||||||
if (!ret)
|
if (devInfoData.cbSize != 0)
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
|
if (!SetupDiDestroyDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER))
|
||||||
return FALSE;
|
DPRINT("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SetupDiDestroyDeviceInfoList(hDevInfo);
|
if (hDevInfo != INVALID_HANDLE_VALUE)
|
||||||
if (!ret)
|
|
||||||
{
|
{
|
||||||
DPRINT1("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
|
if (!SetupDiDestroyDeviceInfoList(hDevInfo))
|
||||||
return FALSE;
|
DPRINT("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
if (buffer)
|
||||||
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,4 @@
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
|
|
||||||
ULONG DbgPrint(PCH Format,...);
|
ULONG DbgPrint(PCH Format,...);
|
||||||
#define UNIMPLEMENTED \
|
|
||||||
DbgPrint("NEWDEV: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__)
|
|
||||||
#define DPRINT1 DbgPrint("(%s:%d) ", __FILE__, __LINE__), DbgPrint
|
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
|
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#include "newdev.h"
|
#include "newdev.h"
|
||||||
|
|
||||||
BOOL WINAPI
|
BOOL WINAPI
|
||||||
|
|
Loading…
Reference in a new issue