[KERNEL32] Fix IsShimInfrastructureDisabled. CORE-13352
authorMark Jansen <mark.jansen@reactos.org>
Sat, 3 Jun 2017 13:06:32 +0000 (13:06 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Sat, 3 Jun 2017 13:06:32 +0000 (13:06 +0000)
svn path=/trunk/; revision=74760

reactos/dll/win32/kernel32/client/appcache.c

index 2180498..cd49ebe 100644 (file)
@@ -15,7 +15,7 @@
 
 /* GLOBALS ********************************************************************/
 
 
 /* GLOBALS ********************************************************************/
 
-ULONG g_ShimsEnabled = -1;
+ULONG g_ShimsDisabled = -1;
 static BOOL g_ApphelpInitialized = FALSE;
 static PVOID g_pApphelpCheckRunAppEx;
 static PVOID g_pSdbPackAppCompatData;
 static BOOL g_ApphelpInitialized = FALSE;
 static PVOID g_pApphelpCheckRunAppEx;
 static PVOID g_pSdbPackAppCompatData;
@@ -54,8 +54,10 @@ IsShimInfrastructureDisabled(VOID)
      * This is a TROOLEAN, -1 means we haven't yet figured it out.
      * 0 means shims are enabled, and 1 means shims are disabled!
      */
      * This is a TROOLEAN, -1 means we haven't yet figured it out.
      * 0 means shims are enabled, and 1 means shims are disabled!
      */
-    if (g_ShimsEnabled == -1)
+    if (g_ShimsDisabled == -1)
     {
     {
+        ULONG DisableShims = FALSE;
+
         /* Open the safe mode key */
         Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &OptionKeyAttributes);
         if (NT_SUCCESS(Status))
         /* Open the safe mode key */
         Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &OptionKeyAttributes);
         if (NT_SUCCESS(Status))
@@ -74,66 +76,63 @@ IsShimInfrastructureDisabled(VOID)
                  (KeyInfo.Data[0] == TRUE))
             {
                 /* It is, so disable shims! */
                  (KeyInfo.Data[0] == TRUE))
             {
                 /* It is, so disable shims! */
-                g_ShimsEnabled = TRUE;
+                DisableShims = TRUE;
+            }
+        }
+
+        if (!DisableShims)
+        {
+            /* Open the app compatibility engine settings key */
+            Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &AppCompatKeyAttributes);
+            if (NT_SUCCESS(Status))
+            {
+                /* Check if the app compat engine is turned off */
+                Status = NtQueryValueKey(KeyHandle,
+                                         &DisableAppCompat,
+                                         KeyValuePartialInformation,
+                                         &KeyInfo,
+                                         sizeof(KeyInfo),
+                                         &ResultLength);
+                NtClose(KeyHandle);
+                if ((NT_SUCCESS(Status)) &&
+                    (KeyInfo.Type == REG_DWORD) &&
+                    (KeyInfo.DataLength == sizeof(ULONG)) &&
+                    (KeyInfo.Data[0] == TRUE))
+                {
+                    /* It is, so disable shims! */
+                    DisableShims = TRUE;
+                }
             }
             }
-            else
+        }
+        if (!DisableShims)
+        {
+            /* Finally, open the app compatibility policy key */
+            Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &PolicyKeyAttributes);
+            if (NT_SUCCESS(Status))
             {
             {
-                /* Open the app compatibility engine settings key */
-                Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &AppCompatKeyAttributes);
-                if (NT_SUCCESS(Status))
+                /* Check if the system policy disables app compat */
+                Status = NtQueryValueKey(KeyHandle,
+                                         &DisableEngine,
+                                         KeyValuePartialInformation,
+                                         &KeyInfo,
+                                         sizeof(KeyInfo),
+                                         &ResultLength);
+                NtClose(KeyHandle);
+                if ((NT_SUCCESS(Status)) &&
+                    (KeyInfo.Type == REG_DWORD) &&
+                    (KeyInfo.DataLength == sizeof(ULONG)) &&
+                    (KeyInfo.Data[0] == TRUE))
                 {
                 {
-                    /* Check if the app compat engine is turned off */
-                    Status = NtQueryValueKey(KeyHandle,
-                                             &DisableAppCompat,
-                                             KeyValuePartialInformation,
-                                             &KeyInfo,
-                                             sizeof(KeyInfo),
-                                             &ResultLength);
-                    NtClose(KeyHandle);
-                    if ((NT_SUCCESS(Status)) &&
-                        (KeyInfo.Type == REG_DWORD) &&
-                        (KeyInfo.DataLength == sizeof(ULONG)) &&
-                        (KeyInfo.Data[0] == TRUE))
-                    {
-                        /* It is, so disable shims! */
-                        g_ShimsEnabled = TRUE;
-                    }
-                    else
-                    {
-                        /* Finally, open the app compatibility policy key */
-                        Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &PolicyKeyAttributes);
-                        if (NT_SUCCESS(Status))
-                        {
-                            /* Check if the system policy disables app compat */
-                            Status = NtQueryValueKey(KeyHandle,
-                                                     &DisableEngine,
-                                                     KeyValuePartialInformation,
-                                                     &KeyInfo,
-                                                     sizeof(KeyInfo),
-                                                     &ResultLength);
-                            NtClose(KeyHandle);
-                            if ((NT_SUCCESS(Status)) &&
-                                (KeyInfo.Type == REG_DWORD) &&
-                                (KeyInfo.DataLength == sizeof(ULONG)) &&
-                                (KeyInfo.Data[0] == TRUE))
-                            {
-                                /* It does, so disable shims! */
-                                g_ShimsEnabled = TRUE;
-                            }
-                            else
-                            {
-                                /* No keys are set, so enable shims! */
-                                g_ShimsEnabled = FALSE;
-                            }
-                        }
-                    }
+                    /* It does, so disable shims! */
+                    DisableShims = TRUE;
                 }
             }
         }
                 }
             }
         }
+        g_ShimsDisabled = DisableShims;
     }
 
     /* Return if shims are disabled or not ("Enabled == 1" means disabled!) */
     }
 
     /* Return if shims are disabled or not ("Enabled == 1" means disabled!) */
-    return g_ShimsEnabled ? TRUE : FALSE;
+    return g_ShimsDisabled ? TRUE : FALSE;
 }
 
 /*
 }
 
 /*