Skip to main content
Participant
August 27, 2009
Question

as3 bytecode

  • August 27, 2009
  • 1 reply
  • 1822 views

i hv been working on the as3 bytecode which i retrieved form a swf created using as3!when i went through the abc(as3 bytecode) file structure i came across a cpool_info structure which is composed of an element called the 'integer' which specifies the integer constants used which is specified using a integer array having integer values at respective offsets.My problem is that when i went through the count of the number of integers used, it turned out to be greater than the number of bytes which are actually designated for the whole of the bytecode! How am i supposed to find  out the integer count in this case?

This topic has been closed for replies.

1 reply

August 27, 2009

I think this question belongs in the Open SWF form, but I see you've been there and haven't been getting much traffic.

So I took a quick look at the spec, and it would seem the count is given in the the first field of the struct: int_count

cpool_info
{
u30 int_count
s32 integer[int_count]
u30 uint_count
u32 uinteger[uint_count]
u30 double_count
d64 double[double_count]
u30 string_count
string_info string[string_count]
u30 namespace_count
namespace_info namespace[namespace_count]
u30 ns_set_count
ns_set_info ns_set[ns_set_count]
u30 multiname_count
multiname_info multiname[multiname_count]
}

openadobeAuthor
Participant
August 28, 2009

thanks for your help however that is not exactly my question.i read the int_count field from the bytes available and the value of the same came out to be more than the actual size of the whole of ABC bytecodes.How is that possible?Are the multi bytes stored in little-endian format or big endian??

August 28, 2009

from avm2overview.pdf:

 

Multi-byte primitive data are stored in little-endian order (less significant bytes precede more significant bytes).

Negative integers are represented using two’s complement.

  • The type u8 represents a one-byte unsigned integer value.
  • The type u16 represents a two-byte unsigned integer value.
  • The type s24 represents a three-byte signed integer value.
  • The type u30 represents a variable-length encoded 30-bit unsigned integer value.
  • The types u32 and s32 represent variable-length encoded 32-bit unsigned and signed integer values
  • respectively.

The type d64 defines an 8-byte IEEE-754 floating point value. The high byte of the double value

contains the sign and upper bits of the exponent, and the low byte contains the least significant bits of

the significand.

The variable-length encoding for u30, u32, and s32 uses one to five bytes, depending on the magnitude of the

value encoded. Each byte contributes its low seven bits to the value. If the high (eighth) bit of a byte is set,

then the next byte of the

abcFile is also part of the value. In the case of s32, sign extension is applied: the

seventh bit of the last byte of the encoding is propagated to fill out the 32 bits of the decoded value.