From: Hans Leidekker hans@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57119 --- dlls/wmiutils/path.c | 32 +++++++++++++++++++++++++------- dlls/wmiutils/tests/path.c | 14 ++++++++++++-- 2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/dlls/wmiutils/path.c b/dlls/wmiutils/path.c index 152f933e3a6..f6d8bff0fda 100644 --- a/dlls/wmiutils/path.c +++ b/dlls/wmiutils/path.c @@ -472,7 +472,7 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text ) } if (*q == ':') q++; p = q; - while (*q && *q != '.') q++; + while (*q && *q != '.' && *q != '=') q++; len = q - p; if (!(path->class = malloc( (len + 1) * sizeof(WCHAR) ))) goto done; memcpy( path->class, p, len * sizeof(WCHAR) ); @@ -500,6 +500,13 @@ static HRESULT parse_text( struct path *path, ULONG mode, const WCHAR *text ) i++; } } + else if (*q == '=') + { + path->num_keys = 1; + if (!(path->keys = calloc( path->num_keys, sizeof(struct key) ))) goto done; + hr = parse_key( &path->keys[0], q, &len ); + if (hr != S_OK) goto done; + } hr = S_OK;
done: @@ -643,12 +650,14 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len ) lstrcpyW( ret, namespace ); if (path->len_class) { + unsigned int offset = len_namespace + path->len_class + 1; + ret[len_namespace] = ':'; lstrcpyW( ret + len_namespace + 1, path->class ); if (path->num_keys) { - ret[len_namespace + path->len_class + 1] = '.'; - lstrcpyW( ret + len_namespace + path->len_class + 2, keylist ); + if (*keylist != '=') ret[offset++] = '.'; + lstrcpyW( ret + offset, keylist ); } } free( namespace ); @@ -674,8 +683,10 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len ) lstrcpyW( ret, path->class ); if (path->num_keys) { - ret[path->len_class] = '.'; - lstrcpyW( ret + path->len_class + 1, keylist ); + unsigned int offset = path->len_class; + + if (*keylist != '=') ret[offset++] = '.'; + lstrcpyW( ret + offset, keylist ); } free( keylist ); return ret; @@ -717,8 +728,10 @@ static WCHAR *build_path( struct path *path, LONG flags, int *len ) lstrcpyW( p, path->class ); if (path->num_keys) { - p[path->len_class] = '.'; - lstrcpyW( p + path->len_class + 1, keylist ); + unsigned int offset = path->len_class; + + if (*keylist != '=') p[offset++] = '.'; + lstrcpyW( p + offset, keylist ); } } free( namespace ); @@ -833,7 +846,12 @@ static HRESULT WINAPI path_GetInfo( { *response |= WBEMPATH_INFO_HAS_SUBSCOPES; if (path->num_keys) + { + unsigned int i; + for (i = 0; i < path->num_keys; i++) + if (!path->keys[i].name[0]) *response |= WBEMPATH_INFO_HAS_IMPLIED_KEY; *response |= WBEMPATH_INFO_IS_INST_REF; + } else *response |= WBEMPATH_INFO_IS_CLASS_REF; } diff --git a/dlls/wmiutils/tests/path.c b/dlls/wmiutils/tests/path.c index 879d86af32e..c7f47937a32 100644 --- a/dlls/wmiutils/tests/path.c +++ b/dlls/wmiutils/tests/path.c @@ -506,8 +506,7 @@ static void test_IWbemPath_GetInfo(void) ok( hr == S_OK, "got %#lx\n", hr ); ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF | WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT | - WBEMPATH_INFO_CIM_COMPLIANT), - "got %s\n", wine_dbgstr_longlong(resp) ); + WBEMPATH_INFO_CIM_COMPLIANT), "got %s\n", wine_dbgstr_longlong(resp) );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 ); ok( hr == S_OK, "got %#lx\n", hr ); @@ -518,6 +517,17 @@ static void test_IWbemPath_GetInfo(void) ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY), "got %s\n", wine_dbgstr_longlong(resp) );
+ hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, L"Win32_LogicalDisk="C:"" ); + ok( hr == S_OK, "got %#lx\n", hr ); + + resp = 0xdeadbeef; + hr = IWbemPath_GetInfo( path, 0, &resp ); + ok( hr == S_OK, "got %#lx\n", hr ); + ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF | + WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_HAS_IMPLIED_KEY | + WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT), + "got %s\n", wine_dbgstr_longlong(resp) ); + IWbemPath_Release( path ); }