1 /* Copyright (C) 2022 Esme Povirk
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
33 #include "diasymreader_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(diasymreader
);
39 HRESULT (*constructor
)(REFIID
,void**);
42 static const classinfo classes
[] = {
43 {&CLSID_CorSymWriter_SxS
, SymWriter_CreateInstance
}
47 IClassFactory IClassFactory_iface
;
49 const classinfo
*info
;
52 static inline ClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
54 return CONTAINING_RECORD(iface
, ClassFactoryImpl
, IClassFactory_iface
);
57 static HRESULT WINAPI
ClassFactoryImpl_QueryInterface(IClassFactory
*iface
,
58 REFIID iid
, void **ppv
)
60 ClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
61 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
63 if (!ppv
) return E_INVALIDARG
;
65 if (IsEqualIID(&IID_IUnknown
, iid
) ||
66 IsEqualIID(&IID_IClassFactory
, iid
))
68 *ppv
= &This
->IClassFactory_iface
;
76 IUnknown_AddRef((IUnknown
*)*ppv
);
80 static ULONG WINAPI
ClassFactoryImpl_AddRef(IClassFactory
*iface
)
82 ClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
83 ULONG ref
= InterlockedIncrement(&This
->ref
);
85 TRACE("(%p) refcount=%lu\n", iface
, ref
);
90 static ULONG WINAPI
ClassFactoryImpl_Release(IClassFactory
*iface
)
92 ClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
93 ULONG ref
= InterlockedDecrement(&This
->ref
);
95 TRACE("(%p) refcount=%lu\n", iface
, ref
);
103 static HRESULT WINAPI
ClassFactoryImpl_CreateInstance(IClassFactory
*iface
,
104 IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
106 ClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
110 if (pUnkOuter
) return CLASS_E_NOAGGREGATION
;
112 return This
->info
->constructor(riid
, ppv
);
115 static HRESULT WINAPI
ClassFactoryImpl_LockServer(IClassFactory
*iface
, BOOL lock
)
117 TRACE("(%p, %i): stub\n", iface
, lock
);
121 static const IClassFactoryVtbl ClassFactoryImpl_Vtbl
= {
122 ClassFactoryImpl_QueryInterface
,
123 ClassFactoryImpl_AddRef
,
124 ClassFactoryImpl_Release
,
125 ClassFactoryImpl_CreateInstance
,
126 ClassFactoryImpl_LockServer
129 static HRESULT
ClassFactoryImpl_Constructor(const classinfo
*info
, REFIID riid
, LPVOID
*ppv
)
131 ClassFactoryImpl
*This
;
136 This
= malloc(sizeof(ClassFactoryImpl
));
137 if (!This
) return E_OUTOFMEMORY
;
139 This
->IClassFactory_iface
.lpVtbl
= &ClassFactoryImpl_Vtbl
;
143 ret
= IClassFactory_QueryInterface(&This
->IClassFactory_iface
, riid
, ppv
);
144 IClassFactory_Release(&This
->IClassFactory_iface
);
149 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
152 const classinfo
*info
=NULL
;
155 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
157 if (!rclsid
|| !iid
|| !ppv
)
162 for (i
=0; classes
[i
].classid
; i
++)
164 if (IsEqualCLSID(classes
[i
].classid
, rclsid
))
172 ret
= ClassFactoryImpl_Constructor(info
, iid
, ppv
);
174 ret
= CLASS_E_CLASSNOTAVAILABLE
;
176 TRACE("<-- %08lx\n", ret
);