https://git.reactos.org/?p=reactos.git;a=commitdiff;h=343442cc3fedd084990bc…
commit 343442cc3fedd084990bc02ccb32f2b8aab78cea
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Mon Aug 19 02:33:13 2019 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Mon Aug 19 12:08:06 2019 +0200
[LDR][APPHELP] Add a shim that disables manifest compatibility version parsing
---
dll/appcompat/apphelp/hsdb.c | 5 +++--
dll/ntdll/ldr/ldrinit.c | 33 +++++++++++++++++++++++----------
media/sdb/sysmain.xml | 8 ++++++--
sdk/include/reactos/compat_undoc.h | 17 ++++++-----------
4 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/dll/appcompat/apphelp/hsdb.c b/dll/appcompat/apphelp/hsdb.c
index f04312e034a..89eb6284e8c 100644
--- a/dll/appcompat/apphelp/hsdb.c
+++ b/dll/appcompat/apphelp/hsdb.c
@@ -29,7 +29,7 @@ typedef struct _ShimData
} ShimData;
#define SHIMDATA_MAGIC 0xAC0DEDAB
-
+#define REACTOS_COMPATVERSION_IGNOREMANIFEST 0xffffffff
C_ASSERT(SHIMDATA_MAGIC == REACTOS_SHIMDATA_MAGIC);
C_ASSERT(sizeof(ShimData) == sizeof(ReactOS_ShimData));
@@ -739,7 +739,8 @@ BOOL WINAPI SdbPackAppCompatData(HSDB hsdb, PSDBQUERYRESULT
pQueryResult, PVOID*
if (SdbQueryData(hsdb, pQueryResult->atrLayers[n], L"SHIMVERSIONNT",
&dwType, &dwValue, &dwValueSize) == ERROR_SUCCESS &&
dwType == REG_DWORD && dwValueSize == sizeof(dwValue))
{
- dwValue = (dwValue % 100) | ((dwValue / 100) << 8);
+ if (dwValue != REACTOS_COMPATVERSION_IGNOREMANIFEST)
+ dwValue = (dwValue % 100) | ((dwValue / 100) << 8);
if (dwValue > pData->dwRosProcessCompatVersion)
pData->dwRosProcessCompatVersion = dwValue;
}
diff --git a/dll/ntdll/ldr/ldrinit.c b/dll/ntdll/ldr/ldrinit.c
index 16a3361421a..c23783a77ce 100644
--- a/dll/ntdll/ldr/ldrinit.c
+++ b/dll/ntdll/ldr/ldrinit.c
@@ -1541,9 +1541,17 @@ VOID
NTAPI
LdrpInitializeProcessCompat(PVOID* pOldShimData)
{
- static const GUID* GuidOrder[] = { &COMPAT_GUID_WIN10, &COMPAT_GUID_WIN81,
&COMPAT_GUID_WIN8,
- &COMPAT_GUID_WIN7, &COMPAT_GUID_VISTA };
- static const DWORD GuidVersions[] = { WINVER_WIN10, WINVER_WIN81, WINVER_WIN8,
WINVER_WIN7, WINVER_VISTA };
+ static const struct
+ {
+ const GUID* Guid;
+ const DWORD Version;
+ } KnownCompatGuids[] = {
+ { &COMPAT_GUID_WIN10, _WIN32_WINNT_WIN10 },
+ { &COMPAT_GUID_WIN81, _WIN32_WINNT_WINBLUE },
+ { &COMPAT_GUID_WIN8, _WIN32_WINNT_WIN8 },
+ { &COMPAT_GUID_WIN7, _WIN32_WINNT_WIN7 },
+ { &COMPAT_GUID_VISTA, _WIN32_WINNT_VISTA },
+ };
ULONG Buffer[(sizeof(COMPATIBILITY_CONTEXT_ELEMENT) * 10 +
sizeof(ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION)) / sizeof(ULONG)];
ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION* ContextCompatInfo;
@@ -1552,8 +1560,6 @@ LdrpInitializeProcessCompat(PVOID* pOldShimData)
DWORD n, cur;
ReactOS_ShimData* pShimData = *pOldShimData;
- C_ASSERT(RTL_NUMBER_OF(GuidOrder) == RTL_NUMBER_OF(GuidVersions));
-
if (pShimData)
{
if (pShimData->dwMagic != REACTOS_SHIMDATA_MAGIC ||
@@ -1564,7 +1570,14 @@ LdrpInitializeProcessCompat(PVOID* pOldShimData)
}
if (pShimData->dwRosProcessCompatVersion)
{
- DPRINT1("LdrpInitializeProcessCompat: ProcessCompatVersion already set
to 0x%x\n", pShimData->dwRosProcessCompatVersion);
+ if (pShimData->dwRosProcessCompatVersion ==
REACTOS_COMPATVERSION_IGNOREMANIFEST)
+ {
+ DPRINT1("LdrpInitializeProcessCompat: ProcessCompatVersion set to
ignore manifest\n");
+ }
+ else
+ {
+ DPRINT1("LdrpInitializeProcessCompat: ProcessCompatVersion already
set to 0x%x\n", pShimData->dwRosProcessCompatVersion);
+ }
return;
}
}
@@ -1590,12 +1603,12 @@ LdrpInitializeProcessCompat(PVOID* pOldShimData)
return;
/* Search for known GUID's, starting from newest to oldest. */
- for (cur = 0; cur < RTL_NUMBER_OF(GuidOrder); ++cur)
+ for (cur = 0; cur < RTL_NUMBER_OF(KnownCompatGuids); ++cur)
{
for (n = 0; n < ContextCompatInfo->ElementCount; ++n)
{
if (ContextCompatInfo->Elements[n].Type ==
ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS &&
- RtlCompareMemory(&ContextCompatInfo->Elements[n].Id,
GuidOrder[cur], sizeof(GUID)) == sizeof(GUID))
+ RtlCompareMemory(&ContextCompatInfo->Elements[n].Id,
KnownCompatGuids[cur].Guid, sizeof(GUID)) == sizeof(GUID))
{
/* If this process did not need shim data before, allocate and store it
*/
if (pShimData == NULL)
@@ -1619,8 +1632,8 @@ LdrpInitializeProcessCompat(PVOID* pOldShimData)
}
/* Store the highest found version, and bail out. */
- pShimData->dwRosProcessCompatVersion = GuidVersions[cur];
- DPRINT1("LdrpInitializeProcessCompat: Found guid for winver
0x%x\n", GuidVersions[cur]);
+ pShimData->dwRosProcessCompatVersion = KnownCompatGuids[cur].Version;
+ DPRINT1("LdrpInitializeProcessCompat: Found guid for winver
0x%x\n", KnownCompatGuids[cur].Version);
return;
}
}
diff --git a/media/sdb/sysmain.xml b/media/sdb/sysmain.xml
index 7afab95388e..c41413abde0 100644
--- a/media/sdb/sysmain.xml
+++ b/media/sdb/sysmain.xml
@@ -233,9 +233,9 @@
<DLLFILE>aclayers.dll</DLLFILE>
</SHIM>
- <SHIM NAME="HideShimEnv">
+ <!--<SHIM NAME="HideShimEnv">
<DLLFILE>aclayers.dll</DLLFILE>
- </SHIM>
+ </SHIM>-->
<FLAG NAME="GetShortPathNameNT4">
<FLAG_MASK_KERNEL>1</FLAG_MASK_KERNEL>
@@ -248,6 +248,10 @@
<!-- Backwards compatibility layers, incomplete! -->
+ <LAYER NAME="IgnoreManifestCompatVersion">
+ <DATA NAME="SHIMVERSIONNT" DATA_DWORD="0xffffffff"
/> <!-- REACTOS_COMPATVERSION_IGNOREMANIFEST -->
+ </LAYER>
+
<LAYER NAME="WIN95">
<SHIM_REF NAME="Win95VersionLie" />
<SHIM_REF NAME="ForceDXSetupSuccess" />
diff --git a/sdk/include/reactos/compat_undoc.h b/sdk/include/reactos/compat_undoc.h
index fc6a04794dc..44212efb2d2 100644
--- a/sdk/include/reactos/compat_undoc.h
+++ b/sdk/include/reactos/compat_undoc.h
@@ -13,21 +13,16 @@ typedef struct _ReactOS_ShimData
#define REACTOS_SHIMDATA_MAGIC 0xAC0DEDAB
+#define REACTOS_COMPATVERSION_UNINITIALIZED 0xfffffffe
+#define REACTOS_COMPATVERSION_IGNOREMANIFEST 0xffffffff
-#ifndef WINVER_VISTA
-#define WINVER_VISTA 0x0600
-#define WINVER_WIN7 0x0601
-#define WINVER_WIN8 0x0602
-#define WINVER_WIN81 0x0603
-#define WINVER_WIN10 0x0a00
-#endif
-
+// Returns values in the form of _WIN32_WINNT_VISTA, _WIN32_WINNT_WIN7 etc
static
inline
DWORD RosGetProcessCompatVersion(VOID)
{
- static DWORD g_CompatVersion = 0xffffffff;
- if (g_CompatVersion == 0xffffffff)
+ static DWORD g_CompatVersion = REACTOS_COMPATVERSION_UNINITIALIZED;
+ if (g_CompatVersion == REACTOS_COMPATVERSION_UNINITIALIZED)
{
ReactOS_ShimData* pShimData = (ReactOS_ShimData*)NtCurrentPeb()->pShimData;
if (pShimData && pShimData->dwMagic == REACTOS_SHIMDATA_MAGIC
&&
@@ -36,7 +31,7 @@ DWORD RosGetProcessCompatVersion(VOID)
g_CompatVersion = pShimData->dwRosProcessCompatVersion;
}
}
- return g_CompatVersion != 0xffffffff ? g_CompatVersion : 0;
+ return g_CompatVersion < REACTOS_COMPATVERSION_UNINITIALIZED ? g_CompatVersion :
0;
}