From 294468d4e7da4dbe06e2596e9a3a4c85085ef613 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Wed, 29 Apr 2015 01:21:58 +0000 Subject: [PATCH] [NTVDM] If both e_minalloc and e_maxalloc are 0, the program should be loaded high. svn path=/trunk/; revision=67477 --- reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c index b4028a127bc..8812fa3558f 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c @@ -297,6 +297,7 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, PDWORD RelocationTable; PWORD RelocWord; LPSTR CmdLinePtr = (LPSTR)CommandLine; + BYTE OldStrategy = DosAllocStrategy; DPRINT1("DosLoadExecutable(%d, %s, %s, %s, 0x%08X, 0x%08X)\n", LoadType, @@ -382,6 +383,12 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, /* Make sure it does not pass 0xFFFF */ if (ExeSize > 0xFFFF) ExeSize = 0xFFFF; + if (Header->e_minalloc == 0 && Header->e_maxalloc == 0) + { + /* This program should be loaded high */ + DosAllocStrategy = DOS_ALLOC_LAST_FIT; + } + /* Try to allocate that much memory */ Segment = DosAllocateMemory((WORD)ExeSize, &MaxAllocSize); @@ -517,6 +524,9 @@ Cleanup: if (Segment) DosFreeMemory(Segment); } + /* Restore the old allocation strategy */ + DosAllocStrategy = OldStrategy; + /* Unmap the file*/ if (Address != NULL) UnmapViewOfFile(Address);