mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 17:43:38 +00:00
imm32: Prevent deadlock on unload.
ole32 is delay loaded, which can cause race conditions against krnl386.exe when unloading. This is because imm32 tries to get the loader lock while holding the win16 mutex, and kernel386 does the opposite. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52511 Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
This commit is contained in:
parent
131aa5135b
commit
5be2a01ce6
|
@ -80,6 +80,9 @@ typedef struct _tagImmHkl{
|
||||||
DWORD (WINAPI *pImeGetImeMenuItems)(HIMC, DWORD, DWORD, IMEMENUITEMINFOW *, IMEMENUITEMINFOW *, DWORD);
|
DWORD (WINAPI *pImeGetImeMenuItems)(HIMC, DWORD, DWORD, IMEMENUITEMINFOW *, IMEMENUITEMINFOW *, DWORD);
|
||||||
} ImmHkl;
|
} ImmHkl;
|
||||||
|
|
||||||
|
static HRESULT (WINAPI *pCoRevokeInitializeSpy)(ULARGE_INTEGER cookie);
|
||||||
|
static void (WINAPI *pCoUninitialize)(void);
|
||||||
|
|
||||||
typedef struct tagInputContextData
|
typedef struct tagInputContextData
|
||||||
{
|
{
|
||||||
HIMC handle;
|
HIMC handle;
|
||||||
|
@ -249,7 +252,7 @@ static void imm_couninit_thread(BOOL cleanup)
|
||||||
|
|
||||||
if (cleanup && spy->cookie.QuadPart)
|
if (cleanup && spy->cookie.QuadPart)
|
||||||
{
|
{
|
||||||
CoRevokeInitializeSpy(spy->cookie);
|
pCoRevokeInitializeSpy(spy->cookie);
|
||||||
spy->cookie.QuadPart = 0;
|
spy->cookie.QuadPart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +264,7 @@ static void imm_couninit_thread(BOOL cleanup)
|
||||||
{
|
{
|
||||||
spy->apt_flags &= ~IMM_APT_CREATED;
|
spy->apt_flags &= ~IMM_APT_CREATED;
|
||||||
if (spy->apt_flags & IMM_APT_CAN_FREE)
|
if (spy->apt_flags & IMM_APT_CAN_FREE)
|
||||||
CoUninitialize();
|
pCoUninitialize();
|
||||||
}
|
}
|
||||||
if (cleanup)
|
if (cleanup)
|
||||||
spy->apt_flags = 0;
|
spy->apt_flags = 0;
|
||||||
|
@ -359,10 +362,19 @@ static const IInitializeSpyVtbl InitializeSpyVtbl =
|
||||||
InitializeSpy_PostUninitialize,
|
InitializeSpy_PostUninitialize,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static BOOL WINAPI init_ole32_funcs( INIT_ONCE *once, void *param, void **context )
|
||||||
|
{
|
||||||
|
HMODULE module_ole32 = GetModuleHandleA("ole32");
|
||||||
|
pCoRevokeInitializeSpy = (void*)GetProcAddress(module_ole32, "CoRevokeInitializeSpy");
|
||||||
|
pCoUninitialize = (void*)GetProcAddress(module_ole32, "CoUninitialize");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void imm_coinit_thread(void)
|
static void imm_coinit_thread(void)
|
||||||
{
|
{
|
||||||
struct coinit_spy *spy;
|
struct coinit_spy *spy;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
static INIT_ONCE init_ole32_once = INIT_ONCE_STATIC_INIT;
|
||||||
|
|
||||||
TRACE("implicit COM initialization\n");
|
TRACE("implicit COM initialization\n");
|
||||||
|
|
||||||
|
@ -391,6 +403,8 @@ static void imm_coinit_thread(void)
|
||||||
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
spy->apt_flags |= IMM_APT_CREATED;
|
spy->apt_flags |= IMM_APT_CREATED;
|
||||||
|
|
||||||
|
InitOnceExecuteOnce(&init_ole32_once, init_ole32_funcs, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL IMM_IsDefaultContext(HIMC imc)
|
static BOOL IMM_IsDefaultContext(HIMC imc)
|
||||||
|
|
Loading…
Reference in a new issue