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 


[Solved] Preferred method to delay until process attached

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

Joined: 29 Sep 2011
Posts: 2

PostPosted: Thu Sep 29, 2011 6:36 pm    Post subject: [Solved] Preferred method to delay until process attached Reply with quote

The below code fails to patch, without the "Hit OK to patch!" line. I added it as a simple delay. What is the preferred method to ensure that a LUA script has attached to the container process, before it executes?
(I used the "create form" menu item, and left it blank, to be able to use showMessage calls.)

Thanks

Sample.CT file:
Code:
-- Set process to Flash in Firefox...
--hideAllCEWindows()
strings_add(getAutoAttachList(), "plugin-container.exe");

showMessage( "Hit OK to patch!\n" );
-- Attempt AS3 code patching...
local count = 0;
local scan = AOBScan( "24 76 02 02 02 48" );
if ( scan ~= nil ) then count = strings_getCount( scan ) end
if ( count > 0 ) then
    for n = 0, ( count - 1 ) do writeBytes( strings_getString( scan, n ), 0x24, 0x75, 0x02, 0x02, 0x02, 0x48) end
    showMessage( string.format( "Applied patch(es) to %s locations...\nEnjoy your game!\n", count ) );
else
    showMessage( "Could not locate code(s) to patch!\n" );
end
object_destroy( scan );
object_destroy( count );


Last edited by slancer91 on Thu Sep 29, 2011 6:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Sep 29, 2011 6:50 pm    Post subject: This post has 1 review(s) Reply with quote

use "function onOpenProcess(processid)"

e.g:
Code:

function onOpenProcess(processid)
  -- Attempt AS3 code patching...
  local count = 0;
  local scan = AOBScan( "24 76 02 02 02 48" );
  if ( scan ~= nil ) then count = strings_getCount( scan ) end
  if ( count > 0 ) then
      for n = 0, ( count - 1 ) do writeBytes( strings_getString( scan, n ), 0x24, 0x75, 0x02, 0x02, 0x02, 0x48) end
      showMessage( string.format( "Applied patch(es) to %s locations...\nEnjoy your game!\n", count ) );
  else
      showMessage( "Could not locate code(s) to patch!\n" );
  end
  object_destroy( scan );
 
end

strings_add(getAutoAttachList(), "plugin-container.exe");

_________________
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


Last edited by Dark Byte on Thu Sep 29, 2011 6:59 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
slancer91
How do I cheat?
Reputation: 0

Joined: 29 Sep 2011
Posts: 2

PostPosted: Thu Sep 29, 2011 6:57 pm    Post subject: Reply with quote

Thank you & again for the below

Last edited by slancer91 on Thu Sep 29, 2011 7:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Sep 29, 2011 6:59 pm    Post subject: Reply with quote

oh yes, don't free count, it's a normal integer, not a class object
_________________
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