|
Last change
on this file since 711 was 699, checked in by sandervl, 26 years ago |
|
Memory mapped file (writes) changes
|
|
File size:
1.6 KB
|
| Line | |
|---|
| 1 | /* $Id: mmap.h,v 1.8 1999-08-25 17:05:57 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Memory mapped class
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 10 | *
|
|---|
| 11 | */
|
|---|
| 12 | #ifndef __MMAP_H__
|
|---|
| 13 | #define __MMAP_H__
|
|---|
| 14 |
|
|---|
| 15 | #include <vmutex.h>
|
|---|
| 16 |
|
|---|
| 17 | #ifndef PAGE_SIZE
|
|---|
| 18 | #define PAGE_SIZE 4096
|
|---|
| 19 | #endif
|
|---|
| 20 |
|
|---|
| 21 | class Win32MemMap
|
|---|
| 22 | {
|
|---|
| 23 | public:
|
|---|
| 24 | Win32MemMap(HFILE hfile, ULONG size, ULONG fdwProtect, LPSTR lpszName);
|
|---|
| 25 | ~Win32MemMap();
|
|---|
| 26 |
|
|---|
| 27 | BOOL Init(HANDLE hMemMap);
|
|---|
| 28 | BOOL flushView(LPVOID lpvBase, ULONG cbFlush);
|
|---|
| 29 | LPVOID mapViewOfFile(ULONG size, ULONG offset, ULONG fdwAccess);
|
|---|
| 30 | BOOL unmapViewOfFile();
|
|---|
| 31 |
|
|---|
| 32 | HFILE getMapHandle() { return hMemMap; };
|
|---|
| 33 | LPSTR getMemName() { return lpszMapName; };
|
|---|
| 34 | DWORD getProtFlags() { return mProtFlags; };
|
|---|
| 35 |
|
|---|
| 36 | void AddRef() { ++referenced; };
|
|---|
| 37 | void Release() { if(--referenced == 0) delete this; };
|
|---|
| 38 |
|
|---|
| 39 | BOOL hasReadAccess();
|
|---|
| 40 | BOOL hasWriteAccess();
|
|---|
| 41 | BOOL hasExecuteAccess();
|
|---|
| 42 |
|
|---|
| 43 | BOOL commitPage(LPVOID lpPageFaultAddr, ULONG nrpages, BOOL fWriteAccess);
|
|---|
| 44 |
|
|---|
| 45 | static Win32MemMap *findMap(LPSTR lpszName);
|
|---|
| 46 | static Win32MemMap *findMap(ULONG address);
|
|---|
| 47 |
|
|---|
| 48 | //Should only be called in ExitProcess
|
|---|
| 49 | static void deleteAll();
|
|---|
| 50 |
|
|---|
| 51 | protected:
|
|---|
| 52 | HFILE hMemMap, hMemFile;
|
|---|
| 53 | ULONG mSize;
|
|---|
| 54 | ULONG mProtFlags;
|
|---|
| 55 | ULONG mMapAccess;
|
|---|
| 56 | LPSTR lpszMapName;
|
|---|
| 57 | void *pMapping;
|
|---|
| 58 | BOOL fMapped;
|
|---|
| 59 |
|
|---|
| 60 | ULONG referenced;
|
|---|
| 61 |
|
|---|
| 62 | VMutex mapMutex;
|
|---|
| 63 |
|
|---|
| 64 | private:
|
|---|
| 65 | static Win32MemMap *memmaps;
|
|---|
| 66 | Win32MemMap *next;
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | #endif //__MMAP_H__
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.