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 


Find the directory of the program?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
MErtHRMKsE
Newbie cheater
Reputation: 0

Joined: 02 Jul 2012
Posts: 21

PostPosted: Fri Jul 03, 2015 6:28 pm    Post subject: Find the directory of the program? Reply with quote

Is there a function in CE's Lua to find the directory of the program CE is attached to?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Jul 03, 2015 7:52 pm    Post subject: Reply with quote

Not sure I would trust someone trying to find my installation directory. Smile

Have fun...

local path = io.popen("PowerShell Get-Process -Id "..getOpenedProcessID().." ^| Format-List Path"):read("*all"):gsub("^%s*Path : (.-)%s*","%1");
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Jul 04, 2015 12:30 am    Post subject: Reply with quote

Dear Zanzer,

I have a question related to post above.
Instead to find patch or directory, how can find a specific process name running in memory?.

This code find all process running in memory

Code:

TempTable = {}
function GetTheProcessList()
   local SL=createStringlist()
   getProcesslist(SL)
   for i=0,strings_getCount(SL)-1 do
      local entry = strings_getString(SL,i)
      local processname = entry:sub(10,255)
      local PID = tonumber('0x'..entry:sub(1,8))
     TempTable[i] = {PID, processname}
  end
  return TempTable
end

function AddTheProcessList()
   GetTheProcessList()
   index = 0
   for y in pairs (TempTable) do
      index = index+1
   end
   for i=0, index-1 do
      if TempTable[i]~='' and TempTable[i]~= nil then
         TempText = "Process ID : "..TempTable[i][1].."   Process Name : "..TempTable[i][2]
         strings_add(Items, TempText)
      end
   end
end
AddTheProcessList()


How to get only one or some specific process name from the process list.
The idea is if found target process name then will close a opened tool/game/trainer/etc.

How about use this function :

Code:

function isFile(name)
    if type(name)~="string" then return false end
    if not exist(name) then return false end
    local f = io.open(name)
    if f then
        f:close()
        return true
    end
    return false
end

function isDir(name)
    return (exist(name) and not isFile(name))
end


I hope you should help to give a solution.
Thanks and regard
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Jul 04, 2015 8:06 am    Post subject: Reply with quote

If I understand you correctly, this should do it:
Code:
if getProcessIDFromProcessName("calc.exe") ~= nil then
  closeCE()
end
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Jul 04, 2015 9:23 pm    Post subject: Reply with quote

Thanks for quick reply Zanzer,

I tried your hint and it work good.

Any how it work while a specified process name already running first and stay in memory. But if I run my stand alone trainer (in exe file) and next open a tool (e.q : HxD editor = HxD.exe / or Cheat Engine = cheatengine-i386.exe), My trainer not close.

I want it work when any memory viewer / editor open, then my trainer will close, doesn't matter when these memory viewer / editor open. Before or after my trainer running.

How to fix this problem ?

Code:

--- check if any memory viewer / editor is running in memory,
--- No matter before or after this process (trainer) has run
--- if found close this process (trainer) immediately
---
if getProcessIDFromProcessName("HxD.exe") ~= nil then
 showMessage("Process Found")
 closeCE()
end
---
--- check again for other tools which able to view a process
--- running in memory  e.q:
---
if getProcessIDFromProcessName("cheatengine-386.exe") ~= nil then
 showMessage("Process Found")
 closeCE()
end
showMessage("Not found memory viewer")
return
-- start trainer


Sorry, my English are suck....

Thanks and regards[/code]
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Jul 04, 2015 9:59 pm    Post subject: Reply with quote

Code:
t=createTimer(nil)
t.Interval=1000
t.OnTimer=function(t)
  if getProcessIDFromProcessName("cheatengine-386.exe") ~= nil or getProcessIDFromProcessName("HxD.exe") ~= nil then
    closeCE()
  end
end
t.Enabled=true
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Jul 05, 2015 8:30 pm    Post subject: Reply with quote

Waaoo, Thanks so much Zanzer
It work like a charm.
Now i can use it into my trainer. Just for little protection due leechers.

Now I try make a process name table which should be block while the trainer running and put on an array.

Regards
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