 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
izytang How do I cheat?
Reputation: 2
Joined: 07 Feb 2022 Posts: 7 Location: Columbus, OH
|
Posted: Mon Feb 07, 2022 4:52 am Post subject: Custom Standalone Trainer EXE won't show UI Form |
|
|
Hi there,
I'm learning CT and created my first trainer, complete with LUA script and a manually designed form. Everything interacts within CT fine - no script issues, form glitches, etc. I've tested for full functionality within CT. However, when creating a standalone exe, the form doesn't appear when opening the exe - which is the main way to interact with the trainer. I know the program is actually running because I can see the exe in Task Manager. I also left a print function in this version as a means to "debug", and the lua window pops up for that.
I'm guessing there might be some a little code I'm missing to wrap it up for the exe. Or perhaps I'm not compiling correctly. Here's some details on my setup:
For context, this trainer is for the US PS3 version of Resident Evil: Code Veronica X, emulated via RPCS3. I've compiled to a 64-bit target, size set as Gigantic, no features selected, ico file added with max compression, no extra folders/files. No errors come up during compiling. I also make sure the RPCS3 process is opened so it is "attached" to the standalone (though, I'm not sure where you would explicitly list the process, like in the generic trainer maker).
I've double checked the script, and form designer, and CT addresses, and I'm not seeing any obvious issues. Again, it all works flawlessly in CT with the game running. But this is my first trainer, so I could be missing something in this unique step from CT to standalone exe.
I'm on a Windows 10 machine with the most up to date versions of CT, drivers, etc. If anyone needs the files to troubleshoot, including CT, script, form, etc, I can provide them. Thanks for the help!
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Mon Feb 07, 2022 7:02 am Post subject: |
|
|
Personally, without seeing what you have I couldn't give you an exact answer but it could be something like form_name.show() is missing somewhere, or you unintentionally have the visibility set to false.
|
|
Back to top |
|
 |
izytang How do I cheat?
Reputation: 2
Joined: 07 Feb 2022 Posts: 7 Location: Columbus, OH
|
Posted: Mon Feb 07, 2022 5:32 pm Post subject: |
|
|
Yes, that totally fixed the issue of the exe not showing the form window - thanks for that! I had all this code interacting with the form, but didn't have anything to actually show it. In Cheat Engine, I was using the form designer and "Show/restore" to go back and forth, not realizing that the compiled exe wouldn't show it by default.
Now I'm seeing some other issues, including:
1. Standalone exe won't connect with the game/emulator, and doesn't function, flags various nil/variable errors, etc. I suspect it's because my code doesn't explicitly state the process of the game/emulator. How can I hook that? The emulator is rpcs3.exe.
2. When I close the window, I still see the standalone exe as a running process. Opening it again adds more instances. Is there something I'm missing in the code to properly close out the trainer from memory?
3. While the trainer and form work fine within CE, nothing functions in the standalone exe, including health, ammo, and inventory options. But I suspect this is due to point (1) above, unless I'm missing something else.
To help troubleshoot, here is the lua script I've come up with (note: it's my first trainer, so I'm sure it's pretty rough - if there are betters to do these things, I'm all ears):
Code: | -- Health Variables
infHealth = false
-- Memory Addresses Variables
-- For Item Type, Quanity, and Infinity Toggle
slot_InfOn = 25
slot_InfOff = 0
slot01_InfAddr = 0x300bb3790
slot01_ItemAddr = 0x300bb3791
slot01_Item = 0
slot01_QtyAddr = 0x300bb3793
slot01_Qty = 0
slot02_InfAddr = 0x300bb3794
slot02_ItemAddr = 0x300bb3795
slot02_Item = 0
slot02_QtyAddr = 0x300bb3797
slot02_Qty = 0
slot03_InfAddr = 0x300bb3798
slot03_ItemAddr = 0x300bb3799
slot03_Item = 0
slot03_QtyAddr = 0x300bb379b
slot03_Qty = 0
slot04_InfAddr = 0x300bb379c
slot04_ItemAddr = 0x300bb379d
slot04_Item = 0
slot04_QtyAddr = 0x300bb379f
slot04_Qty = 0
slot05_InfAddr = 0x300bb37a0
slot05_ItemAddr = 0x300bb37a1
slot05_Item = 0
slot05_QtyAddr = 0x300bb37a3
slot05_Qty = 0
slot06_InfAddr = 0x300bb37a4
slot06_ItemAddr = 0x300bb37a5
slot06_Item = 0
slot06_QtyAddr = 0x300bb37a7
slot06_Qty = 0
slot07_InfAddr = 0x300bb37a8
slot07_ItemAddr = 0x300bb37a9
slot07_Item = 0
slot07_QtyAddr = 0x300bb37ab
slot07_Qty = 0
slot08_InfAddr = 0x300bb37ac
slot08_ItemAddr = 0x300bb37ad
slot08_Item = 0
slot08_QtyAddr = 0x300bb37af
slot08_Qty = 0
-- Infinite Health, called from timer and button
function CheckHealth(t)
local a = readBytes(0x300bdea1f,1,false)
--print('Check toggled')
if(a < 160) then
writeBytes(0x300bdea1f,160)
-- print('low health')
end
end
-- Infinite Health Timer, updates every 100 ms
function ActivateTimer()
timer = createTimer()
timer.OnTimer = CheckHealth
timer.Interval=100
timer.Enabled=true
end
-- Infinite Health Button Changed
function UDF1_infHealthToggleChange(sender)
infHealth = not infHealth
if (infHealth == true and sender.Checked == true) then
ActivateTimer()
else
timer.destroy()
infHealth = false
end
UDF1.testLabel.Caption = tostring(infHealth)
end
-- Show UI Form
UDF1.show()
-- Update Inventory Form via Button
-- Also called whenever Form window is active
function updateInventory()
UDF1.CEComboBox01.ItemIndex = readBytes(slot01_ItemAddr,1,false)
UDF1.qtySlot01.Text = readBytes(slot01_QtyAddr,1,false)
UDF1.CEComboBox2.ItemIndex = readBytes(slot02_ItemAddr,1,false)
UDF1.qtySlot2.Text = readBytes(slot02_QtyAddr,1,false)
UDF1.CEComboBox3.ItemIndex = readBytes(slot03_ItemAddr,1,false)
UDF1.qtySlot3.Text = readBytes(slot03_QtyAddr,1,false)
UDF1.CEComboBox4.ItemIndex = readBytes(slot04_ItemAddr,1,false)
UDF1.qtySlot4.Text = readBytes(slot04_QtyAddr,1,false)
UDF1.CEComboBox5.ItemIndex = readBytes(slot05_ItemAddr,1,false)
UDF1.qtySlot5.Text = readBytes(slot05_QtyAddr,1,false)
UDF1.CEComboBox6.ItemIndex = readBytes(slot06_ItemAddr,1,false)
UDF1.qtySlot6.Text = readBytes(slot06_QtyAddr,1,false)
-- Also update Inf Health
if UDF1.infHealthToggle.Checked == true then
infHealth = true
else
infHealth = false
end
UDF1.testLabel.Caption = tostring(infHealth)
-- print('inv updated')
end
-- Item Changes via Drop Down Menu in Form
-- Adds or changes selected item from Form to game inventory
-- Slots 1 through 6
-- Slot 1
function UDF1_CEComboBox01Change(sender)
writeBytes(slot01_ItemAddr,sender.ItemIndex)
end
-- Slot 2
function UDF1_CEComboBox2Change(sender)
writeBytes(slot02_ItemAddr,sender.ItemIndex)
end
-- Slot 3
function UDF1_CEComboBox3Change(sender)
writeBytes(slot03_ItemAddr,sender.ItemIndex)
end
-- Slot 4
function UDF1_CEComboBox4Change(sender)
writeBytes(slot04_ItemAddr,sender.ItemIndex)
end
-- Slot 5
function UDF1_CEComboBox5Change(sender)
writeBytes(slot05_ItemAddr,sender.ItemIndex)
end
-- Slot 6
function UDF1_CEComboBox6Change(sender)
writeBytes(slot06_ItemAddr,sender.ItemIndex)
end
-- Infinite Ammo and Items Check Boxes
-- Slots 1 through 6
-- Slot 1
function UDF1_CheckBoxInf01Change(sender)
if (sender.State == 1) then
writeBytes(slot01_InfAddr,slot_InfOn)
else
writeBytes(slot01_InfAddr,slot_InfOff)
end
end
-- Slot 2
function UDF1_CheckBoxInf2Change(sender)
if (sender.State == 1) then
writeBytes(slot02_InfAddr,slot_InfOn)
else
writeBytes(slot02_InfAddr,slot_InfOff)
end
end
-- Slot 3
function UDF1_CheckBoxInf3Change(sender)
if (sender.State == 1) then
writeBytes(slot03_InfAddr,slot_InfOn)
else
writeBytes(slot03_InfAddr,slot_InfOff)
end
end
-- Slot 4
function UDF1_CheckBoxInf4Change(sender)
if (sender.State == 1) then
writeBytes(slot04_InfAddr,slot_InfOn)
else
writeBytes(slot04_InfAddr,slot_InfOff)
end
end
-- Slot 5
function UDF1_CheckBoxInf5Change(sender)
if (sender.State == 1) then
writeBytes(slot05_InfAddr,slot_InfOn)
else
writeBytes(slot05_InfAddr,slot_InfOff)
end
end
-- Slot 6
function UDF1_CheckBoxInf6Change(sender)
if (sender.State == 1) then
writeBytes(slot06_InfAddr,slot_InfOn)
else
writeBytes(slot06_InfAddr,slot_InfOff)
end
end
-- Update Item Quantity Button
function UDF1_CEButton1Click(sender)
writeBytes(slot01_QtyAddr,UDF1.qtySlot01.Text)
writeBytes(slot02_QtyAddr,UDF1.qtySlot2.Text)
writeBytes(slot03_QtyAddr,UDF1.qtySlot3.Text)
writeBytes(slot04_QtyAddr,UDF1.qtySlot4.Text)
writeBytes(slot05_QtyAddr,UDF1.qtySlot5.Text)
writeBytes(slot06_QtyAddr,UDF1.qtySlot6.Text)
end
-- Initial Loading Form with current game inventory
updateInventory()
-- Close Out Trainer
-- Destroy any Timer(s)
function mainFormClose()
if infHealth == true then
timer.destroy()
UDF1.infHealthToggle.Checked = false
end
end
|
Any help on this training making exercise is much appreciated. I think I'm most of the way there on this one, but could use some help to tidy things up and it fully working.
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Tue Feb 08, 2022 6:41 am Post subject: |
|
|
To attach to a process you can use:
Code: |
OpenProcess('exe_name.exe')
|
You can also cross-check the open process based on the process ID of the executable like so:
Code: |
local openPID = getOpenedProcessID()
local wantedPID = getProcessIDFromProcessName('name_of_process.exe')
if openPID ~= nil and wantedPID ~= nil then
-- Make sure that the IDs are not nil values
if openPID == wantedPID then
-- We have the correct process
else
-- Since we don't have the correct process, let's open it
OpenProcess('exe_name.exe')
end
else
print('Could not find process ID')
end
|
As for the rest, there are things that you could change, but I'm not sure how much benefit these changes would provide. The changes I mention are that you could potentially use a nested table to store the addresses, quantities, and states of the slots; maybe even wrapping the state check in a function to prevent lots of copy/pasted code.
|
|
Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 511
|
Posted: Tue Feb 08, 2022 10:07 am Post subject: |
|
|
instead of Code: | if UDF1.infHealthToggle.Checked == true then
infHealth = true
else
infHealth = false
end |
do
Code: | infHealth = UDF1.infHealthToggle.Checked |
and thing with booleans
Code: | --[[
if check == true then --WRONG
--do something
end
--]]
if check then --Right
--do something
end |
@LeFiXER
your code is right,but instead we can create global function in "Cheat Table Lua Script"
Code: | function IsAttached()
return getOpenedProcessID() == getProcessIDFromProcessName("game.exe") --Must be replaced with game name
end
function IsProcessExists()
return getProcessIDFromProcessName("game.exe") ~= nil
end |
One more thing that getOpenedProcessID() will never be equal to nil,it will only equal 0
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Tue Feb 08, 2022 3:52 pm Post subject: |
|
|
Frouk wrote: |
...
and thing with booleans
Code: | --[[
if check == true then --WRONG
--do something
end
--]]
if check then --Right
--do something
end |
|
Technically, both are correct. The former just allows for easier legibility.
Frouk wrote: |
@LeFiXER
your code is right,but instead we can create global function in "Cheat Table Lua Script"
Code: | function IsAttached()
return getOpenedProcessID() == getProcessIDFromProcessName("game.exe") --Must be replaced with game name
end
function IsProcessExists()
return getProcessIDFromProcessName("game.exe") ~= nil
end |
One more thing that getOpenedProcessID() will never be equal to nil,it will only equal 0 |
My apologies, I was not aware that the return value was 0 upon failure. Thank you for pointing that out.
|
|
Back to top |
|
 |
|
|
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
|
|