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 


Need assistance with CE Lua with some parameters.

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

Joined: 12 Nov 2024
Posts: 3
Location: Land of the Free

PostPosted: Tue Nov 12, 2024 2:31 pm    Post subject: Need assistance with CE Lua with some parameters. Reply with quote

So I need a LUA script for a CT table, I could write the whole thing in C++ but that'd be a huge pain in the ass and unfortunately I don't know CE Lua or much LUA. I have a general markup for a script that I'd like written and I'm not sure how complex if someone can write it or instruct me on how I'd do these things as I've been searching and not finding that caters to my specific use case.

What I am trying to do:

1. Have one or two editable placeholder strings (A file location and a 15 character string).
2. Automatically open a game process and hook to it based on one of said placeholder strings (which would be a file location).
3. Have a script automatically go to a specific module+address and set a string value based on one of those placeholders.
4. Verify specific address is set to said string before ending script execution or possibly freezing the value.

For more specifics I need it to:
1. Have an activation button that will capture or launch and then capture a program based on it's name or file location. Let's say "program.exe" or "C:\games\program.exe".
2. It needs to write to a specific module "dllname.dll+5432" with a 15 character string. Then verify it's changed to this specific placeholder string before ending execution.
3. Possibly freeze it maybe.

Normally I'd go into the executable and modify it with HxD but sadly newer versions prevent this and make it a pain cause I have to manually change it and paste in a string every time. So I figure this would be way easier.

Any code or any instructions anywhere would be greatly appreciated!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 147

Joined: 06 Jul 2014
Posts: 4584

PostPosted: Tue Nov 12, 2024 4:01 pm    Post subject: Reply with quote

"Freezing" a value just means writing the same value to it several times per second. You can't really end execution then.

If you want a table, edit the Lua script (Table -> Show Cheat Table Lua Script) and write something like this:
Code:
getAutoAttachList().add'game.exe'

MainForm.OnProcessOpened = function(pid, handle, caption)
  print('attached to', pid)

  local addr = getAddress'dllname.dll+5432'
  local new_string = 'uidfhiauiofh'

  -- might need `fullAccess(addr,#new_string)` if memory is read only
  assert(writeString(addr, new_string), 'Failed to write string')
  print'Write successful. Exiting...'
  createTimer(2000, function()
    closeCE()
  end)
end

If you want a trainer, there's plenty of tutorials out there. (I mostly work with tables)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Oroborius
How do I cheat?
Reputation: 0

Joined: 12 Nov 2024
Posts: 3
Location: Land of the Free

PostPosted: Tue Nov 12, 2024 11:04 pm    Post subject: Reply with quote

ParkourPenguin wrote:
"Freezing" a value just means writing the same value to it several times per second. You can't really end execution then.

If you want a table, edit the Lua script (Table -> Show Cheat Table Lua Script) and write something like this:
Code:
getAutoAttachList().add'game.exe'

MainForm.OnProcessOpened = function(pid, handle, caption)
  print('attached to', pid)

  local addr = getAddress'dllname.dll+5432'
  local new_string = 'uidfhiauiofh'

  -- might need `fullAccess(addr,#new_string)` if memory is read only
  assert(writeString(addr, new_string), 'Failed to write string')
  print'Write successful. Exiting...'
  createTimer(2000, function()
    closeCE()
  end)
end

If you want a trainer, there's plenty of tutorials out there. (I mostly work with tables)


So this is great. Does pretty much exactly what I needed. Smile I've been trying to see if there's a way to make a header with a value and have the lua grab the value from the header and plug that into the lua script. But also not getting any luck there. Although not sure how difficult it is. I've seen a lot of ways that let you make headers with addresses but not just values that don't affect the game.

Still huge thanks I appreciate it so much you save me a lot of headache!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 147

Joined: 06 Jul 2014
Posts: 4584

PostPosted: Tue Nov 12, 2024 11:19 pm    Post subject: Reply with quote

What do you mean by "header"? If you're referring to the address list (bottom half of main window), you can directly add the address itself. Click "Add Address Manually", enter dllname.dll+5432 for the address, change the value type to String, and click OK. You can then change the value as you see fit.

If you want a list of values to choose from, there are dropdown options you can play around with. Right click the new memory record in the address list and select "Set/Change dropdown selection options".

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Oroborius
How do I cheat?
Reputation: 0

Joined: 12 Nov 2024
Posts: 3
Location: Land of the Free

PostPosted: Tue Nov 12, 2024 11:33 pm    Post subject: Reply with quote

So I need a placeholder in the address list to read from so people can save the data to a new CT file when they edit it as everyone is going to have a different value here. I'm effectively replacing a string with a custom string people can replace for custom usage. It's supposed to make it as easy as possible. Although since this works I clarified to friends that they can just edit the CT file in a text editor but a header of group with a string value that is read from in the lua code instead of directly having the string in the lua code would make it easier for people. Currently the way everyone does this is we manually paste in that module+offset to get to an exact string and then replace it every time a game launches, but effectively this is making a config/quick launcher for a game that only stores that string reference in memory somehow (maybe obfuscated in the dlls/exes?? Not sure).

But yeah it's not required or anything and this works fantasticly and I appreciate it a ton.

Ideally I'd just have an ini file read from or in this case id want the address list to be used like a config file/list to be edited. Although I've only seen that in some pretty advanced tables like Phokz tables.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 147

Joined: 06 Jul 2014
Posts: 4584

PostPosted: Wed Nov 13, 2024 1:18 pm    Post subject: Reply with quote

Oroborius wrote:
...or in this case id want the address list to be used like a config file/list to be edited. Although I've only seen that in some pretty advanced tables like Phokz tables.
Any memory shown in the address list belongs to the attached process. You could allocate memory and change that, but at that point simply adding the address itself and changing it would be more direct. Even if it did work like you think, it's not like CE will remember how you changed values when you restart CE.

You could store the new string in a table file and interact with the user through dialogues (e.g. inputQuery, messageDialog), but it gets really annoying to handle every edge case whenever user input is involved. Also it would need to prompt the user on every launch whether or not they'd like to change the string.

Storing the string to write in a separate file (e.g. ini) could work, but then you run into the problem of where to store that file. If you want that to be configurable, you've just kicked the can down the road; if it's not configurable, then it either won't work for everyone or leads to filesystem pollution.

I really think the best way is for users to edit the Lua script themselves. Move that line to the top and add a comment to make it easier for them:
Code:
-- change this:
local new_string = 'uidfhiauiofh'


getAutoAttachList().add'game.exe'

MainForm.OnProcessOpened = function(pid, handle, caption)
  print('attached to', pid)

  local addr = getAddress'dllname.dll+5432'

  -- might need `fullAccess(addr,#new_string)` if memory is read only
  assert(writeString(addr, new_string), 'Failed to write string')
  print'Write successful. Exiting...'
  createTimer(2000, function()
    closeCE()
  end)
end
They can save the table after they change it (Main window -> File -> Save). Note that they need to open and edit it while the game is closed.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
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