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:
Hervé Poussineau 2005-10-12 16:54:34 +00:00
parent 71552e4e2f
commit 15afaf3715
3 changed files with 99 additions and 66 deletions

View file

@ -7,28 +7,34 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/
#define NDEBUG
#include <debug.h>
#include "newdev.h"
BOOL WINAPI
DevInstallW(
IN HWND Hwnd,
IN HINSTANCE Handle,
IN HWND hWndParent,
IN HINSTANCE hInstance,
IN LPCWSTR InstanceId,
IN INT Show)
{
HDEVINFO hDevInfo;
SP_DEVINFO_DATA devInfoData;
SP_DRVINFO_DATA_W drvInfoData;
DWORD index;
DWORD requiredSize;
DWORD regDataType;
PTSTR buffer = NULL;
SP_DRVINFO_DATA drvInfoData;
BOOL ret;
DPRINT1("Installing device %S\n", InstanceId);
devInfoData.cbSize = 0; /* Tell if the devInfoData is valid */
hDevInfo = SetupDiCreateDeviceInfoListExW(NULL, NULL, NULL, NULL);
if (hDevInfo == INVALID_HANDLE_VALUE)
{
DPRINT1("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCreateDeviceInfoListExW() failed with error 0x%lx\n", GetLastError());
ret = FALSE;
goto cleanup;
}
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
@ -40,42 +46,66 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiOpenDeviceInfoW() failed with error 0x%lx\n", GetLastError());
devInfoData.cbSize = 0;
goto cleanup;
}
SetLastError(ERROR_GEN_FAILURE);
ret = SetupDiGetDeviceRegistryProperty(
hDevInfo,
&devInfoData,
SPDRP_DEVICEDESC,
&regDataType,
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,
&regDataType,
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);
if (!ret)
{
DPRINT1("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
#ifndef NDEBUG
ret = TRUE;
index = 0;
drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA_W);
while (ret)
{
ret = SetupDiEnumDriverInfoW(
drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
ret = SetupDiEnumDriverInfo(
hDevInfo,
&devInfoData,
SPDIT_COMPATDRIVER,
index,
0,
&drvInfoData);
if (!ret)
{
if (GetLastError() != ERROR_NO_MORE_ITEMS)
{
DPRINT1("SetupDiEnumDriverInfoW() failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiEnumDriverInfo() failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
break;
}
index++;
DPRINT1("- %S: %S\n", drvInfoData.MfgName, drvInfoData.Description);
}
#endif
DPRINT("Installing driver %s: %s\n", drvInfoData.MfgName, drvInfoData.Description);
ret = SetupDiCallClassInstaller(
DIF_SELECTBESTCOMPATDRV,
@ -83,8 +113,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_SELECTBESTCOMPATDRV) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -93,8 +123,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_ALLOW_INSTALL) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -103,8 +133,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_PREANALYZE) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -113,8 +143,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_POSTANALYZE) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -123,8 +153,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -133,8 +163,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -143,8 +173,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_INSTALLINTERFACES) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -153,8 +183,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_INSTALLDEVICE) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -163,8 +193,8 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_NEWDEVICEWIZARD_FINISHINSTALL) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiCallClassInstaller(
@ -173,23 +203,25 @@ DevInstallW(
&devInfoData);
if (!ret)
{
DPRINT1("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
return FALSE;
DPRINT("SetupDiCallClassInstaller(DIF_DESTROYPRIVATEDATA) failed with error 0x%lx\n", GetLastError());
goto cleanup;
}
ret = SetupDiDestroyDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER);
if (!ret)
cleanup:
if (devInfoData.cbSize != 0)
{
DPRINT1("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
return FALSE;
if (!SetupDiDestroyDriverInfoList(hDevInfo, &devInfoData, SPDIT_COMPATDRIVER))
DPRINT("SetupDiDestroyDriverInfoList() failed with error 0x%lx\n", GetLastError());
}
ret = SetupDiDestroyDeviceInfoList(hDevInfo);
if (!ret)
if (hDevInfo != INVALID_HANDLE_VALUE)
{
DPRINT1("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
return FALSE;
if (!SetupDiDestroyDeviceInfoList(hDevInfo))
DPRINT("SetupDiDestroyDeviceInfoList() failed with error 0x%lx\n", GetLastError());
}
return TRUE;
if (buffer)
HeapFree(GetProcessHeap(), 0, buffer);
return ret;
}

View file

@ -2,6 +2,4 @@
#include <setupapi.h>
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

View file

@ -7,6 +7,9 @@
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/
//#define NDEBUG
#include <debug.h>
#include "newdev.h"
BOOL WINAPI