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 


Code executed every frame

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

Joined: 27 Aug 2021
Posts: 41

PostPosted: Mon Aug 30, 2021 1:02 am    Post subject: Code executed every frame Reply with quote

I'm trying to understand the code from forum post "Find out what accesses/writes to this address" in (sorry, not allowed to send links yet), specifically this part:
Code:
function waitTillWritten(address, timeout)
  local written=false
  local lastaccess=nil

  local stoptime=nil
  if timeout~=nil then
    stoptime=getTickCount()+timeout
  end


  debug_setBreakpoint(address, 1, bptWrite, function()
    lastaccess=RIP
    print(string.format("%X accessed %X", RIP, address))
    written=true
    debug_continueFromBreakpoint(co_run)
    return 0
  end)

  while (not written) and ((stoptime==nil) or (getTickCount()<stoptime)) do
    checkSynchronize()
    if not written then sleep(10) end
  end

  debug_removeBreakpoint(address)

  if timeout then
    return written,lastaccess
  else
    return lastaccess
  end
 
end


I have slightly modified it by adding
Code:
address1 = '[Minecraft.Windows.exe+Minecraft.Windows.exe+0x4030538]+0x3CA51F0
print(waitTillWritten(address1, 1))

When I execute this script, it runs every frame, crashing my game, and practically freezing Cheat Engine.
How exactly would I go about fixing this?

My goal is to have a range of addresses that all automatically get NOPed once they are written to for the first time.

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Mon Aug 30, 2021 2:28 am    Post subject: Reply with quote

run this function in new thread:
Code:

thisThread = createThread(function()
address1 = '[Minecraft.Windows.exe+Minecraft.Windows.exe+0x4030538]+0x3CA51F0
print(waitTillWritten(address1, 1))
end)

while function is looping

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Mon Aug 30, 2021 6:40 am    Post subject: Reply with quote

Code:
thisThread = createThread(function()
address1 = '[Minecraft.Windows.exe+0x4030538]+0x3CA51F0'
print(waitTillWritten(address1, 5))
end)


Code:
Error in native thread called Unnamed::CheckSynchronize called from non-main thread "$76DC"

Everytime I execute the last part of the error is different.

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Mon Aug 30, 2021 7:01 am    Post subject: Reply with quote

Try to use this
Code:
createNativeThread(function()
address1 = '[Minecraft.Windows.exe+0x4030538]+0x3CA51F0'
print(waitTillWritten(address1, 5))
end)

If error still appears, search up this error in Search[/code]

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Mon Aug 30, 2021 8:56 am    Post subject: Reply with quote

Can't seem to find any forum posts about this.
Any suggestions?

EDIT for clarification: no, the new code does not work.

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Mon Aug 30, 2021 9:05 am    Post subject: Reply with quote

Code:

function waitTillWritten(address, timeout)
  local written=false
  local lastaccess=nil

  local stoptime=nil
  if timeout~=nil then
    stoptime=getTickCount()+timeout
  end


  debug_setBreakpoint(address, 1, bptWrite, function()
    lastaccess=RIP
    print(string.format("%X accessed %X", RIP, address))
    written=true
    debug_continueFromBreakpoint(co_run)
    return 0
  end)
timer = createTimer
timer.Enabled = true
timer.Interval = 10 --You can change interval
timer.OnTimer = function()
if (not written) and ((stoptime==nil) or (getTickCount()<stoptime)) then
    if not written then sleep(10) end
end
end

debug_removeBreakpoint(address)

  if timeout then
    return written,lastaccess
  else
    return lastaccess
  end
 
function disableTimer()
timer.destroy() --To make sure that timer will be destroyed
end

Try this

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Mon Aug 30, 2021 10:40 am    Post subject: Reply with quote

Thank you so much for helpig me with this!

How would I get an output through this? Following example doesn't work:
Code:
print(waitTillWritten('[Minecraft.Windows.exe+0x4030538]+0x3CA51F0',100))(


It doesn't crash or give me an error, just no output.

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Mon Aug 30, 2021 10:46 am    Post subject: Reply with quote

idk, because i can't use pc rn
_________________
void(__cdecl *Haxing)(HWND hGameWindow)
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