|
12 | 12 | #define NDEBUG
|
13 | 13 |
|
14 | 14 | #include "emulator.h"
|
| 15 | +#include "../../memory.h" |
15 | 16 |
|
16 | 17 | #include "dos.h"
|
17 | 18 | #include "dos/dem.h"
|
@@ -409,16 +410,24 @@ WORD DosReadFile(WORD FileHandle,
|
409 | 410 | if (SftEntry->Type == DOS_SFT_ENTRY_WIN32)
|
410 | 411 | {
|
411 | 412 | DWORD BytesRead32 = 0;
|
| 413 | + LPVOID LocalBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Count); |
| 414 | + ASSERT(LocalBuffer != NULL); |
412 | 415 |
|
413 | 416 | /* Read the file */
|
414 |
| - if (!ReadFile(SftEntry->Handle, FAR_POINTER(Buffer), Count, &BytesRead32, NULL)) |
| 417 | + if (ReadFile(SftEntry->Handle, LocalBuffer, Count, &BytesRead32, NULL)) |
| 418 | + { |
| 419 | + /* Write to the memory */ |
| 420 | + MemWrite(TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), LocalBuffer, LOWORD(BytesRead32)); |
| 421 | + } |
| 422 | + else |
415 | 423 | {
|
416 | 424 | /* Store the error code */
|
417 | 425 | Result = (WORD)GetLastError();
|
418 | 426 | }
|
419 | 427 |
|
420 | 428 | /* The number of bytes read is always 16-bit */
|
421 | 429 | *BytesRead = LOWORD(BytesRead32);
|
| 430 | + RtlFreeHeap(RtlGetProcessHeap(), 0, LocalBuffer); |
422 | 431 | }
|
423 | 432 | else if (SftEntry->Type == DOS_SFT_ENTRY_DEVICE)
|
424 | 433 | {
|
@@ -457,16 +466,22 @@ WORD DosWriteFile(WORD FileHandle,
|
457 | 466 | if (SftEntry->Type == DOS_SFT_ENTRY_WIN32)
|
458 | 467 | {
|
459 | 468 | DWORD BytesWritten32 = 0;
|
| 469 | + LPVOID LocalBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Count); |
| 470 | + ASSERT(LocalBuffer != NULL); |
| 471 | + |
| 472 | + /* Read from the memory */ |
| 473 | + MemRead(TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), LocalBuffer, Count); |
460 | 474 |
|
461 | 475 | /* Write the file */
|
462 |
| - if (!WriteFile(SftEntry->Handle, FAR_POINTER(Buffer), Count, &BytesWritten32, NULL)) |
| 476 | + if (!WriteFile(SftEntry->Handle, LocalBuffer, Count, &BytesWritten32, NULL)) |
463 | 477 | {
|
464 | 478 | /* Store the error code */
|
465 | 479 | Result = (WORD)GetLastError();
|
466 | 480 | }
|
467 | 481 |
|
468 | 482 | /* The number of bytes written is always 16-bit */
|
469 | 483 | *BytesWritten = LOWORD(BytesWritten32);
|
| 484 | + RtlFreeHeap(RtlGetProcessHeap(), 0, LocalBuffer); |
470 | 485 | }
|
471 | 486 | else if (SftEntry->Type == DOS_SFT_ENTRY_DEVICE)
|
472 | 487 | {
|
|
0 commit comments