[PATCH 1/7] setupapi: Add a basic implementation of SetupDiInstallDevice().

Zebediah Figura z.figura12 at gmail.com
Fri May 24 23:33:52 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/setupapi/devinst.c     | 58 ++++++++++++++++++++++++++++++++++++-
 dlls/setupapi/setupapi.spec |  2 +-
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 23707dc7d84..0919eec198e 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -3725,8 +3725,9 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP
             return SetupDiInstallDriverFiles(devinfo, device_data);
         case DIF_INSTALLINTERFACES:
             return SetupDiInstallDeviceInterfaces(devinfo, device_data);
-        case DIF_FINISHINSTALL_ACTION:
         case DIF_INSTALLDEVICE:
+            return SetupDiInstallDevice(devinfo, device_data);
+        case DIF_FINISHINSTALL_ACTION:
         case DIF_PROPERTYCHANGE:
         case DIF_SELECTDEVICE:
         case DIF_UNREMOVE:
@@ -4718,3 +4719,58 @@ BOOL WINAPI SetupDiInstallDriverFiles(HDEVINFO devinfo, SP_DEVINFO_DATA *device_
     SetupCloseInfFile(hinf);
     return TRUE;
 }
+
+/***********************************************************************
+ *              SetupDiInstallDevice (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiInstallDevice(HDEVINFO devinfo, SP_DEVINFO_DATA *device_data)
+{
+    WCHAR section[LINE_LEN], section_ext[LINE_LEN];
+    UINT install_flags = SPINST_ALL;
+    struct device *device;
+    struct driver *driver;
+    void *callback_ctx;
+    HKEY driver_key;
+    INFCONTEXT ctx;
+    HINF hinf;
+    LONG l;
+
+    TRACE("devinfo %p, device_data %p.\n", devinfo, device_data);
+
+    if (!(device = get_device(devinfo, device_data)))
+        return FALSE;
+
+    if (!(driver = device->selected_driver))
+    {
+        ERR("No driver selected for device %p.\n", devinfo);
+        SetLastError(ERROR_NO_DRIVER_SELECTED);
+        return FALSE;
+    }
+
+    if ((hinf = SetupOpenInfFileW(driver->inf_path, NULL, INF_STYLE_WIN4, NULL)) == INVALID_HANDLE_VALUE)
+        return FALSE;
+
+    SetupFindFirstLineW(hinf, driver->mfg_key, driver->description, &ctx);
+    SetupGetStringFieldW(&ctx, 1, section, ARRAY_SIZE(section), NULL);
+    SetupDiGetActualSectionToInstallW(hinf, section, section_ext, ARRAY_SIZE(section_ext), NULL, NULL);
+
+    if ((l = create_driver_key(device, &driver_key)))
+    {
+        SetLastError(l);
+        SetupCloseInfFile(hinf);
+        return FALSE;
+    }
+
+    if (device->params.Flags & DI_NOFILECOPY)
+        install_flags &= ~SPINST_FILES;
+
+    callback_ctx = SetupInitDefaultQueueCallback(NULL);
+
+    SetupInstallFromInfSectionW(NULL, hinf, section_ext, install_flags, driver_key, NULL,
+            SP_COPY_NEWER_ONLY, SetupDefaultQueueCallbackW, callback_ctx, NULL, NULL);
+
+    SetupTermDefaultQueueCallback(callback_ctx);
+    SetupCloseInfFile(hinf);
+    RegCloseKey(driver_key);
+    return TRUE;
+}
diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec
index 9ecff232d8f..eee83075fd1 100644
--- a/dlls/setupapi/setupapi.spec
+++ b/dlls/setupapi/setupapi.spec
@@ -366,7 +366,7 @@
 @ stub SetupDiInstallClassExA
 @ stub SetupDiInstallClassExW
 @ stdcall SetupDiInstallClassW(long wstr long ptr)
-@ stub SetupDiInstallDevice
+@ stdcall SetupDiInstallDevice(ptr ptr)
 @ stdcall SetupDiInstallDeviceInterfaces(ptr ptr)
 @ stdcall SetupDiInstallDriverFiles(ptr ptr)
 @ stdcall SetupDiLoadClassIcon(ptr ptr ptr)
-- 
2.21.0




More information about the wine-devel mailing list