[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 25 Jun 2013 16:46:35 +0000 (16:46 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Tue, 25 Jun 2013 16:46:35 +0000 (16:46 +0000)
Fix the VDM DOS memory manager to use the segment of the data portion of the block, rather than the MCB itself.

svn path=/branches/ntvdm/; revision=59338

subsystems/ntvdm/dos.c
subsystems/ntvdm/ntvdm.h

index 59f03f0..10ae350 100644 (file)
@@ -148,12 +148,13 @@ Next:
     /* Take ownership of the block */
     CurrentMcb->OwnerPsp = CurrentPsp;
 
     /* Take ownership of the block */
     CurrentMcb->OwnerPsp = CurrentPsp;
 
-    return Result;
+    /* Return the segment of the data portion of the block */
+    return Result + 1;
 }
 
 }
 
-WORD DosResizeMemory(WORD Segment, WORD NewSize)
+WORD DosResizeMemory(WORD BlockData, WORD NewSize)
 {
 {
-    WORD ReturnSize = 0, NextSegment;
+    WORD Segment = BlockData - 1, ReturnSize = 0, NextSegment;
     PDOS_MCB Mcb = SEGMENT_TO_MCB(Segment), NextMcb;
 
     /* Make sure this is a valid, allocated block */
     PDOS_MCB Mcb = SEGMENT_TO_MCB(Segment), NextMcb;
 
     /* Make sure this is a valid, allocated block */
@@ -222,9 +223,9 @@ WORD DosResizeMemory(WORD Segment, WORD NewSize)
     return ReturnSize;
 }
 
     return ReturnSize;
 }
 
-BOOLEAN DosFreeMemory(WORD Segment)
+BOOLEAN DosFreeMemory(WORD BlockData)
 {
 {
-    PDOS_MCB Mcb = SEGMENT_TO_MCB(Segment);
+    PDOS_MCB Mcb = SEGMENT_TO_MCB(BlockData - 1);
 
     /* Make sure the MCB is valid */
     if (Mcb->BlockType != 'M' && Mcb->BlockType != 'Z') return FALSE;
 
     /* Make sure the MCB is valid */
     if (Mcb->BlockType != 'M' && Mcb->BlockType != 'Z') return FALSE;
index 0ca6729..7f959b9 100644 (file)
@@ -207,8 +207,8 @@ VOID BiosUpdateConsole(ULONG StartAddress, ULONG EndAddress);
 VOID BiosPrintCharacter(CHAR Character, BYTE Attribute);
 BOOLEAN DosInitialize();
 WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable);
 VOID BiosPrintCharacter(CHAR Character, BYTE Attribute);
 BOOLEAN DosInitialize();
 WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable);
-BOOLEAN DosFreeMemory(WORD Segment);
-WORD DosResizeMemory(WORD Segment, WORD NewSize);
+BOOLEAN DosFreeMemory(WORD BlockData);
+WORD DosResizeMemory(WORD BlockData, WORD NewSize);
 BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock);
 VOID DosInt20h(WORD CodeSegment);
 VOID DosInt21h(WORD CodeSegment);
 BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock);
 VOID DosInt20h(WORD CodeSegment);
 VOID DosInt21h(WORD CodeSegment);