vmem

package
v0.0.0-...-18136f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2023 License: MIT, ISC Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemCommit    = 0x00001000
	MemReserve   = 0x00002000
	MemReset     = 0x00080000
	MemResetUndo = 0x10000000
)

Enumeration of allocation type values.

View Source
const (
	PageNoAccess         = 0x01
	PageReadOnly         = 0x02
	PageReadWrite        = 0x04
	PageWriteCopy        = 0x08
	PageExecute          = 0x10
	PageExecuteRead      = 0x20
	PageExecuteReadWrite = 0x40
	PageExecuteWriteCopy = 0x80
)

Enumeration of protection levels.

Variables

This section is empty.

Functions

func GetPageSize

func GetPageSize() uint64

GetPageSize returns the size of a memory page.

func RoundDown

func RoundDown(addr uint64, size uint64) uint64

RoundDown rounds an address up to a given multiple of size. Size must be a power of two.

func RoundUp

func RoundUp(addr uint64, size uint64) uint64

RoundUp rounds an address up to a given multiple of size. Size must be a power of two.

Types

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory represents a raw block of memory.

func Alloc

func Alloc(addr, size uint64, allocType, protect int) *Memory

Alloc allocates memory at addr of size with allocType and protect. It returns nil if it fails.

func Get

func Get(addr, size uint64) *Memory

Get returns a range of existing memory. If the range is not a block of allocated memory, the returned memory will pagefault when accessed.

func (*Memory) Addr

func (m *Memory) Addr() uint64

Addr returns the actual address of the memory.

func (*Memory) Clear

func (m *Memory) Clear()

Clear sets all bytes in the memory block to zero.

func (*Memory) Free

func (m *Memory) Free()

Free frees the block of memory.

func (*Memory) Protect

func (m *Memory) Protect(addr, size uint64, protect int) error

Protect changes the memory protection for a range of memory.

func (*Memory) Read

func (m *Memory) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

func (*Memory) ReadAt

func (m *Memory) ReadAt(b []byte, off int64) (n int, err error)

ReadAt implements the io.ReaderAt interface.

func (*Memory) Seek

func (m *Memory) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

func (*Memory) Write

func (m *Memory) Write(b []byte) (n int, err error)

Write implements the io.Writer interface.

func (*Memory) WriteAt

func (m *Memory) WriteAt(b []byte, off int64) (n int, err error)

WriteAt implements the io.WriterAt interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL