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
Modified: trunk/reactos/lib/newdev/newdev.c
Modified: trunk/reactos/lib/newdev/newdev.h
Modified: trunk/reactos/lib/newdev/stubs.c
_____
Modified: trunk/reactos/lib/newdev/newdev.c
--- trunk/reactos/lib/newdev/newdev.c 2005-10-12 14:07:49 UTC (rev
18411)
+++ trunk/reactos/lib/newdev/newdev.c 2005-10-12 16:54:34 UTC (rev
18412)
@@ -7,28 +7,34 @@
* PROGRAMMERS: HervÚ Poussineau (hpoussin(a)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 @@
&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,
+ ®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);
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)
+ drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
+ ret = SetupDiEnumDriverInfo(
+ hDevInfo,
+ &devInfoData,
+ SPDIT_COMPATDRIVER,
+ 0,
+ &drvInfoData);
+ if (!ret)
{
- ret = SetupDiEnumDriverInfoW(
- hDevInfo,
- &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);
+ DPRINT("SetupDiEnumDriverInfo() failed with error
0x%lx\n", GetLastError());
+ goto cleanup;
}
-#endif
+ DPRINT("Installing driver %s: %s\n", drvInfoData.MfgName,
drvInfoData.Description);
ret = SetupDiCallClassInstaller(
DIF_SELECTBESTCOMPATDRV,
@@ -83,8 +113,8 @@
&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 @@
&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 @@
&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 @@
&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 @@
&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 @@
&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 @@
&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 @@
&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 @@
&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 @@
&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;
}
_____
Modified: trunk/reactos/lib/newdev/newdev.h
--- trunk/reactos/lib/newdev/newdev.h 2005-10-12 14:07:49 UTC (rev
18411)
+++ trunk/reactos/lib/newdev/newdev.h 2005-10-12 16:54:34 UTC (rev
18412)
@@ -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
+
_____
Modified: trunk/reactos/lib/newdev/stubs.c
--- trunk/reactos/lib/newdev/stubs.c 2005-10-12 14:07:49 UTC (rev
18411)
+++ trunk/reactos/lib/newdev/stubs.c 2005-10-12 16:54:34 UTC (rev
18412)
@@ -7,6 +7,9 @@
* PROGRAMMERS: HervÚ Poussineau (hpoussin(a)reactos.org)
*/
+//#define NDEBUG
+#include <debug.h>
+
#include "newdev.h"
BOOL WINAPI