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 


CE losing game process after reboot
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Sat Jan 06, 2018 8:10 pm    Post subject: CE losing game process after reboot Reply with quote

Using CE in old game, where after finish round, game going reboot (complete restart - close game to windows and run it again)
After reboot game, CE losing process and must reboot trainer too.
How make auto detect game process?
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sat Jan 06, 2018 8:53 pm    Post subject: Reply with quote

if its your trainer you can let it go inside a loop, something like while loop to to refresh every 100ms and search for the specific process name and attach to it.

if you are not into lua then don't worry, we have great people here will post a nice and shiny script for you if needed.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Sun Jan 07, 2018 9:30 am    Post subject: Reply with quote

so i can do that only by lua script?
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Jan 07, 2018 9:57 am    Post subject: Reply with quote

Hm, in the GUI you can go to edit->settings->General Settings->Automatically Attach... and add the process name and then check the "Even autoattach when another process has already been selected" and it'll find it when you close and reopen the process but I'm not certain if you can enable those from a trainer so that it would work for other people without them having to do anything (the always autoattach part, setting the process name is simple and done in the generated script for every trainer)...

Some looking at celua.txt and testing and this seems to work:

Code:

getAutoAttachList().add('Tutorial-i386.exe')
local settings = getSettings() -- stored in windows registry (eg. regedit)
local originalAA = settings.Value['Always AutoAttach']

-- setup to restore value when closed (may need to be adjusted to use CETrainer etc.)
MainForm.OnClose = function(...)
  settings.Value['Always AutoAttach'] = originalAA
  return caFree
end

settings.Value['Always AutoAttach'] = 1
reloadSettingsFromRegistry()


note that if you open the same process again CE will switch to the newest process even if the old one hasn't closed. Probably not an issue in this case but perhaps something to be aware of for other uses (could probably disable always autoattach after attaching to the process to prevent that and then detect when the process has been killed and re-enable it)


For other knowledgeable people: When I tried to call any existing OnClose action CE didn't want to actually close however (the mainform would disappear but the process would be open and so would the lua engine form I pasted the script in), eg.
Code:
getAutoAttachList().add('Tutorial-i386.exe')
local settings = getSettings()
local originalAA = settings.Value['Always AutoAttach']

-- setup to restore value when closed (may need to be adjusted to use CETrainer etc.)
local originalOnClose = MainForm.OnClose
MainForm.OnClose = function(...)
  settings.Value['Always AutoAttach'] = originalAA
  local CloseAction
  if originalOnClose then
    CloseAction = originalOnClose(...)
  end
  return CloseAction or caFree
end

settings.Value['Always AutoAttach'] = 1
reloadSettingsFromRegistry()
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Sun Jan 07, 2018 12:47 pm    Post subject: Reply with quote

thanks so much.
In CE work very well, later i check ur script in trainer but previous i have another problem.

Have two green addresses, but they was not stable. Every game reboot values changing. (on pic they were 1&2 but after game reboot they could be 3&4 , 5&6, 8&9 etc.)
Want create two buttons to switch dynamic values like on picture below but how?
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Jan 07, 2018 4:08 pm    Post subject: Reply with quote

As long as the addresses are static (or you have pointers or a registered symbol etc.) it's simple enough

Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F}
swapValuesHotKey = createHotKey(function()
  local first = 0xAC35B8
  local second = 0x703530
    writeInteger(first, readInteger(second))
  end
end, swapValuesHotKeyKeys)


if you want to swap both values so that 1 becomes 2 and 2 becomes 1 then instead of just writing the second value use
Code:
local firstValue, secondValue = readInteger(first), readInteger(second) --read
firstValue, secondValue = secondValue, firstValue -- swap
-- write
writeInteger(first, firstValue)
writeInteger(second, secondValue)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Sun Jan 07, 2018 4:45 pm    Post subject: Reply with quote

something goes wrong

Or i dont know what i do.


Last edited by !BEWARE! on Tue Jan 09, 2018 10:20 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Jan 07, 2018 6:08 pm    Post subject: Reply with quote

Hm, looking at the code I'd bet that VK_F isn't defined in defines.lua, VK_F1 etc. would be but the f key itself uses the ascii value eg. string.byte('F',1) or 70. Though that's not the error I'd expect for it lol...


So, actually there are a couple mistakes there, sorry, first the VK thing, also createHotKey should be createHotkey, and finally there's an extra end that shouldn't be there. Here's a tested example

Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F2}
swapValuesHotKey = createHotkey(function()
  local first = 0xAC35B8
  local second = 0x703530
    writeInteger(first, readInteger(second))
  end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Mon Jan 08, 2018 3:30 am    Post subject: Reply with quote

Dont work. changed button to f5 and put in my adresses. but got new error msg: "malformed number near '007C35B8'
i dont understand it Confused
Code:

-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F5}
swapValuesHotKey = createHotkey(function()
  local first = 007C35B8
  local second = 00B83530
    writeInteger(first, readInteger(second))
  end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jan 08, 2018 9:58 am    Post subject: Reply with quote

That's because you can't have letters in decimal numbers, you have to prefix hex numbers with 0x, see the given example Smile

Though you can also pass them as strings, in which case getAddress will be used internally to determine the actual address, that way you can use symbols like 'game.exe+5234' or 'INJECT' registered from a script, and getAddress will read numbers as hex. A lot of CE's functions will work with string addresses for that reason.

eg.
Code:

-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F5}
swapValuesHotKey = createHotkey(function()
  local first = '007C35B8'
  local second = '00B83530'
    writeInteger(first, readInteger(second))
  end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Mon Jan 08, 2018 11:06 am    Post subject: Reply with quote

Damn, Im blind
Those values changing adress .... but they was green and i thought adress was static. My bad Sad
But if i fix adresses manualy script work Wink
Is any other way to catch them? maybe for descriptions?
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jan 08, 2018 11:48 am    Post subject: Reply with quote

Hm, green usually is static Smile

You can try to find a pointer using the pointer scanner (with pointer maps, you can "encode" a pointer in a string address eg. '[[game.exe+323]+4]+24' so the code really wouldn't change) or create a script to copy the addresses somewhere when they are accessed and then use that as a pointer (make sure it's a registered symbol so it's recognized outside the script) , or if you don't mind doing a scan each time to find them yourself then you can use memory records (of course, this method works with either pointer option above as well) eg.

Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local swapValuesHotKeyKeys = {VK_F5}
swapValuesHotKey = createHotkey(function()
  local getmr = getAddressList().getMemoryRecordByDescription
  local first = getmr('first') -- gets memory record with name/description 'first'
  local second = getmr('second') -- ^ but 'second'
  first.Value = second.Value
end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Mon Jan 08, 2018 3:39 pm    Post subject: Reply with quote

Thanks
Now work pretty good Wink
Btw. how make Execute script automatic? After start CE i must hit button to get it work
Could you also add code to restore back first value by other key?
I have no idea how to made this
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jan 08, 2018 6:29 pm    Post subject: Reply with quote

execute script on attach
Code:
onOpenProcess = function(pid)
  reinitializeSymbolhandler()
  local al = getAddressList()
  al.disableAllWithoutExecute()
  al.getMemoryRecordByDescription('enable on attach').Active = true
  swapValueBackup = nil -- part of restore script
end


and second hotkey to restore value

Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
swapValueBackup = nil -- needs to be reset when process is closed since the value is random
local swapValuesHotKeyKeys = {VK_F5}
local swapValuesBackHotKeyKeys = {VK_F6}

local getmr = getAddressList().getMemoryRecordByDescription
local first = getmr('first')
local second = getmr('second')

swapValuesHotKey = createHotkey(function()
  if not swapValueBackup then swapValueBackup = first.Value end -- this is new (saves value before overwriting)
  first.Value = second.Value
end, swapValuesHotKeyKeys)

swapValuesBackHotKey = createHotkey(function()
  if not swapValueBackup then return end
  first.Value = swapValueBackup
end, swapValuesBackHotKeyKeys)


Though it kind of seems like you could have one hotkey that toggles back and forth (if it's never written back on it's own) eg

Code:
-- see defines.lua and https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
swapValueBackup = nil -- needs to be reset when process is closed since the value is random
local swapValuesHotKeyKeys = {VK_F5}

swapValuesHotKey = createHotkey(function()
  local getmr = getAddressList().getMemoryRecordByDescription
  local first = getmr('first')
  if not swapValueBackup then
    swapValueBackup = first.Value
    local second = getmr('second')
    first.Value = second.Value
  else
    first.Value = swapValueBackup
  end
end, swapValuesHotKeyKeys)
Back to top
View user's profile Send private message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 56
Location: !BEWARE!

PostPosted: Tue Jan 09, 2018 8:53 am    Post subject: Reply with quote

In execute script must write PID manual to get it work? But PID every start game is different so i need little help how to get it work.

Script to swap values is almost perfect. Turn on and off work fine but manual reset CE after game reboot is a bit problematic because game rebooting many times. Its strange game construction but anyway ,I have idea...
"first" and "second" loading correct values when i start the match. In the rest time (in main menu, lobby and also after game restart) they count always 0. Would be great to use this fact and create term like this "When 'first' value 0 - clear clipboard from old value"
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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