Ignore:
Timestamp:
Aug 25, 1999, 10:57:14 AM (26 years ago)
Author:
phaller
Message:

Add: HMDeviceMemMapClass fixed

File:
1 edited

Legend:

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

    r657 r673  
    1 /* $Id: virtual.cpp,v 1.2 1999-08-24 12:23:25 sandervl Exp $ */
     1/* $Id: virtual.cpp,v 1.3 1999-08-25 08:55:19 phaller Exp $ */
    22
    33/*
     
    2020#include <heapstring.h>
    2121#include "mmap.h"
     22#include <handlemanager.h>
    2223
    2324/***********************************************************************
     
    3839                LPCSTR name      /* [in] Name of file-mapping object */ )
    3940{
    40  HANDLE dupHandle;
    41 
    42    if((hFile == -1 && size_low == 0) || size_high ||
    43        protect & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|SEC_COMMIT|SEC_IMAGE|SEC_RESERVE|SEC_NOCACHE) ||
    44        ((protect & SEC_COMMIT) && (protect & SEC_RESERVE)))
    45    {
    46 
    47         dprintf(("CreateFileMappingA: invalid parameter (combination)!"));
    48         SetLastError(ERROR_INVALID_PARAMETER);
    49         return 0;       
    50    }
    51    if(DuplicateHandle(GetCurrentProcess(), hFile, GetCurrentProcess(),
    52                         &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE)
    53    {
    54         dprintf(("CreateFileMappingA: DuplicateHandle failed!"));
    55         return 0;
    56    }
    57    return dupHandle;
     41  return HMCreateFileMapping(hFile, sa, protect, size_high, size_low, name);
    5842}
    5943
     
    6347 * See CreateFileMapping32A
    6448 */
    65 HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES attr, 
    66                                       DWORD protect, DWORD size_high, 
     49HANDLE WINAPI CreateFileMappingW( HFILE hFile, LPSECURITY_ATTRIBUTES attr,
     50                                      DWORD protect, DWORD size_high,
    6751                                      DWORD size_low, LPCWSTR name )
    6852{
     
    8872                LPCSTR name )   /* [in] Name of file-mapping object */
    8973{
    90     dprintf(("OpenFileMappingA: NOT IMPLEMENTED"));
    91     return 0;
     74  return (HMOpenFileMapping(access, inherit, name));
    9275}
    9376
     
    120103              DWORD offset_low,  /* [in] Low-order 32 bits of file offset */
    121104              DWORD count        /* [in] Number of bytes to map */
    122 ) 
    123 {
    124     return MapViewOfFileEx( mapping, access, offset_high,
    125                             offset_low, count, NULL );
     105)
     106{
     107  return HMMapViewOfFile( mapping, access, offset_high,
     108                          offset_low, count);
    126109}
    127110
     
    142125              DWORD count,       /* [in] Number of bytes to map */
    143126              LPVOID addr        /* [in] Suggested starting address for mapped view */
    144 )
    145 {
    146  DWORD filesize, bytesread;
    147  LPSTR lpBuffer;
    148 
    149    filesize = GetFileSize(handle, 0);
    150    if(filesize == 0) {
    151         dprintf(("MapViewOfFileEx: filesize = 0!"));
    152         return 0;
    153    }
    154    lpBuffer = (LPSTR)VirtualAlloc(0, filesize, MEM_COMMIT, PAGE_READWRITE);
    155    if(lpBuffer == 0) {
    156         dprintf(("MapViewOfFileEx: VirtualAlloc failed (%d bytes)!", filesize));
    157         return 0;
    158    }
    159    if(ReadFile(handle, lpBuffer, filesize, &bytesread, NULL) == FALSE) {
    160         dprintf(("MapViewOfFileEx: ReadFile failed (%d bytes)!", filesize));
    161         VirtualFree(lpBuffer, 0, MEM_RELEASE);
    162         return 0;
    163    }
    164    return lpBuffer;
     127)
     128{
     129  return HMMapViewOfFileEx( handle, access, offset_high,
     130                            offset_low, count, addr);
    165131}
    166132
     
    177143              LPCVOID base, /* [in] Start address of byte range to flush */
    178144              DWORD cbFlush /* [in] Number of bytes in range */
    179 )
    180 {
    181     dprintf(("FlushViewOfFile: NOT IMPLEMENTED"));
    182     return TRUE;
     145)
     146{
     147  return HMFlushViewOfFile( (LPVOID)base, cbFlush);
    183148}
    184149
     
    196161 */
    197162BOOL WINAPI UnmapViewOfFile(LPVOID addr /* [in] Address where mapped view begins */
    198 )
    199 {
    200     if (!addr)
    201     {
    202         SetLastError( ERROR_INVALID_PARAMETER );
    203         return FALSE;
    204     }
    205     return VirtualFree(addr, 0, MEM_RELEASE);
    206 }
     163)
     164{
     165  return HMUnmapViewOfFile( addr );
     166}
     167
    207168
    208169/***********************************************************************
     
    210171 *
    211172 * Helper function to map a file to memory:
    212  *  name                        -       file name 
     173 *  name                        -       file name
    213174 *  [RETURN] ptr                -       pointer to mapped file
    214175 */
     
    218179    LPVOID ptr = NULL;
    219180
    220     hFile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL, 
     181    hFile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL,
    221182                           OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0);
    222183    if (hFile != INVALID_HANDLE_VALUE)
     
    237198 *
    238199 * Helper function to map a file to memory:
    239  *  name                        -       file name 
     200 *  name                        -       file name
    240201 *  [RETURN] ptr                -       pointer to mapped file
    241202 */
     
    245206    LPVOID ptr = NULL;
    246207
    247     hFile = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ, NULL, 
     208    hFile = CreateFileA(name, GENERIC_READ, FILE_SHARE_READ, NULL,
    248209                        OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0);
    249210    if (hFile != INVALID_HANDLE_VALUE)
     
    259220    return ptr;
    260221}
     222
Note: See TracChangeset for help on using the changeset viewer.