[PATCH v3 5/8] dllhost: Implement ISurrogate::FreeSurrogate().
Dmitry Timoshkov
dmitry at baikal.ru
Thu Feb 24 02:50:46 CST 2022
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
programs/dllhost/dllhost.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/programs/dllhost/dllhost.c b/programs/dllhost/dllhost.c
index 681a20a6bb5..ce21aff9f8a 100644
--- a/programs/dllhost/dllhost.c
+++ b/programs/dllhost/dllhost.c
@@ -210,6 +210,7 @@ struct surrogate
ISurrogate ISurrogate_iface;
IClassFactory *factory;
DWORD cookie;
+ HANDLE event;
LONG ref;
};
@@ -273,15 +274,35 @@ static HRESULT WINAPI surrogate_LoadDllServer(ISurrogate *iface, const CLSID *cl
if (hr != S_OK)
IClassFactory_Release(&factory->IClassFactory_iface);
else
+ {
surrogate->factory = &factory->IClassFactory_iface;
+ surrogate->event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ }
return hr;
}
static HRESULT WINAPI surrogate_FreeSurrogate(ISurrogate *iface)
{
- FIXME("(%p): stub\n", iface);
- return E_NOTIMPL;
+ struct surrogate *surrogate = impl_from_ISurrogate(iface);
+
+ TRACE("(%p)\n", iface);
+
+ if (surrogate->cookie)
+ {
+ CoRevokeClassObject(surrogate->cookie);
+ surrogate->cookie = 0;
+ }
+
+ if (surrogate->factory)
+ {
+ IClassFactory_Release(surrogate->factory);
+ surrogate->factory = NULL;
+ }
+
+ SetEvent(surrogate->event);
+
+ return S_OK;
}
static const ISurrogateVtbl Surrogate_Vtbl =
@@ -307,6 +328,7 @@ int WINAPI wWinMain(HINSTANCE hinst, HINSTANCE previnst, LPWSTR cmdline, int sho
surrogate.ISurrogate_iface.lpVtbl = &Surrogate_Vtbl;
surrogate.factory = NULL;
surrogate.cookie = 0;
+ surrogate.event = NULL;
surrogate.ref = 1;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -323,8 +345,7 @@ int WINAPI wWinMain(HINSTANCE hinst, HINSTANCE previnst, LPWSTR cmdline, int sho
goto cleanup;
}
- /* FIXME: wait for FreeSurrogate being called */
- Sleep(INFINITE);
+ WaitForSingleObject(surrogate.event, INFINITE);
}
cleanup:
--
2.35.1
More information about the wine-devel
mailing list