mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
- Implement missing parts of "application verifier" initialization which boils down to just enabling DPH either globally or per-DLL.
svn path=/trunk/; revision=53363
This commit is contained in:
parent
6574d03aac
commit
eb0df1b66f
3 changed files with 55 additions and 6 deletions
|
@ -20,6 +20,9 @@
|
|||
#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
|
||||
{
|
||||
LIST_ENTRY TlsLinks;
|
||||
|
@ -43,6 +46,7 @@ extern ULONG LdrpActiveUnloadCount;
|
|||
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);
|
||||
|
|
|
@ -82,7 +82,6 @@ VOID RtlpInitializeVectoredExceptionHandling(VOID);
|
|||
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
|
||||
|
@ -1307,6 +1306,26 @@ LdrpFreeTls(VOID)
|
|||
TlsVector);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -1398,14 +1417,28 @@ LdrpInitializeExecutionOptions(PUNICODE_STRING ImagePathName, PPEB Peb, PHKEY Op
|
|||
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 @@ LdrpInitializeProcess(IN PCONTEXT Context,
|
|||
/* Reset DPH if requested */
|
||||
if (RtlpPageHeapEnabled && DebugProcessHeapOnly)
|
||||
{
|
||||
RtlpDphGlobalFlags &= ~0x40;
|
||||
RtlpDphGlobalFlags &= ~DPH_FLAG_DLL_NOTIFY;
|
||||
RtlpPageHeapEnabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,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
|
||||
LdrpSnapIAT(IN PLDR_DATA_TABLE_ENTRY ExportLdrEntry,
|
||||
|
@ -758,8 +770,8 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
|
|||
/* 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 */
|
||||
|
|
Loading…
Reference in a new issue