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 help telling Cheat Engine to wait until a DLL is loaded

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
gir489
Grandmaster Cheater
Reputation: 14

Joined: 03 Jan 2012
Posts: 837
Location: Maryland, United States

PostPosted: Sat May 25, 2024 1:11 pm    Post subject: Need help telling Cheat Engine to wait until a DLL is loaded Reply with quote

I have the following script:

Code:
while getProcessIDFromProcessName('helldivers2.exe') == nil do
      sleep(100)
end
OpenProcess("helldivers2.exe")
errorOnLookupFailure(false)
while getAddress("game.dll") == 0 do
      sleep(100)
end
local base_scripts = getAddressList().getMemoryRecordByDescription("Base Scripts")
for i=0, base_scripts.Count-1 do
    local script = base_scripts.Child[i]
    while not script.Active do
        script.Active = true
    end
end
closeCE()


The problem is, the script just gets stuck waiting for game.dll to resolve. I have encountered this before manually doing this with HELLDIVERS 2. For some reason, Cheat Engine only grabs the list of mapped in modules when you attach it, not when you attempt to resolve a symbol, so the problem here is it will never escape the while game.dll == 0 loop regardless if the game has mapped in the dll.

How can I fix this?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 143

Joined: 06 Jul 2014
Posts: 4382

PostPosted: Sat May 25, 2024 1:53 pm    Post subject: Reply with quote

Running Lua code blocks everything else from happening in CE. Calling functions like processMessages or reinitializeSymbolhandler sometimes helps, but you're better off changing your synchronous blocking code to be asynchronous.
Code:
getAutoAttachList().add'helldivers2.exe'

local t = createTimer()
t.Interval = 100
t.OnTimer = function()
  if not getAddressSafe'game.dll' then return end

  local m = AddressList["Base Scripts"]
  for i = 0, m.Count - 1 do
    -- no need for while loop- this is blocking, and if it fails to activate the first time, it probably won't work the next
    m.Child[i].Active = true
  end
  closeCE()
end
PS: right click memory record -> Group config -> Activating this entry activates its children
_________________
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
Dark Byte
Site Admin
Reputation: 460

Joined: 09 May 2003
Posts: 25367
Location: The netherlands

PostPosted: Sat May 25, 2024 2:04 pm    Post subject: Reply with quote

reinitializeSymbolhandler(true)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
gir489
Grandmaster Cheater
Reputation: 14

Joined: 03 Jan 2012
Posts: 837
Location: Maryland, United States

PostPosted: Sat May 25, 2024 5:05 pm    Post subject: Reply with quote

Dark Byte wrote:
reinitializeSymbolhandler(true)


This doesn't work if it was attached before it was mapped and Game Guard was active. If I use a Game Gaurd bypass that shuts it down completly, it will work and it can find User32 and game.dll after it's been mapped. But if I load Cheat Engine after game.dll has been mapped with Game Guard active, my script will work.

ParkourPenguin wrote:
Running Lua code blocks everything else from happening in CE. Calling functions like processMessages or reinitializeSymbolhandler sometimes helps, but you're better off changing your synchronous blocking code to be asynchronous.
Code:
getAutoAttachList().add'helldivers2.exe'

local t = createTimer()
t.Interval = 100
t.OnTimer = function()
  if not getAddressSafe'game.dll' then return end

  local m = AddressList["Base Scripts"]
  for i = 0, m.Count - 1 do
    -- no need for while loop- this is blocking, and if it fails to activate the first time, it probably won't work the next
    m.Child[i].Active = true
  end
  closeCE()
end
PS: right click memory record -> Group config -> Activating this entry activates its children


Using a timer causes Cheat Engine to actually load, which causes Game Guard to detect it. If it doesn't load its main window, Game Guard never detects it, asynchronous threads are not an option.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 460

Joined: 09 May 2003
Posts: 25367
Location: The netherlands

PostPosted: Sun May 26, 2024 6:23 am    Post subject: Reply with quote

inside the loop
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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