Commit 3b1e55d0 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

crypt32: CryptFreeOIDFunctionAddress should not unload a registered module.

MSDN states that hModule passed to CryptInstallOIDFunctionAddress() should be used to prevent this module to be unloaded by CryptFreeOIDFunctionAddress in case the provider's DLL uses CryptRegisterOIDFunction to add its own entries. Signed-off-by: 's avatarDmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 787133fc
......@@ -59,6 +59,7 @@ struct OIDFunctionSet
struct OIDFunction
{
HMODULE hModule;
DWORD encoding;
CRYPT_OID_FUNC_ENTRY entry;
struct list next;
......@@ -271,6 +272,7 @@ BOOL WINAPI CryptInstallOIDFunctionAddress(HMODULE hModule,
else
func->entry.pszOID = rgFuncEntry[i].pszOID;
func->entry.pvFuncAddr = rgFuncEntry[i].pvFuncAddr;
func->hModule = hModule;
list_add_tail(&set->functions, &func->next);
}
else
......@@ -428,6 +430,38 @@ BOOL WINAPI CryptGetOIDFunctionAddress(HCRYPTOIDFUNCSET hFuncSet,
return ret;
}
static BOOL is_module_registered(HMODULE hModule)
{
struct OIDFunctionSet *set;
BOOL ret = FALSE;
EnterCriticalSection(&funcSetCS);
LIST_FOR_EACH_ENTRY(set, &funcSets, struct OIDFunctionSet, next)
{
struct OIDFunction *function;
EnterCriticalSection(&set->cs);
LIST_FOR_EACH_ENTRY(function, &set->functions, struct OIDFunction, next)
{
if (function->hModule == hModule)
{
ret = TRUE;
break;
}
}
LeaveCriticalSection(&set->cs);
if (ret) break;
}
LeaveCriticalSection(&funcSetCS);
return ret;
}
BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr,
DWORD dwFlags)
{
......@@ -441,9 +475,12 @@ BOOL WINAPI CryptFreeOIDFunctionAddress(HCRYPTOIDFUNCADDR hFuncAddr,
{
struct FuncAddr *addr = hFuncAddr;
CryptMemFree(addr->dllList);
FreeLibrary(addr->lib);
CryptMemFree(addr);
if (!is_module_registered(addr->lib))
{
CryptMemFree(addr->dllList);
FreeLibrary(addr->lib);
CryptMemFree(addr);
}
}
return TRUE;
}
......
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