uiautomationcore: Increment module reference count when starting provider thread.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
This commit is contained in:
Connor McAdams 2022-09-12 11:36:23 -04:00 committed by Alexandre Julliard
parent 02b87a4002
commit d7c95765d0
3 changed files with 33 additions and 2 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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;
}