[NTDLL] Allow shimdata to override the process manifest. 485/head
authorMark Jansen <mark.jansen@reactos.org>
Tue, 10 Apr 2018 22:18:17 +0000 (00:18 +0200)
committerMark Jansen <mark.jansen@reactos.org>
Thu, 12 Apr 2018 16:49:25 +0000 (18:49 +0200)
dll/ntdll/ldr/ldrinit.c

index b35321e..5162f1a 100644 (file)
@@ -1470,9 +1470,25 @@ LdrpInitializeProcessCompat(PVOID* pOldShimData)
     SIZE_T SizeRequired;
     NTSTATUS Status;
     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 ||
+            pShimData->dwSize != sizeof(ReactOS_ShimData))
+        {
+            DPRINT1("LdrpInitializeProcessCompat: Corrupt pShimData (0x%x, %u)\n", pShimData->dwMagic, pShimData->dwSize);
+            return;
+        }
+        if (pShimData->dwRosProcessCompatVersion)
+        {
+            DPRINT1("LdrpInitializeProcessCompat: ProcessCompatVersion already set to 0x%x\n", pShimData->dwRosProcessCompatVersion);
+            return;
+        }
+    }
+
     SizeRequired = sizeof(Buffer);
     Status = RtlQueryInformationActivationContext(RTL_QUERY_ACTIVATION_CONTEXT_FLAG_NO_ADDREF,
                                                   NULL,
@@ -1501,8 +1517,6 @@ LdrpInitializeProcessCompat(PVOID* pOldShimData)
             if (ContextCompatInfo->Elements[n].Type == ACTCX_COMPATIBILITY_ELEMENT_TYPE_OS &&
                 RtlCompareMemory(&ContextCompatInfo->Elements[n].Id, GuidOrder[cur], sizeof(GUID)) == sizeof(GUID))
             {
-                ReactOS_ShimData* pShimData = *pOldShimData;
-
                 /* If this process did not need shim data before, allocate and store it */
                 if (pShimData == NULL)
                 {