Author: hbelusca
Date: Tue Aug 25 01:48:17 2015
New Revision: 68816
URL:
http://svn.reactos.org/svn/reactos?rev=68816&view=rev
Log:
[NTVDM]: Correctly set last (and returned) errors when we fail at reallocating a memory
block (in case this is the last block), or if the block is invalid. Do the same stuff also
for few other memory functions.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Tue Aug 25
01:48:17 2015
@@ -1314,7 +1314,7 @@
else
{
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
- setAX(ERROR_ARENA_TRASHED);
+ setAX(Sda->LastErrorCode);
}
break;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c [iso-8859-1] Tue Aug 25
01:48:17 2015
@@ -109,7 +109,7 @@
if (!ValidateMcb(NextMcb))
{
DPRINT1("The DOS memory arena is corrupted!\n");
- // Sda->LastErrorCode = ERROR_ARENA_TRASHED;
+ Sda->LastErrorCode = ERROR_ARENA_TRASHED;
return;
}
@@ -297,8 +297,8 @@
/* Make sure this is a valid and allocated block */
if (BlockData == 0 || !ValidateMcb(Mcb) || Mcb->OwnerPsp == 0)
{
+ Sda->LastErrorCode = ERROR_INVALID_BLOCK;
Success = FALSE;
- Sda->LastErrorCode = ERROR_INVALID_HANDLE;
goto Done;
}
@@ -310,6 +310,8 @@
/* We can't expand the last block */
if (Mcb->BlockType == 'Z')
{
+ DPRINT("Cannot expand memory block 0x%04X: this is the last block (size
0x%04X)!\n", Segment, Mcb->Size);
+ Sda->LastErrorCode = ERROR_NOT_ENOUGH_MEMORY;
Success = FALSE;
goto Done;
}
@@ -416,7 +418,11 @@
PDOS_MCB Mcb = SEGMENT_TO_MCB(BlockData - 1);
DPRINT("DosFreeMemory: BlockData 0x%04X\n", BlockData);
- if (BlockData == 0) return FALSE;
+ if (BlockData == 0)
+ {
+ Sda->LastErrorCode = ERROR_INVALID_BLOCK;
+ return FALSE;
+ }
DosMemValidate();
@@ -424,6 +430,7 @@
if (!ValidateMcb(Mcb))
{
DPRINT("MCB block type '%c' not valid!\n", Mcb->BlockType);
+ Sda->LastErrorCode = ERROR_INVALID_BLOCK;
return FALSE;
}