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 


Get Path of a Exe File?

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

Joined: 11 Dec 2020
Posts: 7
Location: Germany

PostPosted: Tue Apr 23, 2024 12:16 pm    Post subject: Get Path of a Exe File? Reply with quote

I want to check in my Cheat Table for XCOM 2 WOTC on start up if you installed Steam and get the Path Location of it.

From there I want to get the Path of the XCOM 2 WOTC Exe file.

Why you ask?

Because Vanilla XCOM 2 and XCOM 2 WOTC (the dlc) uses the exact same Process Name.

Could someone help me with that?

_________________
Call me KitsuneHD because I'm a cute Kitsune, lol.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4317

PostPosted: Tue Apr 23, 2024 12:47 pm    Post subject: Reply with quote

celua.txt:
Quote:
enumModules(processid OPTIONAL):
Returns a table containing information about each module in the current process, or the specified processid
Each entry is a table with fields
Name : String containing the modulename
Address: Integer representing the address the module is loaded
Is64Bit: Boolean set to true if it's a 64-bit module
PathToFile: String to the location this module is loaded
Probably what you're looking for
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 33

Joined: 16 Feb 2017
Posts: 1289

PostPosted: Wed Apr 24, 2024 3:59 am    Post subject: Reply with quote

Once the process is selected, run this code:
Code:
processFullPath = enumModules()[1].PathToFile -- path + process.exe
processPath = extractFilePath(processFullPath)  -- path

print("Full path: \n"..processFullPath)
print("Path: \n"..processPath)


or ..
Code:
-- select process auto (process; max memory)

function open_process(pname,pmem)
local p = io.popen('tasklist.exe /fi "IMAGENAME eq '..pname..'.exe" /fi "MEMUSAGE gt '..pmem..'" /nh', 'r');
   local procInfo = p:read('*a');

   local pid = procInfo:match(' (%d+) ');
   pid = tonumber(pid);
   if(pid == nil)then
      messageDialog("You Must Start The Game First!", mtWarning, mbOK)
      --closeCE()
   else
      openProcess(pid)
      --print(pid)
   end
end

pname = "cheatengine-x86_64"
pmem = 30000 -- When you open the application, it appears in the application's memory in the task manager.

open_process(pname,pmem)

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
SparkleArts
How do I cheat?
Reputation: 0

Joined: 11 Dec 2020
Posts: 7
Location: Germany

PostPosted: Wed Apr 24, 2024 10:48 am    Post subject: Reply with quote

How is it working with the Path Locations?

I mean do I need to specify for example the Hard Disk Letter like "C:" or it will automatically detect it?

Also is there a way to find automatically a process on the entire hard disk where Cheat Engine is installed? I don't want to open Steam Process anyway so. Is there a way without it?

_________________
Call me KitsuneHD because I'm a cute Kitsune, lol.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 33

Joined: 16 Feb 2017
Posts: 1289

PostPosted: Wed Apr 24, 2024 2:35 pm    Post subject: Reply with quote

Code:
function executablePath(appName,ops)
local res = ""
   if ops==1 then
     aa = io.popen([[where ]]..appName)
     res = aa:read('*a');
   elseif ops==2 then
     aa = io.popen([[where *]]..appName)
     res = aa:read('*a');
   elseif ops==3 then
     aa = extractFileExt(appName)
     aa1 = io.popen([[where *]]..aa)
     aa2 = aa1:read('*a');
     sl = createStringList()
     sl.Text=aa2
       for i=0, sl.count -1 do
         aa3 = extractFileName(sl[i])
          if aa3==appName then
            res = sl[i]
          end
       end
       sl.Destroy()
   end
return res
end


Use:

Ops 1 ) If you know the executable file name, use it. (Limited options!)
Code:
pname1 = "cheatengine-x86_64"
aa22 = executablePath(pname1,1)
aa23 = aa22:sub(1,2) -- C:
print("system disc:\n"..aa23.."\nexecutablePath:\n"..aa22)


Ops 2 ) (Extra feature, for those who want it) Just give the file extension and get an associated list. (.xml, .jpg, .txt, .exe etc.)
Code:
pname1 = ".exe"
aa22 = executablePath(pname1,2)
--aa23 = aa22:sub(1,2) -- C:
print("Path:\n"..aa22)


Ops 3 ) Give the associated file name with its extension and scan all system files and view the result. (Wide range of options!)
Code:
pname1 = "Skype.exe"
aa22 = executablePath(pname1,3)
aa23 = aa22:sub(1,2) -- C:
print("system disc:\n"..aa23.."\nexecutablePath:\n"..aa22)

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website 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