From 54519fea36312e21c82ae7ca80339fbc0124b5a9 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Mariusz=20Pluci=C5=84ski?= Date: Mon, 7 Jun 2010 22:25:03 +0200 Subject: gameux: Add IClassFactory implementation --- dlls/gameux/Makefile.in | 1 + dlls/gameux/factory.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++ dlls/gameux/gameux.spec | 1 + 3 files changed, 138 insertions(+), 0 deletions(-) create mode 100644 dlls/gameux/factory.c diff --git a/dlls/gameux/Makefile.in b/dlls/gameux/Makefile.in index 94ad833..bb31630 100644 --- a/dlls/gameux/Makefile.in +++ b/dlls/gameux/Makefile.in @@ -8,6 +8,7 @@ IMPORTS = ole32 user32 kernel32 advapi32 EXTRALIBS = -luuid C_SRCS = \ + factory.c \ main.c \ regsvr.c diff --git a/dlls/gameux/factory.c b/dlls/gameux/factory.c new file mode 100644 index 0000000..50f52ef --- /dev/null +++ b/dlls/gameux/factory.c @@ -0,0 +1,136 @@ +/* + * gameux Class Factory + * + * Copyright (C) 2008 Alistair Leslie-Hughes + * Copyright (C) 2010 Mariusz PluciƄski + * + * 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 +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "gameux.h" + +#include "wine/debug.h" + + +WINE_DEFAULT_DEBUG_CHANNEL(gameux); + +typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); + +/****************************************************************************** + * comsvcs ClassFactory + */ +typedef struct _gameuxcf +{ + const struct IClassFactoryVtbl *lpVtbl; + fnCreateInstance pfnCreateInstance; +} gameuxcf; + +static inline gameuxcf *impl_from_IClassFactory( IClassFactory *iface ) +{ + return (gameuxcf *)((char*)iface - FIELD_OFFSET(gameuxcf, lpVtbl)); +} + +static HRESULT WINAPI gameuxcf_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 gameuxcf_AddRef( + IClassFactory *iface ) +{ + return 2; +} + +static ULONG WINAPI gameuxcf_Release( + IClassFactory *iface ) +{ + return 1; +} + +static HRESULT WINAPI gameuxcf_CreateInstance( + IClassFactory *iface, + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID *ppobj ) +{ + gameuxcf *This = impl_from_IClassFactory( iface ); + HRESULT r; + IUnknown *punk; + + TRACE("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppobj ); + + *ppobj = NULL; + + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + r = This->pfnCreateInstance( pUnkOuter, (LPVOID*)&punk ); + if (FAILED(r)) + return r; + + r = IUnknown_QueryInterface( punk, riid, ppobj ); + IUnknown_Release( punk ); + return r; +} + +static HRESULT WINAPI gameuxcf_LockServer( + IClassFactory *iface, + BOOL dolock) +{ + FIXME("(%p)->(%d),stub!\n",iface,dolock); + return S_OK; +} + +static const struct IClassFactoryVtbl gameuxcf_vtbl = +{ + gameuxcf_QueryInterface, + gameuxcf_AddRef, + gameuxcf_Release, + gameuxcf_CreateInstance, + gameuxcf_LockServer +}; + +/****************************************************************** + * DllGetClassObject (GAMEUX.@) + */ +HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv ) +{ + TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv ); + FIXME("stub\n"); + + return CLASS_E_CLASSNOTAVAILABLE; +} + diff --git a/dlls/gameux/gameux.spec b/dlls/gameux/gameux.spec index 89f32c7..def4ca2 100644 --- a/dlls/gameux/gameux.spec +++ b/dlls/gameux/gameux.spec @@ -1,5 +1,6 @@ @ stub GameUXShimW @ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) @ stdcall -private DllRegisterServer() @ stdcall -private DllUnregisterServer() -- 1.6.2.5