Skip to content

Commit

Permalink
krnl386.exe16: Fix heap size determination process.
Browse files Browse the repository at this point in the history
Improve #617
  • Loading branch information
otya128 committed Mar 8, 2021
1 parent 99affc3 commit c7e373b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
3 changes: 0 additions & 3 deletions krnl386/ne_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,6 @@ static HMODULE16 build_module( const void *mapping, SIZE_T mapping_size, LPCSTR
if (!(pModule->ne_flags & NE_FFLAGS_LIBMODULE) && (pModule->ne_stack < 0x1400))
pModule->ne_stack = 0x1400;

if (pModule->ne_heap && (pModule->ne_heap < 0x800))
pModule->ne_heap = 0x800;

pModule->self = hModule;
pModule->mapping = mapping;
pModule->mapping_size = mapping_size;
Expand Down
26 changes: 24 additions & 2 deletions krnl386/ne_segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,30 @@ BOOL NE_CreateSegment( NE_MODULE *pModule, int segnum )
return TRUE; /* all but DGROUP only allocated once */

minsize = pSeg->minsize ? pSeg->minsize : 0x10000;
if ( segnum == pModule->ne_autodata ) minsize += pModule->ne_stack;
if ( segnum == pModule->ne_autodata ) minsize += pModule->ne_heap;

minsize += 2;

if ( segnum == pModule->ne_autodata )
{
minsize += pModule->ne_stack;
if (pModule->ne_heap > 0 && pModule->ne_heap < 0x800)
{
if (minsize + 0x800 > 0x10000)
{
if (pModule->ne_heap < 0x100)
{
pModule->ne_heap = 0x100;
}
}
else
{
pModule->ne_heap = 0x800;
}
}
minsize += pModule->ne_heap;
if (!(pModule->ne_flags & NE_FFLAGS_BUILTIN) && minsize >= 0x10000)
return FALSE;
}

selflags = (pSeg->flags & NE_SEGFLAGS_DATA) ? WINE_LDT_FLAGS_DATA : WINE_LDT_FLAGS_CODE;
if (pSeg->flags & NE_SEGFLAGS_32BIT) selflags |= WINE_LDT_FLAGS_32BIT;
Expand Down

0 comments on commit c7e373b

Please sign in to comment.