#include <File.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 343, 57, 192, 114, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_DLGFRAME,$WS_POPUP,$WS_GROUP))
$Progress1 = GUICtrlCreateProgress(8, 8, 326, 16)
$Progress2 = GUICtrlCreateProgress(8, 24, 326, 24)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$Timer = TimerInit()
	$Read1 = FileRead(_arrayDisplay($CmdLine))
	$Read2 = $Read1
	$Read3 = 0
	$Count = _FileCountLines($Read1)
	$obfus = 0
	$counter = 0
	$hlp = 0
	Dim $Array[$Count]
	_FileCreate($Read2)
	_FileReadToArray($Read1, $Array)
	For $i = 1 To $Count
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE
				$box = MsgBox(33, "Sind sie sicher?", "Wollen sie wirklich den Vorgang wirklich abbrechen?")
				If $box = 1 Then
					Exit
				EndIf



		EndSwitch
		If StringInStr($Array[$i], "0x") <> 0 Then
			$obfus = 1
			$Address = StringTrimLeft($Array[$i], StringInStr($Array[$i], "0x") - 1)
			$Len = StringLen($Address)
			$FullLen = StringLen($Array[$i])
			If $Len > 9 Then
				$Address = StringTrimRight($Address, StringLen(StringTrimLeft($Address, 10)))
			ElseIf $Len < 9 Then
				$obfus = 0
			EndIf
			$AddressLen = StringLen($Address)
			GUICtrlSetData($Progress2, 10)
			$LeftString = StringTrimRight($Array[$i], $Len)
			If StringRight($LeftString, 1) = """" Then
				$LeftString = StringTrimRight($LeftString, 1)
			EndIf
			$LeftLen = StringLen($LeftString)
			GUICtrlSetData($Progress2, 20)
			$RightString = StringTrimLeft($Array[$i], $FullLen-($FullLen-$AddressLen-$LeftLen))
			If StringLeft($RightString, 1) = """" Then
				$RightString = StringTrimLeft($RightString, 1)
			EndIf
			GUICtrlSetData($Progress2, 30)
			$binary = StringToBinary($Address)
			GUICtrlSetData($Progress2, 40)
			$final = "0x'"
			For $j = 2 To StringLen($binary) - 1
				$w = StringLeft(StringTrimLeft($binary, $j), 1)
				Switch $w
					Case 0
						$final &= "&'0'"
					Case 1
						$final &= "&StringLen('-')"
					Case 2
						$final &= "&StringLen('--')"
					Case 3
						$final &= "&StringLen('---')"
					Case 4
						$final &= "&StringLen('----')"
					Case 5
						$final &= "&StringLen('-----')"
					Case 6
						$final &= "&StringLen('------')"
					Case 7
						$final &= "&StringLen('-------')"
					Case 8
						$final &= "&StringLen('--------')"
					Case 9
						$final &= "&StringLen('---------')"
				EndSwitch
			Next
			If $obfus = 1 Then
				_FileWriteToLine($Read2, $i, $LeftString & "BinaryToString('" & $final & ")" & $RightString)

			Else
				_FileWriteToLine($Read2, $i, $Array[$i])
			EndIf

		ElseIf StringInStr($Array[$i], "0x") = 0 Then
			_FileWriteToLine($Read2, $i, $Array[$i])
		EndIf
		GUICtrlSetData($Progress2, 100)
		$hlp += 1
		GUICtrlSetData($Progress1, $hlp * 100 / $Count)
	Next
	_FileWriteToLine($Read2, $Count+2,";-------------------------------------------------------"&@CRLF&@CRLF&";Addy Changer by MrMoonlightTutorials"&@CRLF&@CRLF&";-------------------------------------------------------")
GUISetState(@SW_HIDE)


