[PATCH v2 3/8] dllhost: Implement ISurrogate::LoadDllServer().

Huw Davies huw at codeweavers.com
Wed Feb 23 04:45:26 CST 2022


On Tue, Feb 22, 2022 at 05:50:02PM +0300, Dmitry Timoshkov wrote:
> v2: Fixed a few -Wformat warnings.
> 
> Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
> ---
>  programs/dllhost/dllhost.c | 217 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 213 insertions(+), 4 deletions(-)
> 
> diff --git a/programs/dllhost/dllhost.c b/programs/dllhost/dllhost.c
> index ac1cf0e3d33..5c0a93c9a71 100644
> --- a/programs/dllhost/dllhost.c
> +++ b/programs/dllhost/dllhost.c
> @@ -28,9 +28,193 @@
> +static HRESULT WINAPI factory_QueryInterface(IClassFactory *iface,
> +    REFIID iid, void **ppv)
> +{
> +    struct factory *factory = impl_from_IClassFactory(iface);
> +
> +    TRACE("(%p,%s,%p)\n", iface, wine_dbgstr_guid(iid), ppv);
> +
> +    if (!ppv) return E_INVALIDARG;
> +
> +    if (IsEqualIID(iid, &IID_IUnknown) ||
> +        IsEqualIID(iid, &IID_IClassFactory))
> +    {
> +        IClassFactory_AddRef(&factory->IClassFactory_iface);
> +        *ppv = &factory->IClassFactory_iface;
> +        return S_OK;
> +    }
> +    else if (IsEqualIID(iid, &IID_IMarshal))
> +    {
> +        IClassFactory_AddRef(&factory->IClassFactory_iface);
> +        *ppv = &factory->IMarshal_iface;
> +        return S_OK;
> +    }
> +
> +    *ppv = NULL;
> +    return E_NOINTERFACE;
> +}

[snip]

> +static HRESULT WINAPI marshal_QueryInterface(IMarshal *iface, REFIID iid, LPVOID *ppv)
> +{
> +    struct factory *factory = impl_from_IMarshal(iface);
> +
> +    TRACE("(%p,%s,%p)\n", iface, wine_dbgstr_guid(iid), ppv);
> +
> +    if (!ppv) return E_INVALIDARG;
> +
> +    if (IsEqualIID(iid, &IID_IUnknown) ||
> +        IsEqualIID(iid, &IID_IMarshal))
> +    {
> +        IMarshal_AddRef(&factory->IMarshal_iface);
> +        *ppv = &factory->IMarshal_iface;
> +        return S_OK;
> +    }
> +
> +    *ppv = NULL;
> +    return E_NOINTERFACE;
> +}

These two QI implementations break two of the QI rules:
https://docs.microsoft.com/en-us/windows/win32/com/rules-for-implementing-queryinterface

There isn't a unique identity and it's not possible to QI
IClassFactory from the IMarshal interface.


> +    factory->IClassFactory_iface.lpVtbl = &ClassFactory_Vtbl;
> +    factory->IMarshal_iface.lpVtbl = &Marshal_Vtbl;
> +    factory->clsid = *clsid;
> +    factory->ref = 1;
> +
> +    hr = CoRegisterClassObject(clsid, (IUnknown *)&factory->IClassFactory_iface,
> +                               CLSCTX_LOCAL_SERVER, REGCLS_SURROGATE, &surrogate->cookie);

Does REGCLS_SURROGATE require any special treatment from combase?

Huw.



More information about the wine-devel mailing list