Any Windows External coders out there?

Trevor DeVore trevor at mangomultimedia.com
Wed Jun 4 02:46:01 EDT 2003


On Tuesday, June 3, 2003, at 06:09 PM, Monte Goulding wrote:
>>>> For a project I am working on I need access to zlib decompression
>>>> (Version 6 SWF files can be compressed using zlib and I need to
>>>> decompress them to get their header information).
>>> Check out the compress/decompress functions. They use zlib.
>>
>> Hmmm, I tried that once but kept getting an error message that the
>> string I provided wasn't a compressed string so assumed the functions
>> used a different compression type.  Must have been user error, I will
>> give it another go.
>>
> You can get that if you don't read in the file as binary. Try:
>
>  decompress(url ("binfile:test.swf"))

Monte,

Thanks for the suggestion but the way a Version 6 SWF is created you 
can't decompress the file like that.  The first 8 bytes are 
uncompressed data which contain the file signature ("FWS" or "CWS" if 
compressed), file version and file size (after decompression if 
compressed).

Here is what I have tried so far.  I read the file as binary with start 
9 to EOF.  As I understand it this should start reading from the 9th 
byte until the end of file.  Looking at the data that is being read it 
seems to be correct when compared with the data as viewed from within 
HexEditor.  I then pass this data directly to decompress which says it 
is not a valid string.

I'm not really sure how to troubleshoot the problem at this point.  As 
I don't know how to ensure that the data I am getting is in fact the 
full string and if decompress really should decompress it.

If anyone has any additional ideas I would appreciate it.  I posted a 
SWF file at http://www.mangomultimedia.com/examples/test.swf which is a 
version 6 SWF with compression applied if anyone wants to fiddle with 
it.

Thanks,

Trevor


Here is what the Flash file format spec says.  Note that they say the 
sig for compressed files is "FWC" which is wrong.  It is "CWS".

--- SWF File Format Spec-------

The header begins with a three-byte Signature of either 0x46, 0x57, 
0x53 (“FWS”) or 0x46, 0x57, 0x43 (“FWC”). An FWS signature indicates an 
uncompressed SWF file; FWC indicates that the entire file after the 
first 8 bytes (that is, after the FileLength field) has been compressed 
using the open standard ZLIB. The data format used by the ZLIB library 
is described by Request for Comments (RFCs) documents 1950 to 1952. FWC 
file compression is only permitted in SWF version 6 or greater.

A one-byte Version number follows the signature. The version number is 
not an ASCII character, but an 8-bit number. For example, for SWF 4 the 
version byte is 0x04, not the ASCII character ‘4’ (0x35).  The 
FileLength field is the total length of the SWF file including the 
header. If this is an
uncompressed SWF (FWS signature), the FileLength field should exactly 
match the file size. If this is a compressed SWF (FWC signature), the 
FileLength field indicates the total length of the file after 
decompression, and thus will generally not match the file size. Having 
the uncompressed size available can make the decompression process more 
efficient.




More information about the use-livecode mailing list