I'm adding the code below to a script inside a table, so that i can enable and disable it. The code bellow only works if variables "address", "original" and "newmem" are not locals. If another script uses the same variable names, it overwrites the values of these variables. When that happens, if i disable the first script the original bytes are not restored correctly and the process crashes.
Is it possible to add as many lua scripts to a table as i want using only local variables, so that i can enable and disable them?
By using local variables i can reuse this code with minimal chages. Else, i have to rename every global variable throughout the code.
Code: Select all
[ENABLE]
{$lua}
if syntaxcheck then return end
local address_list = AOBScan("F3 0F 10 * * * 00 00 0F 57 C0 0F 2F D0 F3 0F 10 * * * 00 00 0F 97 C0")
local address = getAddress(address_list[0])
local original = readBytes(address,8,true)
local edited = readBytes(address,8,true)
edited[3] = 0x11
local newmem = allocateMemory(100,address)
local strOriginal = "db"
for i, v in next,original do
strOriginal = strOriginal .. string.format(" %.2X",v)
end
strOriginal = strOriginal .. string.format("\n")
local strEdited = "db"
for i, v in next,edited do
strEdited = strEdited .. string.format(" %.2X",v)
end
strEdited = strEdited .. string.format("\n")
local script_enable = [[
label(code)
label(return)
label(value)
newmem:
movss xmm2,[value]
]].. strEdited ..[[
code:
]].. strOriginal ..[[
jmp return
value:
dd (float)1.0
address:
jmp newmem
nop 3
return:
]]
--print(script_enable)
local a, b = autoAssemble(script_enable, false)
[DISABLE]
{$lua}
writeBytes(address,original)
deAlloc(newmem)
ctl3d32