ReactOS  0.4.15-dev-2956-g61e7ea5
wbemlocator.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wbemcli.h"
#include "wine/debug.h"
#include "wbemprox_private.h"
Include dependency graph for wbemlocator.c:

Go to the source code of this file.

Classes

struct  wbem_locator
 

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wbemprox)
 
static wbem_locatorimpl_from_IWbemLocator (IWbemLocator *iface)
 
static ULONG WINAPI wbem_locator_AddRef (IWbemLocator *iface)
 
static ULONG WINAPI wbem_locator_Release (IWbemLocator *iface)
 
static HRESULT WINAPI wbem_locator_QueryInterface (IWbemLocator *iface, REFIID riid, void **ppvObject)
 
static BOOL is_local_machine (const WCHAR *server)
 
static HRESULT parse_resource (const WCHAR *resource, WCHAR **server, WCHAR **namespace)
 
static HRESULT WINAPI wbem_locator_ConnectServer (IWbemLocator *iface, const BSTR NetworkResource, const BSTR User, const BSTR Password, const BSTR Locale, LONG SecurityFlags, const BSTR Authority, IWbemContext *pCtx, IWbemServices **ppNamespace)
 
HRESULT WbemLocator_create (LPVOID *ppObj)
 

Variables

static const IWbemLocatorVtbl wbem_locator_vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file wbemlocator.c.

Function Documentation

◆ impl_from_IWbemLocator()

static wbem_locator* impl_from_IWbemLocator ( IWbemLocator iface)
inlinestatic

Definition at line 39 of file wbemlocator.c.

40 {
41  return CONTAINING_RECORD(iface, wbem_locator, IWbemLocator_iface);
42 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by wbem_locator_AddRef(), wbem_locator_QueryInterface(), and wbem_locator_Release().

◆ is_local_machine()

static BOOL is_local_machine ( const WCHAR server)
static

Definition at line 87 of file wbemlocator.c.

88 {
89  static const WCHAR dotW[] = {'.',0};
90  static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0};
93 
94  if (!server || !wcscmp( server, dotW ) || !wcsicmp( server, localhostW )) return TRUE;
95  if (GetComputerNameW( buffer, &len ) && !wcsicmp( server, buffer )) return TRUE;
96  return FALSE;
97 }
static const WCHAR localhostW[]
Definition: notification.c:35
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wcsicmp
Definition: compat.h:15
GLenum GLsizei len
Definition: glext.h:6722
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ARRAY_SIZE(a)
Definition: main.h:24
static const WCHAR dotW[]
Definition: directory.c:80

Referenced by wbem_locator_ConnectServer().

◆ parse_resource()

static HRESULT parse_resource ( const WCHAR resource,
WCHAR **  server,
WCHAR **  namespace 
)
static

Definition at line 99 of file wbemlocator.c.

100 {
101  static const WCHAR rootW[] = {'R','O','O','T'};
102  static const WCHAR cimv2W[] = {'C','I','M','V','2',0};
103  static const WCHAR defaultW[] = {'D','E','F','A','U','L','T',0};
105  const WCHAR *p, *q;
106  unsigned int len;
107 
108  *server = NULL;
109  *namespace = NULL;
110  p = q = resource;
111  if (*p == '\\' || *p == '/')
112  {
113  p++;
114  if (*p == '\\' || *p == '/') p++;
115  if (!*p) return WBEM_E_INVALID_NAMESPACE;
116  if (*p == '\\' || *p == '/') return WBEM_E_INVALID_PARAMETER;
117  q = p + 1;
118  while (*q && *q != '\\' && *q != '/') q++;
119  if (!*q) return WBEM_E_INVALID_NAMESPACE;
120  len = q - p;
121  if (!(*server = heap_alloc( (len + 1) * sizeof(WCHAR) )))
122  {
123  hr = E_OUTOFMEMORY;
124  goto done;
125  }
126  memcpy( *server, p, len * sizeof(WCHAR) );
127  (*server)[len] = 0;
128  q++;
129  }
130  if (!*q) goto done;
131  p = q;
132  while (*q && *q != '\\' && *q != '/') q++;
133  len = q - p;
134  if (len >= ARRAY_SIZE( rootW ) && _wcsnicmp( rootW, p, len )) goto done;
135  if (!*q)
136  {
137  hr = S_OK;
138  goto done;
139  }
140  q++;
141  len = lstrlenW( q );
142  if (wcsicmp( q, cimv2W ) && wcsicmp( q, defaultW ))
143  goto done;
144  if (!(*namespace = heap_alloc( (len + 1) * sizeof(WCHAR) ))) hr = E_OUTOFMEMORY;
145  else
146  {
147  memcpy( *namespace, p, len * sizeof(WCHAR) );
148  (*namespace)[len] = 0;
149  hr = S_OK;
150  }
151 
152 done:
153  if (hr != S_OK)
154  {
155  heap_free( *server );
156  heap_free( *namespace );
157  }
158  return hr;
159 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
HRESULT hr
Definition: shlfolder.c:183
static const WCHAR rootW[]
Definition: chain.c:69
static const WCHAR defaultW[]
Definition: lex.c:42
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
int resource
Definition: rdpsnd_sgi.c:44
#define lstrlenW
Definition: compat.h:609
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define wcsicmp
Definition: compat.h:15
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by wbem_locator_ConnectServer().

◆ wbem_locator_AddRef()

static ULONG WINAPI wbem_locator_AddRef ( IWbemLocator iface)
static

Definition at line 44 of file wbemlocator.c.

46 {
47  wbem_locator *wl = impl_from_IWbemLocator( iface );
48  return InterlockedIncrement( &wl->refs );
49 }
static wbem_locator * impl_from_IWbemLocator(IWbemLocator *iface)
Definition: wbemlocator.c:39
#define InterlockedIncrement
Definition: armddk.h:53

◆ wbem_locator_ConnectServer()

static HRESULT WINAPI wbem_locator_ConnectServer ( IWbemLocator iface,
const BSTR  NetworkResource,
const BSTR  User,
const BSTR  Password,
const BSTR  Locale,
LONG  SecurityFlags,
const BSTR  Authority,
IWbemContext *  pCtx,
IWbemServices **  ppNamespace 
)
static

Definition at line 161 of file wbemlocator.c.

171 {
172  HRESULT hr;
173  WCHAR *server, *namespace;
174 
175  TRACE("%p, %s, %s, %s, %s, 0x%08x, %s, %p, %p)\n", iface, debugstr_w(NetworkResource), debugstr_w(User),
176  debugstr_w(Password), debugstr_w(Locale), SecurityFlags, debugstr_w(Authority), pCtx, ppNamespace);
177 
178  hr = parse_resource( NetworkResource, &server, &namespace );
179  if (hr != S_OK) return hr;
180 
181  if (!is_local_machine( server ))
182  {
183  FIXME("remote computer not supported\n");
184  heap_free( server );
185  heap_free( namespace );
187  }
188  if (User || Password || Authority)
189  FIXME("authentication not supported\n");
190  if (Locale)
191  FIXME("specific locale not supported\n");
192  if (SecurityFlags)
193  FIXME("unsupported flags\n");
194 
195  hr = WbemServices_create( namespace, (void **)ppNamespace );
196  heap_free( namespace );
197  heap_free( server );
198  if (SUCCEEDED( hr ))
199  return WBEM_NO_ERROR;
200 
201  return WBEM_E_FAILED;
202 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
HRESULT hr
Definition: shlfolder.c:183
static BOOL is_local_machine(const WCHAR *server)
Definition: wbemlocator.c:87
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
HRESULT WbemServices_create(const WCHAR *namespace, LPVOID *ppObj)
Definition: services.c:925
static HRESULT parse_resource(const WCHAR *resource, WCHAR **server, WCHAR **namespace)
Definition: wbemlocator.c:99
#define S_OK
Definition: intsafe.h:52
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ wbem_locator_QueryInterface()

static HRESULT WINAPI wbem_locator_QueryInterface ( IWbemLocator iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 64 of file wbemlocator.c.

68 {
70 
71  TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
72 
73  if ( IsEqualGUID( riid, &IID_IWbemLocator ) ||
75  {
76  *ppvObject = iface;
77  }
78  else
79  {
80  FIXME("interface %s not implemented\n", debugstr_guid(riid));
81  return E_NOINTERFACE;
82  }
83  IWbemLocator_AddRef( iface );
84  return S_OK;
85 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define FIXME(fmt,...)
Definition: debug.h:111
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
REFIID LPVOID * ppvObject
Definition: precomp.h:44
static wbem_locator * impl_from_IWbemLocator(IWbemLocator *iface)
Definition: wbemlocator.c:39
#define S_OK
Definition: intsafe.h:52
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ wbem_locator_Release()

static ULONG WINAPI wbem_locator_Release ( IWbemLocator iface)
static

Definition at line 51 of file wbemlocator.c.

53 {
54  wbem_locator *wl = impl_from_IWbemLocator( iface );
55  LONG refs = InterlockedDecrement( &wl->refs );
56  if (!refs)
57  {
58  TRACE("destroying %p\n", wl);
59  heap_free( wl );
60  }
61  return refs;
62 }
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static wbem_locator * impl_from_IWbemLocator(IWbemLocator *iface)
Definition: wbemlocator.c:39
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ WbemLocator_create()

HRESULT WbemLocator_create ( LPVOID ppObj)

Definition at line 212 of file wbemlocator.c.

213 {
214  wbem_locator *wl;
215 
216  TRACE("(%p)\n", ppObj);
217 
218  wl = heap_alloc( sizeof(*wl) );
219  if (!wl) return E_OUTOFMEMORY;
220 
222  wl->refs = 1;
223 
224  *ppObj = &wl->IWbemLocator_iface;
225 
226  TRACE("returning iface %p\n", *ppObj);
227  return S_OK;
228 }
IWbemLocator IWbemLocator_iface
Definition: wbemlocator.c:35
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IWbemLocatorVtbl wbem_locator_vtbl
Definition: wbemlocator.c:204
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wbemprox  )

Variable Documentation

◆ wbem_locator_vtbl

const IWbemLocatorVtbl wbem_locator_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI wbem_locator_QueryInterface(IWbemLocator *iface, REFIID riid, void **ppvObject)
Definition: wbemlocator.c:64
static ULONG WINAPI wbem_locator_AddRef(IWbemLocator *iface)
Definition: wbemlocator.c:44
static ULONG WINAPI wbem_locator_Release(IWbemLocator *iface)
Definition: wbemlocator.c:51
static HRESULT WINAPI wbem_locator_ConnectServer(IWbemLocator *iface, const BSTR NetworkResource, const BSTR User, const BSTR Password, const BSTR Locale, LONG SecurityFlags, const BSTR Authority, IWbemContext *pCtx, IWbemServices **ppNamespace)
Definition: wbemlocator.c:161

Definition at line 204 of file wbemlocator.c.

Referenced by WbemLocator_create().