Imagine MemoryEx Action Plugin Overview


MemoryEx is a plugin released by Imagine Programming, allowing for more advanced operations from within the Lua environment you will find in Autoplay Media Studio 8. This plugin has been growing since the first release date, and now comes with many more features allowing for even more advanced programming.

MemoryEx was inspired because a good friend and good developer MadDogDean was trying to find a way of sharing data with other applications. Originally, MemoryEx's name was SharedMemory, and pretty much only included that feature in the plugin. This inspired Imagine Programming to start building around this idea and adding Memory operations, Library operations, Bitwise operations and now even real-time assembling. It is even possible to subclass a window and catch all its events using the Subclass functions!

It is also quite common for Imagine Programming to implement as much object oriented programming as possible. This means that MemoryEx comes with a possibility to have most of your code written in OOP, cutting down time spent coding and increasing execution speed.


Memory allocationAllocate and re-allocate private memory buffers you can use in your application.
Shared memory allocationAllocate shared memory buffers you can share with other processes. These buffers can be accessed using an ID you specify at the time of allocation.
Memory manipulationModify buffers using the MemoryEx functions, all type-sizes are supported. There is also support to write a Lua table to memory, so you can read it back later or write it to a file.
StructuresDefine structures containing one or more fields of specific data. All types supported, unions and structures in structures are also supported. After definition, these structures can be assigned to a buffer for interpretation.
ArraysWhen using the OOP implementation, it is possible to interpret the buffer as an array. For this, you can set several types, for different types of arrays.
Further memory operationsAside from the basic memory manipulation functions, there are also functions for memory comparison, memory-string comparison, copying of memory, filling of memory, initializing memory to zero and more.
Storing tables and functionsIt is also possible to export Lua tables to a memory buffer, with the support for most value types. Even functions can be exported and loaded back in later, allowing you to share functions with other processes!
Bitwise operationLua does not have native bitwise operators, and Lua 5.1 doesn't have a native bitwise library. That is why, to help some memory operations, MemoryEx also contains a set of functions for bitwise calculations. Most of these functions accept a large number of arguments, to make e.g. a condition such as (a ^ b ^ c ^ d ^ e) possible.
Library callsBy default, the AMS DLL.CallFunction function opens and closes a DLL before and after the function call. This is why a Library module was added to MemoryEx. Using Library.Load, you can open a DLL and call any function in the library as regular Lua function.

The calling-convention and thus stack handling is done by MemoryEx, so no worrying about that. You can specify the desired return type at any time, making it easier to call the same function with fewer arguments.
Library from memoryAs from version 2.2 of MemoryEx, it is now also possible to load a DLL from Base64 encoded data or simply a memory buffer containing the DLL. This allows you to include the DLL file as Base64 string in e.g. your Global section, load it and call it's functions without ever writing it to disk.
Call Lua closuresAlso MemoryEx 2.2 and higher, when loading a DLL, you can now call a function as Lua CClosure. This allows you to e.g. include a Lua module as Base64 string in your code, load it and call the luaopen_modulename function which will register all the functions in the module. CallClosure_ is basically a package.loadlib, but it also supports the DLL's you store as Base64 string or data in a buffer.
Flat AssemblerIt is now also possible to assemble Assembly code to an executable memorybuffer. This is for advanced programmers, as this form of programming is a little more delicate. As an example, one could now write an encryption algorithm procedure, or a checksum procedure in assembly and execute it as it was a regular Lua function.

These assembled chunks of code can be called like any Lua function, and accept an infinite number of arguments, as long as the assembly code you provided processes all of these. Fast data routines and algorithms can be coded using this feature, but also any operations depending on WinAPI functions.
Definition files / LHMemoryEx now also has a custom format compiled definition files, which can contain anything you would like to load in the AMS Lua environment. You can globally define structures, constants, functions. You can locally (private) declare functions and assembled chunks of machine code (The LH compiler assembles the assemblies for you).

This allows for re-usable compiled LH files containing data, functions and assemblies you would like to re-use. See Imagine MemoryEx LH Compiler for information on how to compile these files.
Window SubclassingWith MemoryEx, you can subclass windows and controls with a window handle and catch all their events. Using these Subclass functions, you can catch and process events sent to window handles allowing you to completely customize behaviour in objects and windows.
Memory pattern scanningScan data at a specific address for a certain pattern of memory, and find all the matching occurrences. This may be useful when you want to parse data files without data structure specification. This method is also often used with writing cheats for videogames, which is problematic. Beware!


Filename Version / Changelog  
MemoryEx-Plugin- Fri 21 Jun 2024, version - View changes.
  • Added: AMS9 Support
x Download
MemoryEx-Plugin- Mon 22 Apr 2019, version - View changes.
  • Fixed: A lot of issues in the implementation of Lua
  • Updated: Manual version number
  • Added: Compatibility with thread-safe Lua implementation
x Download
MemoryEx-Plugin- Mon 09 Nov 2015, version - View changes.
  • Fixed: MemoryEx.ReAllocate (was wrong name, SharedMemory.ReAllocate)
x Download
MemoryEx-Plugin- Tue 24 Dec 2013, version - View changes.
  • Added: MemoryEx.CompileScan
  • Added: MemoryEx.Scan
  • Added: MemoryEx.ScanAll
  • Added: MemoryEx.FreeScan
  • Added: Bitwise.ROL
  • Added: Bitwise.ROR
  • Added: Bitwise._ROL
  • Added: Bitwise._ROR
  • Updated: All bitwise functions have been optimized.
  • Updated: Documentation
  • Added: Scan example
x Download
MemoryEx-Plugin- Fri 10 May 2013, version - View changes.
  • Added: Base64 / buffer support for Library.Load, can now load DLL from Base64 encoded data or a buffer.
  • Added: CallClosure_ method for library handles, allowing you to call a CClosure enabling registering modules from e.g. DLL's which are loaded from memory.
  • Added: Base64 DLL example.
  • Updated: Documentation and examples
x Download
MemoryEx-Plugin- Thu 11 Apr 2013, version - View changes.
  • Added: Memory function support, storing and executing of Lua functions in / from memory buffers.
  • Added: Support for functions in MemoryEx.Table
  • Added: MemoryEx.Function
  • Added: MemoryEx.AllowMemoryFunctions
  • Added: MemoryEx.FunctionRequiredSize
  • Added: MemoryEx.LString
  • Updated: Documentation and examples
x Download
MemoryEx-Plugin- Sat 15 Dec 2012, version - View changes.
  • Added: Structure allocation (STRUCT:New())
  • Added: hStruct:Free() for allocated structures.
  • Updated: Documentation
x Download
MemoryEx-Plugin- Thu 06 Dec 2012, version - View changes.
  • Fixed: Issues regarding the Library system.
  • Added: Real-time assembler! Assemble and execute assembly code.
  • Added: Subclass control, subclass any window handle with a Lua function and customize behaviour!
  • Added: LH Support, load compiled LH files. These files can be compiled with IMXLH and add serious security to code and projects.
x Download
MemoryEx-Plugin- Thu 30 Aug 2012, version - View changes.
  • Comment: First stable release
x Download

Additional Information

Before trying things out yourself, it would be wise to read the documentation regarding this plugin as some operations can cause unwanted behaviour if not executed well. Also read the fASM documentation, before using the assembler.

Note regarding Bitwise functions
When using the Bitwise functions and you have the "Fixup text case while typing language keywords" feature enabled (See documentation), please do mind that then AMS will rename Bitwise.And and Bitwise.Or to Bitwise.and and Bitwise.or. This is not supposed to happen, AMS is to leave functions in objects alone in this process, but it does not. If you have this feature enabled, you can use the Bitwise function aliases.

Each function also has an alias with a prefaced underscore character. So, Bitwise._And, Bitwise._Or, Bitwise._Xor etc. Use these or disable the "Fixup text case" feature.

Compatibility Information

  • This plugin requires the Autoplay Media Studio 8 runtime engine, without it, it will not work.
  • This software requires an operating system equal to or higher than Windows 2000.


  • ASM.Assemble
  • ASM.Close
  • ASM.Initialize
  • Bitwise._And
  • Bitwise._ASL
  • Bitwise._ASR
  • Bitwise._Mod
  • Bitwise._Not
  • Bitwise._Or
  • Bitwise._Xor
  • Bitwise._ROL
  • Bitwise._ROR
  • Bitwise.And
  • Bitwise.ASL
  • Bitwise.ASR
  • Bitwise.Mod
  • Bitwise.Not
  • Bitwise.Or
  • Bitwise.Xor
  • Bitwise.ROL
  • Bitwise.ROR
  • Library.Load
  • MemoryEx.Allocate
  • MemoryEx.AllocateEx
  • MemoryEx.AssignStruct
  • MemoryEx.Byte
  • MemoryEx.Compare
  • MemoryEx.CompareStrings
  • MemoryEx.Copy
  • MemoryEx.CopyEx
  • MemoryEx.DefineStruct
  • MemoryEx.Double
  • MemoryEx.DWORD
  • MemoryEx.Fill
  • MemoryEx.Float
  • MemoryEx.Free
  • MemoryEx.FromPointer
  • MemoryEx.Integer
  • MemoryEx.LoadLH
  • MemoryEx.QWORD
  • MemoryEx.ReAllocate
  • MemoryEx.Size
  • MemoryEx.String
  • MemoryEx.LString
  • MemoryEx.StringLength
  • MemoryEx.StructEntryOffset
  • MemoryEx.StructEntrySize
  • MemoryEx.StructSize
  • MemoryEx.Table
  • MemoryEx.TableRequiredSize
  • MemoryEx.Function
  • MemoryEx.FunctionRequiredSize
  • MemoryEx.AllowMemoryFunctions
  • MemoryEx.UnsignedByte
  • MemoryEx.UnsignedDWORD
  • MemoryEx.UnsignedInteger
  • MemoryEx.UnsignedWord
  • MemoryEx.Word
  • MemoryEx.Zero
  • MemoryEx.CompileScan
  • MemoryEx.Scan
  • MemoryEx.ScanAll
  • MemoryEx.FreeScan
  • SharedMemory.Access
  • SharedMemory.AccessEx
  • SharedMemory.Allocate
  • SharedMemory.Free
  • SharedMemory.IsBuffer
  • SharedMemory.ReleaseAccess
  • Subclass.Create
  • Subclass.HasSubclass
  • Subclass.OldWinProc
  • Subclass.Remove

Special credits

Special credits go to these friends:

  • MadDogDean - For helping me test the product and being the original inspiration for developing this work.