Mono Helper Project

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
jgoemat
Table Makers
Table Makers
Posts: 38
Joined: Fri Jul 21, 2017 6:47 pm
Reputation: 37

Mono Helper Project

Post by jgoemat »

Update 1/4/2021

I finally found some time over the holidays to do some more work on this and make it easier to make changes in the future. Now there's a website in github pages with an easy link to the file you need to copy to autorun ('the current release' link) and a tutorial for a simple cheat in the game Raft: [Link]

I've also attached a table that is empty except for having the script as the table script which will work as an alternative.

I've fixed the bug causing the search window to appear off screen, and it now automatically selects the image 'Assembly-CSharp' if present, which is normal for Unity games. You can always load a different assembly using the 'Image' menu on the search form. I also put the link as a 'Search' item under the existing 'Mono' menu that appears with mono games instead of having a seperate top-level menu.

Searching is very fast as you type. Double-click on a method to create an AA script you can save to your table.

I have lots of ideas for future changes if I get the time, but feature suggestions are welcome on the github repository. I need to figure out how to do Popup menus better, I think I found the clear() method that will make it easy to update them based on context so I might do that soon. Ideas:
  • Right-click option on method to add generated script to cheat table automatically
  • In addition to above, another option to add it with code to save RCX and have a counter and have those displayed as children to the script. I found myself doing that a lot in writing a Raft table and copying the address to structure dissect.
  • If I have LOTS of time, make the previous option work smoother, maybe a seperate window allowing you to do this for different methods and see all them together and enable/disable them individually. Also save to table (maybe as AA script comment in a table entry?)
  • Generate AA script to find addresses for static members that you can add to another script (CE doesn't do that yet with an AA command, does it?)
  • Option to search for uses (i.e. from 'Slot' class, menu option to search for all a) classes that are children or parents of Slot, fields of type Slot (or descendant?), methods with parameters or return values of type 'Slot'
  • Get 'Notes' working - see notes on class in class window, and list of notes in a new window
Image

Website: [Link]
Repository: [Link]
monohelper.lua (righ-click and save as): [Link]
Tutorial using 'Raft' as an example: [Link]

If you're interested in hacking the actual code for the script, clone the repository. The 'Dev.CT' table has a table script with a dev menu allowing you to build and reload a single script from the individual files (now in the 'src' directory), and an option to build with the forms into the CE autorun directory directly to check in new CE window.

Fixes from previous version:

* Moved source code to 'src' directory
* Added github pages in 'docs' directory
* Added Raft tutorial
* Fixed Search window appearing offscreen (now centers on screen when first shown)
* Auto-select 'Assembly-CSharp' if present

Known bugs:

* Sometimes it doesn't show all the classes/methods/fields for a name, i.e. typing 'Play' will show 'PlayerStats' class but when you keep typing and add the 'e' it no longer shows up... Hard to track down
Attachments
MonoHelper.CT
(50.58 KiB) Downloaded 74 times
Last edited by jgoemat on Tue Jan 05, 2021 4:01 am, edited 4 times in total.

User avatar
TheyCallMeTim13
Administration
Administration
Posts: 1506
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 775

Re: Mono Helper Project

Post by TheyCallMeTim13 »

If you do a search on the CEF for "cheat engine form to lua" there's a script to convert forms to lua scripts.

gideon25
Table Makers
Table Makers
Posts: 643
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 407

Re: Mono Helper Project

Post by gideon25 »

jgoemat wrote:
Sat Jan 25, 2020 6:30 am
I created a cheat table with some forms and external scripts to help analyze games that use mono. ...
So which files over there at the repository do I put into my autorun folder for maximum functionality?

User avatar
TheyCallMeTim13
Administration
Administration
Posts: 1506
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 775

Re: Mono Helper Project

Post by TheyCallMeTim13 »

I thought Corroder actually had something. But the last script I posted should work; at least with CE 6.8.3, haven't tried it with CE 7.0.
But as mgr.inz.Player pointed out you can also just convert LFM file format to lua.

Here's the script I posted.
I2CEForm2Lua.7z
Password: FearLess Cheat Engine
(3.04 KiB) Downloaded 147 times

gideon25
Table Makers
Table Makers
Posts: 643
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 407

Re: Mono Helper Project

Post by gideon25 »

Using cheat engine 7,with the monohelper scripts, cheat engine spits out errors, particularly "Attempt to index a nil value" (global mono) as well as a few other nil values and when I try to use the search under mono its: Error:C:\Program Files\Cheat Engine 7.0\autorun\monomenu.lua:23: attempt to call a nil value (method 'show') and nothing works. Its a shame because the stuff looks pretty cool.

jgoemat
Table Makers
Table Makers
Posts: 38
Joined: Fri Jul 21, 2017 6:47 pm
Reputation: 37

Re: Mono Helper Project

Post by jgoemat »

@gideon25 Looks like you put the scripts in the cheat engine autorun directory, but they're set to be run from the directory with the cheat table, and the forms have to be in the table too. That might be the reason...


UPDATE

I updated the repo, now it has 'autorun/monohelper.lua' drop the file in your cheat engine autorun folder and it should work (it does for me). Let me know if you get any errors. Now it creates a separate menu 'Mono Search' when a mono game is loaded, using the same code that CE's mono code uses.

User avatar
corroder
Novice Cheater
Novice Cheater
Posts: 17
Joined: Fri Mar 03, 2017 1:54 am
Reputation: 1

Re: Mono Helper Project

Post by corroder »

This is an old script I am used, just a little modified to generated an LFM file.

Code: Select all

--c = getMainForm()
--c.Visible = false
local path = TrainerOrigin or getMainForm()

if moduleForm then moduleForm.Destroy() end
moduleForm = createForm()
moduleForm.setSize(200,50)
moduleForm.borderStyle = 'bsSingle'
moduleForm.Caption = 'LOL'

bgen = createButton(moduleForm)
bgen.setSize(180,30)
bgen.setPosition(10,10)
bgen.Caption = 'Generate Lua Form Script'


function TranslateToFunction(Str, parent)
   if (type(Str) ~= 'string') then error('Not valid type'); end;
   local action = 'create' .. string.gsub(Str, 'TCE', '')
   if ( Str == 'TTabSheet' and parent and object_getClassName(parent) == 'TCEPageControl') then
      action = parent.getName() .. '.addTab()';
   end
   return action
end

function GenerateLuaScript(WantedForm)
Form = WantedForm
FormToLua = {}
FormToLua.MainForm = {}
CompCount = Form.getComponentCount()
FormToLua.MainForm.name = Form.getName()
FormToLua.MainForm.caption = Form.Caption
FormToLua.MainForm.left = Form.Left
FormToLua.MainForm.top = Form.Top
FormToLua.MainForm.width = Form.Width
FormToLua.MainForm.height = Form.Height
FormToLua.MainForm.align = Form.Align
FormToLua.MainForm.enabled = tostring(Form.Enabled)
FormToLua.MainForm.visible = control_getVisible(Form) and 'true' or 'false'
for i=1,CompCount do
   i = i-1
   FormToLua[i] = {}
   Object = UDF1.getComponent(i)
   FormToLua[i].Object_parent = Object.Parent.getName()
   FormToLua[i].Object_type = TranslateToFunction(object_getClassName(Object), Object.Parent) or error("No object type???");
   FormToLua[i].Object_name = Object.getName() or false
   FormToLua[i].Object_caption = Object.caption or false
   FormToLua[i].Object_left = Object.Left or false
   FormToLua[i].Object_top = Object.Top or false
   FormToLua[i].Object_width = Object.Width or false
   FormToLua[i].Object_height = Object.Height or false
   FormToLua[i].Object_align = Object.Align or false
   FormToLua[i].Object_enabled = Object.Enabled and 'true' or false
   FormToLua[i].Object_visible = control_getVisible(Object) and 'true' or false
   FormToLua[i].IsTab = object_getClassName(Object) == 'TTabSheet';
   -- FormToLua[i].Object_color = tostring(Object.Color)
   -- FormToLua[i].Object_font = tostring(Object.Font)
end

GenerateScript = [[--Creates first the form
]] .. FormToLua.MainForm.name .. [[ = createForm(]] .. FormToLua.MainForm.visible .. [[)

]] .. FormToLua.MainForm.name .. [[.caption = ]] .. "[[" .. FormToLua.MainForm.caption .. "]]" .. [[

]] .. FormToLua.MainForm.name .. [[.left = ]]  .. FormToLua.MainForm.left .. [[

]] .. FormToLua.MainForm.name .. [[.top = ]]  .. FormToLua.MainForm.top .. [[

]] .. FormToLua.MainForm.name .. [[.width = ]]  .. FormToLua.MainForm.width .. [[

]] .. FormToLua.MainForm.name .. [[.height = ]]  .. FormToLua.MainForm.height .. [[

]] .. FormToLua.MainForm.name .. [[.align = ]]  .. FormToLua.MainForm.align .. [[

]] .. FormToLua.MainForm.name .. [[.enabled = ]]  .. FormToLua.MainForm.enabled .. [[

]] .. FormToLua.MainForm.name .. [[.visible = ]]  .. FormToLua.MainForm.visible

local f = assert(io.open(path..FormToLua.MainForm.name..'.LFM', "w"))
for line in string.gfind (GenerateScript,"[^\n]+") do
   f:write(line, "\n")
   print(line)
end

TempText = [[-- Creating the objects]]

for i = 1, CompCount do
   i = i-1
   TempText = TempText ..[[

]] .. (FormToLua[i].IsTab and FormToLua[i].Object_name .. [[ = ]] .. FormToLua[i].Object_type or FormToLua[i].Object_name .. [[ = ]] .. FormToLua[i].Object_type .. [[(]] .. FormToLua[i].Object_parent .. [[)]]) .. [[

]] .. ((FormToLua[i].Object_caption == false) and '' or FormToLua[i].Object_name .. [[.caption = ]] .. "[[" .. FormToLua[i].Object_caption  .. "]]") .. [[


]] .. ((FormToLua[i].Object_left == false) and '' or FormToLua[i].Object_name .. [[.left = ]] .. "[[" .. FormToLua[i].Object_left  .. "]]") .. [[

]] .. ((FormToLua[i].Object_top == false) and '' or FormToLua[i].Object_name .. [[.top = ]] .. "[[" .. FormToLua[i].Object_top  .. "]]") .. [[

]] .. ((FormToLua[i].Object_width == false) and '' or FormToLua[i].Object_name .. [[.width = ]] .. "[[" .. FormToLua[i].Object_width  .. "]]") .. [[

]] .. ((FormToLua[i].Object_height == false) and '' or FormToLua[i].Object_name .. [[.height = ]] .. "[[" .. FormToLua[i].Object_height  .. "]]") .. [[

]] .. ((FormToLua[i].Object_align == false) and '' or FormToLua[i].Object_name .. [[.align = ]] .. "[[" .. FormToLua[i].Object_align  .. "]]") .. [[

]] .. ((FormToLua[i].Object_enabled == false) and '' or FormToLua[i].Object_name .. [[.enabled = ]] .. "[[" .. FormToLua[i].Object_enabled  .. "]]") .. [[

]] .. ((FormToLua[i].Object_visible == false) and '' or FormToLua[i].Object_name .. [[.visible = ]] .. "[[" .. FormToLua[i].Object_visible  .. "]]")
end

for line in string.gfind (TempText,"[^\n]+") do
   if (line~= '' and #line > 1) then
      f:write(line, "\n")
      print(line)
   end
end
f:write(FormToLua.MainForm.name..'Show()')
f:close()
end


local mess = [[
Enter FORM NAME you has been created
using CE form designer
]]

function Start()
   CEToLua = createForm(false)
   CEToLua.height = 70
   CEToLua.width = 240
   CEToLua.caption = "Generator"
   CEToLuaButton = createButton(CEToLua)
   CEToLuaButton.caption = "Generate"
   CEToLuaButton.height = 20
   CEToLuaButton.width = 60
   CEToLuaButton.top = 2
   CEToLuaButton.left = 178
   CEToLuaLabel = createLabel(CEToLua)
   CEToLuaLabel.setPosition(5,33)
   CEToLuaLabel.Caption = mess
   CEToLuaEdit = createEdit(CEToLua)
   CEToLuaEdit.width = 174
   CEToLuaEdit.left = 2
   CEToLuaEdit.top = 2
   CEToLuaEdit.Caption = ""
   CEToLuaButton.onClick = function ()
                        a = CEToLuaEdit.Text
                        if a == "" or a == nil then
                           showMessage("Form name can not be empty")
                           return a
                        end
                        loadstring([[test = (]] .. a .. [[ or nil) -- Defines test as a form]])()
                        a = nil
                        if (type(test)~="userdata") then
                           test = nil
                           CEToLuaEdit.Caption = ""
                           showMessage("Sorry but this is not a valid form!")
                           return
                        end
                        GenerateLuaScript(test)
                        test = nil
                        CEToLua.hide()
                        moduleForm.Show()
                        --crdr.Visible = true
                     end
   CEToLua.centerScreen()
end
Start()

function CETrainerToLua()
   moduleForm.Hide()
   if CEToLua.getVisible() then
      CEToLua.hide()
   else
      CEToLua.show()
   end
end

function canceled()
 CEToLua.hide()
 moduleForm.Show()
 return caFree
end

function loader()
 c = getMainForm()
 c.Visible = false
end

function clearance()
 closeCE()
 return caFree
end

--moduleForm.onShow = loader
moduleForm.Show()
moduleForm.onClose = clearance
bgen.onClick = CETrainerToLua
CEToLua.onClose = canceled
How to use:
1. Save the script above as a CT file
2. Open with CE (I am use CE 7.0)
3. A LOL form will appear (just ignore it for now)
4. Create your form using CE Form Designer
5. Once you finish, click 'Generate Form Lua Script' on the LOL form
6. Done
7. Check your LFM file on the folder where you start LOL form

Note:
In case if you add 'CheckListBox' and/or 'ScrollBox' on your form within CE form designer then check your LFM form
and change 'createTCECheckListBox' to 'createListBox' and 'createTCEScrollBox' to 'createScrollBox'.
I think 'createScrollBox' not work since CE 6.4 till the latest CE version. You can add a scrollbox via a Lua function:

Code: Select all

function createScrollBox(Parent)
 local box = createComponentClass('TScrollBox', Parent)
 box.Parent = Parent
 return box
end

-- and use with, example:
myscbox = createScrollBox(form_name)
TODO:
You also able to add a function on the main script which searches inside the generated LFM file for strings 'createTCECheckListBox' then change to 'createListBox' and strings 'createTCEScrollBox' and change to 'createScrollBox'.

Good luck

gideon25
Table Makers
Table Makers
Posts: 643
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 407

Re: Mono Helper Project

Post by gideon25 »

jgoemat wrote:
Sun Feb 16, 2020 7:14 am
@gideon25 Looks like you put the scripts in the cheat engine autorun directory, but they're set to be run from the directory with the cheat table, and the forms have to be in the table too. That might be the reason...


UPDATE

I updated the repo, now it has 'autorun/monohelper.lua' drop the file in your cheat engine autorun folder and it should work (it does for me). Let me know if you get any errors. Now it creates a separate menu 'Mono Search' when a mono game is loaded, using the same code that CE's mono code uses.
Thanks! However I get this error when I open cheat engine:

Image

Right now I only have the monohelper from your autorun in my the autorun folder. Cheat Engine 7.0

jgoemat
Table Makers
Table Makers
Posts: 38
Joined: Fri Jul 21, 2017 6:47 pm
Reputation: 37

Re: Mono Helper Project

Post by jgoemat »

Sorry, try the most recent version. I had some code still in it used to load the separate files. Here's the script by itself, password is 'ce'
monohelper.zip
Password is 'ce'
(14.74 KiB) Downloaded 185 times

gideon25
Table Makers
Table Makers
Posts: 643
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 407

Re: Mono Helper Project

Post by gideon25 »

jgoemat wrote:
Thu Feb 27, 2020 3:46 am
Sorry, try the most recent version. I had some code still in it used to load the separate files. Here's the script by itself, password is 'ce'

monohelper.zip
Ok, no errors and I can see the monosearch menu at the top. So I select Mono Search, then search and I select the Assembly-Csharp. It says "initializing fields and methods" with a green bar that fills then disappears. No other window/menu pops up or anything. It just disappears. Do I need some other files or something to go with that monohelper?

jgoemat
Table Makers
Table Makers
Posts: 38
Joined: Fri Jul 21, 2017 6:47 pm
Reputation: 37

Re: Mono Helper Project

Post by jgoemat »

Does another window actually pop-up off screen? That happens to me and I can't figure out why, but I figured it had something to do with my multi-monitor setup. Try hitting ALT+SPACE, then 'm' to move the window. Hit left arrow key and then use the mouse to place the window. Sorry for the trouble, but I don't know why the windows are appearing that way.

gideon25
Table Makers
Table Makers
Posts: 643
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 407

Re: Mono Helper Project

Post by gideon25 »

jgoemat wrote:
Thu Mar 05, 2020 12:15 am
Does another window actually pop-up off screen? That happens to me and I can't figure out why, but I figured it had something to do with my multi-monitor setup. Try hitting ALT+SPACE, then 'm' to move the window. Hit left arrow key and then use the mouse to place the window. Sorry for the trouble, but I don't know why the windows are appearing that way.
Yea, no multiple monitors or any thing. Had DExpot buy uninstalled and rebooted. Then tried everything from changing the scaling thru Nvidia to a number of windows fixes (use cascade all windows, et) that SHOULD show the window if it exists at all. No dice. Bummer.

jgoemat
Table Makers
Table Makers
Posts: 38
Joined: Fri Jul 21, 2017 6:47 pm
Reputation: 37

Re: Mono Helper Project

Post by jgoemat »

I've updated on 1/4/2021 after having time over the holidays to do some cleanup. Check the actual post where there are direct links to the script and an attached table so you don't have to add it to your autorun directory. Also fixed the window not appearing on screen bug and made a few other cosmetic changes. No need to clone the repository now which I think caused a lot of confusion with my lua files all over the place. Now the source lua is all in 'lua', there's a 'Build' directory for me to use, and a 'Dev.CT' table with a nice menu for doing the build for me.

gideon25
Table Makers
Table Makers
Posts: 643
Joined: Mon Mar 20, 2017 1:42 am
Reputation: 407

Re: Mono Helper Project

Post by gideon25 »

Yes, works great now. Thanks.. Keep at it, its quick and less clunky than the new .Net viewer in 7.2. Add all the stuff and tools you can think of that would be useful into it! Its all good :)

SinGul4ritY
Expert Cheater
Expert Cheater
Posts: 123
Joined: Fri Sep 25, 2020 5:45 pm
Reputation: 90

Re: Mono Helper Project

Post by SinGul4ritY »

Very nice thanks for sharing

Post Reply

Who is online

Users browsing this forum: No registered users