[KERNEL32] Fix IsShimInfrastructureDisabled. CORE-13352

svn path=/trunk/; revision=74760
This commit is contained in:
Mark Jansen 2017-06-03 13:06:32 +00:00
parent 63eb4b623a
commit eb88e1e349

View file

@ -15,7 +15,7 @@
/* GLOBALS ********************************************************************/ /* GLOBALS ********************************************************************/
ULONG g_ShimsEnabled = -1; ULONG g_ShimsDisabled = -1;
static BOOL g_ApphelpInitialized = FALSE; static BOOL g_ApphelpInitialized = FALSE;
static PVOID g_pApphelpCheckRunAppEx; static PVOID g_pApphelpCheckRunAppEx;
static PVOID g_pSdbPackAppCompatData; static PVOID g_pSdbPackAppCompatData;
@ -54,8 +54,10 @@ IsShimInfrastructureDisabled(VOID)
* This is a TROOLEAN, -1 means we haven't yet figured it out. * This is a TROOLEAN, -1 means we haven't yet figured it out.
* 0 means shims are enabled, and 1 means shims are disabled! * 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 */ /* Open the safe mode key */
Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &OptionKeyAttributes); Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &OptionKeyAttributes);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
@ -74,9 +76,11 @@ IsShimInfrastructureDisabled(VOID)
(KeyInfo.Data[0] == TRUE)) (KeyInfo.Data[0] == TRUE))
{ {
/* It is, so disable shims! */ /* It is, so disable shims! */
g_ShimsEnabled = TRUE; DisableShims = TRUE;
} }
else }
if (!DisableShims)
{ {
/* Open the app compatibility engine settings key */ /* Open the app compatibility engine settings key */
Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &AppCompatKeyAttributes); Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &AppCompatKeyAttributes);
@ -96,9 +100,11 @@ IsShimInfrastructureDisabled(VOID)
(KeyInfo.Data[0] == TRUE)) (KeyInfo.Data[0] == TRUE))
{ {
/* It is, so disable shims! */ /* It is, so disable shims! */
g_ShimsEnabled = TRUE; DisableShims = TRUE;
} }
else }
}
if (!DisableShims)
{ {
/* Finally, open the app compatibility policy key */ /* Finally, open the app compatibility policy key */
Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &PolicyKeyAttributes); Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &PolicyKeyAttributes);
@ -118,22 +124,15 @@ IsShimInfrastructureDisabled(VOID)
(KeyInfo.Data[0] == TRUE)) (KeyInfo.Data[0] == TRUE))
{ {
/* It does, so disable shims! */ /* It does, so disable shims! */
g_ShimsEnabled = TRUE; DisableShims = TRUE;
}
else
{
/* No keys are set, so enable shims! */
g_ShimsEnabled = FALSE;
}
}
}
} }
} }
} }
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;
} }
/* /*