Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


luacode section not functional in generated trainer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
MetaUnv_WithCE
How do I cheat?
Reputation: 0

Joined: 27 Jul 2021
Posts: 9

PostPosted: Mon Jan 17, 2022 8:10 am    Post subject: luacode section not functional in generated trainer Reply with quote

may I know if new {$LUACODE} function in CE7.3 works in generated trainner?

I got a old trainner code(execute a codeinjection AAscript ) upgrade to luacode,and it works well in CE,but if compiled it as a standalone trainner,it will not functional to write AAscript code injection to target process(verified by using CE to check the memory)

for simply concept the keypart code just like:


Code:
--controlMainForm = getMainForm()
xx=false

function enableit()
  scan="B8 ? ? ? ? E8 "
  x=AOBScanUnique(scan)
  registerSymbol("subaddr",x)
  mem=allocateMemory(0x2048)
  registerSymbol("newmem",mem)
  script=[[
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here
push rax
pushfq
{$luacode tt=r9}
x=readString(tt,5000)
http=getInternet()
c="data="..urlEncode(x)
s=http.postURL("http://127.0.0.1/log",c)
http.destroy()
{$asm}
jmp originalcode


originalcode:
popfq
pop rax
mov rax,rsp
mov [rax+08],rbx

exit:
jmp returnhere

subaddr:
jmp newmem
nop 2
returnhere:


  ]]
  ax=autoAssemble(script)
end


function disableit()
  --writeBytes(x,0x48,0x8B,0xC4,0x48,0x89,0x58,0x08)
  --writeBytes(x,0x48,0x8B,0xC4,0x48,0x89,0x58,0x08,0x48,0x89,0x70,0x10,0x48,0x89,0x78,0x18)
  --writeBytes(x,0x48,0x8B,0xC4,0x48,0x89,0x58,0x08)
  writeBytes(x,0x48,0x8B,0xC4,0x48,0x89,0x58,0x08,0x48,0x89,0x70,0x10,0x48,0x89,0x78,0x18,0x4c,0x89,0x48,0x20,0x55)
  unregisterSymbol("newmem")
  unregisterSymbol("subaddr")
  deAlloc(mem,0x2048)
  mem=nil
  scan=nil
  x=nil
  ax=nil
end

--writeBytes(x,0x48,0x8B,0xC4,0x48,0x89,0x58,0x08,0x48,0x89,0x70,0x10,0x48,0x89,0x78,0x18,0x4c)
--48 8B C4 48 89 58 08 48 89 70 10 48 89 78 18 4c 89 48 20 55 41 54 41 55 41 56 41 57 48 8d a8 68EDFFFF
function CETrainer_CEButton1Click(sender)
  if not(xx) then
  enableit()
  xx=true
  CETrainer.CEButton1.setCaption("Disable")
  else
  disableit()
  xx=false
  CETrainer.CEButton1.setCaption("Enable")
  end
end






tried with all features enabled



222.png
 Description:
 Filesize:  13.58 KB
 Viewed:  1234 Time(s)

222.png


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Jan 17, 2022 8:35 am    Post subject: Reply with quote

looks like I forgot to add the luacode required files to the exe pre-built options

You'll need to add luaclient*.dll files to the .exe package (use the add file(s) option in extra files for that)(

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
MetaUnv_WithCE
How do I cheat?
Reputation: 0

Joined: 27 Jul 2021
Posts: 9

PostPosted: Mon Jan 17, 2022 8:50 am    Post subject: Reply with quote

Dark Byte wrote:
looks like I forgot to add the luacode required files to the exe pre-built options

You'll need to add luaclient*.dll files to the .exe package (use the add file(s) option in extra files for that)(


Thanks So Much Dark Byte!Very Happy
and here is another question:
Is luacode section thread safe?

for example the codeinjection in original post
will may executed by mutlithread in target process

(in fact it's a network packet function,and where codeinejction injected was a code section shared in multiple tcp socket client in target process, one socket client one thread,I'm trying to log every packet data by that injection and post it to local webserver to save)

so,if luacode executed concurrently ,for example instancehttp1=getInternet() ,will the instancehttp1instance here shared across multiple thread is same instance?if not,will it block and hang to execute one by one(sometimes the webserver may slow to response)?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Jan 17, 2022 10:16 am    Post subject: Reply with quote

the luacode section runs in it's own thread, so don't access gui code unless you synchronize() it with the main thread first

Also, right now, only one luacode section can run at a time, so if you take a long time, or even wait for some other lua code, it'll freeze the target process


(Instead of luacode you may want to use createThread(function()) )

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
MetaUnv_WithCE
How do I cheat?
Reputation: 0

Joined: 27 Jul 2021
Posts: 9

PostPosted: Mon Jan 17, 2022 11:05 pm    Post subject: Reply with quote

Dark Byte wrote:
the luacode section runs in it's own thread, so don't access gui code unless you synchronize() it with the main thread first

Also, right now, only one luacode section can run at a time, so if you take a long time, or even wait for some other lua code, it'll freeze the target process


(Instead of luacode you may want to use createThread(function()) )


found a post /viewtopic.php?t=611040 said Lua is not thread-safe,got some clue.

may I confirm the gui code you mentioned here is the gui thread in trainner,not the render thread in game?

and createThread might not suitable here since the Shared Packet Process Code Section is in inside different Network Thread and managed by game process itself?

so the createThread might not suitable in this situation but we may create multiple LuaThread in trainner.exe when needed when it's a function we can directly execute(for ex a loop that consistently add 1 health per seconds)

im assume it works like follow picture



333.png
 Description:
 Filesize:  77.6 KB
 Viewed:  1146 Time(s)

333.png


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Tue Jan 18, 2022 12:36 am    Post subject: Reply with quote

CE's gui thread yes

you may want to implement a producer/consumer mechanic as postURL can take a while.

example: network thread 1 calls luacode, then network thread 2 and 3 have to wait till network thread 1 has finished sending the data

(you can also write the data to a file if it's localhost only)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
MetaUnv_WithCE
How do I cheat?
Reputation: 0

Joined: 27 Jul 2021
Posts: 9

PostPosted: Tue Jan 18, 2022 1:06 am    Post subject: Reply with quote

Dark Byte wrote:
CE's gui thread yes

you may want to implement a producer/consumer mechanic as postURL can take a while.

example: network thread 1 calls luacode, then network thread 2 and 3 have to wait till network thread 1 has finished sending the data

(you can also write the data to a file if it's localhost only)



Thanks so much my legend! got it finally Very Happy

looks {$luacode} and {$ccode} bring by 7.3 opens a whole new land,there gonna be alot daily reverse job gonna benefit from this! !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites