From ff7a8116621fc755b47abcafa4462d01681eb517 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Tue, 2 May 2017 00:48:45 +0200
Subject: [PATCH] setupapi: Fix CabinetName passed to SPFILENOTIFY_CABINETINFO
 handler.

---
 dlls/setupapi/setupcab.c       |  5 +++--
 dlls/setupapi/tests/setupcab.c | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/setupapi/setupcab.c b/dlls/setupapi/setupcab.c
index 54c0256ee99..0146e575d41 100644
--- a/dlls/setupapi/setupcab.c
+++ b/dlls/setupapi/setupcab.c
@@ -297,7 +297,7 @@ static INT_PTR CDECL sc_FNNOTIFY_A(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION p
     TRACE("  Cabinet Set#: %d\n", pfdin->setID);
     TRACE("  Cabinet Cab#: %d\n", pfdin->iCabinet); */
     WARN("SPFILENOTIFY_CABINETINFO undocumented: guess implementation.\n");
-    ci.CabinetFile = phsc->most_recent_cabinet_name;
+    ci.CabinetFile = "";
     ci.CabinetPath = pfdin->psz3;
     ci.DiskName = pfdin->psz2;
     ci.SetId = pfdin->setID;
@@ -389,6 +389,7 @@ static INT_PTR CDECL sc_FNNOTIFY_A(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION p
 
 static INT_PTR CDECL sc_FNNOTIFY_W(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
 {
+  static const WCHAR emptyW[] = {0};
   FILE_IN_CABINET_INFO_W fici;
   PSC_HSC_W phsc;
   CABINET_INFO_W ci;
@@ -423,7 +424,7 @@ static INT_PTR CDECL sc_FNNOTIFY_W(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION p
     TRACE("  Cabinet Set#: %d\n", pfdin->setID);
     TRACE("  Cabinet Cab#: %d\n", pfdin->iCabinet); */
     WARN("SPFILENOTIFY_CABINETINFO undocumented: guess implementation.\n");
-    ci.CabinetFile = phsc->most_recent_cabinet_name;
+    ci.CabinetFile = emptyW;
     len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz3, -1, buf, MAX_PATH);
     if ((len > MAX_PATH) || (len <= 1))
       buf[0] = '\0';
diff --git a/dlls/setupapi/tests/setupcab.c b/dlls/setupapi/tests/setupcab.c
index 37254aa9621..e58d35fd8f0 100644
--- a/dlls/setupapi/tests/setupcab.c
+++ b/dlls/setupapi/tests/setupcab.c
@@ -314,8 +314,15 @@ static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification,
     switch (Notification)
     {
     case SPFILENOTIFY_CABINETINFO:
+    {
+        CABINET_INFO_A *info = (CABINET_INFO_A *)Param1;
+
+        ok(!strcmp(info->CabinetFile, ""),
+           "Expected empty CabinetFile, got \"%s\"\n", info->CabinetFile);
+
         index = 0;
         return NO_ERROR;
+    }
     case SPFILENOTIFY_FILEINCABINET:
     {
         FILE_IN_CABINET_INFO_A *info = (FILE_IN_CABINET_INFO_A *)Param1;
@@ -380,14 +387,22 @@ struct contextW
 static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification,
                                       UINT_PTR Param1, UINT_PTR Param2)
 {
+    static const WCHAR emptyW[] = {0};
     static int index;
     struct contextW *ctx = Context;
 
     switch (Notification)
     {
     case SPFILENOTIFY_CABINETINFO:
+    {
+        CABINET_INFO_W *info = (CABINET_INFO_W *)Param1;
+
+        ok(!lstrcmpW(info->CabinetFile, emptyW),
+           "Expected empty CabinetFile, got %s\n", wine_dbgstr_w(info->CabinetFile));
+
         index = 0;
         return NO_ERROR;
+    }
     case SPFILENOTIFY_FILEINCABINET:
     {
         FILE_IN_CABINET_INFO_W *info = (FILE_IN_CABINET_INFO_W *)Param1;
-- 
2.17.1

