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 


Imporve Enumerate DLL's and Symbols window PLZ

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Wed Oct 04, 2023 5:23 pm    Post subject: Imporve Enumerate DLL's and Symbols window PLZ Reply with quote

Enumerate DLLs and Symbols is a great feature. But finding a call in it is a huge pain. The search function is very limited and I know how hard it is to implement a better search engine but can we at least have the ability to export the entire output and/or the ability to only export calls of a single binary as text?
I don't know of any other software to give this information. Is it possible to use x64dbg (I use it already but IDK if it has such a feature) to see the calls the way Cheat Engine represents them (to show the original calls' names)?
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Wed Oct 04, 2023 7:58 pm    Post subject: Reply with quote

export main symbols:
Code:
local savedialog = createSaveDialog()
savedialog.Title = 'Save Symbols'
savedialog.DefaultExt = '.txt'
savedialog.Filter = 'textfiles (*.txt)|*.txt'
savedialog.Options = '[ofOverwritePrompt, ofHideReadOnly, ofEnableSizing]'

function exportMainSymbols()
  local sd_result = savedialog.Execute()
  if not sd_result then return end

  local filename = savedialog.FileName
  if not filename or filename == '' then return end

  local t = {}
  for k,v in pairs(getMainSymbolList().getSymbolList()) do
    t[#t+1] = { address = v, name = k }
  end

  table.sort(t, function(lhs, rhs) return lhs.address < rhs.address end)

  local sl = createStringList()

  for _,sym in ipairs(t) do
    sl.add(('%08X: %s'):format(sym.address, sym.name))
  end

  local saveResult = sl.saveToFile(filename)
  sl.destroy()

  if not saveResult then
    showMessage('Could not save to file '..filename)
  end
end

_________________
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
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Oct 05, 2023 8:35 am    Post subject: Reply with quote

How do I find the file?
Although I have zero knowledge of Lua, I think I should expect either an error message or a window to save the file. However, neither of them happened using the Lua engine.

Or do I have to fill anything in?

I'm sorry but I'm really noobie when it comes to using Lua. So if you give me a little bit more detail, that would be great.

Thanks in advance
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Thu Oct 05, 2023 10:03 am    Post subject: Reply with quote

All you do is call the function.

This is how a function is defined:
Code:
function exportMainSymbols()
  ...
end

And this is how a function is called:
Code:
exportMainSymbols()


If you just need this for one specific game, put the code in my first post into the table's Lua script, execute it once, and call the function manually from the Lua engine. Otherwise, try putting it in a new .lua file in the autorun folder (it might be required to lazily initialize `savedialog`). Also maybe do some GUI shenanigans to add it as a menu item to the relevant form.

_________________
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
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Fri Oct 06, 2023 1:21 am    Post subject: Reply with quote

Thank you that was very helpful. I made a Lua extension for it now.

Sorry, I couldn't include my code here because the website thinks I'm including URLs in my code.

But anytime I close the popup window without specifying a location it opens Cheat Engine's dir. Can we fix that?

And in case I want to put this option under the "Table" tab what should I do? I tried using "miTable" instead of "Edit3" but it didn't work.

How can I make my own tab and put this extension in it?



ExtractSymbols.lua
 Description:

Download
 Filename:  ExtractSymbols.lua
 Filesize:  1.76 KB
 Downloaded:  349 Time(s)

Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Fri Oct 06, 2023 12:08 pm    Post subject: Reply with quote

You shouldn't copy and paste code from the internet without at least trying to understand what it does.

Don't execute the code in a separate thread. Accessing the GUI from anything other than the main thread is bad.
No need for pcall. My code shouldn't throw errors, and if it does, CE uses lua_pcall and ignores them.
Why shellExecute? There's absolutely no reason for it. My function doesn't even return anything to execute.

Modifying menu items under the "Table" menu is a bad idea as it's managed by CE.

Append this to the code in my first post:
Code:
local miExtensions = MainForm.findComponentByName'miLuaExtensions'
if not miExtensions then
  miExtensions = createMenuItem(MainForm)
  miExtensions.Name = 'miLuaExtensions'
  miExtensions.Caption = 'Lua Extensions'
  MainForm.Menu.Items.insert(MainForm.Menu.Items.Count - 1, miExtensions)
end

local mi = createMenuItem(MainForm)
mi.Name = 'miExportSymbols'
mi.Caption = 'Export Symbols'
mi.OnClick = exportMainSymbols
miExtensions.add(mi)

_________________
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
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Fri Oct 06, 2023 1:28 pm    Post subject: Reply with quote

Thank you so much it worked like a charm.
Since, I have zero idea about Cheat Engine extensions and Lua. I had to find something similar that I could modify to make my script work.

I don't know, but I feel like asking these questions is annoying to you guys. So I try to improvise and research a bit before asking. I would love to learn more about it if there is any documentation on Cheat Engine Lua Engine. There are many things that Cheat Engine could imporve upon and with the ability to make extensions, I could improve it without the need to wait for updates. I just wish Cheat Engine was made in C++. Anyway, thanks again.
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Fri Oct 06, 2023 2:53 pm    Post subject: Reply with quote

If it's annoying, I just won't bother answering in the first place. You're fine.

The CE wiki has some basic information available. The file `celua.txt` contains sporadic documentation on most of CE's Lua API. For specific details, I'll read CE's source code.

CE uses Lua 5.3; documentation is available here:
http://www.lua.org/manual/5.3/contents.html#contents

_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1522

PostPosted: Fri Oct 06, 2023 7:41 pm    Post subject: Reply with quote

I added two edits to the existing code.
1) You can write the file name you want to open for recording in the section I specified in the code. When the code runs, the folder you added will open.
2) If the registration is cancelled, the CE folder will not be opened.
If you want the CE folder to be opened in case of cancellation, the previous code is valid and used.

EDIT (V2)
3) CE >> Added to table menu!
4) Hotkey added. (You can edit it according to your choice.)

Code:

local savedialog = createSaveDialog()
savedialog.Title = 'Save Symbols'
savedialog.InitialDir = [[C:\Users\YourFolderName]]
savedialog.DefaultExt = '.txt'
savedialog.Filter = 'textfiles (*.txt)|*.txt'
savedialog.Options = '[ofOverwritePrompt, ofHideReadOnly, ofEnableSizing]'

function exportMainSymbols()
  local sd_result , err = savedialog.Execute(), "Not save"
  if not sd_result then
   return err
  else

  local filename = savedialog.FileName
  if filename==nil or filename == '' then return false end

  local t = {}
  for k,v in pairs(getMainSymbolList().getSymbolList()) do
    t[#t+1] = { address = v, name = k }
  end

  table.sort(t, function(lhs, rhs) return lhs.address < rhs.address end)

  local sl = createStringList()

  for _,sym in ipairs(t) do
    sl.add(('%08X: %s'):format(sym.address, sym.name))
  end

  local saveResult = sl.saveToFile(filename)
  sl.destroy()

  if not saveResult then
    showMessage('Could not save to file '..filename)
  end
  end
end

local ExtractSymbolsName = 'miExtractSymbols'
local ExtractSymbolsCaption = '&Extract Symbols'

if not newItem then
   newItem = createMenuItem(MainForm)
   newItem.Caption = translate('Extract Symbols') --caption
   newItem.OnClick = exportMainSymbols --onClick
    newItem.Shortcut = 'CTRL+S'
    MainForm.miTable.insert(5,newItem)
else
   newItem.Caption = translate('Extract Symbols') --caption
   newItem.OnClick = exportMainSymbols --onClick
    newItem.Shortcut = 'CTRL+S'
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Oct 12, 2023 6:28 am    Post subject: Reply with quote

I'm working on a different game and had an issue with the script. Although, the game's interesting functions are in the main PE file. When I use the script it exports some of the libraries randomly and consistently (Always with the same results).

When I execute the script I make sure the symbols window has populated all the entries beforehand.

Mr ParkourPenguin could you please help me fix the script and make it export every single element? So I could use it for games that are not main-centric.

Thanks
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Thu Oct 12, 2023 9:59 am    Post subject: Reply with quote

I don't know which symbols you're missing, but there's no easy way to get them right now. This is the only function I can find that iterates over symbols:
Quote:
getMainSymbolList(): Returns the symhandler internal symbol list (Note: This does not contain .net, modulelist, or other info)

_________________
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 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