Home Units Hierarchy Routines All identifiers

Class unaMappedMemory

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type unaMappedMemory = class(unaObject)

Description

This is wrapper class for the Windows mapped memory mechanism.

Hierarchy

Overview

Methods

Public constructor create(const name: wString; size64: int64 = 0; access: DWORD = PAGE_READWRITE; doOpen: bool = true; canCreate: bool = true);
Public function flush(): bool;
Public function mapHeader(size: int = -1): pointer;
Public function mapView(offset: int64; reqSize: unsigned; out subOfs: int): pointer;
Public function mapViewAll(): pointer;
Public function open(access: DWORD = PAGE_READWRITE): bool;
Public function read(offs: int64; buf: pointer; sz: unsigned): unsigned;
Public function unmapView(baseAddr: pointer): bool;
Public function write(offs: int64; buf: pointer; sz: unsigned): unsigned;
Protected function open2(access: DWORD = PAGE_READWRITE): bool; virtual;
Public procedure AfterConstruction(); override;
Public procedure BeforeDestruction(); override;
Public procedure close();
Protected procedure close2(); virtual;
Protected procedure doSetNewSize(newValue: int64); virtual;

Properties

Public property allocGran: unsigned read f_allocGran;
Public property handle: tHandle read f_handle;
Public property size64: int64 read f_size64 write setSize;

Description

Methods

Public constructor create(const name: wString; size64: int64 = 0; access: DWORD = PAGE_READWRITE; doOpen: bool = true; canCreate: bool = true);
 
Public function flush(): bool;

Flushes any pending data from memory.

Public function mapHeader(size: int = -1): pointer;

Maps <size> bytes at offset 0 (allocGran bytes if size = -1, default)

Public function mapView(offset: int64; reqSize: unsigned; out subOfs: int): pointer;

Maps portion of memory to buffer.

Because memory is allocated by pages and because returned pointer is later used in unmapView(), it is not always possible to return pointer to data at requested offset.

Instead function returns nearest pointer and sub-offset, which should be added to this pointer to get data exactly at requested offset.

NOTE: If allocGran is a divisor of specied offset, subOfs will always be zero.

Parameters
offset
map data at this offset
reqSize
how much data we expect to be mapped
subOfs
this should be added to returned pointer to get pointer to data at specified offset
Returns

Nearest possible pointer to data at specified offset.

Public function mapViewAll(): pointer;

Tries to map the whole memory to buffer. Could fail on large data.

Public function open(access: DWORD = PAGE_READWRITE): bool;
 
Public function read(offs: int64; buf: pointer; sz: unsigned): unsigned;

Reads data from mapped memory at specified offset.

Public function unmapView(baseAddr: pointer): bool;

Unmaps memory previously mapped by mapView()

Public function write(offs: int64; buf: pointer; sz: unsigned): unsigned;

Writes data to mapped memory at specified offset.

Protected function open2(access: DWORD = PAGE_READWRITE): bool; virtual;
 
Public procedure AfterConstruction(); override;
 
Public procedure BeforeDestruction(); override;
 
Public procedure close();
 
Protected procedure close2(); virtual;
 
Protected procedure doSetNewSize(newValue: int64); virtual;
 

Properties

Public property allocGran: unsigned read f_allocGran;

Allocation grain. All offsets should be aligned to this value for optimal performace.

Public property handle: tHandle read f_handle;

Handle of mapped memory.

Public property size64: int64 read f_size64 write setSize;

Size of mapped memory.

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09