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 


How to tell if the process is the correct one on lua table

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

Joined: 21 Mar 2017
Posts: 1
Location: Joao Pessoa - Paraiba, Brazil

PostPosted: Tue Mar 21, 2017 11:54 am    Post subject: How to tell if the process is the correct one on lua table Reply with quote

Hello i'm such a newbie at Lua Embarassed I was trying to make this lua 'trainer' thingy using the lua table and i'm having some issues i'm using the wiki to help me but the wiki doesn't help that much

What i'm trying to do:
Code:
openProcess("1.exe")
if getNameFromAddress(2) then
print("Hooked!")
else
print("Failed to hook!")
end


What i want it to do:
I want it to say "Hooked" if the process that it hooked is "1.exe" but it always return hooked even if the process on getNameFromAdress is 2 Mad

I was wondering if i could get some advice on how to do this / get an working command or an example so i could learn from it and make this lua project

Thank you Smile
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Tue Mar 21, 2017 12:58 pm    Post subject: Reply with quote

From CE 6.5+, at main.lua @ your CE installed directory
Code:

process : A variable that contains the main modulename of the currently opened process


So
Code:

if process == "<exact.process.name>" then
...  -- do right process attached
elseif process == nil then
...  -- do no process attached
else
...  -- do wrong process attached
end

can detect if the right process has been attached....
but if the process then detached (eg.close by itself), the variable will be still the previous attached name.

To detect this we can read some memory from the process, whose a handy address is given by the variable itself, so

Code:

if process == "<exact.process.name>" then
  if readInteger(process) then -- return nil if not readable, which same as false
     ...  -- do right process attached
  else  -- do right process has been detached
     ...
  end
elseif process == nil then
...  -- do no process attached
else
...  -- do wrong process attached
end


For case-insensitive compare/find match, try this:
Code:

if process and process:lower():find("<optional partial, lower case process name>",1,true) then
...

eg, partial lower case process name for "cheatengine-x86_64.exe" is like "cheatengine", for "Microsoft.Photos.exe" like "photos".

_________________
- Retarded.
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