monoceres Posted January 7, 2009 Share Posted January 7, 2009 (edited) I wrote this because I wanted a simple way to compress data in memory instead of files.And because rasim has done an excellent job with his 7Zip udf that handle files I did not include any file support.Following functions exists:_Zlib_Version()_Zlib_Shutdown()_Zlib_Startup($Filename = "zlibwapi.dll")_Zlib_CalculateAdler32($DataPtr, $DataSize)_Zlib_Uncompress($CompressedPtr, $CompressedSize, $UncompressedPtr, $UncompressedSize)_Zlib_Compress($InBufferPtr, $InBufferSize, $OutBufferPtr, ByRef $OutBufferSize, $CompressionLevel = $Z_DEFAULT_COMPRESSION)_Zlib_CompressBinary($binary, $CompressionLevel = $Z_DEFAULT_COMPRESSION)_Zlib_UncompressBinary($compressedbinary, $UncompressedBinaryLength)More info in the UDF.Example:#include "zlib udf.au3" _Zlib_Startup() $bin=StringToBinary("hahahahahahahahahahahehe") $binlen=BinaryLen($bin) $compressed=_Zlib_CompressBinary($bin) $uncompressed=_Zlib_UncompressBinary($compressed,$binlen) MsgBox(64,BinaryToString($bin),"Original:"&@CRLF&$bin&@CRLF&@CRLF&"Compressed: "&@CRLF&$compressed&@CRLF&@CRLF&"Uncompressed: "&@CRLF&$uncompressed) _Zlib_Shutdown()Download:zlib_udf.au3Previous downloads: 33Zlib dll download:http://www.zlib.net/ Ps. If anyone want to continue adding functions to this, go ahead I won't probably work anymore one this anyway Edited January 9, 2009 by monoceres mLipok 1 Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
ptrex Posted January 8, 2009 Share Posted January 8, 2009 @monoceres Tested and approved. Very nice as usual !! regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
James Posted January 8, 2009 Share Posted January 8, 2009 I tested this too Works well, not sure when I will need it though. Are there any limitations? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
JRSmile Posted January 8, 2009 Share Posted January 8, 2009 (edited) WOW i already thought of a way to include more dll sources in binary string form in my sources but lower the size.. this is the perfect way to do so, THANK YOU VERY MUCH. Edited January 8, 2009 by JRSmile $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
monoceres Posted January 9, 2009 Author Share Posted January 9, 2009 Thanks guys @James As far as I know there are just the regular autoit limitations @JRSmile Yeah, compressin' stuff directly in memory is so much cooler than those pesky files Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
wraithdu Posted January 9, 2009 Share Posted January 9, 2009 (edited) Figured I'd test this out. I'm not sure what version everyone is using, but I just downloaded v1.2.3, and the function calls use cdecl, so the UDF crashes in current form. And the filename is zlib1.dll. Edited January 9, 2009 by wraithdu Link to comment Share on other sites More sharing options...
Andreik Posted January 9, 2009 Share Posted January 9, 2009 Nice work, monoceres. Link to comment Share on other sites More sharing options...
monoceres Posted January 9, 2009 Author Share Posted January 9, 2009 Figured I'd test this out. I'm not sure what version everyone is using, but I just downloaded v1.2.3, and the function calls use cdecl, so the UDF crashes in current form. And the filename is zlib1.dll.I'm using the one from zlib.net and it's named zlibwapi.dll (_Zlib_Startup has an optional parameter specifying the dll name though). I'm also pretty sure that the __stdcall calling convention is used because when I called the dll from a vc++ app with the cdecl calling convention the app crashed and the debugger whined about "wrong calling convention used" Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
wraithdu Posted January 9, 2009 Share Posted January 9, 2009 Yeah, that's weird. I downloaded it just last night from the link in your first post. I know you know what you're talking about, so it's strange.Here's the link I used - http://www.zlib.net/zlib123-dll.zipIt has the different filename and calling convention. Link to comment Share on other sites More sharing options...
monoceres Posted January 9, 2009 Author Share Posted January 9, 2009 (edited) Yeah, that's weird. I downloaded it just last night from the link in your first post. I know you know what you're talking about, so it's strange.Here's the link I used - http://www.zlib.net/zlib123-dll.zipIt has the different filename and calling convention.You're right I downloaded the dll from here:http://www.winimage.com/zLibDll/Very stupid mistake and I will update the UDF to use the standard dll from the official zlib website Edit: Done! Edited January 9, 2009 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
wraithdu Posted January 9, 2009 Share Posted January 9, 2009 No biggie. Keep up the great work! Link to comment Share on other sites More sharing options...
monoceres Posted January 9, 2009 Author Share Posted January 9, 2009 I'm thinking of changing the behaviour of _Zlib_CompressBinary so it adds a 4 byte header that contains the length of the original data, any thoughts of that? It would be much easier to use the compressed data in your script if you don't have to pass around the original length all the time ? matwachich 1 Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
trancexx Posted January 10, 2009 Share Posted January 10, 2009 (edited) This is nice and useful. btw, I think I found native api compression method available. Uses LZW algorithm. edit: ... ok, I got it. Will make new thread not to be offtopic here. Edited January 10, 2009 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Xand3r Posted December 4, 2009 Share Posted December 4, 2009 Any ideea why _Zlib_CompressBinary(0xff00ff00,9); (0x78DA63F8CFF09F010005FF01FF) returns a different value than php's gzcompress ? php: echo bin2hex(gzcompress(convert('ff00ff00'),9)); function convert($hexString) // converts a hexstring to a binary string { $hexLenght = strlen($hexString); // only hex numbers is allowed if ($hexLenght % 2 != 0 || preg_match("/[^\da-fA-F]/",$hexString)) return FALSE; unset($binString); for ($x = 1; $x <= $hexLenght/2; $x++) { $binString .= chr(hexdec(substr($hexString,2 * $x - 2,2))); } return $binString; } // php output: 0x78dafbcff09f010005fe01ff Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
monoceres Posted December 4, 2009 Author Share Posted December 4, 2009 Any ideea why _Zlib_CompressBinary(0xff00ff00,9); (0x78DA63F8CFF09F010005FF01FF) returns a different value than php's gzcompress ? The data is not 9 bytes long. It's an integer so it's 4 bytes. You might also want to use a binary string in autoit as well. "0xff00ff00" is the way to do it. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
goldenix Posted March 7, 2010 Share Posted March 7, 2010 This is my Code I tried & it results in -3 What does -3 mean? #include <INet.au3> #include "zlib_udf.au3" _Zlib_Startup() $bin=_INetGetSource('http://g.e-hentai.org/non-h') $binlen=BinaryLen($bin) $uncompressed=_Zlib_UncompressBinary($bin,$binlen) ConsoleWrite($uncompressed & @CRLF & @CRLF) _Zlib_Shutdown() My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
prazetto Posted November 5, 2010 Share Posted November 5, 2010 Thats have incompatibilities with general zlib. If you try to using gz_uncompress($string) in php or using other zlib library will give you uncompressed data plus sign: "?". For example: Compress this string with script. "The quick brown fox jumped over the lazy dog." will output decompressed data in other decompressor program: "The quick brown fox jumped over the lazy dog.?" I'm saw in hex editor and compare output of your script and general zlib output and in a few last byte are differs. So here is my problem. Oh man do you have problem solving? # Button. Progressbar - Graphical AutoIt3 Control (UDF) # GTK on AutoIt3 - GTK+ Framework | Widgets cig computer instruction graphics http://code.hstn.me Link to comment Share on other sites More sharing options...
flashlab Posted February 2, 2011 Share Posted February 2, 2011 This is my Code I tried & it results in -3 What does -3 mean? #include <INet.au3> #include "zlib_udf.au3" _Zlib_Startup() $bin=_INetGetSource('http://g.e-hentai.org/non-h') $binlen=BinaryLen($bin) $uncompressed=_Zlib_UncompressBinary($bin,$binlen) ConsoleWrite($uncompressed & @CRLF & @CRLF) _Zlib_Shutdown() '$bin' in '$binlen=BinaryLen($bin)' should be the size of original data Link to comment Share on other sites More sharing options...
Ximorro Posted June 6, 2011 Share Posted June 6, 2011 Hi monoceres. Good work, simple and effective solution! Did you implemented your idea about storing uncompressed data size? It's very strange the DLL needs that information, is there any other call in the library that doesn't have that requirement? It's very limited, to decompress you must now the size of the original data, it's almost as having to know the original data itself... Link to comment Share on other sites More sharing options...
Ward Posted June 8, 2011 Share Posted June 8, 2011 Try my zlib UDF, uncompressed size is not needed. 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 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