monoceres 190 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 Hide monoceres's signature Hide all signatures Broken link? PM me and I'll send you the file! Share this post Link to post Share on other sites
ptrex 89 Posted January 8, 2009 @monoceres Tested and approved. Very nice as usual !! regards, ptrex Hide ptrex's signature Hide all signatures 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 - 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 Share this post Link to post Share on other sites
James 376 Posted January 8, 2009 I tested this too Works well, not sure when I will need it though. Are there any limitations? Hide James's signature Hide all signatures Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Share this post Link to post Share on other sites
JRSmile 17 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 Hide JRSmile's signature Hide all signatures $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:-) Share this post Link to post Share on other sites
monoceres 190 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 Hide monoceres's signature Hide all signatures Broken link? PM me and I'll send you the file! Share this post Link to post Share on other sites
wraithdu 79 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 Share this post Link to post Share on other sites
Andreik 63 Posted January 9, 2009 Nice work, monoceres. Hide Andreik's signature Hide all signatures When the words fail... music speaks Share this post Link to post Share on other sites
monoceres 190 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" Hide monoceres's signature Hide all signatures Broken link? PM me and I'll send you the file! Share this post Link to post Share on other sites
wraithdu 79 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. Share this post Link to post Share on other sites
monoceres 190 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 Hide monoceres's signature Hide all signatures Broken link? PM me and I'll send you the file! Share this post Link to post Share on other sites
wraithdu 79 Posted January 9, 2009 No biggie. Keep up the great work! Share this post Link to post Share on other sites
monoceres 190 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 ? 1 matwachich reacted to this Hide monoceres's signature Hide all signatures Broken link? PM me and I'll send you the file! Share this post Link to post Share on other sites
trancexx 982 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 Hide trancexx's signature Hide all signatures ♡♡♡ . eMyvnE Share this post Link to post Share on other sites
Xand3r 0 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 Hide Xand3r's signature Hide all signatures 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 Share this post Link to post Share on other sites
monoceres 190 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. Hide monoceres's signature Hide all signatures Broken link? PM me and I'll send you the file! Share this post Link to post Share on other sites
goldenix 1 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() Hide goldenix's signature Hide all signatures 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] Share this post Link to post Share on other sites
prazetto 11 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? Hide prazetto's signature Hide all signatures # Button. Progressbar - Graphical AutoIt3 Control (UDF) # GTK on AutoIt3 - GTK+ Framework | Widgets Share this post Link to post Share on other sites
flashlab 1 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 Share this post Link to post Share on other sites
Ximorro 0 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... Share this post Link to post Share on other sites
Ward 109 Posted June 8, 2011 Try my zlib UDF, uncompressed size is not needed. Hide Ward's signature Hide all signatures 新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了。 Share this post Link to post Share on other sites