Robert Shearman : advapi32: Implement RegDisablePredefinedCache.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jun 30 14:15:11 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 52aaddcd3493c263d3e60533ac3473804aad3f47
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=52aaddcd3493c263d3e60533ac3473804aad3f47
Author: Robert Shearman <rob at codeweavers.com>
Date: Fri Jun 30 11:06:48 2006 +0100
advapi32: Implement RegDisablePredefinedCache.
---
dlls/advapi32/advapi32.spec | 2 +-
dlls/advapi32/registry.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec
index 438b671..4826df9 100644
--- a/dlls/advapi32/advapi32.spec
+++ b/dlls/advapi32/advapi32.spec
@@ -475,7 +475,7 @@ # @ stub ReadEncryptedFileRaw
@ 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)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 7790862..e99cce7 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -52,6 +52,7 @@ #define HKEY_SPECIAL_ROOT_LAST HKEY_D
#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( HA
{
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;
+}
More information about the wine-cvs
mailing list