ReactOS  0.4.15-dev-1386-g5cb9f87
shlinstobj.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "objbase.h"
#include "oleauto.h"
#include "shdocvw.h"
#include "wine/debug.h"
Include dependency graph for shlinstobj.c:

Go to the source code of this file.

Classes

struct  _RegistryPropertyBag
 
struct  _InstanceObjectFactory
 

Macros

#define COBJMACROS
 
#define CHARS_IN_GUID   39
 

Typedefs

typedef struct _RegistryPropertyBag RegistryPropertyBag
 
typedef struct _InstanceObjectFactory InstanceObjectFactory
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shdocvw)
 
static RegistryPropertyBagimpl_from_IPropertyBag (IPropertyBag *iface)
 
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface (IPropertyBag *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI RegistryPropertyBag_IPropertyBag_AddRef (IPropertyBag *iface)
 
static ULONG WINAPI RegistryPropertyBag_IPropertyBag_Release (IPropertyBag *iface)
 
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Read (IPropertyBag *iface, LPCOLESTR pwszPropName, VARIANT *pVar, IErrorLog *pErrorLog)
 
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Write (IPropertyBag *iface, LPCOLESTR pwszPropName, VARIANT *pVar)
 
static HRESULT RegistryPropertyBag_Constructor (HKEY hInitPropertyBagKey, REFIID riid, LPVOID *ppvObject)
 
static InstanceObjectFactoryimpl_from_IClassFactory (IClassFactory *iface)
 
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface (IClassFactory *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI InstanceObjectFactory_IClassFactory_AddRef (IClassFactory *iface)
 
static ULONG WINAPI InstanceObjectFactory_IClassFactory_Release (IClassFactory *iface)
 
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_CreateInstance (IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObj)
 
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_LockServer (IClassFactory *iface, BOOL fLock)
 
static HRESULT InstanceObjectFactory_Constructor (REFCLSID rclsid, IPropertyBag *pPropertyBag, REFIID riid, LPVOID *ppvObject)
 
HRESULT SHDOCVW_GetShellInstanceObjectClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppvClassObj)
 

Variables

static const IPropertyBagVtbl RegistryPropertyBag_IPropertyBagVtbl
 
static const IClassFactoryVtbl InstanceObjectFactory_IClassFactoryVtbl
 

Macro Definition Documentation

◆ CHARS_IN_GUID

#define CHARS_IN_GUID   39

Definition at line 42 of file shlinstobj.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 28 of file shlinstobj.c.

Typedef Documentation

◆ InstanceObjectFactory

◆ RegistryPropertyBag

Function Documentation

◆ impl_from_IClassFactory()

static InstanceObjectFactory* impl_from_IClassFactory ( IClassFactory iface)
inlinestatic

Definition at line 206 of file shlinstobj.c.

207 {
208  return CONTAINING_RECORD(iface, InstanceObjectFactory, IClassFactory_iface);
209 }
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 InstanceObjectFactory_IClassFactory_AddRef(), InstanceObjectFactory_IClassFactory_CreateInstance(), InstanceObjectFactory_IClassFactory_QueryInterface(), and InstanceObjectFactory_IClassFactory_Release().

◆ impl_from_IPropertyBag()

static RegistryPropertyBag* impl_from_IPropertyBag ( IPropertyBag iface)
inlinestatic

Definition at line 55 of file shlinstobj.c.

56 {
57  return CONTAINING_RECORD(iface, RegistryPropertyBag, IPropertyBag_iface);
58 }
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 RegistryPropertyBag_IPropertyBag_AddRef(), RegistryPropertyBag_IPropertyBag_QueryInterface(), RegistryPropertyBag_IPropertyBag_Read(), and RegistryPropertyBag_IPropertyBag_Release().

◆ InstanceObjectFactory_Constructor()

static HRESULT InstanceObjectFactory_Constructor ( REFCLSID  rclsid,
IPropertyBag pPropertyBag,
REFIID  riid,
LPVOID ppvObject 
)
static

Definition at line 316 of file shlinstobj.c.

318 {
319  InstanceObjectFactory *pInstanceObjectFactory;
320  HRESULT hr = E_FAIL;
321 
322  TRACE("(RegistryPropertyBag=%p, riid=%s, ppvObject=%p)\n", pPropertyBag,
324 
325  pInstanceObjectFactory = heap_alloc(sizeof(InstanceObjectFactory));
326  if (pInstanceObjectFactory) {
327  pInstanceObjectFactory->IClassFactory_iface.lpVtbl = &InstanceObjectFactory_IClassFactoryVtbl;
328  pInstanceObjectFactory->m_cRef = 0;
329  pInstanceObjectFactory->m_clsidInstance = *rclsid;
330  pInstanceObjectFactory->m_pPropertyBag = pPropertyBag;
331  IPropertyBag_AddRef(pPropertyBag);
332 
333  IClassFactory_AddRef(&pInstanceObjectFactory->IClassFactory_iface);
334  hr = IClassFactory_QueryInterface(&pInstanceObjectFactory->IClassFactory_iface,
335  riid, ppvObject);
336  IClassFactory_Release(&pInstanceObjectFactory->IClassFactory_iface);
337  }
338 
339  return hr;
340 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
IClassFactory IClassFactory_iface
Definition: shlinstobj.c:200
#define E_FAIL
Definition: ddrawi.h:102
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
REFIID LPVOID * ppvObject
Definition: precomp.h:44
static const IClassFactoryVtbl InstanceObjectFactory_IClassFactoryVtbl
Definition: shlinstobj.c:308
IPropertyBag * m_pPropertyBag
Definition: shlinstobj.c:203

Referenced by SHDOCVW_GetShellInstanceObjectClassObject().

◆ InstanceObjectFactory_IClassFactory_AddRef()

static ULONG WINAPI InstanceObjectFactory_IClassFactory_AddRef ( IClassFactory iface)
static

Definition at line 232 of file shlinstobj.c.

233 {
235  ULONG cRef;
236 
237  TRACE("(iface=%p)\n", iface);
238 
239  cRef = InterlockedIncrement(&This->m_cRef);
240 
241  if (cRef == 1)
242  IClassFactory_LockServer(iface, TRUE);
243 
244  return cRef;
245 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
static InstanceObjectFactory * impl_from_IClassFactory(IClassFactory *iface)
Definition: shlinstobj.c:206
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ InstanceObjectFactory_IClassFactory_CreateInstance()

static HRESULT WINAPI InstanceObjectFactory_IClassFactory_CreateInstance ( IClassFactory iface,
IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppvObj 
)
static

Definition at line 265 of file shlinstobj.c.

267 {
269  IPersistPropertyBag *pPersistPropertyBag;
270  HRESULT hr;
271 
272  TRACE("(pUnkOuter=%p, riid=%s, ppvObj=%p)\n", pUnkOuter, debugstr_guid(riid), ppvObj);
273 
274  hr = CoCreateInstance(&This->m_clsidInstance, NULL, CLSCTX_INPROC_SERVER,
275  &IID_IPersistPropertyBag, (LPVOID*)&pPersistPropertyBag);
276  if (FAILED(hr)) {
277  TRACE("Failed to create instance of %s. hr = %08x\n",
278  debugstr_guid(&This->m_clsidInstance), hr);
279  return hr;
280  }
281 
282  hr = IPersistPropertyBag_Load(pPersistPropertyBag, This->m_pPropertyBag, NULL);
283  if (FAILED(hr)) {
284  TRACE("Failed to initialize object from PropertyBag: hr = %08x\n", hr);
285  IPersistPropertyBag_Release(pPersistPropertyBag);
286  return hr;
287  }
288 
289  hr = IPersistPropertyBag_QueryInterface(pPersistPropertyBag, riid, ppvObj);
290  IPersistPropertyBag_Release(pPersistPropertyBag);
291 
292  return hr;
293 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
const GUID IID_IPersistPropertyBag
Definition: proxy.cpp:11
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static InstanceObjectFactory * impl_from_IClassFactory(IClassFactory *iface)
Definition: shlinstobj.c:206
#define NULL
Definition: types.h:112

◆ InstanceObjectFactory_IClassFactory_LockServer()

static HRESULT WINAPI InstanceObjectFactory_IClassFactory_LockServer ( IClassFactory iface,
BOOL  fLock 
)
static

Definition at line 295 of file shlinstobj.c.

297 {
298  TRACE("(iface=%p, fLock=%d) stub\n", iface, fLock);
299 
300  if (fLock)
302  else
304 
305  return S_OK;
306 }
#define TRACE(s)
Definition: solgame.cpp:4
static void SHDOCVW_LockModule(void)
Definition: shdocvw.h:50
#define S_OK
Definition: intsafe.h:51
static void SHDOCVW_UnlockModule(void)
Definition: shdocvw.h:51

◆ InstanceObjectFactory_IClassFactory_QueryInterface()

static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface ( IClassFactory iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 211 of file shlinstobj.c.

213 {
215 
216  TRACE("iface=%p, riid=%s, ppv=%p)\n", iface, debugstr_guid(riid), ppv);
217 
218  if (!ppv)
219  return E_INVALIDARG;
220 
222  *ppv = &This->IClassFactory_iface;
223  } else {
224  *ppv = NULL;
225  return E_NOINTERFACE;
226  }
227 
228  IUnknown_AddRef((IUnknown*)*ppv);
229  return S_OK;
230 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
static InstanceObjectFactory * impl_from_IClassFactory(IClassFactory *iface)
Definition: shlinstobj.c:206
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
const GUID IID_IClassFactory
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ InstanceObjectFactory_IClassFactory_Release()

static ULONG WINAPI InstanceObjectFactory_IClassFactory_Release ( IClassFactory iface)
static

Definition at line 247 of file shlinstobj.c.

248 {
250  ULONG cRef;
251 
252  TRACE("(iface=%p)\n", iface);
253 
254  cRef = InterlockedDecrement(&This->m_cRef);
255 
256  if (cRef == 0) {
257  IClassFactory_LockServer(iface, FALSE);
258  IPropertyBag_Release(This->m_pPropertyBag);
259  heap_free(This);
260  }
261 
262  return cRef;
263 }
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static InstanceObjectFactory * impl_from_IClassFactory(IClassFactory *iface)
Definition: shlinstobj.c:206
unsigned int ULONG
Definition: retypes.h:1
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ RegistryPropertyBag_Constructor()

static HRESULT RegistryPropertyBag_Constructor ( HKEY  hInitPropertyBagKey,
REFIID  riid,
LPVOID ppvObject 
)
static

Definition at line 171 of file shlinstobj.c.

171  {
172  HRESULT hr = E_FAIL;
173  RegistryPropertyBag *pRegistryPropertyBag;
174 
175  TRACE("(hInitPropertyBagKey=%p, riid=%s, ppvObject=%p)\n", hInitPropertyBagKey,
177 
178  pRegistryPropertyBag = heap_alloc(sizeof(RegistryPropertyBag));
179  if (pRegistryPropertyBag) {
180  pRegistryPropertyBag->IPropertyBag_iface.lpVtbl = &RegistryPropertyBag_IPropertyBagVtbl;
181  pRegistryPropertyBag->m_cRef = 0;
182  pRegistryPropertyBag->m_hInitPropertyBagKey = hInitPropertyBagKey;
183 
184  /* The clasping AddRef/Release is for the case that QueryInterface fails, which will result
185  * in a reference count of 0 in the Release call, which will result in object destruction.*/
186  IPropertyBag_AddRef(&pRegistryPropertyBag->IPropertyBag_iface);
187  hr = IPropertyBag_QueryInterface(&pRegistryPropertyBag->IPropertyBag_iface, riid, ppvObject);
188  IPropertyBag_Release(&pRegistryPropertyBag->IPropertyBag_iface);
189  }
190 
191  return hr;
192 }
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define E_FAIL
Definition: ddrawi.h:102
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
static const IPropertyBagVtbl RegistryPropertyBag_IPropertyBagVtbl
Definition: shlinstobj.c:163
REFIID LPVOID * ppvObject
Definition: precomp.h:44
IPropertyBag IPropertyBag_iface
Definition: shlinstobj.c:50

Referenced by SHDOCVW_GetShellInstanceObjectClassObject().

◆ RegistryPropertyBag_IPropertyBag_AddRef()

static ULONG WINAPI RegistryPropertyBag_IPropertyBag_AddRef ( IPropertyBag iface)
static

Definition at line 81 of file shlinstobj.c.

82 {
84  ULONG cRef;
85 
86  TRACE("(iface=%p)\n", iface);
87 
88  cRef = InterlockedIncrement(&This->m_cRef);
89 
90  if (cRef == 1)
92 
93  return cRef;
94 }
#define TRACE(s)
Definition: solgame.cpp:4
static void SHDOCVW_LockModule(void)
Definition: shdocvw.h:50
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1
static RegistryPropertyBag * impl_from_IPropertyBag(IPropertyBag *iface)
Definition: shlinstobj.c:55

◆ RegistryPropertyBag_IPropertyBag_QueryInterface()

static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface ( IPropertyBag iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 60 of file shlinstobj.c.

62 {
64 
65  TRACE("(iface=%p, riid=%s, ppv=%p)\n", iface, debugstr_guid(riid), ppv);
66 
67  if (!ppv)
68  return E_INVALIDARG;
69 
71  *ppv = &This->IPropertyBag_iface;
72  } else {
73  *ppv = NULL;
74  return E_NOINTERFACE;
75  }
76 
77  IUnknown_AddRef((IUnknown*)*ppv);
78  return S_OK;
79 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_INVALIDARG
Definition: ddrawi.h:101
const GUID IID_IPropertyBag
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static RegistryPropertyBag * impl_from_IPropertyBag(IPropertyBag *iface)
Definition: shlinstobj.c:55

◆ RegistryPropertyBag_IPropertyBag_Read()

static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Read ( IPropertyBag iface,
LPCOLESTR  pwszPropName,
VARIANT pVar,
IErrorLog pErrorLog 
)
static

Definition at line 115 of file shlinstobj.c.

117 {
119  WCHAR *pwszValue;
120  DWORD dwType, cbData;
121  LONG res;
122  VARTYPE vtDst = V_VT(pVar);
123  HRESULT hr = S_OK;
124 
125  TRACE("(iface=%p, pwszPropName=%s, pVar=%p, pErrorLog=%p)\n", iface, debugstr_w(pwszPropName),
126  pVar, pErrorLog);
127 
128  res = RegQueryValueExW(This->m_hInitPropertyBagKey, pwszPropName, NULL, &dwType, NULL, &cbData);
129  if (res != ERROR_SUCCESS)
130  return E_INVALIDARG;
131 
132  pwszValue = heap_alloc(cbData);
133  if (!pwszValue)
134  return E_OUTOFMEMORY;
135 
136  res = RegQueryValueExW(This->m_hInitPropertyBagKey, pwszPropName, NULL, &dwType,
137  (LPBYTE)pwszValue, &cbData);
138  if (res != ERROR_SUCCESS) {
139  heap_free(pwszValue);
140  return E_INVALIDARG;
141  }
142 
143  V_VT(pVar) = VT_BSTR;
144  V_BSTR(pVar) = SysAllocString(pwszValue);
145  heap_free(pwszValue);
146 
147  if (vtDst != VT_BSTR) {
148  hr = VariantChangeTypeEx(pVar, pVar, LOCALE_SYSTEM_DEFAULT, 0, vtDst);
149  if (FAILED(hr))
150  SysFreeString(V_BSTR(pVar));
151  }
152 
153  return hr;
154 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned char * LPBYTE
Definition: typedefs.h:53
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define LOCALE_SYSTEM_DEFAULT
unsigned long DWORD
Definition: ntddk_ex.h:95
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define S_OK
Definition: intsafe.h:51
unsigned short VARTYPE
Definition: compat.h:2113
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
static RegistryPropertyBag * impl_from_IPropertyBag(IPropertyBag *iface)
Definition: shlinstobj.c:55
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:988
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ RegistryPropertyBag_IPropertyBag_Release()

static ULONG WINAPI RegistryPropertyBag_IPropertyBag_Release ( IPropertyBag iface)
static

Definition at line 96 of file shlinstobj.c.

97 {
99  ULONG cRef;
100 
101  TRACE("(iface=%p)\n", iface);
102 
103  cRef = InterlockedDecrement(&This->m_cRef);
104 
105  if (cRef == 0) {
106  TRACE("Destroying This=%p)\n", This);
107  RegCloseKey(This->m_hInitPropertyBagKey);
108  heap_free(This);
110  }
111 
112  return cRef;
113 }
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static void SHDOCVW_UnlockModule(void)
Definition: shdocvw.h:51
unsigned int ULONG
Definition: retypes.h:1
static RegistryPropertyBag * impl_from_IPropertyBag(IPropertyBag *iface)
Definition: shlinstobj.c:55
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ RegistryPropertyBag_IPropertyBag_Write()

static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Write ( IPropertyBag iface,
LPCOLESTR  pwszPropName,
VARIANT pVar 
)
static

Definition at line 156 of file shlinstobj.c.

158 {
159  FIXME("(iface=%p, pwszPropName=%s, pVar=%p) stub\n", iface, debugstr_w(pwszPropName), pVar);
160  return E_NOTIMPL;
161 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ SHDOCVW_GetShellInstanceObjectClassObject()

HRESULT SHDOCVW_GetShellInstanceObjectClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppvClassObj 
)

Definition at line 357 of file shlinstobj.c.

359 {
360  WCHAR wszInstanceKey[] = { 'C','L','S','I','D','\\','{','0','0','0','0','0','0','0','0','-',
361  '0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0',
362  '0','0','0','0','}','\\','I','n','s','t','a','n','c','e', 0 };
363  static const WCHAR wszCLSID[] = { 'C','L','S','I','D',0 };
364  static const WCHAR wszInitPropertyBag[] =
365  { 'I','n','i','t','P','r','o','p','e','r','t','y','B','a','g',0 };
366  WCHAR wszCLSIDInstance[CHARS_IN_GUID];
367  CLSID clsidInstance;
368  HKEY hInstanceKey, hInitPropertyBagKey;
369  DWORD dwType, cbBytes = sizeof(wszCLSIDInstance);
370  IPropertyBag *pInitPropertyBag;
371  HRESULT hr;
372  LONG res;
373 
374  TRACE("(rclsid=%s, riid=%s, ppvClassObject=%p)\n", debugstr_guid(rclsid), debugstr_guid(riid),
375  ppvClassObj);
376 
377  /* Figure if there is an 'Instance' subkey for the given CLSID and acquire a handle. */
378  if (!StringFromGUID2(rclsid, wszInstanceKey + 6, CHARS_IN_GUID))
380  wszInstanceKey[5+CHARS_IN_GUID] = '\\'; /* Repair the null-termination. */
381  if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_CLASSES_ROOT, wszInstanceKey, 0, KEY_READ, &hInstanceKey))
382  /* If there is no 'Instance' subkey, then it's not a Shell Instance Object. */
384 
385  if (ERROR_SUCCESS != RegQueryValueExW(hInstanceKey, wszCLSID, NULL, &dwType, (LPBYTE)wszCLSIDInstance, &cbBytes) ||
386  FAILED(CLSIDFromString(wszCLSIDInstance, &clsidInstance)))
387  {
388  /* 'Instance' should have a 'CLSID' value with a well-formed clsid-string. */
389  FIXME("Failed to infer instance CLSID! %s\n", debugstr_w(wszCLSIDInstance));
390  RegCloseKey(hInstanceKey);
392  }
393 
394  /* Try to open the 'InitPropertyBag' subkey. */
395  res = RegOpenKeyExW(hInstanceKey, wszInitPropertyBag, 0, KEY_READ, &hInitPropertyBagKey);
396  RegCloseKey(hInstanceKey);
397  if (res != ERROR_SUCCESS) {
398  /* Besides 'InitPropertyBag's, shell instance objects might be initialized by streams.
399  * So this case might not be an error. */
400  TRACE("No InitPropertyBag key found!\n");
402  }
403 
404  /* If the construction succeeds, the new RegistryPropertyBag is responsible for closing
405  * hInitPropertyBagKey. */
406  hr = RegistryPropertyBag_Constructor(hInitPropertyBagKey, &IID_IPropertyBag,
407  (LPVOID*)&pInitPropertyBag);
408  if (FAILED(hr)) {
409  RegCloseKey(hInitPropertyBagKey);
410  return hr;
411  }
412 
413  /* Construct an Instance Object Factory, which creates objects of class 'clsidInstance'
414  * and asks them to initialize themselves with the help of the 'pInitiPropertyBag' */
415  hr = InstanceObjectFactory_Constructor(&clsidInstance, pInitPropertyBag, riid, ppvClassObj);
416  IPropertyBag_Release(pInitPropertyBag); /* The factory will hold a reference the bag. */
417 
418  return hr;
419 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
REFIID riid
Definition: precomp.h:44
static HRESULT InstanceObjectFactory_Constructor(REFCLSID rclsid, IPropertyBag *pPropertyBag, REFIID riid, LPVOID *ppvObject)
Definition: shlinstobj.c:316
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
const GUID IID_IPropertyBag
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT RegistryPropertyBag_Constructor(HKEY hInitPropertyBagKey, REFIID riid, LPVOID *ppvObject)
Definition: shlinstobj.c:171
LONG HRESULT
Definition: typedefs.h:79
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CHARS_IN_GUID
Definition: shlinstobj.c:42
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by DllGetClassObject().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shdocvw  )

Variable Documentation

◆ InstanceObjectFactory_IClassFactoryVtbl

const IClassFactoryVtbl InstanceObjectFactory_IClassFactoryVtbl
static
Initial value:
= {
}
static ULONG WINAPI InstanceObjectFactory_IClassFactory_Release(IClassFactory *iface)
Definition: shlinstobj.c:247
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObj)
Definition: shlinstobj.c:265
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: shlinstobj.c:211
static ULONG WINAPI InstanceObjectFactory_IClassFactory_AddRef(IClassFactory *iface)
Definition: shlinstobj.c:232
static HRESULT WINAPI InstanceObjectFactory_IClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: shlinstobj.c:295

Definition at line 308 of file shlinstobj.c.

Referenced by InstanceObjectFactory_Constructor().

◆ RegistryPropertyBag_IPropertyBagVtbl

const IPropertyBagVtbl RegistryPropertyBag_IPropertyBagVtbl
static
Initial value:
= {
}
static ULONG WINAPI RegistryPropertyBag_IPropertyBag_Release(IPropertyBag *iface)
Definition: shlinstobj.c:96
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface, REFIID riid, void **ppv)
Definition: shlinstobj.c:60
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Write(IPropertyBag *iface, LPCOLESTR pwszPropName, VARIANT *pVar)
Definition: shlinstobj.c:156
static ULONG WINAPI RegistryPropertyBag_IPropertyBag_AddRef(IPropertyBag *iface)
Definition: shlinstobj.c:81
static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Read(IPropertyBag *iface, LPCOLESTR pwszPropName, VARIANT *pVar, IErrorLog *pErrorLog)
Definition: shlinstobj.c:115

Definition at line 163 of file shlinstobj.c.

Referenced by RegistryPropertyBag_Constructor().