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 


Resolved: Correctly detaching and closing processes

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

Joined: 20 Jun 2024
Posts: 1

PostPosted: Sat Jun 22, 2024 3:07 am    Post subject: Resolved: Correctly detaching and closing processes Reply with quote

Edit: worked it out - see bottom for details

Hi, new to this so please forgive me but I have looked for a while on these forums and haven't found anything that works.

I'm working on a project that uses cheat engine to get addresses from SSBU (running on yuzu) using AOB scans. This is controlled by a python script running LUA subprocesses and needs to happen at multiple different times. I'm currently running LUA by a python equivalent of this

"C:\Program Files\Cheat Engine 7.5\Cheat Engine.exe" -cetrainer "C:\Users\...\script.CETRAINER"

The process runs silently and outputs to a file, as expected, but once completed, does not close and appears not to detach from the emulator. As such I can't run any more trainer files on the yuzu instance after. The cheat engine process that was spawned still appears in task manager, and if i close it yuzu also immediately closes.

Below is the LUA code - I'm just looking for a way to detach from the process so that later processes can attach successfully

Code:

openProcess(##PID##)
local pattern = "43 0F 11 4C 25 00 4D 8B 67 50 4D 8D 5C 24 08"
local result = AOBScan(pattern)

local abs_path = "##ABSPATH##"
local file = io.open(abs_path, "w")

local foundlist = {}
local numrecords = 0

debug_setBreakpoint(result[0], function()
    local target=R13+R12
    if foundlist[target]==nil then
      file:write(string.format("%X\n", target))
      foundlist[target]=true
      numrecords = numrecords + 1
      if numrecords > 0 then
        debug_removeBreakpoint(result[0])
        file:flush()
        file:close()
        openProcess(0)
        print("Process closed and detached")
      end
    end
end)


I have tried closeProcess() in place of openProcess(0) but no luck. Any help would be appreciated

Code:
openProcess(##PID##)
local pattern = "43 0F 11 4C 25 00 4D 8B 67 50 4D 8D 5C 24 08"
local result = AOBScan(pattern)

local target = nil
local abs_path = "##ABSPATH##"
  debug_setBreakpoint(result[0], function()
    target=R13+R12
    if target ~= nil then
      local file = io.open(abs_path, "w")
      file:write(target)
      file:flush()
      debug_removeBreakpoint(result[0])
      createTimer(1000, function()
        closeCE()
      end)
    end
  end)


This is what i ended up with. Needed to set closeCE() on a timer after removing the breakpoint
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