Thread: LawlRez

Results 1 to 7 of 7
  1. #1
    iMaxxx's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    57
    Reputation
    10
    Thanks
    82

    LawlRez

    Hey guys,
    so many ppl asked me for the lawlrez sc, so I decided to make it open source

    Code:
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Icon=..\Law-Dev\lawldev.ico
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <TreeViewConstants.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>
    #include <array.au3>
    #include <File.au3>
    #include <guitreeview.au3>
    #include <GuiListView.au3>
    #include <GuiListBox.au3>
    ;If @Compiled And Ping("google.com", 100) Then CheckUpdates()
    if not FileExists @sCripTDir & "\lawlrez.bmp") then FileInstall("C:\Users\lawliet\Desktop\lawlrez.bmp", @sCripTDir & "\lawlrez.bmp")
    If isCARunning() Then Exit
    $startsplash = SplashImageOn("LawlRez OPEN BETA", @sCripTDir & "\lawlrez.bmp", 300, 200)
    Sleep(2000)
    SplashOff()
    Global $GUI, $menu, $menuitem1, $tabitem, $tab1, $tab2, $treeview, $Group1, $Progress1, $xAddChild, $treeview
    $GUI = GUICreate("LawlRez", 250, 420)
    $menu = GUICtrlCreateMenu("Datei")
    $menuitem1 = GUICtrlCreateMenuItem("Open Rez", $menu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    $menu2 = GUICtrlCreateMenu("Hilfe")
    $menuitem2 = GUICtrlCreateMenuItem("Über..", $menu2)
    $tabitem = GUICtrlCreateTab(0, 0, 255, 400)
    $tab1 = GUICtrlCreateTabItem("Rez Tools")
    $treeview = GUICtrlCreateTreeView(2, 22, 247, 300, BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES))
    GUICtrlSetBkColor(-1, 0xededed)
    $Progress1 = GUICtrlCreateProgress(5, 370, 240, 20)
    GUICtrlCreateGroup("Info", 5, 323, 240, 40)
    $label5 = GUICtrlCreateLabel("Fortschritt 0%", 10, 335, 100, 20)
    GUICtrlSetFont(-1, 7.4, 0, 0, "Arial")
    $label6 = GUICtrlCreateLabel("File: ", 10, 345, 250, 10)
    GUICtrlSetFont(-1, 7.4, 0, 0, "Arial")
    $tab2 = GUICtrlCreateTabItem("DTX")
    $list2 = GUICtrlCreateListView("Pfad|Name|Typ", 10, 50, 230, 280)
    $addDtx = GUICtrlCreateButton("++ Add Items ++", 10, 340, 115, 30)
    $convertnx = GUICtrlCreateButton("Convert to Nexon", 125, 340, 115, 15)
    $convertlt = GUICtrlCreateButton("Convert to LithTech", 125, 355, 115, 15)
    $clear = GUICtrlCreateButton("Clear List", 10, 25, 230, 20)
    $Progress2 = GUICtrlCreateProgress(10, 375, 230)
    
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    Dim $Mainitems[1][8]
    Dim $ChildItems[1][5]
    Dim $tvKontext[1][2]
    Dim $mainview[3]
    Main()
    Func Main()
    	Local $nMsg = 0, $path, $generalitem, $files = 0, $i = 0, $cFolder, $ts = 0, $Name = 0
    	While 1
    		$nMsg = GUIGetMsg()
    		Switch $nMsg
    			Case $GUI_EVENT_CLOSE
    				Exit
    			Case $menuitem1
    				$path = FileOpenDialog("Choose a Rez File", "E:\Spiele\anno\Combat Arms EU\Game\", "Rez Files(*.rez)")
    				If $path Then
    					$Name = RezOpen($path)
    				EndIf
    			Case $mainview
    				If _GUICtrlTreeView_GetChecked($treeview, $mainview) Then
    					For $b = 1 To $ChildItems[0][0] Step 1
    						_GUICtrlTreeView_SetChecked($treeview, $ChildItems[$b][0])
    					Next
    					For $b = 1 To $Mainitems[0][0] Step 1
    						_GUICtrlTreeView_SetChecked($treeview, $Mainitems[$b][0])
    					Next
    				EndIf
    			Case $menuitem2
    				MsgBox(0, "Über", "LawlRez wurde von Lawliet! (Maxim B.) Entwickelt" & @crlF & "Version: OPEN BETA"& @crlF & "Bei Problemen bitte an mich wenden :)")
    			Case $addDtx
    				$FileList = FileOpenDialog("Choose a DTX File", @desktopDir, "DTXFiles(*.dtx)", 4)
    				If $FileList and StringInStr($FileList, "|") Then
    					$split = StringSplit($FileList, "|")
    					for $i = 2 to $split[0]
    					GUICtrlCreateListViewItem($split[1] & "\" & $split[$i] & "|" & $split[$i]& "|" & _GetDTXTyp($split[1] & "\" & $split[$i]), $list2)
    					Next
    				Else
    					$dtxname = _PathToFilename($FileList)
    					GUICtrlCreateListViewItem($FileList & "|" &  $dtxname[$dtxname[0]] & "." & $dtxname[$dtxname[0]-1] & "|" &   _GetDTXTyp($FileList), $list2)
    					EndIf
    			case $clear
    				_GUICtrlListView_DeleteAllItems($list2)
    			Case $convertlt
    				For $i = 0 to _GUICtrlListView_GetItemCount($list2)
    					GUICtrlSetData($Progress2, (100/_GUICtrlListView_GetItemCount($list2)+1)*$i)
    					$name = _GUICtrlListView_GetItem($list2, $i, 0)
    					$hFile = FileOpen($name[3], 17)
    					FileSetPos($hfile, 0, 0)
    					FileWrite($hfile, "0x00000000FBFFFFFF8000800004")
    					GUICtrlSetData($name[5], "||" & _GetDTXTyp($name[3]))
    					FileClose($hFile)
    				Next
    			Case $convertnx
    				For $i = 0 to _GUICtrlListView_GetItemCount($list2)
    					GUICtrlSetData($Progress2, (100/_GUICtrlListView_GetItemCount($list2)+1)*$i)
    					$name = _GUICtrlListView_GetItem($list2, $i, 0)
    					$hFile = FileOpen($name[3], 17)
    					FileSetPos($hfile, 0, 0)
    					FileWrite($hfile, "0x0000000080008000FBFFFFFF04")
    					GUICtrlSetData($name[5], "||" & _GetDTXTyp($name[3]))
    					FileClose($hFile)
    				Next
    		EndSwitch
    		If IsArray($Mainitems) And $Mainitems[0][2] And $Mainitems[0][3] Then
    			if $nMsg = $Mainitems[0][4] then
    			if MsgBox(1, "Warning", '"Create Folder" is buggy and may not work') = 1 Then
    			RezCreateFolder($path)
    			RezOpen($path)
    			EndIf
    			EndIf
    			If $nMsg = $Mainitems[0][3] Then
    				$FolderPath = FileSelectFolder("Choose a Folder", @desktopDir, 1)
    				$FList = _FileListToArray($FolderPath)
    				if not @error Then
    				ProgressOn("Injecting Data", "")
    				For $i = 1 To $FList[0]
    					$aName = _PathToFilename($FolderPath)
    					ProgressSet((100/$FList[0])*$I, $aName[UBound($aName) - 1] & " ----> " & $FList[$i])
    					LawlInjectFile($FolderPath & "\" & $FList[$i], $path, $aName[UBound($aName) - 1])
    					FileDelete($path)
    					FileMove($path & "new", $path)
    				Next
    				ProgressOff()
    				RezOpen($path)
    			Else
    				MsgBox(0, "Error", "Error code: " & @error & @crlF & "No Files in Folder?")
    				EndIf
    			EndIf
    		EndIf
    		For $i = 1 To $Mainitems[0][0] Step 1
    			if $nMsg = $Mainitems[$i][7] then
    				$files = FileOpenDialog("Choose a File(s)", @desktopDir, "All(*.*)", 4)
    				if StringInStr($Files, "|") Then
    				$split = StringSplit($files, "|")
    				ProgressOn("Injecting Data", "")
    				For $c = 2 to $split[0]
    					ProgressSet((100/$split[0]-1)*$c, $Mainitems[$i][1] & " ----> " & $split[$c])
    					LawlInjectFile($split[1] & "\" & $split[$c], $path, $Mainitems[$i][1])
    					FileDelete($path)
    					FileMove($path & "new", $path)
    				Next
    				ProgressOff()
    				RezOpen($path)
    				MsgBox(0, "Done", $split[0]-1 & " Daten erfolgreich in " & $Mainitems[$i][1] & " injected")
    			Else
    				ProgressOn("Injecting Data", "")
    				LawlInjectFile($files, $path, $Mainitems[$i][1])
    				FileDelete($path)
    					FileMove($path & "new", $path)
    				ProgressSet(100, "")
    				ProgressOff()
    				RezOpen($path)
    				MsgBox(0, "Done", "1 Daten erfolgreich in " & $Mainitems[$i][1] & " injected")
    			EndIf
    			EndIf
    			If $nMsg = $Mainitems[$i][5] Then
    				GUICtrlSetData($Progress1, 0)
    				For $z = 1 To $ChildItems[0][0] Step 1
    					GUICtrlSetData($Progress1, (100 / $ChildItems[0][0]) * $z)
    					GUICtrlSetData($label5, "Fortschritt: " & Round((100 / $ChildItems[0][0]) * $z, 2) & " %")
    					If StringInStr($ChildItems[$z][4], $Mainitems[$i][1]) And StringInStr($ChildItems[$z][1], ".") Then
    						GUICtrlSetData($label6, "File: " & $ChildItems[$z][1])
    						$hFile = FileOpen($path, 16)
    						FileSetPos($hFile, $ChildItems[$z][2], 0)
    						DirCreate @desktopDir & "\" & $Name[1] & "." & $Name[2] & "\" & $ChildItems[$z][4])
    						FileWrite @desktopDir & "\" & $Name[1] & "." & $Name[2] & "\" & $ChildItems[$z][4] & "\" & $ChildItems[$z][1], FileRead($hFile, $ChildItems[$z][3]))
    						FileClose($hFile)
    					EndIf
    				Next
    				MsgBox(0, "100%", "Entpackt nach " & @desktopDir & "\" & $Name[1] & "." & $Name[2] & "\")
    			EndIf
    			If $nMsg = $Mainitems[$i][0] Then
    				If _GUICtrlTreeView_GetChecked($treeview, $Mainitems[$i][0]) Then
    					For $c = 1 To $ChildItems[0][0] Step 1
    						If StringRight($ChildItems[$c][4], StringLen($Mainitems[$i][1])) = $Mainitems[$i][1] Then _GUICtrlTreeView_SetChecked($treeview, $ChildItems[$c][0])
    					Next
    				EndIf
    			EndIf
    		Next
    
    	WEnd
    EndFunc   ;==>Main
    
    
    Func LawlReadFolder($data, $sString)
    	Dim $Folder[2][3]
    	Local $pos = 1, $i = 2, $c = 0
    	Do
    		ReDim $Folder[$i][3]
    		$pos = StringInStr($data, StringTrimLeft($sString, 2), 0, 1, $pos + 8) - 2
    		$Folder[$i - 1][1] = Dec(ConvertRezBack(BinaryMid($data, ($pos / 2) - 8, 4)))
    		$Folder[$i - 1][2] = Dec(ConvertRezBack(BinaryMid($data, ($pos / 2) - 4, 4)))
    		$c = 0
    		Do
    			$Folder[$i - 1][0] &= BinaryToString(BinaryMid($data, $pos / 2 + 4 + $c, 1))
    			$c += 1
    		Until BinaryMid($data, $pos / 2 + 4 + $c, 1) = "0x00" Or BinaryMid($data, $pos / 2 + 4 + $c, 1) = False
    		$i += 1
    	Until StringInStr($data, StringTrimLeft($sString, 2), 0, 1, $pos + 4) <= 0
    	$Folder[0][0] = $i - 2
    	Return $Folder
    EndFunc   ;==>LawlReadFolder
    
    Func ConvertRez($data)
    	Local $hex, $sRet = ""
    	If $data Then
    		If Not IsBinary($data) Then
    			$hex = Hex($data)
    		Else
    			$hex = StringTrimLeft($data, 2)
    		EndIf
    	Else
    		SetError(1, 0, 0)
    	EndIf
    	For $i = 2 To StringLen($hex) Step 2
    		$sRet &= StringTrimRight(StringRight($hex, $i), $i - 2)
    	Next
    	While StringLen($sRet) < 8
    		$sRet &= "00"
    	WEnd
    	Return $sRet
    EndFunc   ;==>ConvertRez
    
    
    
    Func ConvertRezBack($data)
    	Local $sRet = ""
    	If IsBinary($data) Then
    		$data = StringTrimLeft($data, 2)
    	Else
    		SetError(1, 0, 0)
    	EndIf
    	For $i = 2 To StringLen($data) Step 2
    		$sRet &= StringTrimRight(StringRight($data, $i), $i - 2)
    	Next
    	Return $sRet
    EndFunc   ;==>ConvertRezBack
    
    Func LawlReadRez($path, $opt = 0, $off = 0, $lOff = 0)
    	Local $pos = 0, $posi = 1, $sString = "", $c = 2, $b = 32, $i = 1, $hFile = 0, $sPointer1 = 0, $lPointer1 = 0, $sPointer2 = 0, $lPointer2 = 0, $Folder = 0, $FileEx = 0, $data = ""
    	Dim $files[1][4]
    	$hFile = FileOpen($path, 16)
    	ConsoleWrite($hFile & @crlF)
    	FileSetPos($hFile, 215, 0)
    	$sString = StringTrimLeft(FileRead($hFile, 4), 2)
    	ConsoleWrite($sString & @crlF)
    	FileSetPos($hFile, 199, 0)
    	$sPointer1 = Dec(ConvertRezBack(FileRead($hFile, 4)))
    	ConsoleWrite($sPointer1 & @crlF)
    	FileSetPos($hFile, 203, 0)
    	$lPointer1 = Dec(ConvertRezBack(FileRead($hFile, 4)))
    	ConsoleWrite($lPointer1 & @crlF)
    	FileSetPos($hFile, $sPointer1, 0)
    	$Folder = LawlReadFolder(FileRead($hFile, $lPointer1), $sString)
    	If $opt Then
    		FileClose($hFile)
    		Return $Folder
    	EndIf
    	#cs
    		FileSetPos($hfile, $sPointer1 + 4, 0)
    		$sPointer2 = Dec(ConvertRezBack(FileRead($hfile, 4))) + 1
    		FileSetPos($hfile, $sPointer1 + 4 * 2, 0)
    		$lPointer2 = Dec(ConvertRezBack(FileRead($hfile, 4)))
    	#ce
    
    	If $off And $lOff Then
    		$sPointer2 = $off
    		$lPointer2 = $lOff
    	EndIf
    	#cs
    		_ArrayDisplay($Folder)
    		MsgBox(0, "", $sPointer2 & "   " & $lPointer2)
    	#ce
    
    	FileSetPos($hFile, $sPointer2, 0)
    	$data = StringTrimLeft(FileRead($hFile, $lPointer2), 2)
    	While True
    		$i += 1
    		ReDim $files[$i][3]
    		$posi = StringInStr($data, StringTrimLeft($sString, 2), 0, 1, $posi + 8) - 2
    		If @error Then MsgBox(0, "ERROR", @error)
    		If $posi > 0 Then
    			If Dec(ConvertRezBack(StringMid($data, $posi + 9, 2))) = "00" Then
    				$files[$i - 1][1] = Dec(ConvertRezBack(StringMid($data, $posi - 16, 8)))
    				$files[$i - 1][2] = Dec(ConvertRezBack(StringMid($data, $posi - 8, 8)))
    				$b = 32
    				Do
    					$files[$i - 1][0] &= BinaryToString("0x" & (StringMid($data, $posi + $b, 2)))
    					$b += 2
    				Until StringMid($data, $posi + $b, 2) = "00"
    				$c = 2
    				Do
    					If $c = 2 Then $files[$i - 1][0] &= Chr(46)
    					$files[$i - 1][0] &= BinaryToString("0x" & (StringMid($data, $posi + 22 - $c, 2)))
    					$c += 2
    				Until $c = 8
    			Else
    				$files[$i - 1][1] = Dec(ConvertRezBack(StringMid($data, $posi - 16, 8)))
    				$files[$i - 1][2] = Dec(ConvertRezBack(StringMid($data, $posi - 8, 8)))
    				$b = 1
    				Do
    					$files[$i - 1][0] &= BinaryToString("0x" & (StringMid($data, $posi + 7 + $b, 2)))
    					$b += 2
    				Until StringMid($data, $posi + 7 + $b, 2) = "00" Or StringMid($data, $posi + 7 + $b, 2) = False
    				$c = 2
    			EndIf
    		Else
    			$files[0][0] = $i - 2
    			FileClose($hFile)
    			Return $files
    		EndIf
    	WEnd
    	$files[0][0] = $i - 2
    EndFunc   ;==>LawlReadRez
    
    
    
    Func _PathToFilename($path)
    	Local $aFileInfo = "", $FileEx = ""
    	$aFileInfo = StringSplit($path, "\")
    	$FileEx = StringSplit($aFileInfo[$aFileInfo[0]], ".")
    	Return $FileEx
    EndFunc   ;==>_PathToFilename
    
    
    
    
    Func LawlInjectFile($source, $target, $FolderN, $opt = 0)
    	Local $sData = "", $b = 0, $i = 0, $pos = 1, $sourcePointer = "", $FolderString = "", $hFile = 0, $FolderData = "", $FileEx = "", $FList = "", $files = "", $fileexist = 0
    	$FileEx = _PathToFilename($source)
    	if not $opt then Dim $sFileInfo[2] = [$FileEx[$FileEx[0]], $FileEx[$FileEx[0] - 1]]
    	Dim $lastFolder[3] = [0, 0, 0]
    	Dim $lastFile[3] = [0, 0, 0]
    	Dim $FolderExist[4] = [0, 0, 0, 0]
    	If $opt Then
    		$sData = $source
    	Else
    		$hFile = FileOpen($source, 16)
    		$sData = FileRead($hFile)
    	EndIf
    	$FList = LawlReadRez($target, 1)
    	For $i = 1 To $FList[0][0] Step 1
    		If $FList[$i][1] > $lastFolder[0] Then
    			$lastFolder[0] = $FList[$i][0]
    			$lastFolder[1] = $FList[$i][1]
    			$lastFolder[2] = $FList[$i][2]
    		EndIf
    		$files = LawlReadRez($target, 0, $FList[$i][1], $FList[$i][2])
    		For $b = 1 To $files[0][0] Step 1
    			;If $files[$b][0] = $FileEx[2] & "." & $FileEx[1] Then $fileexist = True
    			If $files[$b][1] > $lastFile[1] Then
    				$lastFile[0] = $files[$b][0]
    				$lastFile[1] = $files[$b][1]
    				$lastFile[2] = $files[$b][2]
    			EndIf
    		Next
    	Next
    	FileClose($hFile)
    	$hFile = FileOpen($target, 16)
    	FileSetPos($hFile, 215, 0)
    	$sString = StringTrimLeft(FileRead($hFile, 4), 2)
    	FileSetPos($hFile, 199, 0)
    	$sPointer1 = Dec(ConvertRezBack(FileRead($hFile, 4)))
    	FileSetPos($hFile, 203, 0)
    	$lPointer1 = Dec(ConvertRezBack(FileRead($hFile, 4)))
    	FileSetPos($hFile, $sPointer1, 0)
    	$Folder = LawlReadFolder(FileRead($hFile, $lPointer1), $sString)
    	FileSetPos($hFile, $sPointer1 + 4, 0)
    	$sPointer2 = Dec(ConvertRezBack(FileRead($hFile, 4))) + 1
    	FileSetPos($hFile, $sPointer1 + 4 * 2, 0)
    	$lPointer2 = Dec(ConvertRezBack(FileRead($hFile, 4)))
    	FileSetPos($hFile, $lastFile[1] + $lastFile[2], 0)
    	For $i = 0 To $Folder[0][0] Step 1
    		If $Folder[$i][0] = $FolderN Then
    			$FolderExist[0] = True
    			$FolderExist[1] = $Folder[$i][0]
    			$FolderExist[2] = $Folder[$i][1]
    			$FolderExist[3] = $Folder[$i][2]
    		EndIf
    	Next
    	If $opt Then
    	$sourcePointer = ""
    	Else
    	If $FileEx[0] > 1 Then
    		$sourcePointer = "00000000" & ConvertRez($lastFile[1] + $lastFile[2]) & ConvertRez(BinaryLen($sData)) & $sString & "00000000" & ConvertRez(StringToBinary($FileEx[UBound($FileEx) - 1])) & "00000000" & StringTrimLeft(StringToBinary($FileEx[1]), 2) & "0000"
    	Else
    		$sourcePointer = "00000000" & ConvertRez($lastFile[1] + $lastFile[2]) & ConvertRez(BinaryLen($sData)) & $sString & "00000000" & ConvertRez(StringToBinary($FileEx[UBound($FileEx) - 1])) & "00000000" & StringTrimLeft(StringToBinary($FileEx[1]), 2) & "0000"
    	EndIf
    	EndIf
    	$data = StringTrimLeft(FileRead($hFile, $sPointer1 - ($lastFile[1] + $lastFile[2])), 2)
    	FileWrite @desktopDir & "\test.txt", $data & @crlF)
    	If $FolderExist[0] Then
    		$data = StringLeft($data, (($FolderExist[2] + $FolderExist[3]) * 2) - (($lastFile[1] + $lastFile[2]) * 2)) & $sourcePointer & LawladdBytes(BinaryLen("0x" & $sourcePointer)) & StringRight($data, (StringLen($data)) - ((($FolderExist[2] + $FolderExist[3]) * 2) - (($lastFile[1] + $lastFile[2]) * 2)))
    		FileWrite @desktopDir & "\test.txt", $data & @crlF & @crlF)
    	EndIf
    	FileSetPos($hFile, $sPointer1, 0)
    	$FolderData = FileRead($hFile, FileGetSize($target) - $sPointer1)
    	If Not $FolderExist[0] Then
    		Do
    			$pos = StringInStr($FolderData, StringTrimLeft($sString, 2), 0, 1, $pos + 8) - 2
    			$FolderData = StringReplace($FolderData, StringTrimLeft(BinaryMid($FolderData, ($pos / 2) - 8, 4), 2), ConvertRez(Dec(ConvertRezBack(StringTrimLeft(BinaryMid($FolderData, $pos / 2 - 8, 4), 2))) + BinaryLen($sData)))
    		Until StringInStr($FolderData, StringTrimLeft($sString, 2), 0, 1, $pos + 8) <= 0
    	Else
    		Do
    			$pos = StringInStr($FolderData, $sString, 0, 1, $pos + 8)
    			If BinaryToString("0x" & StringMid($FolderData, $pos + 8, StringLen($FolderN) * 2)) = $FolderN Then
    				$FolderData = StringLeft($FolderData, $pos - 9) & ConvertRez(Dec(ConvertRezBack(StringMid($FolderData, $pos - 8, 8))) + BinaryLen("0x" & $sourcePointer)) & StringTrimLeft($FolderData, $pos - 1)
    			EndIf
    			$FolderData = StringLeft($FolderData, $pos - 17) & ConvertRez(Dec(ConvertRezBack(StringMid($FolderData, $pos - 16, 8))) + BinaryLen($sData)) & StringTrimLeft($FolderData, $pos - 9)
    		Until StringInStr($FolderData, StringTrimLeft($sString, 2), 0, 1, $pos + 8) <= 0
    	EndIf
    	If $FolderExist[0] = False Then $FolderString = "01000000" & ConvertRez($lastFolder[1] + ($lastFolder[2] * 2) + BinaryLen($sData)) & ConvertRez(BinaryLen("0x" & $sourcePointer)) & $sString & StringTrimLeft(StringToBinary($FolderN), 2) & "00"
    	$sourcePointer &= LawladdBytes(BinaryLen("0x" & $sourcePointer))
    	FileSetPos($hFile, 0, 0)
    	_FileCreate($target & "new")
    	$hnFile = FileOpen($target & "new", 1)
    	If Not $fileexist Then
    		FileWrite($hnFile, BinaryToString(FileRead($hFile, 199) & ConvertRez($sPointer1 + BinaryLen($sData) + BinaryLen("0x" & $sourcePointer)) & ConvertRez($lPointer1 + BinaryLen("0x" & $FolderString))))
    		FileSetPos($hFile, 199 + 8, 0)
    		FileWrite($hnFile, BinaryToString(FileRead($hFile, ($lastFile[1] + $lastFile[2]) - 199 - 8)))
    		FileWrite($hnFile, BinaryToString($sData))
    		FileWrite($hnFile, BinaryToString("0x" & $data))
    		If $FolderExist[0] = False Then
    			If Not $opt Then FileWrite($hnFile, BinaryToString("0x" & $sourcePointer))
    			FileWrite($hnFile, BinaryToString($FolderData & $FolderString))
    		Else
    			FileWrite($hnFile, BinaryToString($FolderData))
    		EndIf
    		FileClose($hnFile)
    		FileClose($hFile)
    
    	Else
    		FileWrite($hnFile, BinaryToString(FileRead($hFile, 199) & ConvertRez($sPointer1 + BinaryLen($sData) + BinaryLen("0x" & $sourcePointer)) & ConvertRez($lPointer1 + BinaryLen("0x" & $FolderString))))
    		FileSetPos($hFile, 199 + 8, 0)
    		$i = 0
    		Do
    			$i += 1
    			FileWrite($hnFile, BinaryToString(FileRead($hFile, 1) - 199 - 8))
    			FileSetPos($hFile, 199 + 8 + $i, 0)
    		Until $i = $lastFile[1] + $lastFile[2]
    		FileWrite($hnFile, BinaryToString($sData))
    		FileWrite($hnFile, BinaryToString("0x" & $data))
    		If $FolderExist[0] = False Then
    			If Not $opt Then FileWrite($hnFile, BinaryToString("0x" & $sourcePointer))
    			FileWrite($hnFile, BinaryToString($FolderData & $FolderString))
    		Else
    			FileWrite($hnFile, BinaryToString($FolderData))
    		EndIf
    		FileClose($hnFile)
    		FileClose($hFile)
    	EndIf
    EndFunc   ;==>LawlInjectFile
    
    Func LawladdBytes($size)
    	Local $Ret = ""
    	For $i = 1 To $size Step 1
    		$Ret &= "00"
    	Next
    	Return $Ret
    EndFunc   ;==>LawladdBytes
    
    Func isCARunning()
    	If ProcessExists("Engine.exe") Then Return True
    	Return False
    EndFunc   ;==>isCARunning
    
    Func RezOpen($path)
    	$Folder = LawlReadRez($path, 1)
    	If IsArray($Folder) Then
    		;del all
    		ReDim $Mainitems[1][9]
    		ReDim $ChildItems[1][5]
    		ReDim $mainview[2]
    		$xAddChild = 0
    		_GUICtrlTreeView_DeleteAll($treeview)
    		$Name = _PathToFilename($path)
    		$mainview[0] = GUICtrlCreateTreeViewItem($Name[1] & "." & $Name[2], $treeview)
    		$mainview[1] = GUICtrlCreateContextMenu($treeview)
    		$Mainitems[0][2] = GUICtrlCreateContextMenu($mainview[0])
    		$Mainitems[0][3] = GUICtrlCreateMenuItem("Inject Folder", $Mainitems[0][2])
    		$Mainitems[0][4] = GUICtrlCreateMenuItem("Create Folder", $Mainitems[0][2])
    		For $i = 1 To $Folder[0][0] Step 1
    			ReDim $Mainitems[$i + 1][9]
    			$Mainitems[0][0] = $Folder[0][0]
    			$Mainitems[$i][1] = $Folder[$i][0]
    			$Mainitems[$i][2] = $Folder[$i][1]
    			$Mainitems[$i][3] = $Folder[$i][2]
    			$Mainitems[$i][0] = GUICtrlCreateTreeViewItem($Folder[$i][0], $mainview[0])
    			GUICtrlSetColor($Mainitems[$i][0], 0x0000C0)
    			$files = LawlReadRez($path, 0, $Folder[$i][1], $Folder[$i][2])
    			$ChildItems[0][0] += $files[0][0]
    			For $b = 1 To $files[0][0] Step 1
    				$x = 0
    				$xAddChild += 1
    				ReDim $ChildItems[$xAddChild + 1][5]
    				$ChildItems[$xAddChild][1] = $files[$b][0]
    				$ChildItems[$xAddChild][2] = $files[$b][1]
    				$ChildItems[$xAddChild][3] = $files[$b][2]
    				$ChildItems[$xAddChild][4] = $Mainitems[$i][1]
    				$ChildItems[$xAddChild][0] = GUICtrlCreateTreeViewItem($files[$b][0], $Mainitems[$i][0])
    				If Not StringInStr($files[$b][0], ".") Then GUICtrlSetColor($ChildItems[$xAddChild][0], 0x0000C0)
    			Next
    		Next
    		$i = 0
    		Do
    			$i += 1
    			If StringInStr($ChildItems[$i][1], ".") = False Then
    				ReDim $Mainitems[UBound($Mainitems) + 1][9]
    				$Mainitems[UBound($Mainitems) - 1][0] = $ChildItems[$i][0]
    				$Mainitems[UBound($Mainitems) - 1][1] = $ChildItems[$i][1]
    				$Mainitems[UBound($Mainitems) - 1][2] = $ChildItems[$i][2]
    				$Mainitems[UBound($Mainitems) - 1][3] = $ChildItems[$i][3]
    				$Mainitems[UBound($Mainitems) - 1][8] = $ChildItems[$i][4]
    				$cFiles = LawlReadRez($path, 0, $ChildItems[$i][2], $ChildItems[$i][3])
    				For $x = 1 To $cFiles[0][0] Step 1
    					ReDim $ChildItems[UBound($ChildItems) + 1][5]
    					$ChildItems[UBound($ChildItems) - 1][1] = $cFiles[$x][0]
    					$ChildItems[UBound($ChildItems) - 1][2] = $cFiles[$x][1]
    					$ChildItems[UBound($ChildItems) - 1][3] = $cFiles[$x][2]
    					$ChildItems[UBound($ChildItems) - 1][4] = $ChildItems[$i][4] & "\" & $ChildItems[$i][1]
    					If StringInStr($cFiles[$x][0], ".") Then
    						$ChildItems[UBound($ChildItems) - 1][0] = GUICtrlCreateTreeViewItem($cFiles[$x][0], $ChildItems[$i][0])
    					Else
    						$ChildItems[UBound($ChildItems) - 1][0] = GUICtrlCreateTreeViewItem($cFiles[$x][0], $ChildItems[$i][0])
    						GUICtrlSetColor($ChildItems[UBound($ChildItems) - 1][0], 0x0000C0)
    					EndIf
    				Next
    			EndIf
    		Until $i = UBound($ChildItems) - 1
    		$ChildItems[0][0] = UBound($ChildItems) - 1
    		$Mainitems[0][0] = UBound($Mainitems) - 1
    		GUICtrlSetState($mainview[0], BitOR($GUI_EXPAND, $GUI_DEFBUTTON))
    	EndIf
    	For $i = 1 To $Mainitems[0][0] Step 1
    		$Mainitems[$i][4] = GUICtrlCreateContextMenu($Mainitems[$i][0])
    		$Mainitems[$i][5] = GUICtrlCreateMenuItem("Extract selected File / Folder", $Mainitems[$i][4])
    		If Not $Mainitems[$i][8] Then
    			$Mainitems[$i][7] = GUICtrlCreateMenuItem("Inject File /s in this Folder", $Mainitems[$i][4])
    		Else
    			$Mainitems[$i][7] = GUICtrlCreateMenuItem("Inject File /s in this Folder - Alpha (may not working)", $Mainitems[$i][4])
    			GUICtrlSetState($Mainitems[$i][7], $GUI_DISABLE)
    		EndIf
    		$Mainitems[$i][6] = GUICtrlCreateMenuItem("Create Folder - Alpha (may not working)", $Mainitems[$i][4])
    		GUICtrlSetState($Mainitems[$i][6], $GUI_DISABLE)
    
    	Next
    	Return $Name
    EndFunc   ;==>RezOpen
    
    Func RezCreateFolder($path, $FolderInfo = 0)
    	LawlInjectFile("", $path, InputBox("Folder Name", "Name:", "", "", 250, 120), 1)
    	FileDelete($path)
    	FileMove($path & "new", $path)
    EndFunc   ;==>RezCreateFolder
    #cs
    Func CheckUpdates()
    	If Not (FileGetSize @sCripTFullPath) = InetGetSize("https://-removed-/download/LawlRez.exe")) Then
    		If Not Run @sCripTDir & "\LawlRezUpdater.exe") Then Return MsgBox(0, "Error", "Bitte Laden sie sich den LawlRezUpdater, um an die aktuelle Version von LawlRez zu kommen")
    		Exit
    	EndIf
    EndFunc   ;==>CheckUpdates
    #ce
    
    Func _GetDTXTyp($dtxpath)
    	$hdtxfile = FileOpen($dtxpath, 16)
    	if FileRead($hdtxfile, 13) = "0x00000000FBFFFFFF8000800004" Then
    		FileClose($hdtxfile)
    		Return "LithTech"
    	Else
    		FileClose($hdtxfile)
    		Return "Nexon"
    	EndIf
    EndFunc


    But If you use it, give credits @Lawliet!

    thx
    <b>Downloadable Files</b> Downloadable Files

  2. #2
    gotter's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    Minecraft snowy Biome
    Posts
    360
    Reputation
    6
    Thanks
    153
    Thank you for that!
    Last edited by gotter; 08-08-2012 at 09:36 PM.

  3. #3
    iMaxxx's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    57
    Reputation
    10
    Thanks
    82
    It was a lie^^

  4. #4
    Drake's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Belgium,Oost-Vlaanderen
    Posts
    12,680
    Reputation
    1801
    Thanks
    4,929
    / Approved

  5. #5
    .REZ's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Location
    Real life
    Posts
    10,385
    Reputation
    1110
    Thanks
    2,218
    My Mood
    Psychedelic
    Not a mod, goes to discussion.
    /moved

  6. #6
    Password77's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Canada, ON
    Posts
    179
    Reputation
    10
    Thanks
    181
    My Mood
    Cheerful
    Quote Originally Posted by .REZ View Post
    Not a mod, goes to discussion.
    /moved
    You moved it to help discussion, wouldn't this fit in Source code O.o
    Doing more Java and Python
    Need help with your hack? Ask me, I will try to help you with all my might .

  7. #7
    .REZ's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Location
    Real life
    Posts
    10,385
    Reputation
    1110
    Thanks
    2,218
    My Mood
    Psychedelic
    Quote Originally Posted by Password77 View Post
    You moved it to help discussion, wouldn't this fit in Source code O.o
    Coding help/discussion. Its fine.

Similar Threads

  1. [Release] LawlRez - Rez Tool by Lawliet!
    By iMaxxx in forum Combat Arms Mods & Rez Modding
    Replies: 26
    Last Post: 08-09-2012, 09:29 AM