advapi32: Implement RegDisablePredefinedCache.

This commit is contained in:
Robert Shearman 2006-06-30 11:06:48 +01:00 committed by Alexandre Julliard
parent 8a42a8c11a
commit 52aaddcd34
2 changed files with 37 additions and 1 deletions

View File

@ -475,7 +475,7 @@
@ stdcall RegDeleteKeyW(long wstr)
@ stdcall RegDeleteValueA(long str)
@ stdcall RegDeleteValueW(long wstr)
# @ stub RegDisablePredefinedCache
@ stdcall RegDisablePredefinedCache()
@ stdcall RegEnumKeyA(long long ptr long)
@ stdcall RegEnumKeyExA(long long ptr ptr ptr ptr ptr ptr)
@ stdcall RegEnumKeyExW(long long ptr ptr ptr ptr ptr ptr)

View File

@ -52,6 +52,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(reg);
#define NB_SPECIAL_ROOT_KEYS ((UINT)HKEY_SPECIAL_ROOT_LAST - (UINT)HKEY_SPECIAL_ROOT_FIRST + 1)
static HKEY special_root_keys[NB_SPECIAL_ROOT_KEYS];
static BOOL hkcu_cache_disabled;
static const WCHAR name_CLASSES_ROOT[] =
{'M','a','c','h','i','n','e','\\',
@ -108,6 +109,10 @@ static HKEY create_special_root_hkey( HANDLE hkey, DWORD access )
{
if (RtlOpenCurrentUser( access, &hkey )) return 0;
TRACE( "HKEY_CURRENT_USER -> %p\n", hkey );
/* don't cache the key in the table if caching is disabled */
if (hkcu_cache_disabled)
return hkey;
}
else
{
@ -2565,3 +2570,34 @@ cleanup:
return result;
}
/******************************************************************************
* RegDisablePredefinedCache [ADVAPI32.@]
*
* Disables the caching of the HKEY_CLASSES_ROOT key for the process.
*
* PARAMS
* None.
*
* RETURNS
* Success: ERROR_SUCCESS
* Failure: nonzero error code from Winerror.h
*
* NOTES
* This is useful for services that use impersonation.
*/
LONG WINAPI RegDisablePredefinedCache(void)
{
HKEY hkey_current_user;
int idx = (UINT_PTR)HKEY_CURRENT_USER - (UINT_PTR)HKEY_SPECIAL_ROOT_FIRST;
/* prevent caching of future requests */
hkcu_cache_disabled = TRUE;
hkey_current_user = InterlockedExchangePointer( (void **)&special_root_keys[idx], NULL );
if (hkey_current_user)
NtClose( hkey_current_user );
return ERROR_SUCCESS;
}