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 


Possible to automatically execute script on process attach?

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

Joined: 27 Feb 2023
Posts: 64

PostPosted: Tue Mar 28, 2023 12:40 am    Post subject: Possible to automatically execute script on process attach? Reply with quote

Is it possible for this to automatically execute when I attach cheat engine to the target process.

Code:
alloc(newmem,2048,"myGame.exe"+165D88)
label(returnhere)
label(originalcode)
label(exit)

// Define a variable to store the value
alloc(value, 8)

newmem:
  // Save the value from R13+88 into R10
  mov r10,[r13+00000088]

  // Store the value from R10 into the variable
  mov [value], r10

  // Jump back to the original code
  jmp originalcode

originalcode:
  // Continue with the original code
  mov r10,[r13+00000088]

exit:
  jmp returnhere

"myGame.exe"+165D88:
  jmp newmem
  nop 2
returnhere:
Back to top
View user's profile Send private message  
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Tue Mar 28, 2023 1:38 am    Post subject: Reply with quote

try this lua code:
Code:

local executedlist={}
local oldpo=MainForm.OnProcessOpened
MainForm.OnProcessOpened=function(processid, processhandle, caption)
  if not executedlist[processid] then
    local r,r2=autoAssemble([[
alloc(newmem,2048,"myGame.exe"+165D88)
label(returnhere)
label(originalcode)
label(exit)

// Define a variable to store the value
alloc(value, 8)

newmem:
  // Save the value from R13+88 into R10
  mov r10,[r13+00000088]

  // Store the value from R10 into the variable
  mov [value], r10

  // Jump back to the original code
  jmp originalcode

originalcode:
  // Continue with the original code
  mov r10,[r13+00000088]

exit:
  jmp returnhere

"myGame.exe"+165D88:
  jmp newmem
  nop 2
returnhere:
]])
    if r then
      executedlist[processid]=true
      print("assembled the script into the target")
    else
      print("Error assembling the script: "..r2)
    end
  end
  if oldpo then
    return oldpo(processid, processhandle, caption)
  end
end

_________________
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 
ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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