Write value of a lua variable to an address

nihilism

nihilism

Cheater
Joined
Mar 29, 2018
Messages
34
Just messing around with different mono hacking methods, but stuck at this part. I was able to use the mono lua commands to consistently get the base address that I want to use for pointers/other codes. But not able to get that to write to the symbol I made for it.



Thought at first maybe value is not in the correct format but no dice with conversions.



Think I am missing an obvious step. Please point me in the right direction!


Lua:
<i>
</i>[ENABLE]

registersymbol(baseaddress)

alloc(baseaddress,64)



baseaddress:

dd 0



{$lua}

images={}

for i=1, #a1 do

  images[i]=mono_getImageFromAssembly(a1[i])



  if mono_image_get_name(images[i])=="Assembly-CSharp" then

    classes=mono_image_enumClasses(images[i])



    for j=1, #classes do

      if classes[j].classname=="GameManager" then

        baseaddress=mono_class_findInstancesOfClassListOnly(d[1],classes[j].class)

        --print(string.format("%.8x",baseaddress[1]))

      end

    end

  end

end



--[[addy=readStringLocal(baseaddy,8)

temp=stringToByteTable(addy)

addy1=byteTableToDword(temp)

--]]

{$asm}



[DISABLE]



unregistersymbol(baseaddress)

dealloc(baseaddress)
 
koderkrazy

koderkrazy

Expert Cheater
Fearless Donors
Table Maker
Joined
Jun 17, 2018
Messages
255
Hey try this:<br />
Lua:
local myLuaAddr = mono_class_findInstancesOfClassListOnly(d[1],classes[j].class)<br />
writeQword('baseaddress', myLuaAddr)  --if it is 64bit address<br />
   --or writePointer('[baseaddress]', myLuaAddr) if you want to write to address pointed by baseaddress directly
<br />
<br />
See attached table for example:<br />
1. connect to any process. May be connect to Cheat Engine itself.<br />
2. Load the example table. <br />
3. Run CreateASMVariable script<br />
4. Keep hitting 'Add 5 in Lua' script.
 
nihilism

nihilism

Cheater
Joined
Mar 29, 2018
Messages
34
Thanks a lot that helped me find what was wrong.<br />
<br />
My main problem though is that my lua variable was a table so I needed to add [1] to get the value I wanted.<br />
<br />
Knew it was something obvious. Thanks again.
 
T

tabman

Novice Cheater
Joined
Jun 10, 2018
Messages
15
You can also allocate memory and register symbols by means of lua:<br />
Lua:
{$Lua}<br />
[ENABLE]<br />
<br />
local size = 4<br />
addr = allocateMemory(size)<br />
<br />
--unlike autoassembler, registerered symbol must be unregistered first<br />
unregisterSymbol("var")<br />
registerSymbol("var",addr)<br />
<br />
local val = 10<br />
writeInteger("var",val)<br />
--or<br />
--writeInteger(addr,val)<br />
<br />
[DISABLE]<br />
<br />
unregisterSymbol("var")<br />
deAlloc(addr)
 
Top