Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/hnetcfg/tests/policy.c | 52 ++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/dlls/hnetcfg/tests/policy.c b/dlls/hnetcfg/tests/policy.c index 4ee19d8..012bbcd 100644 --- a/dlls/hnetcfg/tests/policy.c +++ b/dlls/hnetcfg/tests/policy.c @@ -105,48 +105,42 @@ static void test_interfaces(void) static void test_NetFwAuthorizedApplication(void) { INetFwAuthorizedApplication *app; + static WCHAR empty[] = {0}; + WCHAR image[MAX_PATH]; HRESULT hr; + BSTR bstr;
hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_INetFwAuthorizedApplication, (void**)&app); ok(hr == S_OK, "got: %08x\n", hr); - if(hr == S_OK) - { - BSTR image = SysAllocStringLen( NULL, MAX_PATH ); - static WCHAR empty[] = {0}; - BSTR bstr;
- if (!GetModuleFileNameW( NULL, image, MAX_PATH )) - { - ok(0, "Failed to get filename\n"); - SysFreeString( image ); - return; - } + hr = GetModuleFileNameW(NULL, image, sizeof(image)); + ok(hr, "GetModuleFileName failed: %u\n", GetLastError());
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL); - ok(hr == E_POINTER, "got: %08x\n", hr); + hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL); + ok(hr == E_POINTER, "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr); - ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr); - ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr)); + hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr); + ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr); + ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr));
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL); - ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr); + hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL); + ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty); - ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr); + hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty); + ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, image); - ok(hr == S_OK, "got: %08x\n", hr); + bstr = SysAllocString(image); + hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, bstr); + ok(hr == S_OK, "got: %08x\n", hr); + SysFreeString(bstr);
- 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)); - SysFreeString( bstr ); + 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)); + SysFreeString(bstr);
- SysFreeString( image ); - INetFwAuthorizedApplication_Release(app); - } + INetFwAuthorizedApplication_Release(app); }
START_TEST(policy)
Fixes test failures when running from virtual drive.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v2: add some changes I forgot to commit...
dlls/hnetcfg/Makefile.in | 2 +- dlls/hnetcfg/apps.c | 32 +++++++++++++++++++++++++++----- dlls/hnetcfg/tests/Makefile.in | 2 +- dlls/hnetcfg/tests/policy.c | 15 ++++++++++++++- 4 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/dlls/hnetcfg/Makefile.in b/dlls/hnetcfg/Makefile.in index 3744368..44c9cb5 100644 --- a/dlls/hnetcfg/Makefile.in +++ b/dlls/hnetcfg/Makefile.in @@ -1,5 +1,5 @@ MODULE = hnetcfg.dll -IMPORTS = oleaut32 ole32 advapi32 +IMPORTS = oleaut32 ole32 advapi32 mpr
C_SRCS = \ apps.c \ diff --git a/dlls/hnetcfg/apps.c b/dlls/hnetcfg/apps.c index fda714e..34ef108 100644 --- a/dlls/hnetcfg/apps.c +++ b/dlls/hnetcfg/apps.c @@ -29,6 +29,7 @@ #include "netfw.h"
#include "wine/debug.h" +#include "wine/heap.h" #include "wine/unicode.h" #include "hnetcfg_private.h"
@@ -263,18 +264,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);