Notes
- If the pointer is a
char*
,wchar_t*
,char*
,string
, orwstring
, the returned string is the memory content as a C string. - In other cases, it returns a string formatted like this :
"Pointer<type>: address"
C Pointer string conversion
Pointer objects supports conversion to Lua string using the standard Lua function tostring()
Example
local c = require "c"
-- Creates a Pointer to a Buffer in memory (a void* pointer)
local c_ptr = c.Pointer(sys.Buffer("\x48\x65\x6C\x6C\x6F\x20\x4C\x75\x61\x52\x54\x20\x21\x00"))
-- Casts the pointer to a C string and converts converts it as a Lua string
print(tostring(c_ptr:as("char*")))