Commit 7c0da27b authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

wbemprox: Do not call Release() inside wbemprox_cf_CreateInstance().

The Ubisoft overlay version 135 hot patches and hooks wbem_locator_Release(), but crashes if Release() is called inside CoCreateInstance(), a condition that doesn't appear to happen on Windows. So we try to exhibit the same behavior. (cherry picked from commit 798fbd42)
parent 49ca079b
...@@ -37,7 +37,7 @@ static HINSTANCE instance; ...@@ -37,7 +37,7 @@ static HINSTANCE instance;
struct list *table_list[WBEMPROX_NAMESPACE_LAST]; struct list *table_list[WBEMPROX_NAMESPACE_LAST];
typedef HRESULT (*fnCreateInstance)( LPVOID *ppObj ); typedef HRESULT (*fnCreateInstance)( LPVOID *ppObj, REFIID riid );
typedef struct typedef struct
{ {
...@@ -77,8 +77,6 @@ static HRESULT WINAPI wbemprox_cf_CreateInstance( IClassFactory *iface, LPUNKNOW ...@@ -77,8 +77,6 @@ static HRESULT WINAPI wbemprox_cf_CreateInstance( IClassFactory *iface, LPUNKNOW
REFIID riid, LPVOID *ppobj ) REFIID riid, LPVOID *ppobj )
{ {
wbemprox_cf *This = impl_from_IClassFactory( iface ); wbemprox_cf *This = impl_from_IClassFactory( iface );
HRESULT r;
IUnknown *punk;
TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj); TRACE("%p %s %p\n", pOuter, debugstr_guid(riid), ppobj);
...@@ -87,13 +85,7 @@ static HRESULT WINAPI wbemprox_cf_CreateInstance( IClassFactory *iface, LPUNKNOW ...@@ -87,13 +85,7 @@ static HRESULT WINAPI wbemprox_cf_CreateInstance( IClassFactory *iface, LPUNKNOW
if (pOuter) if (pOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
r = This->pfnCreateInstance( (LPVOID *)&punk ); return This->pfnCreateInstance( ppobj, riid );
if (FAILED(r))
return r;
r = IUnknown_QueryInterface( punk, riid, ppobj );
IUnknown_Release( punk );
return r;
} }
static HRESULT WINAPI wbemprox_cf_LockServer( IClassFactory *iface, BOOL dolock ) static HRESULT WINAPI wbemprox_cf_LockServer( IClassFactory *iface, BOOL dolock )
......
...@@ -1058,7 +1058,7 @@ static HRESULT WINAPI wbem_context_Clone( ...@@ -1058,7 +1058,7 @@ static HRESULT WINAPI wbem_context_Clone(
TRACE("%p, %p\n", iface, newcopy); TRACE("%p, %p\n", iface, newcopy);
if (SUCCEEDED(hr = WbemContext_create( (void **)&cloned_context ))) if (SUCCEEDED(hr = WbemContext_create( (void **)&cloned_context, &IID_IWbemContext )))
{ {
LIST_FOR_EACH_ENTRY( value, &context->values, struct wbem_context_value, entry ) LIST_FOR_EACH_ENTRY( value, &context->values, struct wbem_context_value, entry )
{ {
...@@ -1225,12 +1225,16 @@ static const IWbemContextVtbl wbem_context_vtbl = ...@@ -1225,12 +1225,16 @@ static const IWbemContextVtbl wbem_context_vtbl =
wbem_context_DeleteAll, wbem_context_DeleteAll,
}; };
HRESULT WbemContext_create( void **obj ) HRESULT WbemContext_create( void **obj, REFIID riid )
{ {
struct wbem_context *context; struct wbem_context *context;
TRACE("(%p)\n", obj); TRACE("(%p)\n", obj);
if ( !IsEqualGUID( riid, &IID_IWbemContext ) &&
!IsEqualGUID( riid, &IID_IUnknown ) )
return E_NOINTERFACE;
if (!(context = malloc( sizeof(*context) ))) return E_OUTOFMEMORY; if (!(context = malloc( sizeof(*context) ))) return E_OUTOFMEMORY;
context->IWbemContext_iface.lpVtbl = &wbem_context_vtbl; context->IWbemContext_iface.lpVtbl = &wbem_context_vtbl;
......
...@@ -202,12 +202,16 @@ static const IWbemLocatorVtbl wbem_locator_vtbl = ...@@ -202,12 +202,16 @@ static const IWbemLocatorVtbl wbem_locator_vtbl =
wbem_locator_ConnectServer wbem_locator_ConnectServer
}; };
HRESULT WbemLocator_create( LPVOID *ppObj ) HRESULT WbemLocator_create( LPVOID *ppObj, REFIID riid )
{ {
wbem_locator *wl; wbem_locator *wl;
TRACE("(%p)\n", ppObj); TRACE("(%p)\n", ppObj);
if ( !IsEqualGUID( riid, &IID_IWbemLocator ) &&
!IsEqualGUID( riid, &IID_IUnknown ) )
return E_NOINTERFACE;
if (!(wl = malloc( sizeof(*wl) ))) return E_OUTOFMEMORY; if (!(wl = malloc( sizeof(*wl) ))) return E_OUTOFMEMORY;
wl->IWbemLocator_iface.lpVtbl = &wbem_locator_vtbl; wl->IWbemLocator_iface.lpVtbl = &wbem_locator_vtbl;
......
...@@ -246,9 +246,9 @@ void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN; ...@@ -246,9 +246,9 @@ void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN;
HRESULT create_signature( enum wbm_namespace ns, const WCHAR *, const WCHAR *, enum param_direction, HRESULT create_signature( enum wbm_namespace ns, const WCHAR *, const WCHAR *, enum param_direction,
IWbemClassObject ** ) DECLSPEC_HIDDEN; IWbemClassObject ** ) DECLSPEC_HIDDEN;
HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN; HRESULT WbemLocator_create(LPVOID *, REFIID) DECLSPEC_HIDDEN;
HRESULT WbemServices_create(const WCHAR *, IWbemContext *, LPVOID *) DECLSPEC_HIDDEN; HRESULT WbemServices_create(const WCHAR *, IWbemContext *, LPVOID *) DECLSPEC_HIDDEN;
HRESULT WbemContext_create(void **) DECLSPEC_HIDDEN; HRESULT WbemContext_create(void **, REFIID) DECLSPEC_HIDDEN;
HRESULT create_class_object(enum wbm_namespace ns, const WCHAR *, IEnumWbemClassObject *, UINT, HRESULT create_class_object(enum wbm_namespace ns, const WCHAR *, IEnumWbemClassObject *, UINT,
struct record *, IWbemClassObject **) DECLSPEC_HIDDEN; struct record *, IWbemClassObject **) DECLSPEC_HIDDEN;
HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN; HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment