Skip to content

Instantly share code, notes, and snippets.

@qsniyg
Last active January 9, 2023 16:38
Show Gist options
  • Select an option

  • Save qsniyg/ed7b13439a887d9688dfdb6806fe7c86 to your computer and use it in GitHub Desktop.

Select an option

Save qsniyg/ed7b13439a887d9688dfdb6806fe7c86 to your computer and use it in GitHub Desktop.
[PATCH] ntdll: Map top-down if DllCharacteristics include DYNAMIC_BASE.
---
dlls/ntdll/loader.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index a7e6d712df1..5f4b78e133c 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2279,8 +2279,9 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam
{
void *module = NULL;
SIZE_T len = 0;
+ ULONG alloc_type = (image_info->DllCharacteristics & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) ? MEM_TOP_DOWN : 0;
NTSTATUS status = NtMapViewOfSection( mapping, NtCurrentProcess(), &module, 0, 0, NULL, &len,
- ViewShare, 0, PAGE_EXECUTE_READ );
+ ViewShare, alloc_type, PAGE_EXECUTE_READ );
if (status == STATUS_IMAGE_NOT_AT_BASE) status = STATUS_SUCCESS;
#ifdef _WIN64
--
2.30.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment