panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Tue Feb 23, 2016 9:27 pm Post subject: |
|
|
This return the pid of 1st found process with matching browser name which having a matching dll name of a flash/unity player.
Code: | function selBrowser(playerStr,browserStrs)
if type(browserStrs)=='string' then browserStrs = {browserStrs} end
if type(browserStrs)~='table' then browserStrs = {'.'} end -- match all process name
assert(type(playerStr)=='string',"invalid input")
playerStr=playerStr:lower()
local ps = createStringlist()
getProcesslist(ps)
for i=ps.Count-1,0,-1 do -- reverse order, so in general last started process check 1st
local pid,pname = ps[i]:match('^(%x+)%-(.+)')
local modules
pid = tonumber(pid,16) -- need to be number type for enumModules
for j=1,#browserStrs do
if pname:lower():match(browserStrs[j]:lower()) then
modules = modules or enumModules(pid)
for k=1,#modules do
if modules[k].Name:lower():match(playerStr) then
ps.Destroy()
return pid,pname
end
end
end
end
end
ps.Destroy()
end
print(tostring(selBrowser('flash','chrome') or 0))
print(tostring(selBrowser('flash',{'firefox','chrome'}) or 0)) |
It return nil if found nothing, so please check if it return a valid pid before openProcess, for example.
_________________
- Retarded. |
|