Author: aandrejevic
Date: Tue Apr 7 04:00:54 2015
New Revision: 67082
URL:
http://svn.reactos.org/svn/reactos?rev=67082&view=rev
Log:
[NTVDM]
Always use MemRead and MemWrite to read/write memory.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Tue Apr 7
04:00:54 2015
@@ -12,6 +12,7 @@
#define NDEBUG
#include "emulator.h"
+#include "../../memory.h"
#include "dos.h"
#include "dos/dem.h"
@@ -409,9 +410,16 @@
if (SftEntry->Type == DOS_SFT_ENTRY_WIN32)
{
DWORD BytesRead32 = 0;
+ LPVOID LocalBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Count);
+ ASSERT(LocalBuffer != NULL);
/* Read the file */
- if (!ReadFile(SftEntry->Handle, FAR_POINTER(Buffer), Count, &BytesRead32,
NULL))
+ if (ReadFile(SftEntry->Handle, LocalBuffer, Count, &BytesRead32, NULL))
+ {
+ /* Write to the memory */
+ MemWrite(TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), LocalBuffer,
LOWORD(BytesRead32));
+ }
+ else
{
/* Store the error code */
Result = (WORD)GetLastError();
@@ -419,6 +427,7 @@
/* The number of bytes read is always 16-bit */
*BytesRead = LOWORD(BytesRead32);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, LocalBuffer);
}
else if (SftEntry->Type == DOS_SFT_ENTRY_DEVICE)
{
@@ -457,9 +466,14 @@
if (SftEntry->Type == DOS_SFT_ENTRY_WIN32)
{
DWORD BytesWritten32 = 0;
+ LPVOID LocalBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Count);
+ ASSERT(LocalBuffer != NULL);
+
+ /* Read from the memory */
+ MemRead(TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), LocalBuffer, Count);
/* Write the file */
- if (!WriteFile(SftEntry->Handle, FAR_POINTER(Buffer), Count,
&BytesWritten32, NULL))
+ if (!WriteFile(SftEntry->Handle, LocalBuffer, Count, &BytesWritten32,
NULL))
{
/* Store the error code */
Result = (WORD)GetLastError();
@@ -467,6 +481,7 @@
/* The number of bytes written is always 16-bit */
*BytesWritten = LOWORD(BytesWritten32);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, LocalBuffer);
}
else if (SftEntry->Type == DOS_SFT_ENTRY_DEVICE)
{