The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 4 of 4

Thread: Reading AS3 ABC bytecode with a hex editor?

  1. #1

    Reading AS3 ABC bytecode with a hex editor?

    I have tried to learn a bit of the way AS3 works behind the scenes by skimming the surface of the AS3 bytecode.

    I started with this document, and so far I'm at page 25 of 278.

    I tried following along a bit, opening a SWF I had laying around and exploring the header. I was able to read the first 4 bytes until I got to "FrameSize". The data type for that was RECT (found on page 16)

    The problem is, the first value of the RECT is stored as 5 BITS (not bytes). Since it doesn't round up to an even 16 bits per "chunk of data", it throws the "offset" of all bits off.

    This means that unless I manually copy down the SWF hex values into binary data, reading this information simply with a Hex editor would not work, correct? Or is there anything I have missed such as some form of padding to offset this etc?
    Blog article of the month: Why My One Line 'if' Statements Are Unusual
    Twitter: @IQAndreas
    GitHub: IQAndreas

  2. #2
    some hex editors I've used had shift parameters to offset the values a certain number of bits for this very thing.

    If you can't find one, there are several open source ones that you could edit. Grab one in like C# or something, it'd be easy to put the feature in. - come read my blog!

    If you want to know how to program, take a math class, take a lot of math classes!

  3. #3
    Great. I was worried I had misread the documentation in some way.

    One similar question (I'd rather not make an entirely new thread), starting from the 5th byte and spanning for 4 byes (a total of 32 bits) should give me the length of the SWF file.

    According to that UB32, the file is "209,832" bytes long.
    According to the file system, the entire file is only "123,127" bytes long.

    Am I doing something wrong? Or will I get to that part in the documentation that elaborates on the FileSize what it actually refers to?

    EDIT: I checked another SWF. The header says "1,020" bytes, and the file system says "657" bytes. There is definitely a relation between the two.
    Blog article of the month: Why My One Line 'if' Statements Are Unusual
    Twitter: @IQAndreas
    GitHub: IQAndreas

  4. #4
    If the SWF is compressed (which is true if the very first byte of the file is 0x43), then that filesize field refers to the size of the entire file after it's uncompressed. The first 8 bytes of a file are never compressed, but the rest can be uncompressed with ByteArray#uncompress.

    You should look at senocular's SWFReader class:

    It doesn't parse bytecode, but it parses the SWF file to the point where you can get a ByteArray of each of the DoABC tags in the file, and then you could write a parser for that yourself (check your PMs for more on that).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012