[ros-diffs] [fireball] 53363: - Implement missing parts of "application verifier" initialization which boils down to just enabling DPH either globally or per-DLL.

fireball at svn.reactos.org fireball at svn.reactos.org
Sun Aug 21 22:15:09 UTC 2011


Author: fireball
Date: Sun Aug 21 22:15:08 2011
New Revision: 53363

URL: http://svn.reactos.org/svn/reactos?rev=53363&view=rev
Log:
- Implement missing parts of "application verifier" initialization which boils down to just enabling DPH either globally or per-DLL.

Modified:
    trunk/reactos/dll/ntdll/include/ntdllp.h
    trunk/reactos/dll/ntdll/ldr/ldrinit.c
    trunk/reactos/dll/ntdll/ldr/ldrpe.c

Modified: trunk/reactos/dll/ntdll/include/ntdllp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/include/ntdllp.h?rev=53363&r1=53362&r2=53363&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/include/ntdllp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/include/ntdllp.h [iso-8859-1] Sun Aug 21 22:15:08 2011
@@ -19,6 +19,9 @@
 /* Loader flags */
 #define IMAGE_LOADER_FLAGS_COMPLUS 0x00000001
 #define IMAGE_LOADER_FLAGS_SYSTEM_GLOBAL 0x01000000
+
+/* Page heap flags */
+#define DPH_FLAG_DLL_NOTIFY 0x40
 
 typedef struct _LDRP_TLS_DATA
 {
@@ -43,6 +46,7 @@
 extern BOOLEAN LdrpShutdownInProgress;
 extern UNICODE_STRING LdrpKnownDllPath;
 extern PLDR_DATA_TABLE_ENTRY LdrpGetModuleHandleCache, LdrpLoadedDllHandleCache;
+extern ULONG RtlpDphGlobalFlags;
 
 /* ldrinit.c */
 NTSTATUS NTAPI LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL);

Modified: trunk/reactos/dll/ntdll/ldr/ldrinit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrinit.c?rev=53363&r1=53362&r2=53363&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrinit.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrinit.c [iso-8859-1] Sun Aug 21 22:15:08 2011
@@ -82,7 +82,6 @@
 VOID NTAPI RtlpInitDeferedCriticalSection(VOID);
 VOID RtlInitializeHeapManager(VOID);
 extern BOOLEAN RtlpPageHeapEnabled;
-extern ULONG RtlpDphGlobalFlags;
 
 ULONG RtlpDisableHeapLookaside; // TODO: Move to heap.c
 ULONG RtlpShutdownProcessFlags; // TODO: Use it
@@ -1309,6 +1308,26 @@
 
 NTSTATUS
 NTAPI
+LdrpInitializeApplicationVerifierPackage(PUNICODE_STRING ImagePathName, PPEB Peb, BOOLEAN SystemWide, BOOLEAN ReadAdvancedOptions)
+{
+    /* If global flags request DPH, perform some additional actions */
+    if (Peb->NtGlobalFlag & FLG_HEAP_PAGE_ALLOCS)
+    {
+        // TODO: Read advanced DPH flags from the registry if requested
+        if (ReadAdvancedOptions)
+        {
+            UNIMPLEMENTED;
+        }
+
+        /* Enable page heap */
+        RtlpPageHeapEnabled = TRUE;
+    }
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
 LdrpInitializeExecutionOptions(PUNICODE_STRING ImagePathName, PPEB Peb, PHKEY OptionsKey)
 {
     NTSTATUS Status;
@@ -1398,14 +1417,28 @@
             Peb->NtGlobalFlag = GlobalFlag;
         else
             GlobalFlag = 0;
+
+        /* Call AVRF if necessary */
+        if (Peb->NtGlobalFlag & (FLG_POOL_ENABLE_TAIL_CHECK | FLG_HEAP_PAGE_ALLOCS))
+        {
+            Status = LdrpInitializeApplicationVerifierPackage(ImagePathName, Peb, TRUE, FALSE);
+            if (!NT_SUCCESS(Status))
+            {
+                DPRINT1("AVRF: LdrpInitializeApplicationVerifierPackage failed with %08X\n", Status);
+            }
+        }
     }
     else
     {
         /* There are no image-specific options, so perform global initialization */
         if (Peb->NtGlobalFlag & (FLG_POOL_ENABLE_TAIL_CHECK | FLG_HEAP_PAGE_ALLOCS))
         {
-            // TODO: Initialize app verifier package
-            // Status = LdrpInitializeApplicationVerifierPackage(ImagePathName, Peb, 1, FALSE);
+            /* Initialize app verifier package */
+            Status = LdrpInitializeApplicationVerifierPackage(ImagePathName, Peb, TRUE, FALSE);
+            if (!NT_SUCCESS(Status))
+            {
+                DPRINT1("AVRF: LdrpInitializeApplicationVerifierPackage failed with %08X\n", Status);
+            }
         }
     }
 
@@ -1698,7 +1731,7 @@
             /* Reset DPH if requested */
             if (RtlpPageHeapEnabled && DebugProcessHeapOnly)
             {
-                RtlpDphGlobalFlags &= ~0x40;
+                RtlpDphGlobalFlags &= ~DPH_FLAG_DLL_NOTIFY;
                 RtlpPageHeapEnabled = FALSE;
             }
         }

Modified: trunk/reactos/dll/ntdll/ldr/ldrpe.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrpe.c?rev=53363&r1=53362&r2=53363&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] Sun Aug 21 22:15:08 2011
@@ -18,6 +18,18 @@
 ULONG LdrpNormalSnap;
 
 /* FUNCTIONS *****************************************************************/
+
+VOID
+NTAPI
+AVrfPageHeapDllNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
+{
+    /* Check if page heap dll notification is turned on */
+    if (!(RtlpDphGlobalFlags && DPH_FLAG_DLL_NOTIFY))
+        return;
+
+    /* We don't support this flag currently */
+    UNIMPLEMENTED;
+}
 
 NTSTATUS
 NTAPI
@@ -758,8 +770,8 @@
             /* Check if Page Heap was enabled */
             if (Peb->NtGlobalFlag & FLG_HEAP_PAGE_ALLOCS)
             {
-                /* FIXME */
-                DPRINT1("We don't support Page Heaps yet!\n");
+                /* Initialize target DLL */
+                AVrfPageHeapDllNotification(LdrEntry);
             }
 
             /* Check if Application Verifier was enabled */




More information about the Ros-diffs mailing list