imagine.memory
is a memory management library, allowing you to manage and interact with memory addresses. You can allocate, read from and write to memory. This module also allows you to specify structures with default C alignment, create arrays of these structs and manipulate complex memory structures.
The imagine.memory
library provides the Lua programmer with an interface between Lua and memory management systems. With this library, you can allocate, free, clear, copy and manipulate memory. In conjunction with imagine.ffi you have all the power you need for full control of the environment your application is running in.
With just an address in memory, you can use imagine.memory
to read and write data from and to certain memory addresses. This can be used with any native integer or floating point type, strings in multiple encodings and structured data.
Besides writing separate writes and reads in order to work with structured data, it's also possible to define structures using imagine.memory
. The structures will be aligned to the C alignment by default, but you can define how structure fields are aligned yourself as well.
local mem = require "imagine.memory"; -- no need for this if you use the ImagineMemory AMS Plugin
local dot = mem.struct "dot2d" {
mem.uint32_t "color"; -- offset 0
mem.int64_t "x"; -- offset 8, even though the previous member is only 4 bytes (C alignment)
mem.int64_t "y"; -- offset 16
};
There are multiple versions for this product. Older versions might be useful in the case of compatibility issues, but please do note that these versions are not supported anymore. The documentation for this product might also have been updated, we do not host the documentation for older versions.