Difference between revisions of "Lua:createMemoryStream"

From Cheat Engine
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
  
 
m.destroy()
 
m.destroy()
 +
m = nil
 
</pre>
 
</pre>
  
Line 36: Line 37:
  
 
m.destroy()
 
m.destroy()
 +
m = nil
 +
</pre>
 +
 +
<h3>Example 3</h3>
 +
<pre>
 +
local m = createMemoryStream()
 +
m.Size = 1024
 +
 +
local hwnd = findWindow("WTWindow", "Game")
 +
local r = executeCodeLocalEx("GetWindowTextA", hwnd, m.Memory,  m.Size)
 +
 +
if r ~= 0 then
 +
m.Position = 0
 +
print( readStringLocal(m.Memory ,  m.Size) ) -- Game
 +
end
 +
 +
m.destroy()
 +
m = nil
 
</pre>
 
</pre>

Latest revision as of 03:49, 28 August 2020

Example 1

m = createMemoryStream()
m.Size = 8
m.Position = 0

print("addr: ", m.Memory)

writeIntegerLocal(m.Memory, 1)
m.Position = m.Position + 4
writeIntegerLocal(m.Memory+m.Position, -1)

m.Position = 0
print( readIntegerLocal(m.Memory) ) -- 1
m.Position = m.Position + 4
print( readIntegerLocal(m.Memory+m.Position, true) ) -- -1
print( readIntegerLocal(m.Memory+m.Position) )       -- 4294967295 

m.destroy()
m = nil

Example 2

m = createMemoryStream()
m.Size = 8
m.Position = 0

print("addr: ", m.Memory)

m.writeDword(1)
m.writeDword(-1)

m.Position = 0
print( m.readDword() ) -- 1
print( m.readDword() ) -- 4294967295

m.destroy()
m = nil

Example 3

local m = createMemoryStream()
m.Size = 1024

local hwnd = findWindow("WTWindow", "Game")
local r = executeCodeLocalEx("GetWindowTextA", hwnd, m.Memory,  m.Size)

if r ~= 0 then
 m.Position = 0
 print( readStringLocal(m.Memory ,  m.Size) ) -- Game
end

m.destroy()
m = nil