cppman Posted October 7, 2006 Share Posted October 7, 2006 (edited) Added better example If the files that you pack are big (perhaps above 300kb) be perpared to spend your afternoon.... waiting lol.Here is a little program I wrote so that you can protect files that your program uses, such as: Images, Music Files, Text Files, and more. It packs together as one file, and all you need to do is call, _pacExtractFile("main_package_name.pac", "original_filename.ext", "outputname.ext") and it extracts the file to the specified location.Using the Pacme program is pretty self explanatory but i'll explain...All you need to do, is click, "Add File", and then choose the file you want to be in your package. And if you no longer want that file, all you need to do is click, Remove File.After you have gotten all the files you want in the package, Click, Make Package, and it will let you name your package, and save it to the specified file. From there you can do whatever you'd like with the file. Pacme.au3 - Main File.expandcollapse popup#include <GUIConstants.au3> #include <GUIlist.au3> ;#include <file.au3> #include "pack_data.au3" ;File Packager #cs 1) Write first line information. Package Name @ Amount of Files 2) Write seconds line information FileName1 | FileName2 | FileName3 | FileName4 | FileName5 #ce $hWinHandle = GUICreate("File Packager", 320, 327, 343, 140) $hFileList = GUICtrlCreateList("", 11, 26, 293, 214) $hTitle = GUICtrlCreateLabel("File Packager", 116, 9, 69, 17) $hAddFileButton = GUICtrlCreateButton("Add File", 12, 242, 124, 25, 0) $hRemoveFileButton = GUICtrlCreateButton("Remove File", 177, 242, 124, 25, 0) $hMakePackageButton = GUICtrlCreateButton("Make Package", 36, 289, 238, 28, 0) GUISetState() Global $nItemCount = 0 While (1) $nMsg = GUIGetMsg() Select Case $nMsg = $hAddFileButton Local $fFile = FileOpenDialog("Choose a file", @ScriptDir, "All Files(*.*)") _GUICtrlListAddItem($hFileList, $fFile) $nItemCount += 1 Case $nMsg = $hRemoveFileButton Local $nIndex = _GUICtrlListGetCaretIndex($hFileList) _GUICtrlListDeleteItem($hFileList, $nIndex) $nItemCount -= 1 Case $nMsg = $hMakePackageButton if ($nItemCount <= 0) Then MsgBox(0, "", "No files to work with.") ContinueLoop EndIf $sOutputFile = FileSaveDialog("Output file", @ScriptDir, "Package Files(*.pac)") & ".pac" $sPackageName = InputBox("Package Name", "Enter the package's name. (e.g. My Files)", "MyPackage") ;Build the package. SplashTextOn("Generating File", "Please wait while the package is made. " & @CRLF & " It may take a few moments.") _pacFileWriteData($sOutputFile, _pacHeaderEncode($sPackageName & "@" & $nItemCount)& @CRLF) ;Write the header. Local $avFiles[$nItemCount] For $i = 0 to $nItemCount-1 $avFiles[$i] = _GUICtrlListGetText($hFileList, $i) _pacFileWRiteData($sOutputFile, _pacHeaderEncode($avFiles[$i] & "|")) ;File information Next _pacFileWriteData($sOutputFile, @CRLF) ;Now we need to write the actual data contents. For $i = 0 to $nItemCount-1 $sData = _pacFileGetData($avFiles[$i]) $sFileName = StringSplit($avFiles[$i], "\") _pacFileWriteData($sOutputfile, @CRLF&_pacHeaderDecode("%$CFHJO`GJMF>")&_pacHeaderEncode($sFileName[$sFileName[0]]) & @CRLF) _pacFileWriteData($sOutputFile, _StringToHex($sData)) _pacFileWriteData($sOutputfile, @CRLF & "~~~~~~~#END_FILE=" & _pacHeaderEncode($sFileName[$sFileName[0]]) & @CRLF) Next SplashOff() MsgBox(0, "", "Complete!") Case $nMsg = -3 Exit EndSelect WEnd oÝ÷ ÚÖi«·"w%¹×WºÚ"µÍÚ[ÛYH Ù[K]LÉÝÂÚ[ÛYH ÜÝ[Ë]LÉÝÂÚ[ÛYH Ø^K]LÉÝÂ×ÜXÑ^XÝ[J ][ÝÛÝ]]XÉ][ÝË ][ÝÚ[][[[YK^ ][ÝË ][ÝÛÝ]]^ ][ÝÊBÐÛ] ÜXÒXY[ÛÙJ ][ÝßÌÍÈÐQÒSÑSOI][ÝÊJB[ÈÜXÑ^XÝ[J ÌÍÜÔXÑ[K ÌÍÜÒ[[S[YK ÌÍÜÓÝ][S[YJBIÌÍÜÐÛÛQ[S[YHH ][ÝßÌÍÈÐQÒSÑSOI][ÝÈ [ÈÜXÒXY[ÛÙJ ÌÍÜÒ[[S[YJBIÌÍÜÐÛÛQ[[S[YHH ][ÝßÑSÑSOI][ÝÈ [ÈÜXÒXY[ÛÙJ ÌÍÜÒ[[S[YJBSØØ[ ÌÍÛÝ[HHSØØ[ ÌÍÛ[[HHSØØ[ ÌÍØ][ÂWÑ[TXYÐ^J ÌÍÜÔXÑ[K ÌÍØ][ÊBZYÝ Ð^J ÌÍØ][ÊJH[]LBQÂBIÌÍÛÝ[H ÏHBU[[ ÌÍØ][ÖÉÌÍÛÝ[WHOH ÌÍÜÐÛÛQ[S[YJBQÂBIÌÍÛ[[H ÏHBU[[ ÌÍØ][ÖÉÌÍÛ[[WHOH ÌÍÜÐÛÛQ[[S[YJBSØØ[ ÌÍÜÑ]HH ÌÍÛÝ[JÌBIÌÍÛÝ]H[SÜ[ ÌÍÜÓÝ][S[YKJBQ[UÜ]J ÌÍÛÝ]Ò^ÔÝ[Ê ÌÍØ][ÖÉÌÍÜÑ]WJJBQ[PÛÜÙJ ÌÍÛÝ] BZY ÜH[]LB] ÌÍÜÓÝ][S[YB[[Â[ÈÜXÑ[QÙ]]J ÌÍÜÑ[JBSØØ[ ÌÍÚ[HH[SÜ[ ÌÍÜÑ[K BSØØ[ ÌÍÜÐÛÛ[ÈH[TXY ÌÍÚ[JBZY ÜH[]LBQ[PÛÜÙJ ÌÍÚ[JBT] ÌÍÜÐÛÛ[ÊB[[Â[ÈÜXÑ[UÜ]Q]J ÌÍÜÓÝ]][K ÌÍÜÑ]JBSØØ[ ÌÍÚ[HH[SÜ[ ÌÍÜÓÝ]][KJBQ[UÜ]J ÌÍÚ[K[TÝ[Ê ÌÍÜÑ]JJBQ[PÛÜÙJ ÌÍÚ[JBZY ÜH[]LBT][[Â[ÈÜXÒXY[ÛÙJ ÌÍÜÑ]JBØØ[ ÌÍÜÝHÝ[ÔÜ] ÌÍÜÑ]K ][ÝÉ][ÝÊBØØ[ ÌÍÜ]Ý[ÈH ][ÝÉ][ÝÂÜ ÌÍÚHHHÈ ÌÍÜÝÌBY ØÊ ÌÍÜÝÉÌÍÚWJHOHMJH[ ÌÍÜ]Ý[È [ÏHÚØÊ JB[ÙB ÌÍÜ]Ý[È [ÏHÚØÊ ÌÍÜÝÉÌÍÚWJJÌJB[Y^] ÌÍÜ]Ý[Â[[Â[ÈÜXÒXYXÛÙJ ÌÍÜÑ]JBØØ[ ÌÍÜÝHÝ[ÔÜ] ÌÍÜÑ]K ][ÝÉ][ÝÊBØØ[ ÌÍÜ]Ý[ÈH ][ÝÉ][ÝÂÜ ÌÍÚHHHÈ ÌÍÜÝÌBY ØÊ ÌÍÜÝÉÌÍÚWJHOH H[ ÌÍÜ]Ý[È [ÏHÚØÊMJJB[ÙB ÌÍÜ]Ý[È [ÏHÚØÊ ÌÍÜÝÉÌÍÚWJKLJB[Y^] ÌÍÜ]Ý[Â[[Âand here you can download the zip version of it. Includes an example Edited October 8, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
spyrorocks Posted October 7, 2006 Share Posted October 7, 2006 Looks cool. Good idea:) [center] My Projects: Online AutoIt Compiler - AutoForum - AutoGuestbook - AutoIt Web-based Auto Installer - Pure AutoIt Zipping Functions - ConfuseGen - MindReader - P2PChat[/center] Link to comment Share on other sites More sharing options...
RazerM Posted October 7, 2006 Share Posted October 7, 2006 I was thinking about doing something like this but never got round to it. This is really good. I noticed that you do not check to see if $sInFileName exists in the package. This can be done by adding one line to _pacExtractFile: Func _pacExtractFile($sPacFile, $sInFileName, $sOutFileName) $sCompareFileName = "~~~~~~~~~~~~~~~~~~~~~~~$#BEGIN_FILE=" & _pacHeaderEncode($sInFileName) $sCompareEndFileName = "~~~~~~~#END_FILE=" & _pacHeaderEncode($sInFileName) Local $nStartLine = 0 Local $nEndLine = 0 Local $avLines _FileReadToArray($sPacFile, $avLines) if not (IsArray($avLines)) Then return -1 Do $nStartLine += 1 If $nStartLine = UBound($avLines) Then Return -1 ;file does not exist Until ($avLines[$nStartLine] == $sCompareFileName) Do $nEndLine += 1 Until ($avLines[$nEndLine] == $sCompareEndFileName) Local $sData = $nStartLine+1 $out = FileOpen($sOutFileName, 1) FIleWrite($out, _HexToString($avLines[$sData])) FileClose($out) if (@error) then return -1 return $sOutFileName EndFunc My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
cppman Posted October 7, 2006 Author Share Posted October 7, 2006 Thanks. Updated first post. Miva OS Project Link to comment Share on other sites More sharing options...
themax90 Posted October 8, 2006 Share Posted October 8, 2006 This is similar in nature to my AgentEncrypt which people didn't take on to all that well. I used FileInstall with AutoIt as my method and an inputbox with encrypted pasword. Link to comment Share on other sites More sharing options...
cppman Posted October 8, 2006 Author Share Posted October 8, 2006 (edited) This is similar in nature to my AgentEncrypt which people didn't take on to all that well. I used FileInstall with AutoIt as my method and an inputbox with encrypted pasword.That's not what this does. lol (well yeah. The general concept i guess) This makes a package of all the files you included. Similiar to that of a zip file, except it does not compress the data. Then you can use the function: _pacExtractFile($pacfile, $inFile, $outFile) to extract the specified file. And just treat the file that was extracted normally.. like: $temp_name = _TempName() $file = _pacExtractFile("DataRunner.pac", "clown.bmp", @TempDir&"\"&$temp_name) GUICtrlCreatePic($file, 32, 32) Just something like that Edited October 8, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
layer Posted October 8, 2006 Share Posted October 8, 2006 this looks really neat FootbaG Link to comment Share on other sites More sharing options...
dandymcgee Posted October 8, 2006 Share Posted October 8, 2006 No offense, but isn't that EXACTLY what the built in windows tool "iexpress" does? Search you computer for a file called "iexpress.exe". It should be in the System32 folder. Let me know if I'm wrong... - Dan [Website] Link to comment Share on other sites More sharing options...
cppman Posted October 8, 2006 Author Share Posted October 8, 2006 (edited) somewhat... Iexpress actually builds somewhat of an installer. This is used for extracting data from within YOUR program. You can use the function _pacExtractFile() to get the file from in your program, then delete it when done using it. If you try out the game called in the examples, it will explain it better than I can... Edited October 8, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
spyrorocks Posted October 8, 2006 Share Posted October 8, 2006 I just might use this in the future. [center] My Projects: Online AutoIt Compiler - AutoForum - AutoGuestbook - AutoIt Web-based Auto Installer - Pure AutoIt Zipping Functions - ConfuseGen - MindReader - P2PChat[/center] Link to comment Share on other sites More sharing options...
gamerman2360 Posted October 8, 2006 Share Posted October 8, 2006 Your adding 1 to each byte? Bytes only go up to 255.Asc(Chr(256)); Returns 0Just need something to change bytes that are 255 to 0 in _pacHeaderEncode() and the inverse in _pacHeaderDecode(). Unless, of course, I've missed something. Other than that, this is very cool. Link to comment Share on other sites More sharing options...
cppman Posted October 8, 2006 Author Share Posted October 8, 2006 Your adding 1 to each byte? Bytes only go up to 255.Asc(Chr(256)); Returns 0Just need something to change bytes that are 255 to 0 in _pacHeaderEncode() and the inverse in _pacHeaderDecode(). Unless, of course, I've missed something. Other than that, this is very cool.Thanks. Fixed that Miva OS Project Link to comment Share on other sites More sharing options...
gamerman2360 Posted October 8, 2006 Share Posted October 8, 2006 Well, then you have things going to 255(from 254), and things staying at 255... I ment something like:Func _pacHeaderEncode($sData) Local $str = StringSplit($sData, "") Local $retString = "" For $i = 1 to $str[0] if (Asc($str[$i]) == 255) Then $retString &= Chr(Asc(0)) Else $retString &= Chr(Asc($str[$i])+1) EndIf Next Return $retString EndFunc Func _pacHeaderDecode($sData) Local $str = StringSplit($sData, "") Local $retString = "" For $i = 1 to $str[0] if (Asc($str[$i]) == 0) Then $retString &= Chr(Asc(255)) Else $retString &= Chr(Asc($str[$i])-1) EndIf Next Return $retString EndFunc Link to comment Share on other sites More sharing options...
cppman Posted October 8, 2006 Author Share Posted October 8, 2006 Well, then you have things going to 255(from 254), and things staying at 255... I ment something like:Func _pacHeaderEncode($sData) Local $str = StringSplit($sData, "") Local $retString = "" For $i = 1 to $str[0] if (Asc($str[$i]) == 255) Then $retString &= Chr(Asc(0)) Else $retString &= Chr(Asc($str[$i])+1) EndIf Next Return $retString EndFunc Func _pacHeaderDecode($sData) Local $str = StringSplit($sData, "") Local $retString = "" For $i = 1 to $str[0] if (Asc($str[$i]) == 0) Then $retString &= Chr(Asc(255)) Else $retString &= Chr(Asc($str[$i])-1) EndIf Next Return $retString EndFuncoh. Thx. Miva OS Project Link to comment Share on other sites More sharing options...
CoePSX Posted October 14, 2006 Share Posted October 14, 2006 Actually, Isn't Chr(Asc(255)) the same as Chr(255)? The way I see, the second way is faster because it only calls one function. [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font] Link to comment Share on other sites More sharing options...
cppman Posted October 14, 2006 Author Share Posted October 14, 2006 hmm, yeah. i did'nt even notice that Miva OS Project Link to comment Share on other sites More sharing options...
gamerman2360 Posted October 14, 2006 Share Posted October 14, 2006 Lol, I didn't notice that either... Chr(Asc(255)).. Asc(string) must have gotten the ascii value for 2(first character of the number converted to a string). Then Chr(number) would alwas return with 2... Oops. Link to comment Share on other sites More sharing options...
jpam Posted October 18, 2006 Share Posted October 18, 2006 CHRIS95219 is it possible to disable the encryption routine ? jpam Link to comment Share on other sites More sharing options...
=sinister= Posted November 22, 2006 Share Posted November 22, 2006 Wow, this is one of the best scripts i've ever seen! Great idea! It's very useful to me. I've come up with a few features there could and should be added. (You should consider continuing with this script, it's great!) -Progress bar -Faster compilation I have a 400kb dll I want compiled, yet it's taking forever, and i'm impatient, but still it's great. Keep up the good work! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now