<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="18">
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>f     = {}
f[1]  = createForm(false)
f[2]  = createGroupBox(f[1])
f[3]  = createLabel(f[2])
f[4] = createComboBox(f[2])
f[5] = createButton(f[2])
setProperty(f[1] , "ShowInTaskBar", 'stAlways')
setProperty(f[1] , "Position", "poScreenCenter")
setProperty(f[1] , "BiDiMode", "bdLeftToRight")
control_setSize(f[1], 425, 110)
control_setSize(f[2], 400, 90)
control_setSize(f[4], 255, 21)
control_setSize(f[5], 107, 28)
control_setPosition(f[2], 10, 5)
control_setPosition(f[3], 10, 45)
control_setPosition(f[4], 10, 15)
control_setPosition(f[5], 280, 15)
control_setCaption(f[1], "CRDR Attach Browser Template 1.3")
control_setCaption(f[3], "Attached To Process : Satus: waiting...")
control_setCaption(f[5], "Select Process")

al = combobox_getItems(f[4])
strings_clear(al)
strings_add(al, 'Browser list...')
strings_add(al, 'Google Chrome')
strings_add(al, 'Firefox')
strings_add(al, 'Firefox(Unity Game)')
strings_add(al, 'Maxthon')
strings_add(al, 'Gameroom')
strings_add(al, 'Gameroom (Unity Game)')
setProperty(f[4] , "ItemIndex", "0")
all_enabled = 0
success = 1

errorOnLookupFailure(false)
alreadycheckedPIDS={}
openNextProcTimer = createTimer(nil,false)
timer_setInterval(openNextProcTimer, 1000)
timer_onTimer(openNextProcTimer,
function(sender)
 local tempPIDtable = getPids()
 if #tempPIDtable == 0 then return end
 timer_setEnabled(sender,false)
 openProcess(tempPIDtable[1])
end)


function checkProcessMajor()
	reinitializeSymbolhandler()
	if getAddress("pepflashplayer.dll")~=0 or getAddress("AdobeCPGetAPI") ~=0 then
		return true
	end
	return false
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 == "chrome.exe" 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)
	alreadycheckedPIDS[getOpenedProcessID()]=true
	if checkProcessMajor() then
		timer_setEnabled(openNextProcTimer,false)
		alreadycheckedPIDS={}
		enableHacks()
	else
		timer_setEnabled(openNextProcTimer,true)
	end
end

checkProcessTimer = createTimer(nil,false)
timer_setInterval(checkProcessTimer, 100)
timer_onTimer(checkProcessTimer, checkProcess)

function onOpenProcess()
   if success == 1 then return end
   timer_setEnabled(checkProcessTimer,true)
end

function scanBrowser()
	AttachItems = combobox_getItems(f[4])
	AttachIndex = combobox_getItemIndex(f[4])
	control_setCaption(f[3], "Attached to PID: " .. "Scanning Process, Please wait...")
	processMessages()
	if AttachIndex == -1 then return end
	if AttachIndex == 0 then
	    beep()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. "no Browser selected.")
		return
	end
	local check = strings_getString(AttachItems,AttachIndex)
	if check == 'Google Chrome' then
		success = 0
		local test = openProcess("chrome.exe")
		if test == nil then
			beep()
		    beep()
			control_setCaption(f[3], "Attached to PID: " .. "Chrome not found.")
			timer_setEnabled(openNextProcTimer,false)
			return
		end
		strings_add(getAutoAttachList(),"chrome.exe")
		timer_setEnabled(openNextProcTimer,true)
		return
	end

    local temp = false
	if check == 'Gameroom' then
		facebookarcadescan()
		return
	else
		temp = false
	end


	if check == 'Gameroom (Unity Game)' then
		facebookarcadeunityscan()
		return
	else
		temp = false
	end

	if check == 'Firefox' or check == 'Internet Explorer' or check == 'SeaMonkey Windows 7' then openProcess("FlashPlayerPlugin") end
		errorOnLookupFailure(false)
		reinitializeSymbolhandler()
		err=getAddress("kernel32.dll")==0
	if err==true then
		beep()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. "Flash player plugin not found")
	else
		local PID=getOpenedProcessID()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - flash player plugin")
	end

		if check == 'Firefox(Unity Game)' or check == 'Internet Explorer Windows XP' or check == 'SeaMonkey Windows XP' then openProcess("plugin-container.exe") end
		errorOnLookupFailure(false)
		reinitializeSymbolhandler()
		err=getAddress("kernel32.dll")==0
	if err==true then
		beep()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. "Flash player plugin not found")
	else
		local PID=getOpenedProcessID()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - flash player plugin")
	end

		local check = strings_getString(AttachItems,AttachIndex)
	if check == 'Maxthon' then
		success = 0
		local test = openProcess("Maxthon.exe")
		if test == nil then
			beep()
			beep()
			control_setCaption(f[3], "Attached to PID: " .. "Maxthon not found.")
			timer_setEnabled(openNextProcTimer,false)
			return
		end
		strings_add(getAutoAttachList(),"Maxthon.exe")
		timer_setEnabled(openNextProcTimer,true)
		return
	end
end

function facebookarcadescan (sender)
errorOnLookupFailure(false);
facebookarcade = openProcess("CefSharp.BrowserSubprocess.exe")
facebookarcadeAttach =   {
                  AllProcesses = {};
                  RightProccess = function () return (getAddress("CefSharp.BrowserSubprocess.exe")~=0 or getAddress("CefSharp.BrowserSubprocess.exe")~=0) end;
                  FindProcess = function () if (facebookarcadeAttach.Started) then return end; if (#facebookarcadeAttach.AllProcesses == 0) then facebookarcadeAttach.GetfacebookarcadeProcesses(); end; createNativeThread(function ()   facebookarcadeAttach.Started = true; for k,v in pairs(facebookarcadeAttach.AllProcesses) do openProcess(k); reinitializeSymbolhandler(); if (facebookarcadeAttach.RightProccess()) then facebookarcadeAttach.Function(); facebookarcadeAttach.Started = false; break; end; end; facebookarcadeAttach.AllProcesses = {}; facebookarcadeAttach.Started = false; end); end;
                  GetfacebookarcadeProcesses = function () 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)); if processname:lower() == 'CefSharp.BrowserSubprocess.exe' then facebookarcadeAttach.AllProcesses[PID] = true; end; end; end;
                  Started = false;
                  Start = function (Function) facebookarcadeAttach.Function = Function; facebookarcadeAttach.FindProcess();end;
                  Function = nil;

               };

facebookarcadeAttach.Start(function () messageDialog('Attached to Gameroom', mtInformation, mbOK); end)
		errorOnLookupFailure(false)
		reinitializeSymbolhandler()
		err=getAddress("CefSharp.BrowserSubprocess.exe")==0
	if err==true then
		beep()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. "Gameroom Not Found")
	else
		local PID=getOpenedProcessID()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - Gameroom")
	end
end

function facebookarcadeunityscan (sender)
errorOnLookupFailure(false);
facebookarcadeunity = openProcess("fbunity")
facebookarcadeunityAttach =   {
                  AllProcesses = {};
                  RightProccess = function () return (getAddress("fbunity")~=0 or getAddress("fbunity")~=0) end;
                  FindProcess = function () if (facebookarcadeunityAttach.Started) then return end; if (#facebookarcadeunityAttach.AllProcesses == 0) then facebookarcadeunityAttach.GetfacebookarcadeunityProcesses(); end; createNativeThread(function ()   facebookarcadeunityAttach.Started = true; for k,v in pairs(facebookarcadeunityAttach.AllProcesses) do openProcess(k); reinitializeSymbolhandler(); if (facebookarcadeunityAttach.RightProccess()) then facebookarcadeunityAttach.Function(); facebookarcadeunityAttach.Started = false; break; end; end; facebookarcadeunityAttach.AllProcesses = {}; facebookarcadeunityAttach.Started = false; end); end;
                  GetfacebookarcadeunityProcesses = function () 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)); if processname:lower() == 'fbunity' then facebookarcadeunityAttach.AllProcesses[PID] = true; end; end; end;
                  Started = false;
                  Start = function (Function) facebookarcadeunityAttach.Function = Function; facebookarcadeunityAttach.FindProcess();end;
                  Function = nil;

               };

facebookarcadeunityAttach.Start(function () messageDialog('Attached to Gameroom', mtInformation, mbOK); end)
		errorOnLookupFailure(false)
		reinitializeSymbolhandler()
		err=getAddress("fbunity")==0
	if err==false then
		beep()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. "Gameroom Unity Game Not Found")
	else
		local PID=getOpenedProcessID()
		beep()
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - Gameroom(Unity Game)")
	end
end

function enableHacks()
	setProperty(getProperty(f[3] , "Font"), "Color", white)
	local PID=getOpenedProcessID()
	local check = strings_getString(AttachItems,AttachIndex)
	if check == 'Firefox' or check == 'Internet Explorer' then
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - flash player plugin")
		beep()
    elseif check == 'Google Chrome' then
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - chrome.exe")
		beep()
	elseif check == 'Maxthon' then
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - Maxthon.exe")
	    beep()
    elseif check == 'SeaMonkey' then
		control_setCaption(f[3], "Attached to PID: " .. PID .. " - SeaMonkey")
	    beep()
    end
	success = 1
end

function CloseTrainer()
	form_hide(f[1])
	closeCE()
end

control_onClick(f[5], scanBrowser)
form_onClose(f[1], CloseTrainer)
form_show(f[1])

</LuaScript>
</CheatTable>
