class SwfFile(VStruct): def __init__(self): VStruct.__init__(self) self.Header = SwfHeader() self.Tags = VArray() def vsParse(self, bytez, offset=0): magic = bytez[offset:offset+3] if magic not in ('FWS','CWS','ZWS'): raise Exception('Invalid Swf Magic') if magic == 'CWS': bytez = bytez[:8] + zlib.decompress(bytez[8:]) offset = self.Header.vsParse(bytez, offset=offset) print(('Header Says: %d Bytes Are: %d' % (self.Header.FileLength,len(bytez)))) i = 0 while offset < len(bytez): swftag = SwfTag() offset = swftag.vsParse(bytez, offset=offset) self.Tags.vsAddElement(swftag) i += 1 if i > 3: break
def __init__(self,shape=1): VStruct.__init__(self) self._swf_shape = shape self.BitFields = VBitField() self.BitFields.SpreadMode = v_bits(2) self.BitFields.InterpolationMode = v_bits(2) self.BitFields.NumGradients = v_bits(4) self.GradientRecords = VArray()
class DefineSceneAndFrameLabelData(VStruct): def __init__(self, size): VStruct.__init__(self) self.SceneCount = EncodedU32() self.Scenes = VArray() self.FrameLabelCount = EncodedU32() self.Frames = VArray() def pcb_SceneCount(self): count = self.SceneCount self.Scenes.vsAddElements(count, OffsetName) def pcb_FrameLabelCount(self): count = self.FrameLabelCount self.Scenes.vsAddElements(count, OffsetName)
class GRADIENT(VStruct): def __init__(self,shape=1): VStruct.__init__(self) self._swf_shape = shape self.BitFields = VBitField() self.BitFields.SpreadMode = v_bits(2) self.BitFields.InterpolationMode = v_bits(2) self.BitFields.NumGradients = v_bits(4) self.GradientRecords = VArray() def pcb_BitFields(self): gcount = self.BitFields.NumGradients for i in range(gcount): g = GRADRECORD(shape=self._swf_shape) self.GradientRecords.vsAddElement(g)
def __init__(self): VStruct.__init__(self) self.a = v_uint8() self.b = v_uint16() self.c = v_uint32() self.d = v_uint8() self.e = VArray( (v_uint32(), v_uint32(), v_uint32(), v_uint32()))
def __init__(self, shape=1): VStruct.__init__(self) self.FillStyles = FILLSTYLEARRAY(shape=shape) self.LineStyles = LINESTYLEARRAY(shape=shape) self.NumBits = VBitField() self.NumBits.NumFillBits = v_bits(4) self.NumBits.NumLineBits = v_bits(4) self.ShapeRecords = VArray()
class LINESTYLEARRAY(VStruct): def __init__(self,shape=1): VStruct.__init__(self) self._swf_shape = 1 self.LineStyleCount = v_uint8() self.LineStyleCountEx = v_uint16() self.LineStyles = VArray() def pcb_LineStyleCount(self): if self.LineStyleCount != 0xff: self.vsDelField('LineStyleCountEx') self.swfAddLineStyles(self.LineStyleCount) def pcb_LineStyleCountEx(self): self.swfAddLineStyles(self.LineStyleCountEx) def swfAddLineStyles(self, count): for i in range(count): elem = LINESTYLE(shape=self._swf_shape) self.LineStyles.vsAddElement(elem)
class FILLSTYLEARRAY(VStruct): def __init__(self, shape=1): VStruct.__init__(self) self._swf_shape = shape self.FillStyleCount = v_uint8() self.FillStyleCountEx = v_uint16() self.FillStyles = VArray() def pcb_FillStyleCount(self): if self.FillStyleCount != 0xff: self.vsDelField('FillStyleCountEx') self.swfAddFillStyles(self.FillStyleCount) def pcb_FillStyleCountEx(self): self.swfAddFillStyles(self.FillStyleCountEx) def swfAddFillStyles(self, count): for i in xrange(count): elem = FILLSTYLE(shape=self._swf_shape) self.FillStyles.vsAddElement(elem)
def __init__(self): VStruct.__init__(self) self.Header = SwfHeader() self.Tags = VArray()
def __init__(self, size): VStruct.__init__(self) self.SceneCount = EncodedU32() self.Scenes = VArray() self.FrameLabelCount = EncodedU32() self.Frames = VArray()
def __init__(self,shape=1): VStruct.__init__(self) self._swf_shape = 1 self.LineStyleCount = v_uint8() self.LineStyleCountEx = v_uint16() self.LineStyles = VArray()