Changeset 1718 for trunk/src


Ignore:
Timestamp:
Nov 13, 1999, 3:21:30 PM (26 years ago)
Author:
sandervl
Message:

Fixed ReadFile & aliased memory problems

Location:
trunk/src/kernel32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/heap.cpp

    r1670 r1718  
    1 /* $Id: heap.cpp,v 1.15 1999-11-09 19:22:32 sandervl Exp $ */
     1/* $Id: heap.cpp,v 1.16 1999-11-13 14:21:30 sandervl Exp $ */
    22
    33/*
     
    2828{
    2929 OS2Heap *curheap = OS2Heap::find(hHeap);
    30 
    31   dprintf2(("HeapAlloc %X bytes", dwBytes));
     30 LPVOID   rc;
     31
    3232  if(curheap == NULL)
    3333        return(NULL);
    3434
    35   return(curheap->Alloc(dwFlags, dwBytes));
     35  rc = curheap->Alloc(dwFlags, dwBytes);
     36  dprintf2(("HeapAlloc %X bytes -> %x", dwBytes, rc));
     37  return rc;
    3638}
    3739//******************************************************************************
     
    157159 HANDLE hHeap;
    158160
    159     dprintf2(("KERNEL32: GetProcessHeap\n"));
     161//    dprintf2(("KERNEL32: GetProcessHeap\n"));
    160162    //SvL: Only one process heap per process
    161163    if(processheap == NULL) {
  • trunk/src/kernel32/hmopen32.cpp

    r1713 r1718  
    1 /* $Id: hmopen32.cpp,v 1.11 1999-11-12 14:57:15 sandervl Exp $ */
     1/* $Id: hmopen32.cpp,v 1.12 1999-11-13 14:21:30 sandervl Exp $ */
    22
    33/*
     
    2929#include "HandleManager.h"
    3030#include "HMOpen32.h"
    31 
     31#include "mmap.h"
    3232
    3333/*****************************************************************************
     
    273273{
    274274  BOOL bRC;
     275  LPVOID lpRealBuf;
    275276
    276277  dprintfl(("KERNEL32: HandleManager::Open32::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
     
    283284
    284285#if 1
     286  Win32MemMap *map;
     287  DWORD offset;
     288
     289  //SvL: DosRead doesn't like writing to memory addresses returned by
     290  //     DosAliasMem -> search for original memory mapped pointer and use
     291  //     that one
     292  map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ);
     293  if(map) {
     294        lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
     295  }
     296  else  lpRealBuf = (LPVOID)lpBuffer;
     297 
    285298  bRC = O32_ReadFile(pHMHandleData->hHMHandle,
    286                      (PVOID)lpBuffer,
     299                     (PVOID)lpRealBuf,
    287300                     nNumberOfBytesToRead,
    288301                     lpNumberOfBytesRead,
    289302                     lpOverlapped);
    290303
    291   dprintfl(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh\n",
    292            bRC));
     304  if(bRC == 0) {
     305        dprintf(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh %x\n",
     306                  bRC, GetLastError()));
     307        dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead)));
     308  }
     309  else  dprintfl(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh\n",
     310                   bRC));
    293311
    294312  return (DWORD)bRC;
     
    497515
    498516DWORD HMDeviceOpen32Class::GetFileSize(PHMHANDLEDATA pHMHandleData,
    499                                        PDWORD        pSize)
     517                                       PDWORD        lpdwFileSizeHigh)
    500518{
    501519  dprintfl(("KERNEL32: HandleManager::Open32::GetFileSize %s(%08xh,%08xh)\n",
    502520           lpHMDeviceName,
    503521           pHMHandleData,
    504            pSize));
     522           lpdwFileSizeHigh));
    505523
    506524#if 1
     525  if(lpdwFileSizeHigh)
     526    *lpdwFileSizeHigh = 0;
     527
    507528  return O32_GetFileSize(pHMHandleData->hHMHandle,
    508                          pSize);
     529                         lpdwFileSizeHigh);
    509530#else
    510531  size = OSLibDosGetFileSize(pHMHandleData->hHMHandle);
    511532  if(pSize)
    512     *pSize = size;
     533    *pSize = 0;
    513534  return size;
    514535#endif
     
    544565
    545566#if 1
     567  if(lpDistanceToMoveHigh)
     568    *lpDistanceToMoveHigh = 0;
     569
    546570  return O32_SetFilePointer(pHMHandleData->hHMHandle,
    547571                            lDistanceToMove,
Note: See TracChangeset for help on using the changeset viewer.