Zebediah Figura : wineboot: Create a root-enumerated device object for winebus.

Alexandre Julliard julliard at winehq.org
Thu Nov 7 16:16:02 CST 2019


Module: wine
Branch: master
Commit: 9cf9483a4a0f33af6af0beb67395264f1c8ad259
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9cf9483a4a0f33af6af0beb67395264f1c8ad259

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Nov  6 23:54:59 2019 -0600

wineboot: Create a root-enumerated device object for winebus.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/wineboot/Makefile.in |  2 +-
 programs/wineboot/wineboot.c  | 55 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/programs/wineboot/Makefile.in b/programs/wineboot/Makefile.in
index eaea154057..3921fa9644 100644
--- a/programs/wineboot/Makefile.in
+++ b/programs/wineboot/Makefile.in
@@ -1,7 +1,7 @@
 MODULE    = wineboot.exe
 APPMODE   = -mconsole
 IMPORTS   = uuid advapi32
-DELAYIMPORTS = shell32 shlwapi version user32
+DELAYIMPORTS = shell32 shlwapi version user32 setupapi newdev
 
 EXTRADLLFLAGS = -mno-cygwin
 
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c
index 4dfbca5e2c..cd5c9505b3 100644
--- a/programs/wineboot/wineboot.c
+++ b/programs/wineboot/wineboot.c
@@ -69,6 +69,8 @@
 #include <shobjidl.h>
 #include <shlwapi.h>
 #include <shellapi.h>
+#include <setupapi.h>
+#include <newdev.h>
 #include "resource.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wineboot);
@@ -1121,6 +1123,57 @@ static HANDLE start_rundll32( const WCHAR *inf_path, BOOL wow64 )
     return pi.hProcess;
 }
 
+static void install_root_pnp_devices(void)
+{
+    static const struct
+    {
+        const char *name;
+        const char *hardware_id;
+        const char *infpath;
+    }
+    root_devices[] =
+    {
+        {"root\\wine\\winebus", "root\\winebus\0", "C:\\windows\\inf\\winebus.inf"},
+    };
+    SP_DEVINFO_DATA device = {sizeof(device)};
+    unsigned int i;
+    HDEVINFO set;
+
+    if ((set = SetupDiCreateDeviceInfoList( NULL, NULL )) == INVALID_HANDLE_VALUE)
+    {
+        WINE_ERR("Failed to create device info list, error %#x.\n", GetLastError());
+        return;
+    }
+
+    for (i = 0; i < ARRAY_SIZE(root_devices); ++i)
+    {
+        if (!SetupDiCreateDeviceInfoA( set, root_devices[i].name, &GUID_NULL, NULL, NULL, 0, &device))
+        {
+            if (GetLastError() != ERROR_DEVINST_ALREADY_EXISTS)
+                WINE_ERR("Failed to create device %s, error %#x.\n", debugstr_a(root_devices[i].name), GetLastError());
+            continue;
+        }
+
+        if (!SetupDiSetDeviceRegistryPropertyA(set, &device, SPDRP_HARDWAREID,
+                (const BYTE *)root_devices[i].hardware_id, (strlen(root_devices[i].hardware_id) + 2) * sizeof(WCHAR)))
+        {
+            WINE_ERR("Failed to set hardware id for %s, error %#x.\n", debugstr_a(root_devices[i].name), GetLastError());
+            continue;
+        }
+
+        if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE, set, &device))
+        {
+            WINE_ERR("Failed to register device %s, error %#x.\n", debugstr_a(root_devices[i].name), GetLastError());
+            continue;
+        }
+
+        if (!UpdateDriverForPlugAndPlayDevicesA(NULL, root_devices[i].hardware_id, root_devices[i].infpath, 0, NULL))
+            WINE_ERR("Failed to install drivers for %s, error %#x.\n", debugstr_a(root_devices[i].name), GetLastError());
+    }
+
+    SetupDiDestroyDeviceInfoList(set);
+}
+
 /* execute rundll32 on the wine.inf file if necessary */
 static void update_wineprefix( BOOL force )
 {
@@ -1164,6 +1217,8 @@ static void update_wineprefix( BOOL force )
             }
             DestroyWindow( hwnd );
         }
+        install_root_pnp_devices();
+
         WINE_MESSAGE( "wine: configuration in '%s' has been updated.\n", prettyprint_configdir() );
     }
 




More information about the wine-cvs mailing list