{$DEFINE SMART} {$loadlib libsmartremote} type tSmart=record console:boolean; graphics:tGraphics; pid:int32; target:int32; userAgent:string; end; var smart:tSmart; smartPointers:array of pointer; function tSmart.getAvailablePID():int32; var funcLength, funcIndex:int32; begin if smartGetClients(true) then result:=smartGetAvailablePID(0); exit(result); end; procedure tSmart.create(); begin self.create(800,600);end; procedure tSmart.create(funcWidth,funcHeight:int32);overload; var funcParams:tStringArray; begin if not self.setPair() then begin if length(funcParams:=self.getParams())<2 then begin ogl.debug('tSmart.getParameters() failed'); terminateScript(); end; self.target:=smartSpawnClient(self.getJavaPath(),replace(pluginPath,'\','/',[0]),funcParams[0],','+funcParams[1],funcWidth,funcHeight,'',self.getUserAgent(),'-XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=30','OpenGL32.dll'); if self.target then begin try self.pid:=smartGetClientPID(self.target); setEIOSTarget('libsmartremote',toStr(self.pid)); self.graphics.create(funcWidth,funcHeight,smartDebugArray(self.target)); insert(@self,smartPointers); except ogl.debug('tSmart.create() failed'); smartFreeClient(self.target); terminateScript(); end; end else begin ogl.debug('tSmart.create() failed'); smartFreeClient(self.target); terminateScript(); end; end; addOnTerminate('tSmartSetFree'); end; procedure tSmart.destroy(); begin smartFreeClient(self.target); smartKillClient(self.pid); self.graphics.free(); self.pid:=0; self.target:=0; delete(pointer(@self),smartPointers); end; function tSmart.getDriveLetter():string; begin exit(replaceRegExpr('^(\w):\\.*',pluginPath,'$1',true));end; function tSmart.getJavaPath():ansiString; var funcJava:string=''; funcJRE, funcProgramFiles:tStringArray; funcJREIndex, funcProgramFilesIndex:int32; begin if not self.console then funcJava:='w'; for funcProgramFilesIndex to high(funcProgramFiles:=getDirectories(self.getDriveLetter()+':\Program Files')) do for funcJREIndex:=high(funcJRE:=getDirectories(self.getDriveLetter()+':\'+funcProgramFiles[funcProgramFilesIndex]+'\Java\jre')) downTo 0 do if fileExists(self.getDriveLetter()+':\'+funcProgramFiles[funcProgramFilesIndex]+'\Java\'+funcJRE[funcJREIndex]+'\bin\java'+funcJava+'.exe') then begin result:=self.getDriveLetter()+':\'+funcProgramFiles[funcProgramFilesIndex]+'\Java\'+funcJRE[funcJREIndex]+'\bin\java'+funcJava+'.exe'; break; end; exit(result); end; function tSmart.getHeight():int32; begin if (result:=oglClientHeight)=0 then begin getClientPosition(oglClientWidth,oglClientHeight); result:=oglClientHeight; end; exit(result); end; function tSmart.getParams():tStringArray; var funcAttempts, funcIndex, funcRandom, funcResultIndex:int32; funcExcludeList:tIntegerArray=[13,47,55,75,90,93,94,95,101,102,107,109,110,111,112,113,118,121,122,125,126,127,128,129,130,131,132,133]; funcPage:string; funcPageExplode:tStringArray; begin for 0 to 10 do begin while true do if not funcExcludeList.contains(funcRandom:=random({$IFNDEF DARKSCAPE}1,150{$ELSE}200,207{$ENDIF})) then break; funcPage:=getPage('http://world'+toStr(funcRandom)+'.runescape.com/jav_config_beta.ws'); if pos('404 - Page not found',funcPage)=0 then begin setLength(result,length(funcPageExplode:=explode(#10,funcPage))); for funcIndex to high(funcPageExplode) do if execRegExpr('^(codebase|param)=(.+)',funcPageExplode[funcIndex]) then begin result[funcResultIndex]:=replaceRegExpr('^(codebase|param)=(.+)',funcPageExplode[funcIndex],'$2',true); funcResultIndex+=1; end; break; end; end; setLength(result,funcResultIndex); exit(result); end; function tSmart.getUserAgent():string; const funcUserAgentArray:tStringArray=[ 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240', 'Mozilla/5.0 (Windows NT 6.1; rv:41.0) Gecko/20100101 Firefox/41.0', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0', 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 5.1; rv:41.0) Gecko/20100101 Firefox/41.0', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0; Trident/5.0)', 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0', 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0)', 'Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36 OPR/32.0.1948.69', 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' ]; begin if self.userAgent<>'' then result:=self.userAgent else result:=funcUserAgentArray[random(length(funcUserAgentArray))]; exit(result); end; function tSmart.getWidth():int32; begin if (result:=oglClientWidth)=0 then begin getClientPosition(oglClientWidth,oglClientHeight); result:=oglClientWidth; end; exit(result); end; function tSmart.setPair():boolean; begin if (self.pid:=self.getAvailablePID()) then if (self.target:=smartPairClient(self.pid)) then begin setEIOSTarget('libsmartremote',toStr(self.pid)); self.graphics.create(self.getWidth(),self.getHeight(),smartDebugArray(self.target)); insert(@self,smartPointers); result:=true; end; if result then ogl.debug('tSmart.setPair() was successful (PID: ' + toStr(self.pid) + ')'); exit(result); end; procedure tSmart.setFree();overload; begin smartFreeClient(self.target); self.graphics.free(); self.pid:=0; self.target:=0; delete(pointer(@self),smartPointers); end; procedure tSmartSetFree; var funcIndex:int32; begin for funcIndex to high(smartPointers) do tSmart(smartPointers[funcIndex]^).setFree(); end;