[PATCH 2/2] hnetcfg: Store the UNC path in INetFwAuthorizedApplication_put_ProcessImageFileName().

Zebediah Figura z.figura12 at gmail.com
Sat Jun 16 18:21:21 CDT 2018


Fixes test failures when running from virtual drive.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/hnetcfg/apps.c            | 31 ++++++++++++++++++++++++++-----
 dlls/hnetcfg/tests/Makefile.in |  2 +-
 dlls/hnetcfg/tests/policy.c    | 15 ++++++++++++++-
 3 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/dlls/hnetcfg/apps.c b/dlls/hnetcfg/apps.c
index fda714e..e3b6b36 100644
--- a/dlls/hnetcfg/apps.c
+++ b/dlls/hnetcfg/apps.c
@@ -263,18 +263,39 @@ static HRESULT WINAPI fw_app_get_ProcessImageFileName(
 }
 
 static HRESULT WINAPI fw_app_put_ProcessImageFileName(
-    INetFwAuthorizedApplication *iface,
-    BSTR imageFileName )
+    INetFwAuthorizedApplication *iface, BSTR image )
 {
     fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
+    UNIVERSAL_NAME_INFOW *info;
+    WCHAR *netpath;
+    DWORD res;
+    DWORD sz;
 
-    FIXME("%p, %s\n", This, debugstr_w(imageFileName));
+    FIXME("%p, %s\n", This, debugstr_w(image));
 
-    if (!imageFileName || !imageFileName[0])
+    if (!image || !image[0])
         return E_INVALIDARG;
 
+    sz = 0;
+    res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, NULL, &sz);
+    if (res == WN_MORE_DATA)
+    {
+        if (!(netpath = heap_alloc(sz)))
+            return E_OUTOFMEMORY;
+
+        info = (UNIVERSAL_NAME_INFOW *)&netpath;
+        res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+        if (res == NO_ERROR)
+        {
+            SysFreeString(This->filename);
+            This->filename = SysAllocString(info->lpUniversalName);
+        }
+        heap_free(netpath);
+        return HRESULT_FROM_WIN32(res);
+    }
+
     SysFreeString( This->filename );
-    This->filename = SysAllocString( imageFileName );
+    This->filename = SysAllocString(image);
     return This->filename ? S_OK : E_OUTOFMEMORY;
 }
 
diff --git a/dlls/hnetcfg/tests/Makefile.in b/dlls/hnetcfg/tests/Makefile.in
index 8315b4b..922370a 100644
--- a/dlls/hnetcfg/tests/Makefile.in
+++ b/dlls/hnetcfg/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = hnetcfg.dll
-IMPORTS   = ole32 uuid oleaut32 advapi32
+IMPORTS   = ole32 uuid oleaut32 advapi32 mpr
 
 C_SRCS = \
 	policy.c
diff --git a/dlls/hnetcfg/tests/policy.c b/dlls/hnetcfg/tests/policy.c
index 012bbcd..f2d1372 100644
--- a/dlls/hnetcfg/tests/policy.c
+++ b/dlls/hnetcfg/tests/policy.c
@@ -106,9 +106,12 @@ static void test_NetFwAuthorizedApplication(void)
 {
     INetFwAuthorizedApplication *app;
     static WCHAR empty[] = {0};
+    UNIVERSAL_NAME_INFOW *info;
+    WCHAR netpath[MAX_PATH];
     WCHAR image[MAX_PATH];
     HRESULT hr;
     BSTR bstr;
+    DWORD sz;
 
     hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
             &IID_INetFwAuthorizedApplication, (void**)&app);
@@ -135,9 +138,19 @@ static void test_NetFwAuthorizedApplication(void)
     ok(hr == S_OK, "got: %08x\n", hr);
     SysFreeString(bstr);
 
+    info = (UNIVERSAL_NAME_INFOW *)&netpath;
+    sz = sizeof(netpath);
+    hr = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+    if (hr != NO_ERROR)
+    {
+        info->lpUniversalName = netpath + sizeof(*info)/sizeof(WCHAR);
+        lstrcpyW(info->lpUniversalName, image);
+    }
+
     hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
     ok(hr == S_OK, "got: %08x\n", hr);
-    ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
+    ok(!lstrcmpW(bstr,info->lpUniversalName), "expected %s, got %s\n",
+        wine_dbgstr_w(info->lpUniversalName), wine_dbgstr_w(bstr));
     SysFreeString(bstr);
 
     INetFwAuthorizedApplication_Release(app);
-- 
2.7.4




More information about the wine-devel mailing list