Advertisement
OppaiCyber

sinau_c

Sep 14th, 2020
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. function selBrowser(playerStr,browserStrs)
  2.   if type(browserStrs)=='string' then browserStrs = {browserStrs} end
  3.   if type(browserStrs)~='table' then browserStrs = {'.'} end -- match all process name
  4.   assert(type(playerStr)=='string',"invalid input")
  5.   playerStr=playerStr:lower()
  6.   local ps = createStringlist()
  7.   getProcesslist(ps)
  8.   for i=ps.Count-1,0,-1 do -- reverse order, so in general last started process check 1st
  9.     local pid,pname = ps[i]:match('^(%x+)%-(.+)')
  10.     local modules
  11.     pid = tonumber(pid,16) -- need to be number type for enumModules
  12.     for j=1,#browserStrs do
  13.       if pname:lower():match(browserStrs[j]:lower()) then
  14.         modules = modules or enumModules(pid)
  15.         for k=1,#modules do
  16.           if modules[k].Name:lower():match(playerStr) then
  17.             ps.Destroy()
  18.             return pid,pname
  19.           end
  20.         end
  21.       end
  22.     end
  23.   end
  24.   ps.Destroy()
  25. end
  26.  
  27. print(tostring(selBrowser('flash','chrome') or 0))
  28. print(tostring(selBrowser('flash',{'firefox','chrome'}) or 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement