From 0bc8e64ea2f220a33a4c18421be9b2289f12fc54 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 11 Jun 2009 11:42:07 +0000 Subject: [PATCH] - Add a lazy-initializing hack until user32 is able to delay-load the advapi32 as it should. It fixes a problem of trying to enter a non-initialized critical section object and possibly hanging on every boot. svn path=/trunk/; revision=41379 --- reactos/dll/win32/advapi32/reg/reg.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/reactos/dll/win32/advapi32/reg/reg.c b/reactos/dll/win32/advapi32/reg/reg.c index b89b2546322..37a9a146673 100644 --- a/reactos/dll/win32/advapi32/reg/reg.c +++ b/reactos/dll/win32/advapi32/reg/reg.c @@ -31,6 +31,7 @@ static HANDLE DefaultHandleTable[MAX_DEFAULT_HANDLES]; static HANDLE ProcessHeap; static BOOLEAN DefaultHandlesDisabled = FALSE; static BOOLEAN DefaultHandleHKUDisabled = FALSE; +static BOOLEAN DllInitialized = FALSE; /* HACK */ /* PROTOTYPES ***************************************************************/ @@ -66,10 +67,16 @@ RegInitialize(VOID) { TRACE("RegInitialize()\n"); - ProcessHeap = RtlGetProcessHeap(); - RtlZeroMemory(DefaultHandleTable, - MAX_DEFAULT_HANDLES * sizeof(HANDLE)); - RtlInitializeCriticalSection(&HandleTableCS); + /* Lazy init hack */ + if (!DllInitialized) + { + ProcessHeap = RtlGetProcessHeap(); + RtlZeroMemory(DefaultHandleTable, + MAX_DEFAULT_HANDLES * sizeof(HANDLE)); + RtlInitializeCriticalSection(&HandleTableCS); + + DllInitialized = TRUE; + } return TRUE; } @@ -161,7 +168,7 @@ MapDefaultKey(OUT PHANDLE RealKey, { return STATUS_INVALID_PARAMETER; } - + RegInitialize(); /* HACK until delay-loading is implemented */ RtlEnterCriticalSection (&HandleTableCS); if (Key == HKEY_CURRENT_USER) @@ -205,7 +212,7 @@ static VOID CloseDefaultKeys(VOID) { ULONG i; - + RegInitialize(); /* HACK until delay-loading is implemented */ RtlEnterCriticalSection(&HandleTableCS); for (i = 0; i < MAX_DEFAULT_HANDLES; i++) @@ -311,6 +318,7 @@ OpenCurrentConfigKey (PHANDLE KeyHandle) LONG WINAPI RegDisablePredefinedCache(VOID) { + RegInitialize(); /* HACK until delay-loading is implemented */ RtlEnterCriticalSection(&HandleTableCS); DefaultHandleHKUDisabled = TRUE; RtlLeaveCriticalSection(&HandleTableCS); @@ -326,6 +334,7 @@ RegDisablePredefinedCache(VOID) LONG WINAPI RegDisablePredefinedCacheEx(VOID) { + RegInitialize(); /* HACK until delay-loading is implemented */ RtlEnterCriticalSection(&HandleTableCS); DefaultHandlesDisabled = TRUE; DefaultHandleHKUDisabled = TRUE; @@ -371,7 +380,7 @@ RegOverridePredefKey(IN HKEY hKey, ASSERT(hNewHKey != NULL); } - + RegInitialize(); /* HACK until delay-loading is implemented */ RtlEnterCriticalSection(&HandleTableCS); /* close the currently mapped handle if existing */ @@ -3472,7 +3481,7 @@ ReadTokenSid: handle for example! */ return RtlNtStatusToDosError(Status); } - + RegInitialize(); /* HACK until delay-loading is implemented */ TokenUserData = RtlAllocateHeap(ProcessHeap, 0, RequiredLength); -- 2.17.1