Line | |
---|
1 | /* $Id: mmap.h,v 1.6 1999-08-24 18:46:40 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 | static Win32MemMap *findMap(LPSTR lpszName);
|
---|
40 | static Win32MemMap *findMap(ULONG address);
|
---|
41 |
|
---|
42 | protected:
|
---|
43 | HFILE hMemMap, hMemFile;
|
---|
44 | ULONG mSize;
|
---|
45 | ULONG mProtFlags;
|
---|
46 | ULONG mMapAccess;
|
---|
47 | LPSTR lpszMapName;
|
---|
48 | void *pMapping;
|
---|
49 | BOOL fMapped;
|
---|
50 |
|
---|
51 | ULONG referenced;
|
---|
52 |
|
---|
53 | VMutex mapMutex;
|
---|
54 |
|
---|
55 | private:
|
---|
56 | static Win32MemMap *memmaps;
|
---|
57 | Win32MemMap *next;
|
---|
58 | };
|
---|
59 |
|
---|
60 | #endif //__MMAP_H__
|
---|
Note:
See
TracBrowser
for help on using the repository browser.