[ros-diffs] [fireball] 41379: - 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.

fireball at svn.reactos.org fireball at svn.reactos.org
Thu Jun 11 13:42:08 CEST 2009


Author: fireball
Date: Thu Jun 11 15:42:07 2009
New Revision: 41379

URL: http://svn.reactos.org/svn/reactos?rev=41379&view=rev
Log:
- 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.

Modified:
    trunk/reactos/dll/win32/advapi32/reg/reg.c

Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg.c?rev=41379&r1=41378&r2=41379&view=diff
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Thu Jun 11 15:42:07 2009
@@ -31,6 +31,7 @@
 static HANDLE ProcessHeap;
 static BOOLEAN DefaultHandlesDisabled = FALSE;
 static BOOLEAN DefaultHandleHKUDisabled = FALSE;
+static BOOLEAN DllInitialized = FALSE; /* HACK */
 
 /* PROTOTYPES ***************************************************************/
 
@@ -66,10 +67,16 @@
 {
     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 @@
     {
         return STATUS_INVALID_PARAMETER;
     }
-
+    RegInitialize(); /* HACK until delay-loading is implemented */
     RtlEnterCriticalSection (&HandleTableCS);
 
     if (Key == HKEY_CURRENT_USER)
@@ -205,7 +212,7 @@
 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 @@
 LONG WINAPI
 RegDisablePredefinedCache(VOID)
 {
+    RegInitialize(); /* HACK until delay-loading is implemented */
     RtlEnterCriticalSection(&HandleTableCS);
     DefaultHandleHKUDisabled = TRUE;
     RtlLeaveCriticalSection(&HandleTableCS);
@@ -326,6 +334,7 @@
 LONG WINAPI
 RegDisablePredefinedCacheEx(VOID)
 {
+    RegInitialize(); /* HACK until delay-loading is implemented */
     RtlEnterCriticalSection(&HandleTableCS);
     DefaultHandlesDisabled = TRUE;
     DefaultHandleHKUDisabled = TRUE;
@@ -371,7 +380,7 @@
 
             ASSERT(hNewHKey != NULL);
         }
-
+        RegInitialize(); /* HACK until delay-loading is implemented */
         RtlEnterCriticalSection(&HandleTableCS);
 
         /* close the currently mapped handle if existing */
@@ -3472,7 +3481,7 @@
                   handle for example! */
         return RtlNtStatusToDosError(Status);
     }
-
+    RegInitialize(); /* HACK until delay-loading is implemented */
     TokenUserData = RtlAllocateHeap(ProcessHeap,
                                     0,
                                     RequiredLength);



More information about the Ros-diffs mailing list