Ignore:
Timestamp:
Mar 6, 2003, 11:44:34 AM (22 years ago)
Author:
sandervl
Message:

cleanup/resync

File:
1 edited

Legend:

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

    r9826 r9911  
    1 /* $Id: mmap.cpp,v 1.62 2003-02-18 18:58:47 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.63 2003-03-06 10:44:34 sandervl Exp $ */
    22
    33/*
     
    126126                           &hMemFile, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE)
    127127#else
    128         DWORD dwOdinOptions;
    129 
    130         if(!(mProtFlags & PAGE_READWRITE)) {
    131                 dwOdinOptions = DUPLICATE_ACCESS_READ | DUPLICATE_SHARE_DENYNONE;
    132         }
    133         else    dwOdinOptions = DUPLICATE_ACCESS_READWRITE | DUPLICATE_SHARE_DENYNONE;
    134 
    135         if(HMDuplicateHandleOdin(GetCurrentProcess(), hMemFile, GetCurrentProcess(),
    136                            &hMemFile, 0, FALSE, DUPLICATE_SAME_ACCESS, dwOdinOptions) == FALSE)
     128        if(HMDuplicateHandle(GetCurrentProcess(), hMemFile, GetCurrentProcess(),
     129                           &hMemFile, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE)
    137130#endif
    138131        {
     
    265258}
    266259//******************************************************************************
    267 //We determine whether a page has been modified by checking it's protection flags
    268 //If the write flag is set, this means commitPage had to enable this due to a pagefault
    269 //(all pages are readonly until the app tries to write to it)
    270 //******************************************************************************
    271 BOOL Win32MemMap::commitPage(ULONG offset, BOOL fWriteAccess, int nrpages)
     260// Win32MemMap::commitRange
     261//
     262// Commit a range of pages
     263//
     264// Parameters:
     265//
     266//   ULONG ulFaultAddr          - exception address
     267//   ULONG ulOffset             - offset in memory map
     268//   BOOL  fWriteAccess         - TRUE  -> write exception
     269//                                FALSE -> read exception
     270//   int   nrpages              - number of pages
     271//
     272// Returns:
     273//   TRUE                       - success
     274//   FALSE                      - failure
     275//
     276//******************************************************************************
     277BOOL Win32MemMap::commitRange(ULONG ulFaultAddr, ULONG offset, BOOL fWriteAccess, int nrpages)
     278{
     279    LPVOID lpPageFaultAddr = (LPVOID)((ULONG)pMapping + offset);
     280    DWORD  pageAddr        = (DWORD)lpPageFaultAddr & ~0xFFF;
     281
     282    dprintf(("Win32MemMap::commitRange %x (faultaddr %x)", pageAddr, lpPageFaultAddr));
     283
     284    if(fWriteAccess)
     285    {//writes are handled on a per-page basis
     286        for(int i=i;i<nrpages;i++)
     287        {
     288            if(commitPage(ulFaultAddr, offset, TRUE, 1) == FALSE) {
     289                dprintf(("Win32MemMap::commit: commitPage failed!!"));
     290                return FALSE;
     291            }
     292            ulFaultAddr += PAGE_SIZE;
     293            offset      += PAGE_SIZE;
     294        }
     295        return TRUE;
     296    }
     297    else    return commitPage(ulFaultAddr, offset, FALSE, nrpages);
     298}
     299//******************************************************************************
     300// Win32MemMap::commitPage
     301//
     302// Handle a pagefault for a memory map
     303//
     304// Parameters:
     305//
     306//   ULONG ulFaultAddr          - exception address
     307//   ULONG ulOffset             - offset in memory map
     308//   BOOL  fWriteAccess         - TRUE  -> write exception
     309//                                FALSE -> read exception
     310//   int   nrpages              - number of pages
     311//
     312// Returns:
     313//   TRUE                       - success
     314//   FALSE                      - failure
     315//
     316// NOTE:
     317//   We handle only one pages for write access!
     318//
     319// REMARKS:
     320//   We determine whether a page has been modified by checking it's protection flags
     321//   If the write flag is set, this means commitPage had to enable this due to a pagefault
     322//   (all pages are readonly until the app tries to write to it)
     323//******************************************************************************
     324BOOL Win32MemMap::commitPage(ULONG ulFaultAddr, ULONG offset, BOOL fWriteAccess, int nrpages)
    272325{
    273326 MEMORY_BASIC_INFORMATION memInfo;
     
    365418}
    366419//******************************************************************************
     420// Win32MemMap::commitGuardPage
     421//
     422// Handle a guard page exception for a copy-on-write view (one page only)
     423//
     424// Parameters:
     425//
     426//   ULONG ulFaultAddr          - exception address
     427//   ULONG ulOffset             - offset in memory map
     428//   BOOL  fWriteAccess         - TRUE  -> write exception
     429//                                FALSE -> read exception
     430//
     431// Returns:
     432//   TRUE                       - success
     433//   FALSE                      - failure
     434//
     435//******************************************************************************
     436BOOL Win32MemMap::commitGuardPage(ULONG ulFaultAddr, ULONG ulOffset, BOOL fWriteAccess)
     437{
     438    return FALSE;
     439}
     440//******************************************************************************
     441// Win32MemMap::invalidatePages
     442//
     443// Invalidate map pages. (called by WriteFile)
     444//
     445// Parameters:
     446//
     447//   ULONG offset               - offset in memory map
     448//   ULONG size                 - invalid range size
     449//
     450// Returns:
     451//   TRUE                       - success
     452//   FALSE                      - failure
     453//
     454//******************************************************************************
     455BOOL Win32MemMap::invalidatePages(ULONG offset, ULONG size)
     456{
     457    return FALSE;
     458}
     459//******************************************************************************
    367460// Win32MemMap::unmapViewOfFile
    368461//
     
    517610//      I'm assuming they aren't for now.
    518611//******************************************************************************
    519 BOOL Win32MemMap::flushView(ULONG offset, ULONG cbFlush)
     612BOOL Win32MemMap::flushView(ULONG viewaddr, ULONG offset, ULONG cbFlush)
    520613{
    521614 LPVOID lpvBase = (LPVOID)((ULONG)pMapping+offset);
     
    767860
    768861    if(mfAccess & MEMMAP_ACCESS_WRITE)
    769         mParentMap->flushView(mOffset, mSize);
     862        mParentMap->flushView(MMAP_FLUSHVIEW_ALL, mOffset, mSize);
    770863
    771864    //Don't free memory for executable image map views (only used internally)
Note: See TracChangeset for help on using the changeset viewer.