#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <file.au3>
Opt("GUIOnEventMode", 1)
$gui = GUICreate('ProBot Loader', 200, 200, Default, Default, 0x90CA0000)
;DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
; --- GUI Ctrl Create ---
GUICtrlCreateLabel("Select Division:", 10, 10)
$choser = GUICtrlCreateCombo("", 10, 31, 180, 20, 3)
$start = GUICtrlCreateButton("LAUNCH", 10, 150, 180, 40)
Local $opt[3]
$opt[0] = GUICtrlCreateCheckbox("Enable AutoLogin", 10, 70)
$opt[1] = GUICtrlCreateCheckbox("Enable MultiClient", 10, 90)
$opt[2] = GUICtrlCreateCheckbox("Enable Debug Console", 10,110)
_GUICtrlComboBox_BeginUpdate($choser)
_GUICtrlComboBox_AddString($choser, "FIRE")
_GUICtrlComboBox_AddString($choser, "WATER")
_GUICtrlComboBox_EndUpdate($choser)
; --- GUI Events ---
GUISetOnEvent(-3, 'CloseLoader')
; --- Control Functions ---
GUICtrlSetOnEvent($start, 'Start')
Global $sro_path, $ret
; --- Check for DLL ---
Local $dll = _PathFull("pBot.dll")
if Not FileExists($dll) Then
MsgBox(0, "Error", "pBot.dll Not Found." & @CR & "Loader will exit now")
Exit
EndIf
; --- Check for INI ---
Local $ini_path = "config\config1.ini"
If Not FileExists($ini_path) Then
$f = _WinAPI_CreateFile($ini_path, 0)
_WinAPI_CloseHandle($f)
EndIf
$ini_path = _PathFull("config\config1.ini")
; --- Init Main CTRL
_GUICtrlComboBox_SetCurSel($choser, IniRead($ini_path, "LOADER", "DIV", 0))
GUICtrlSetState($opt[0], IniRead($ini_path, "BOOT", "AUTOLOG", 0))
GUICtrlSetState($opt[1], IniRead($ini_path, "BOOT", "MULTICLIENT", 0))
GUICtrlSetState($opt[2], IniRead($ini_path, "BOOT", "CONSOLE", 0))
; --- Read SRO Path ---
$sro_path = Iniread($ini_path, "LOADER", "SRO", 0)
If StringLen($sro_path) <= 4 Or Not FileExists($sro_path) Then
MsgBox(0, "Info", "SRO_client.exe Path not found, please select it now")
$sro_path = FileOpenDialog("Select SRO_client.exe", @ProgramFilesDir & "", "Executable .exe file (*.exe)", 1, "SRO_client.exe")
If Not @error Then
MsgBox(0, $ret, $sro_path)
$ret = IniWrite($ini_path, "LOADER", "SRO", $sro_path)
Else
MsgBox(0, "Error", "Path to SRO_client.exe not found." & @CR & "Loader will exit now")
Exit
EndIf
EndIf
While Sleep(100)
; --- Avoid Quiting ---
Wend
Func Start()
$division = _GUICtrlComboBox_GetCurSel($choser)
; --- Save INI File ---
IniWrite($ini_path, "LOADER", "DIV", $division)
IniWrite($ini_path, "BOOT", "CONSOLE", GUICtrlRead($opt[2]))
IniWrite($ini_path, "BOOT", "AUTOLOG", GUICtrlRead($opt[0]))
IniWrite($ini_path, "BOOT", "MULTICLIENT", GUICtrlRead($opt[1]))
; --- Run Sro ---
$pid = Run($sro_path & " 0 /4 " & $division & " 0")
; FIRE = 0
; WATER = 1
; --- Inject pBot ---
_InjectDll($pid, $dll, 1)
Exit
EndFunc
Func CloseLoader()
Exit
EndFunc
Func _InjectDll($a, $dllpath, $hWnd_or_pid=0)
;make sure the user passed valid parameters
If $a <= 0 Then
SetError(-1)
Return False
ElseIf StringLen($dllpath) <= 4 Or StringRight($dllpath, 4) <> ".dll" Then
SetError(-2)
Return False
EndIf
Local $pid, $pHandle, $pLibRemote, $modHandle, $LoadLibraryA, $hThread
;open dll that we'll be using
Local $kernel32 = DllOpen("kernel32.dll")
Local $ret
If $hWnd_or_pid = 0 Then
;get the pid from the window provided
$pid = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $a, "int_ptr", 0)
If IsArray($pid) Then
$pid = $pid[2]
Else
SetError(-3)
Return False
EndIf
Else
$pid = $a
EndIf
;open the process for writing
Local $pHandle = DllCall($kernel32, "int", "OpenProcess", "int", BitOr(0x10, 0x20, 0x02, 0x08), "int", 0, "int", $pid)
If IsArray($pHandle) And $pHandle[0] > 0 Then
$pHandle = $pHandle[0]
Else
SetError(-4)
Return False
EndIf
Local $pLibRemote = DllCall($kernel32, "int", "VirtualAllocEx", "int", $pHandle, "short", 0, "int", StringLen($dllpath)+1, "int", 0x1000, "int", 0x40)
If IsArray($pLibRemote) Then
If $pLibRemote[0] > 0 Then
$pLibRemote = $pLibRemote[0]
Else
SetError(-5)
Return False
EndIf
Else
SetError(-6)
Return False
EndIf
Local $struct = DllStructCreate('char['&StringLen($dllpath)+1&']')
For $i = 1 To StringLen($dllpath)
DllStructSetData($struct, 1, StringMid($dllpath, $i, 1), $i)
Next
$ret = DllCall($kernel32, "int", "WriteProcessMemory", "int", $pHandle, "int", $pLibRemote, "int", DllStructGetPtr($struct), "int", DllStructGetSize($struct), "int", 0)
If IsArray($ret) Then
If $ret[0] = 0 Then
SetError(-7)
Return False
EndIf
Else
SetError(-8)
Return False
EndIf
Local $modHandle = DllCall($kernel32, "long", "GetModuleHandle", "str", "kernel32.dll")
If IsArray($modHandle) Then
If $modHandle[0] > 0 Then
$modHandle = $modHandle[0]
Else
SetError(-9)
Return False
EndIf
Else
SetError(-10)
Return False
EndIf
Local $LoadLibraryA = DllCall($kernel32, "long", "GetProcAddress", "long", $modHandle, "str", "LoadLibraryA")
If IsArray($LoadLibraryA) Then
If $LoadLibraryA[0] > 0 Then
$LoadLibraryA = $LoadLibraryA[0]
Else
SetError(-11)
Return False
EndIf
Else
SetError (-12)
Return False
EndIf
Local $hThread = DllCall($kernel32, "int", "CreateRemoteThread", "int", $pHandle, "int", 0, "int", 0, "long", $LoadLibraryA, "long", $pLibRemote, "int", 0, "int", 0)
If IsArray($hThread) Then
If $hThread[0] > 0 Then
$hThread = $hThread[0]
Else
SetError(-13)
Return False
EndIf
Else
SetError(-14)
Return False
EndIf
DllCall($kernel32, "int", "VirtualFreeEx", "int", $pHandle, "int", $pLibRemote, "int", StringLen($dllpath)+1, "int", 0x8000)
DllCall($kernel32, "int", "CloseHandle", "int", $hThread)
DllCall($kernel32, "int", "CloseHandle", "int", $pHandle)
DllClose($kernel32)
Return True
EndFunc
|