[WMIUTILS]

- Import from Wine 1.7.27 (or your choice of any later version)
CORE-9212 #resolve

svn path=/trunk/; revision=66335
This commit is contained in:
Thomas Faber 2015-02-17 15:07:56 +00:00
parent 51fd410d89
commit ddaa717558
18 changed files with 2888 additions and 0 deletions

View file

@ -237,6 +237,7 @@ add_subdirectory(wintrust)
add_subdirectory(wlanapi)
add_subdirectory(wldap32)
add_subdirectory(wmi)
add_subdirectory(wmiutils)
add_subdirectory(ws2_32)
add_subdirectory(ws2_32_new)
add_subdirectory(ws2help)

View file

@ -0,0 +1,17 @@
add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
spec2def(wmiutils.dll wmiutils.spec)
list(APPEND SOURCE
main.c
path.c
statuscode.c
${CMAKE_CURRENT_BINARY_DIR}/wmiutils.def)
add_library(wmiutils SHARED ${SOURCE} wmiutils.rc)
set_module_type(wmiutils win32dll)
target_link_libraries(wmiutils wine)
add_importlibs(wmiutils oleaut32 msvcrt kernel32 ntdll)
add_cd_file(TARGET wmiutils DESTINATION reactos/system32 FOR all)

View file

@ -0,0 +1,171 @@
/*
* Copyright 2009 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "initguid.h"
#include "objbase.h"
#include "wbemcli.h"
#include "wmiutils.h"
#include "rpcproxy.h"
#include "wine/debug.h"
#include "wmiutils_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wmiutils);
static HINSTANCE instance;
typedef HRESULT (*fnCreateInstance)( LPVOID *ppObj );
typedef struct
{
IClassFactory IClassFactory_iface;
fnCreateInstance pfnCreateInstance;
} wmiutils_cf;
static inline wmiutils_cf *impl_from_IClassFactory( IClassFactory *iface )
{
return CONTAINING_RECORD(iface, wmiutils_cf, IClassFactory_iface);
}
static HRESULT WINAPI wmiutils_cf_QueryInterface( IClassFactory *iface, REFIID riid, LPVOID *ppobj )
{
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IClassFactory))
{
IClassFactory_AddRef( iface );
*ppobj = iface;
return S_OK;
}
FIXME("interface %s not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI wmiutils_cf_AddRef( IClassFactory *iface )
{
return 2;
}
static ULONG WINAPI wmiutils_cf_Release( IClassFactory *iface )
{
return 1;
}
static HRESULT WINAPI wmiutils_cf_CreateInstance( IClassFactory *iface, LPUNKNOWN pOuter,
REFIID riid, LPVOID *ppobj )
{
wmiutils_cf *This = impl_from_IClassFactory( iface );
HRESULT r;
IUnknown *punk;
TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
*ppobj = NULL;
if (pOuter)
return CLASS_E_NOAGGREGATION;
r = This->pfnCreateInstance( (LPVOID *)&punk );
if (FAILED(r))
return r;
r = IUnknown_QueryInterface( punk, riid, ppobj );
IUnknown_Release( punk );
return r;
}
static HRESULT WINAPI wmiutils_cf_LockServer( IClassFactory *iface, BOOL dolock )
{
FIXME("(%p)->(%d)\n", iface, dolock);
return S_OK;
}
static const struct IClassFactoryVtbl wmiutils_cf_vtbl =
{
wmiutils_cf_QueryInterface,
wmiutils_cf_AddRef,
wmiutils_cf_Release,
wmiutils_cf_CreateInstance,
wmiutils_cf_LockServer
};
static wmiutils_cf status_code_cf = { { &wmiutils_cf_vtbl }, WbemStatusCodeText_create };
static wmiutils_cf path_cf = { { &wmiutils_cf_vtbl }, WbemPath_create };
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID lpv )
{
switch(reason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
instance = hinst;
DisableThreadLibraryCalls( hinst );
break;
}
return TRUE;
}
HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
{
IClassFactory *cf = NULL;
TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
if (IsEqualGUID( rclsid, &CLSID_WbemStatusCode ))
{
cf = &status_code_cf.IClassFactory_iface;
}
else if (IsEqualGUID( rclsid, &CLSID_WbemDefPath ))
{
cf = &path_cf.IClassFactory_iface;
}
if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
return IClassFactory_QueryInterface( cf, iid, ppv );
}
/***********************************************************************
* DllCanUnloadNow (WMIUTILS.@)
*/
HRESULT WINAPI DllCanUnloadNow( void )
{
return S_FALSE;
}
/***********************************************************************
* DllRegisterServer (WMIUTILS.@)
*/
HRESULT WINAPI DllRegisterServer(void)
{
return __wine_register_resources( instance );
}
/***********************************************************************
* DllUnregisterServer (WMIUTILS.@)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( instance );
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,150 @@
/*
* Copyright 2009 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "wbemcli.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "wmiutils_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wmiutils);
typedef struct status_code
{
IWbemStatusCodeText IWbemStatusCodeText_iface;
LONG refs;
} status_code;
static inline status_code *impl_from_IWbemStatusCodeText( IWbemStatusCodeText *iface )
{
return CONTAINING_RECORD(iface, status_code, IWbemStatusCodeText_iface);
}
static ULONG WINAPI status_code_AddRef(
IWbemStatusCodeText *iface )
{
status_code *status_code = impl_from_IWbemStatusCodeText( iface );
return InterlockedIncrement( &status_code->refs );
}
static ULONG WINAPI status_code_Release(
IWbemStatusCodeText *iface )
{
status_code *status_code = impl_from_IWbemStatusCodeText( iface );
LONG refs = InterlockedDecrement( &status_code->refs );
if (!refs)
{
TRACE("destroying %p\n", status_code);
heap_free( status_code );
}
return refs;
}
static HRESULT WINAPI status_code_QueryInterface(
IWbemStatusCodeText *iface,
REFIID riid,
void **ppvObject )
{
status_code *This = impl_from_IWbemStatusCodeText( iface );
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
if ( IsEqualGUID( riid, &IID_IWbemStatusCodeText ) ||
IsEqualGUID( riid, &IID_IUnknown ) )
{
*ppvObject = iface;
}
else
{
FIXME("interface %s not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
IWbemStatusCodeText_AddRef( iface );
return S_OK;
}
static HRESULT WINAPI status_code_GetErrorCodeText(
IWbemStatusCodeText *iface,
HRESULT res,
LCID lcid,
LONG flags,
BSTR *text )
{
static const WCHAR fmt[] =
{'E','r','r','o','r',' ','c','o','d','e',':',' ','0','x','%','0','8','x',0};
WCHAR msg[32];
FIXME("%p, 0x%08x, 0x%04x, 0x%08x, %p\n", iface, res, lcid, flags, text);
sprintfW(msg, fmt, res);
*text = SysAllocString(msg);
return WBEM_S_NO_ERROR;
}
static HRESULT WINAPI status_code_GetFacilityCodeText(
IWbemStatusCodeText *iface,
HRESULT res,
LCID lcid,
LONG flags,
BSTR *text )
{
static const WCHAR fmt[] =
{'F','a','c','i','l','i','t','y',' ','c','o','d','e',':',' ','0','x','%','0','8','x',0};
WCHAR msg[32];
FIXME("%p, 0x%08x, 0x%04x, 0x%08x, %p\n", iface, res, lcid, flags, text);
sprintfW(msg, fmt, res);
*text = SysAllocString(msg);
return WBEM_S_NO_ERROR;
}
static const struct IWbemStatusCodeTextVtbl status_code_vtbl =
{
status_code_QueryInterface,
status_code_AddRef,
status_code_Release,
status_code_GetErrorCodeText,
status_code_GetFacilityCodeText
};
HRESULT WbemStatusCodeText_create( LPVOID *ppObj )
{
status_code *sc;
TRACE("(%p)\n", ppObj);
if (!(sc = heap_alloc( sizeof(*sc) ))) return E_OUTOFMEMORY;
sc->IWbemStatusCodeText_iface.lpVtbl = &status_code_vtbl;
sc->refs = 1;
*ppObj = &sc->IWbemStatusCodeText_iface;
TRACE("returning iface %p\n", *ppObj);
return S_OK;
}

View file

@ -0,0 +1,2 @@
/* @makedep: wmiutils_classes.rgs */
1 WINE_REGISTRY wmiutils_classes.rgs

View file

@ -0,0 +1,4 @@
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()

View file

@ -0,0 +1,33 @@
/*
* COM Classes for wmiutils
*
* Copyright 2010 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep register
[
threading(both),
uuid(cf4cc405-e2c5-4ddd-b3ce-5e7582d8c9fa)
]
coclass WbemDefPath { interface IWbemPath; }
[
threading(both),
uuid(eb87e1bd-3233-11d2-aec9-00c04fb68820)
]
coclass WbemStatusCode { interface IWbemStatusCodeText; }

View file

@ -0,0 +1,17 @@
HKCR
{
NoRemove Interface
{
}
NoRemove CLSID
{
'{CF4CC405-E2C5-4DDD-B3CE-5E7582D8C9FA}' = s 'WbemDefPath'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
'{EB87E1BD-3233-11D2-AEC9-00C04FB68820}' = s 'WbemStatusCode'
{
InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' }
}
}
}

View file

@ -0,0 +1,53 @@
/*
* Copyright 2009 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/unicode.h"
HRESULT WbemPath_create(LPVOID *) DECLSPEC_HIDDEN;
HRESULT WbemStatusCodeText_create(LPVOID *) DECLSPEC_HIDDEN;
static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
static inline void *heap_alloc( size_t len )
{
return HeapAlloc( GetProcessHeap(), 0, len );
}
static void *heap_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
static inline void *heap_alloc_zero( size_t len )
{
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
}
static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
static inline void *heap_realloc( void *mem, size_t len )
{
return HeapReAlloc( GetProcessHeap(), 0, mem, len );
}
static inline BOOL heap_free( void *mem )
{
return HeapFree( GetProcessHeap(), 0, mem );
}
static inline WCHAR *strdupW( const WCHAR *src )
{
WCHAR *dst;
if (!src) return NULL;
if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
return dst;
}

View file

@ -121,6 +121,7 @@ list(APPEND SOURCE
wincodec.idl
wincodecsdk.idl
winsxs.idl
wmiutils.idl
wtypes.idl
wuapi.idl
xmldom.idl

View file

@ -0,0 +1,236 @@
/*
* Copyright 2012 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
import "oaidl.idl";
interface IWbemPath;
interface IWbemPathKeyList;
typedef [v1_enum] enum tag_WBEM_PATH_STATUS_FLAG
{
WBEMPATH_INFO_ANON_LOCAL_MACHINE = 0x1,
WBEMPATH_INFO_HAS_MACHINE_NAME = 0x2,
WBEMPATH_INFO_IS_CLASS_REF = 0x4,
WBEMPATH_INFO_IS_INST_REF = 0x8,
WBEMPATH_INFO_HAS_SUBSCOPES = 0x10,
WBEMPATH_INFO_IS_COMPOUND = 0x20,
WBEMPATH_INFO_HAS_V2_REF_PATHS = 0x40,
WBEMPATH_INFO_HAS_IMPLIED_KEY = 0x80,
WBEMPATH_INFO_CONTAINS_SINGLETON = 0x100,
WBEMPATH_INFO_V1_COMPLIANT = 0x200,
WBEMPATH_INFO_V2_COMPLIANT = 0x400,
WBEMPATH_INFO_CIM_COMPLIANT = 0x800,
WBEMPATH_INFO_IS_SINGLETON = 0x1000,
WBEMPATH_INFO_IS_PARENT = 0x2000,
WBEMPATH_INFO_SERVER_NAMESPACE_ONLY = 0x4000,
WBEMPATH_INFO_NATIVE_PATH = 0x8000,
WBEMPATH_INFO_WMI_PATH = 0x10000,
WBEMPATH_INFO_PATH_HAD_SERVER = 0x20000
} tag_WBEM_PATH_STATUS_FLAG;
typedef [v1_enum] enum tag_WBEM_PATH_CREATE_FLAG
{
WBEMPATH_CREATE_ACCEPT_RELATIVE = 0x1,
WBEMPATH_CREATE_ACCEPT_ABSOLUTE = 0x2,
WBEMPATH_CREATE_ACCEPT_ALL = 0x4,
WBEMPATH_TREAT_SINGLE_IDENT_AS_NS = 0x8
} tag_WBEM_PATH_CREATE_FLAG;
typedef [v1_enum] enum tag_WBEM_GET_TEXT_FLAGS
{
WBEMPATH_COMPRESSED = 0x1,
WBEMPATH_GET_RELATIVE_ONLY = 0x2,
WBEMPATH_GET_SERVER_TOO = 0x4,
WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY = 0x8,
WBEMPATH_GET_NAMESPACE_ONLY = 0x10,
WBEMPATH_GET_ORIGINAL = 0x20
} tag_WBEM_GET_TEXT_FLAGS;
[
local,
object,
uuid(9ae62877-7544-4bb0-aa26-a13824659ed6)
]
interface IWbemPathKeyList : IUnknown
{
HRESULT GetCount(
[out] ULONG *puKeyCount);
HRESULT SetKey(
[in,string] LPCWSTR wszName,
[in] ULONG uFlags,
[in] ULONG uCimType,
[in] LPVOID pKeyVal);
HRESULT SetKey2(
[in,string] LPCWSTR wszName,
[in] ULONG uFlags,
[in] ULONG uCimType,
[in] VARIANT *pKeyVal);
HRESULT GetKey(
[in] ULONG uKeyIx,
[in] ULONG uFlags,
[in,out] ULONG *puNameBufSize,
[in,out] LPWSTR pszKeyName,
[in,out] ULONG *puKeyValBufSize,
[in,out] LPVOID pKeyVal,
[out] ULONG *puApparentCimType);
HRESULT GetKey2(
[in] ULONG uKeyIx,
[in] ULONG uFlags,
[in,out] ULONG *puNameBufSize,
[in,out] LPWSTR pszKeyName,
[in,out] VARIANT *pKeyValue,
[out] ULONG *puApparentCimType);
HRESULT RemoveKey(
[in,string] LPCWSTR wszName,
[in] ULONG uFlags);
HRESULT RemoveAllKeys(
[in] ULONG uFlags);
HRESULT MakeSingleton([in] boolean bSet);
HRESULT GetInfo(
[in] ULONG uRequestedInfo,
[out] ULONGLONG *puResponse);
HRESULT GetText(
[in] long lFlags,
[in,out] ULONG *puBuffLength,
[in,out,string] LPWSTR pszText);
};
cpp_quote("#ifdef WINE_NO_UNICODE_MACROS")
cpp_quote("#undef GetClassName")
cpp_quote("#endif")
[
local,
object,
uuid(3bc15af2-736c-477e-9e51-238af8667dcc)
]
interface IWbemPath : IUnknown
{
HRESULT SetText(
[in] ULONG uMode,
[in] LPCWSTR pszPath);
HRESULT GetText(
[in] long lFlags,
[in,out] ULONG *puBuffLength,
[in,out,string] LPWSTR pszText);
HRESULT GetInfo(
[in] ULONG uRequestedInfo,
[out] ULONGLONG *puResponse);
HRESULT SetServer(
[in,string] LPCWSTR Name);
HRESULT GetServer(
[in,out] ULONG *puNameBufLength,
[in,out,string] LPWSTR pName);
HRESULT GetNamespaceCount(
[out] ULONG *puCount);
HRESULT SetNamespaceAt(
[in] ULONG uIndex,
[in,string] LPCWSTR pszName);
HRESULT GetNamespaceAt(
[in] ULONG uIndex,
[in,out] ULONG *puNameBufLength,
[in,out,string] LPWSTR pName);
HRESULT RemoveNamespaceAt(
[in] ULONG uIndex);
HRESULT RemoveAllNamespaces();
HRESULT GetScopeCount(
[out] ULONG *puCount);
HRESULT SetScope(
[in] ULONG uIndex,
[in] LPWSTR pszClass);
HRESULT SetScopeFromText(
[in] ULONG uIndex,
[in] LPWSTR pszText);
HRESULT GetScope(
[in] ULONG uIndex,
[in,out] ULONG *puClassNameBufSize,
[in,out] LPWSTR pszClass,
[out] IWbemPathKeyList **pKeyList);
HRESULT GetScopeAsText(
[in] ULONG uIndex,
[in,out] ULONG *puTextBufSize,
[in,out] LPWSTR pszText);
HRESULT RemoveScope(
[in] ULONG uIndex);
HRESULT RemoveAllScopes();
HRESULT SetClassName(
[in,string] LPCWSTR Name);
HRESULT GetClassName(
[in,out] ULONG *puBuffLength,
[in,out,string] LPWSTR pszName);
HRESULT GetKeyList(
[out] IWbemPathKeyList **pOut);
HRESULT CreateClassPart(
[in] long lFlags,
[in,string] LPCWSTR Name);
HRESULT DeleteClassPart(
[in] long lFlags);
BOOL IsRelative(
[in,string] LPWSTR wszMachine,
[in,string] LPWSTR wszNamespace);
BOOL IsRelativeOrChild(
[in,string] LPWSTR wszMachine,
[in,string] LPWSTR wszNamespace,
[in] long lFlags);
BOOL IsLocal(
[in,string] LPCWSTR wszMachine);
BOOL IsSameClassName(
[in,string] LPCWSTR wszClass);
};
[
uuid(cf4cc405-e2c5-4ddd-b3ce-5e7582d8c9fa)
]
coclass WbemDefPath
{
interface IWbemPath;
};

View file

@ -222,6 +222,7 @@ reactos/dll/win32/winscard # Synced to Wine-1.7.27
reactos/dll/win32/wintrust # Synced to Wine-1.7.27
reactos/dll/win32/wldap32 # Synced to Wine-1.7.27
reactos/dll/win32/wmi # Synced to Wine-1.7.27
reactos/dll/win32/wmiutils # Synced to Wine-1.7.27
reactos/dll/win32/wshom.ocx # Synced to Wine-1.7.27
reactos/dll/win32/wtsapi32 # Synced to Wine-1.7.27
reactos/dll/win32/wuapi # Synced to Wine-1.7.27

View file

@ -102,6 +102,7 @@ AddReg=Classes
11,,winhttp.dll,1
11,,wininet.dll,2
11,,wintrust.dll,1
11,,wmiutils.dll,1
11,,wshom.ocx,1
11,,wuapi.dll,1
11,wbem,wbemdisp.dll,1

View file

@ -113,6 +113,7 @@ add_subdirectory(winmm)
add_subdirectory(wintrust)
add_subdirectory(wlanapi)
add_subdirectory(wldap32)
add_subdirectory(wmiutils)
add_subdirectory(ws2_32)
add_subdirectory(wscript)
add_subdirectory(wshom)

View file

@ -0,0 +1,9 @@
add_definitions(
-DUSE_WINE_TODOS
-D__WINESRC__)
add_executable(wmiutils_winetest path.c testlist.c)
set_module_type(wmiutils_winetest win32cui)
add_importlibs(wmiutils_winetest ole32 msvcrt kernel32 ntdll)
add_cd_file(TARGET wmiutils_winetest DESTINATION reactos/bin FOR all)

View file

@ -0,0 +1,882 @@
/*
* Copyright 2012 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <stdarg.h>
#include "windows.h"
#include "initguid.h"
#include "wmiutils.h"
#include "wbemcli.h"
#include "wine/test.h"
static const WCHAR path1[] = {0};
static const WCHAR path2[] = {'\\',0};
static const WCHAR path3[] = {'\\','\\','s','e','r','v','e','r',0};
static const WCHAR path4[] = {'\\','\\','s','e','r','v','e','r','\\',0};
static const WCHAR path5[] = {'\\','\\','.','\\',0};
static const WCHAR path6[] = {'/','/','.','/','r','o','o','t','/','c','i','m','v','2',0};
static const WCHAR path7[] =
{'/','/','.','/','r','o','o','t','/','c','i','m','v','2',':','W','i','n','3','2','_',
'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path8[] =
{'/','r','o','o','t','/','c','i','m','v','2',':','W','i','n','3','2','_',
'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path9[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path10[] =
{'/','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path11[] =
{'/','/','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path12[] =
{'r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path13[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
static const WCHAR path14[] =
{'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
static const WCHAR path15[] =
{'r','o','o','t','\\','c','i','m','v','2',0};
static const WCHAR path16[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
static const WCHAR path17[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',
'"','C',':','"',0};
static const WCHAR path18[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',
'"','C',':','"',',','D','r','i','v','e','T','y','p','e','=','3',0};
static const WCHAR path19[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',0};
static const WCHAR path20[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d',' ','=',' ',
'"','C',':','"',0};
static IWbemPath *create_path(void)
{
HRESULT hr;
IWbemPath *path;
hr = CoCreateInstance( &CLSID_WbemDefPath, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemPath, (void **)&path );
if (hr != S_OK)
{
win_skip( "can't create WbemDefPath instance, skipping tests\n" );
return NULL;
}
return path;
}
static void test_IWbemPath_SetText(void)
{
static const struct
{
const WCHAR *path;
ULONG mode;
HRESULT ret;
BOOL todo;
} test[] =
{
{ path1, 0, WBEM_E_INVALID_PARAMETER },
{ path1, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path2, 0, WBEM_E_INVALID_PARAMETER },
{ path2, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path3, 0, WBEM_E_INVALID_PARAMETER },
{ path3, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path4, 0, WBEM_E_INVALID_PARAMETER },
{ path4, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path5, 0, WBEM_E_INVALID_PARAMETER },
{ path5, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path6, 0, WBEM_E_INVALID_PARAMETER },
{ path6, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path7, 0, WBEM_E_INVALID_PARAMETER },
{ path7, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK },
{ path7, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
{ path7, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, TRUE },
{ path7, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
{ path8, WBEMPATH_CREATE_ACCEPT_RELATIVE, S_OK },
{ path8, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, TRUE },
{ path8, WBEMPATH_CREATE_ACCEPT_ALL, S_OK },
{ path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS, WBEM_E_INVALID_PARAMETER, TRUE },
{ path8, WBEMPATH_TREAT_SINGLE_IDENT_AS_NS + 1, S_OK },
{ path9, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
{ path10, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, WBEM_E_INVALID_PARAMETER, TRUE },
{ path11, WBEMPATH_CREATE_ACCEPT_ABSOLUTE, S_OK },
{ path15, WBEMPATH_CREATE_ACCEPT_ALL, S_OK }
};
IWbemPath *path;
HRESULT hr;
UINT i;
if (!(path = create_path())) return;
hr = IWbemPath_SetText( path, 0, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
for (i = 0; i < sizeof(test)/sizeof(test[0]); i++)
{
hr = IWbemPath_SetText( path, test[i].mode, test[i].path );
if (test[i].todo) todo_wine ok( hr == test[i].ret, "%u got %08x\n", i, hr );
else ok( hr == test[i].ret, "%u got %08x\n", i, hr );
if (test[i].ret == S_OK)
{
WCHAR buf[128];
ULONG len;
memset( buf, 0x55, sizeof(buf) );
len = sizeof(buf)/sizeof(buf[0]);
hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf );
ok( hr == S_OK, "%u got %08x\n", i, hr );
ok( !lstrcmpW( buf, test[i].path ), "%u unexpected path %s\n", i, wine_dbgstr_w(buf) );
ok( len == lstrlenW( test[i].path ) + 1, "%u unexpected length %u\n", i, len );
}
}
IWbemPath_Release( path );
}
static void test_IWbemPath_GetText(void)
{
static const WCHAR serviceW[] =
{'W','i','n','3','2','_','S','e','r','v','i','c','e','.','N','a','m','e','=',
'\"','S','e','r','v','i','c','e','\"',0};
static const WCHAR classW[] =
{'W','i','n','3','2','_','C','l','a','s','s',0};
static const WCHAR expected1W[] =
{'r','o','o','t','\\','c','i','m','v','2',':','W','i','n','3','2','_',
'L','o','g','i','c','a','l','D','i','s','k','.','D','e','v','i','c','e','I','d','=',
'"','C',':','"',0};
static const WCHAR expected2W[] =
{'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','.',
'D','e','v','i','c','e','I','d','=','"','C',':','"',0};
static const WCHAR expected3W[] =
{'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
WCHAR buf[128];
ULONG len, count;
IWbemPath *path;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_GetText( path, 0, NULL, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
hr = IWbemPath_GetText( path, 0, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf)/sizeof(buf[0]), "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == 1, "unexpected length %u\n", len );
hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, NULL, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf)/sizeof(buf[0]), "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_ORIGINAL, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
todo_wine ok( !buf[0], "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
todo_wine ok( len == 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path8 );
ok( hr == S_OK, "got %08x\n", hr );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 2, "got %u\n", count );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path9 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path9 ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path13 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path13 ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path14 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path14 ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_NAMESPACE_ONLY, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path15 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path15 ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path12 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path12 ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 );
ok( hr == S_OK, "got %08x\n", hr );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( !count, "got %u\n", count );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path6 );
ok( hr == S_OK, "got %08x\n", hr );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 2, "got %u\n", count );
len = 0;
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( len == lstrlenW( path16 ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path16 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path16 ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, path17 ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( path17 ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, expected1W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( expected1W ) + 1, "unexpected length %u\n", len );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, expected2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( expected2W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path15 );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_SERVER_TOO, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, expected3W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( expected3W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path18 );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path19 );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path20 );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
IWbemPath_Release( path );
if (!(path = create_path())) return;
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, serviceW );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, serviceW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( serviceW ) + 1, "unexpected length %u\n", len );
IWbemPath_Release( path );
if (!(path = create_path())) return;
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, classW );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf)/sizeof(buf[0]);
memset( buf, 0x55, sizeof(buf) );
hr = IWbemPath_GetText( path, WBEMPATH_GET_RELATIVE_ONLY, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( classW ) + 1, "unexpected length %u\n", len );
IWbemPath_Release( path );
}
static void test_IWbemPath_GetClassName(void)
{
static const WCHAR classW[] = {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
IWbemPath *path;
HRESULT hr;
WCHAR buf[32];
ULONG len;
if (!(path = create_path())) return;
hr = IWbemPath_GetClassName( path, NULL, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = 0;
hr = IWbemPath_GetClassName( path, &len, NULL );
ok( hr == WBEM_E_INVALID_OBJECT_PATH, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetClassName( path, &len, buf );
ok( hr == WBEM_E_INVALID_OBJECT_PATH, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetClassName( path, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
len = 0;
hr = IWbemPath_GetClassName( path, &len, NULL );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetClassName( path, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetClassName( path, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( classW ) + 1, "unexpected length %u\n", len );
IWbemPath_Release( path );
}
static void test_IWbemPath_SetClassName(void)
{
static const WCHAR classW[] = {'c','l','a','s','s',0};
static const WCHAR emptyW[] = {0};
IWbemPath *path;
WCHAR buf[16];
ULONG len;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_SetClassName( path, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetClassName( path, emptyW );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_SetClassName( path, classW );
ok( hr == S_OK, "got %08x\n", hr );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetClassName( path, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, classW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_CLASS_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT),
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
IWbemPath_Release( path );
}
static void test_IWbemPath_GetServer(void)
{
static const WCHAR dotW[] = {'.',0};
IWbemPath *path;
HRESULT hr;
WCHAR buf[32];
ULONG len;
if (!(path = create_path())) return;
hr = IWbemPath_GetServer( path, NULL, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = 0;
hr = IWbemPath_GetServer( path, &len, NULL );
ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, buf );
ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
len = 0;
hr = IWbemPath_GetServer( path, &len, NULL );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, dotW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( dotW ) + 1, "unexpected length %u\n", len );
IWbemPath_Release( path );
}
static void test_IWbemPath_GetInfo(void)
{
IWbemPath *path;
HRESULT hr;
ULONGLONG resp;
if (!(path = create_path())) return;
hr = IWbemPath_GetInfo( path, 0, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_GetInfo( path, 1, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
resp = 0xdeadbeef;
hr = IWbemPath_GetInfo( path, 0, &resp );
ok( hr == S_OK, "got %08x\n", hr );
ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
"got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_GetInfo( path, 0, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_GetInfo( path, 1, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
resp = 0xdeadbeef;
hr = IWbemPath_GetInfo( path, 0, &resp );
ok( hr == S_OK, "got %08x\n", hr );
ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER),
"got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
IWbemPath_Release( path );
if (!(path = create_path())) return;
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path12 );
ok( hr == S_OK, "got %08x\n", hr );
resp = 0xdeadbeef;
hr = IWbemPath_GetInfo( path, 0, &resp );
ok( hr == S_OK, "got %08x\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 %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path1 );
ok( hr == S_OK, "got %08x\n", hr );
resp = 0xdeadbeef;
hr = IWbemPath_GetInfo( path, 0, &resp );
ok( hr == S_OK, "got %08x\n", hr );
ok( resp == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
"got %lx%08lx\n", (unsigned long)(resp >> 32), (unsigned long)resp );
IWbemPath_Release( path );
}
static void test_IWbemPath_SetServer(void)
{
static const WCHAR serverW[] = {'s','e','r','v','e','r',0};
static const WCHAR emptyW[] = {0};
IWbemPath *path;
WCHAR buf[16];
ULONG len;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_SetServer( path, NULL );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, buf );
ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
hr = IWbemPath_SetServer( path, emptyW );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_SetServer( path, serverW );
ok( hr == S_OK, "got %08x\n", hr );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, serverW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == (WBEMPATH_INFO_HAS_MACHINE_NAME | WBEMPATH_INFO_V1_COMPLIANT |
WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT |
WBEMPATH_INFO_SERVER_NAMESPACE_ONLY | WBEMPATH_INFO_PATH_HAD_SERVER),
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
hr = IWbemPath_SetServer( path, NULL );
ok( hr == S_OK, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetServer( path, &len, buf );
ok( hr == WBEM_E_NOT_AVAILABLE, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == (WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_SERVER_NAMESPACE_ONLY),
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
IWbemPath_Release( path );
}
static void test_IWbemPath_GetNamespaceAt(void)
{
static const WCHAR rootW[] = {'r','o','o','t',0};
static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
IWbemPath *path;
HRESULT hr;
WCHAR buf[32];
ULONG len;
if (!(path = create_path())) return;
hr = IWbemPath_GetNamespaceAt( path, 0, NULL, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = 0;
hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
len = 0;
hr = IWbemPath_GetNamespaceAt( path, 2, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
ok( len == sizeof(buf) / sizeof(buf[0]), "unexpected length %u\n", len );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, rootW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( rootW ) + 1, "unexpected length %u\n", len );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
IWbemPath_Release( path );
}
static void test_IWbemPath_RemoveAllNamespaces(void)
{
static const ULONGLONG expected_flags =
WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
IWbemPath *path;
WCHAR buf[16];
ULONG len;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_RemoveAllNamespaces( path );
ok( hr == S_OK, "got %08x\n", hr );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
hr = IWbemPath_RemoveAllNamespaces( path );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
IWbemPath_Release( path );
}
static void test_IWbemPath_RemoveNamespaceAt(void)
{
static const ULONGLONG expected_flags =
WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_IS_INST_REF |
WBEMPATH_INFO_HAS_SUBSCOPES | WBEMPATH_INFO_V2_COMPLIANT |
WBEMPATH_INFO_CIM_COMPLIANT | WBEMPATH_INFO_PATH_HAD_SERVER;
static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
IWbemPath *path;
WCHAR buf[16];
ULONG len, count;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_RemoveNamespaceAt( path, 0 );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetText( path, WBEMPATH_CREATE_ACCEPT_ALL, path17 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 2, "got %u\n", count );
hr = IWbemPath_RemoveNamespaceAt( path, 0 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 1, "got %u\n", count );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_RemoveNamespaceAt( path, 0 );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( !count, "got %u\n", count );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
IWbemPath_Release( path );
}
static void test_IWbemPath_SetNamespaceAt(void)
{
static const ULONGLONG expected_flags =
WBEMPATH_INFO_ANON_LOCAL_MACHINE | WBEMPATH_INFO_V1_COMPLIANT |
WBEMPATH_INFO_V2_COMPLIANT | WBEMPATH_INFO_CIM_COMPLIANT |
WBEMPATH_INFO_SERVER_NAMESPACE_ONLY;
static const WCHAR rootW[] = {'r','o','o','t',0};
static const WCHAR cimv2W[] = {'c','i','m','v','2',0};
IWbemPath *path;
WCHAR buf[16];
ULONG len, count;
ULONGLONG flags;
HRESULT hr;
if (!(path = create_path())) return;
hr = IWbemPath_SetNamespaceAt( path, 0, NULL );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetNamespaceAt( path, 1, cimv2W );
ok( hr == WBEM_E_INVALID_PARAMETER, "got %08x\n", hr );
hr = IWbemPath_SetNamespaceAt( path, 0, cimv2W );
ok( hr == S_OK, "got %08x\n", hr );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 1, "got %u\n", count );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
hr = IWbemPath_SetNamespaceAt( path, 0, rootW );
ok( hr == S_OK, "got %08x\n", hr );
flags = 0;
hr = IWbemPath_GetInfo( path, 0, &flags );
ok( hr == S_OK, "got %08x\n", hr );
ok( flags == expected_flags,
"got %lx%08lx\n", (unsigned long)(flags >> 32), (unsigned long)flags );
count = 0xdeadbeef;
hr = IWbemPath_GetNamespaceCount( path, &count );
ok( hr == S_OK, "got %08x\n", hr );
ok( count == 2, "got %u\n", count );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 0, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, rootW ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( rootW ) + 1, "unexpected length %u\n", len );
buf[0] = 0;
len = sizeof(buf) / sizeof(buf[0]);
hr = IWbemPath_GetNamespaceAt( path, 1, &len, buf );
ok( hr == S_OK, "got %08x\n", hr );
ok( !lstrcmpW( buf, cimv2W ), "unexpected buffer contents %s\n", wine_dbgstr_w(buf) );
ok( len == lstrlenW( cimv2W ) + 1, "unexpected length %u\n", len );
IWbemPath_Release( path );
}
START_TEST (path)
{
CoInitialize( NULL );
test_IWbemPath_SetText();
test_IWbemPath_GetText();
test_IWbemPath_GetClassName();
test_IWbemPath_SetClassName();
test_IWbemPath_GetServer();
test_IWbemPath_GetInfo();
test_IWbemPath_SetServer();
test_IWbemPath_GetNamespaceAt();
test_IWbemPath_RemoveAllNamespaces();
test_IWbemPath_RemoveNamespaceAt();
test_IWbemPath_SetNamespaceAt();
CoUninitialize();
}

View file

@ -0,0 +1,15 @@
/* Automatically generated by make depend; DO NOT EDIT!! */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define STANDALONE
#include "wine/test.h"
extern void func_path(void);
const struct test winetest_testlist[] =
{
{ "path", func_path },
{ 0, 0 }
};