Commit d7c95765 authored by Connor McAdams's avatar Connor McAdams Committed by Alexandre Julliard

uiautomationcore: Increment module reference count when starting provider thread.

parent 02b87a40
......@@ -27,6 +27,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(uiautomation);
HMODULE huia_module;
struct uia_object_wrapper
{
IUnknown IUnknown_iface;
......@@ -349,3 +351,24 @@ HRESULT WINAPI UiaDisconnectProvider(IRawElementProviderSimple *provider)
FIXME("(%p): stub\n", provider);
return E_NOTIMPL;
}
/***********************************************************************
* DllMain (uiautomationcore.@)
*/
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved)
{
TRACE("(%p, %ld, %p)\n", hinst, reason, reserved);
switch (reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinst);
huia_module = hinst;
break;
default:
break;
}
return TRUE;
}
......@@ -21,6 +21,8 @@
#include "uiautomation.h"
#include "uia_classes.h"
extern HMODULE huia_module DECLSPEC_HIDDEN;
enum uia_prop_type {
PROP_TYPE_UNKNOWN,
PROP_TYPE_ELEM_PROP,
......
......@@ -1193,7 +1193,7 @@ static DWORD WINAPI uia_provider_thread_proc(void *arg)
{
WARN("CreateWindow failed: %ld\n", GetLastError());
CoUninitialize();
ExitThread(1);
FreeLibraryAndExitThread(huia_module, 1);
}
SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)uia_provider_thread_msg_proc);
......@@ -1212,7 +1212,7 @@ static DWORD WINAPI uia_provider_thread_proc(void *arg)
DestroyWindow(hwnd);
CoUninitialize();
ExitThread(0);
FreeLibraryAndExitThread(huia_module, 0);
}
static BOOL uia_start_provider_thread(void)
......@@ -1224,12 +1224,18 @@ static BOOL uia_start_provider_thread(void)
{
HANDLE ready_event;
HANDLE events[2];
HMODULE hmodule;
DWORD wait_obj;
/* Increment DLL reference count. */
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
(const WCHAR *)uia_start_provider_thread, &hmodule);
events[0] = ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
if (!(provider_thread.hthread = CreateThread(NULL, 0, uia_provider_thread_proc,
ready_event, 0, NULL)))
{
FreeLibrary(hmodule);
started = FALSE;
goto exit;
}
......
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