So I added a save button to the compiler which saves your current settings in an ini file.
I'm not sure if this is the right place to put it, but here it goes :
Code: Select all
#RequireAdmin
#include "Aut2Exe\Include\ButtonConstants.au3"
#include "Aut2Exe\Include\EditConstants.au3"
#include "Aut2Exe\Include\GUIConstantsEx.au3"
#include "Aut2Exe\Include\WindowsConstants.au3"
#include "Aut2Exe\Include\Constants.au3"
; Exit if the script hasn't been compiled
If Not @Compiled Then
MsgBox(0, "ERROR", 'Script must be compiled before running!', 5)
Exit
EndIf
; Read settings file.
$RepeaterList = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "List", "" )
$ListMax = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "ListMax", "" )
$RepeaterAddressLAN = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterAddressLAN", "" )
$RepeaterAddressWAN = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterAddressWAN", "" )
$RepeaterPortViewer = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterPortViewer", "" )
$RepeaterPortServer = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterPortServer", "" )
$PlainTextPassword = IniRead( @ScriptDir & "\settings.ini", "ChunkViewer", "PlainTextPassword", "" )
$Form1_1 = GUICreate("ChunkVNC Compiler", 434, 370, 192, 124)
GUISetBkColor(0xFFFFFF)
$Group1 = GUICtrlCreateGroup("Repeater Address", 16, 8, 401, 137)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$InputWAN = GUICtrlCreateInput($RepeaterAddressWAN, 96, 48, 305, 28)
GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
$InputLAN = GUICtrlCreateInput($RepeaterAddressLAN, 96, 96, 305, 28)
GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("WAN:", 32, 48, 49, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("LAN:", 32, 96, 43, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Repeater Ports", 16, 160, 401, 89)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label3 = GUICtrlCreateLabel("Viewer:", 32, 200, 63, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Server:", 232, 200, 61, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$InputViewerPort = GUICtrlCreateInput($RepeaterPortViewer, 104, 200, 97, 28)
GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
$InputServerPort = GUICtrlCreateInput($RepeaterPortServer, 304, 200, 97, 28)
GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("InstantSupport Password", 16, 264, 305, 89)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$InputPassword = GUICtrlCreateInput($PlainTextPassword, 32, 304, 273, 28)
GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetLimit( $InputPassword, 8 )
$ButtonSave = GUICtrlCreateButton("Save", 336, 272, 81, 40)
$ButtonCompile = GUICtrlCreateButton("Compile!", 336, 313, 81, 40)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonSave
$RepeaterAddressWAN = GUICtrlRead( $InputWAN )
$RepeaterAddressLAN = GUICtrlRead( $InputLAN )
$RepeaterPortViewer = GUICtrlRead( $InputViewerPort )
$RepeaterPortServer = GUICtrlRead( $InputServerPort )
$PlainTextPassword = GUICtrlRead( $InputPassword )
IniWrite( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterAddressLAN", $RepeaterAddressLan)
IniWrite( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterAddressWAN", $RepeaterAddressWan)
IniWrite( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterPortServer", $RepeaterPortServer)
IniWrite( @ScriptDir & "\settings.ini", "ChunkViewer", "RepeaterPortViewer", $RepeaterPortViewer)
IniWrite( @ScriptDir & "\settings.ini", "ChunkViewer", "PlainTextPassword", $PlainTextPassword)
Case $ButtonCompile
; Check the password.
$PlainTextPassword = GUICtrlRead( $InputPassword )
If $PlainTextPassword = "" or StringInStr( $PlainTextPassword, " " ) Then
MsgBox( 0, "Information", "The password cannot be blank or contain whitespace." )
Else
; Generate password hash and store it in ultravnc.ini
$HashedPassword = GeneratePWD( $PlainTextPassword )
IniWrite( @ScriptDir & "\SRC\InstantSupport_Files\ultravnc.ini", "ultravnc", "passwd", $HashedPassword )
; Setup source files with the repeaters address.
$RepeaterAddressWAN = GUICtrlRead( $InputWAN )
$RepeaterAddressLAN = GUICtrlRead( $InputLAN )
$ViewerPort = GUICtrlRead( $InputViewerPort )
$ServerPort = GUICtrlRead( $InputServerPort )
IniWrite( @ScriptDir & "\Viewer\Bin\chunkviewer.ini", "Repeater", "Address", $RepeaterAddressWAN & ":" & $ViewerPort )
IniWrite( @ScriptDir & "\Viewer\Bin\chunkviewer.ini", "Repeater", "AddressLAN", $RepeaterAddressLAN & ":" & $ViewerPort )
IniWrite( @ScriptDir & "\SRC\InstantSupport_Files\instantsupport.ini", "Repeater", "Address", $RepeaterAddressWAN & ":" & $ServerPort )
IniWrite( @ScriptDir & "\SRC\InstantSupport_Files\instantsupport.ini", "Repeater", "AddressLAN", $RepeaterAddressLAN & ":" & $ServerPort )
; Compile InstantSupport.exe
ShellExecuteWait( "SRC\Aut2Exe\Aut2Exe.exe", "/in SRC\InstantSupport.au3 /out 3C-Support.exe /icon SRC\InstantSupport_Files\icon1.ico", @ScriptDir )
; Compile ChunkViewer.exe
ShellExecuteWait( "SRC\Aut2Exe\Aut2Exe.exe", "/in SRC\ChunkViewer.au3 /out Viewer\3C-Viewer.exe /icon SRC\InstantSupport_Files\icon1.ico", @ScriptDir )
MsgBox( 0, "Information", "Compile Complete." )
Exit
EndIf
EndSwitch
WEnd
Func GeneratePWD( ByRef $plaintextpwd )
; Read the console output of vnc_hash.exe after sending it a plaintext password to hash.
Local $vnchashexe = Run( @ComSpec & " /c SRC\vnc_hash\vnc_hash.exe " & $plaintextpwd, @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
$line = StdoutRead( $vnchashexe ) ; First line is blank
Sleep( 1000 ) ; We have to wait a bit for the console app to write the hash.
$line = StdoutRead( $vnchashexe ) ; Read the hash.
$line = StringStripWS( $line, 2 ) & "00" ; Remove trailing whitespace and add 00. HACK: vnc_hash.exe should return with the trailing 00!
Return $line
EndFunc