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 


Cheat Engine Forum Index
PostGo back to topic
mgr.inz.Player
I post too much
Reputation: 218
Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Apr 14, 2013 5:07 pm    Post subject:

OK. First release of "pickRightProcess" script. I am aware that code needs to be improved.

Code:

-- ############ Adjust those: ##################################################

process = "chrome.exe" -- you can set this variable by using combobox,
                       -- editbox or soemthing

function enableCheatsGuiWhatEver()
  -- initialize UI (or reinitialize UI)
  -- or whatever you want to do afer finding right process:
  -- enabling controls, cheats


end

-- this function returns true if good process, false if bad
function checkProcessMajor()
  reinitializeSymbolhandler()

  -- for Chrome flash

  if getAddress("pepflashplayer.dll")~=0 or
     getAddress("AdobeCPGetAPI")     ~=0 then
       return true
  end

  -- you can change above condition to something else.
  -- for example you can make aobscan check -  if pattern found -> return true


  return false -- return false by default
end

-- #############################################################################







-- do not thouch code below (unless you know what you are doing)
errorOnLookupFailure(false)

strings_add(getAutoAttachList(),process)

alreadycheckedPIDS={} -- checked processes pids

openNextProcTimer = createTimer(nil,false)
timer_setInterval(openNextProcTimer, 1000)
timer_onTimer(openNextProcTimer,
function (sender)
  local tempPIDtable = getPids()
  if #tempPIDtable == 0 then return end

  --OK, we have new PID
  timer_setEnabled(sender,false)
  openProcess(tempPIDtable[1])
end
)

function getPids()
  local SL=createStringlist()
        getProcesslist(SL)
  local tempPIDtable={}

  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))
    if processname == process then
      if alreadycheckedPIDS[PID]~=true then
        table.insert(tempPIDtable,PID)
      end
    end
  end

  object_destroy(SL)
  return tempPIDtable
end


function checkProcess(sender)
  timer_setEnabled(sender,false)

  -- add currently opened process to ignore list
  -- (openNextProc will ignore those)
  alreadycheckedPIDS[getOpenedProcessID()]=true

  if checkProcessMajor() then
    -- OUR TARGET FOUND
    timer_setEnabled(openNextProcTimer,false)
    alreadycheckedPIDS={}
    enableCheatsGuiWhatEver()
  else
    timer_setEnabled(openNextProcTimer,true)
  end
end


function onOpenProcess()
  timer_setEnabled(checkProcessTimer,true)
end

checkProcessTimer = createTimer(nil,false)
timer_setInterval(checkProcessTimer, 1000)
timer_onTimer(checkProcessTimer, checkProcess)




Just launch above code. Open chrome.
CE will attach to first process, then next, then next, until it finds chrome process with loaded Flash plugin.


How I tested this script:
1. Launched CE, I executed script
2. Launched Chrome
3. I open first site without Flash, I open second site without Flash in another Tab. CE keeps attaching to other chrome.exe processes.
4. I repeat step 3 many times
5. I open site with Flash objects, I start game.
6. CE is attached to correct chrome.exe

If user close Tab with game, or close chrome completely. Then launch chrome again. Above script do not seek for chrome.exe anymore.

But you can force searching by enabling timer again. With this code:
Code:
timer_setEnabled(openNextProcTimer,true)

_________________
Dark Souls II Item Swap and Item List
My Borderlands2 tables

Recent CheatEngine builds
Back to top
View user's profile Send private message MSN Messenger
Post reviews:   Approve 1
Author Review
DaSpamer
Review: Approve
Post reference:
ReviewPosted: Mon Apr 15, 2013 4:04 am

Good!
Back to top
View user's profile Send private message
Display:  
Cheat Engine Forum Index


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites