2
#include "blocks/blocktypes.h"
3
#include "blocks/method.h"
4
#include "blocks/output.h"
8
#define OUTPUTRET SWFOutput
12
extern const char *blockName (SWFBlocktype header);
15
* This file contains output functions that can display the different SWF block
16
* types in a human readable format.
19
#define OUT_BEGIN(block) \
20
struct block *sblock = (struct block *)pblock;
22
static struct SWFBlockOutput outputs[] = {
23
/* Add these back at they are converted
24
{SWF_CHARACTERSET, outputSWF_CHARACTERSET},
25
{SWF_DEFINEBITS, outputSWF_DEFINEBITS},
26
{SWF_DEFINEBITSJPEG2, outputSWF_DEFINEBITSJPEG2},
27
{SWF_DEFINEBITSJPEG3, outputSWF_DEFINEBITSJPEG3},
28
{SWF_DEFINEBITSPTR, outputSWF_DEFINEBITSPTR},
29
{SWF_DEFINEBUTTON, outputSWF_DEFINEBUTTON},
30
{SWF_DEFINEBUTTON2, outputSWF_DEFINEBUTTON2},
31
{SWF_DEFINEBUTTONCXFORM, outputSWF_DEFINEBUTTONCXFORM},
32
{SWF_DEFINEBUTTONSOUND, outputSWF_DEFINEBUTTONSOUND},
33
{SWF_DEFINECOMMANDOBJ, outputSWF_DEFINECOMMANDOBJ},
34
{SWF_DEFINEEDITTEXT, outputSWF_DEFINEEDITTEXT},
35
{SWF_DEFINEFONT, outputSWF_DEFINEFONT},
37
{SWF_DEFINEFONT2, outputSWF_DEFINEFONT2},
39
{SWF_DEFINEFONTINFO, outputSWF_DEFINEFONTINFO},
40
{SWF_DEFINELOSSLESS, outputSWF_DEFINELOSSLESS},
41
{SWF_DEFINELOSSLESS2, outputSWF_DEFINELOSSLESS2},
42
{SWF_DEFINEMORPHSHAPE, outputSWF_DEFINEMORPHSHAPE},
43
{SWF_DEFINESHAPE, outputSWF_DEFINESHAPE},
44
{SWF_DEFINESHAPE2, outputSWF_DEFINESHAPE2},
45
{SWF_DEFINESHAPE3, outputSWF_DEFINESHAPE3},
46
{SWF_DEFINESOUND, outputSWF_DEFINESOUND},
47
{SWF_DEFINESPRITE, outputSWF_DEFINESPRITE},
48
{SWF_DEFINETEXT, outputSWF_DEFINETEXT},
49
{SWF_DEFINETEXT2, outputSWF_DEFINETEXT2},
50
{SWF_DEFINETEXTFORMAT, outputSWF_DEFINETEXTFORMAT},
51
{SWF_DEFINEVIDEO, outputSWF_DEFINEVIDEO},
52
{SWF_DEFINEVIDEOSTREAM, outputSWF_DEFINEVIDEOSTREAM},
53
{SWF_DOACTION, outputSWF_DOACTION},
54
{SWF_ENABLEDEBUGGER, outputSWF_ENABLEDEBUGGER},
55
{SWF_END, outputSWF_END},
56
{SWF_EXPORTASSETS, outputSWF_EXPORTASSETS},
57
{SWF_FONTREF, outputSWF_FONTREF},
58
{SWF_FRAMELABEL, outputSWF_FRAMELABEL},
59
{SWF_FRAMETAG, outputSWF_FRAMETAG},
60
{SWF_FREEALL, outputSWF_FREEALL},
61
{SWF_FREECHARACTER, outputSWF_FREECHARACTER},
62
{SWF_GENCOMMAND, outputSWF_GENCOMMAND},
63
{SWF_IMPORTASSETS, outputSWF_IMPORTASSETS},
64
{SWF_JPEGTABLES, outputSWF_JPEGTABLES},
65
{SWF_NAMECHARACTER, outputSWF_NAMECHARACTER},
66
{SWF_PATHSAREPOSTSCRIPT, outputSWF_PATHSAREPOSTSCRIPT},
67
{SWF_PLACEOBJECT, outputSWF_PLACEOBJECT},
68
{SWF_PLACEOBJECT2, outputSWF_PLACEOBJECT2},
69
{SWF_PREBUILT, outputSWF_PREBUILT},
70
{SWF_PREBUILTCLIP, outputSWF_PREBUILTCLIP},
71
{SWF_PROTECT, outputSWF_PROTECT},
72
{SWF_REMOVEOBJECT, outputSWF_REMOVEOBJECT},
73
{SWF_REMOVEOBJECT2, outputSWF_REMOVEOBJECT2},
74
{SWF_SERIALNUMBER, outputSWF_SERIALNUMBER},
75
{SWF_SETBACKGROUNDCOLOR, outputSWF_SETBACKGROUNDCOLOR},
76
{SWF_SHOWFRAME, outputSWF_SHOWFRAME},
77
{SWF_SOUNDSTREAMBLOCK, outputSWF_SOUNDSTREAMBLOCK},
78
{SWF_SOUNDSTREAMHEAD, outputSWF_SOUNDSTREAMHEAD},
79
{SWF_SOUNDSTREAMHEAD2, outputSWF_SOUNDSTREAMHEAD2},
80
{SWF_STARTSOUND, outputSWF_STARTSOUND},
81
{SWF_SYNCFRAME, outputSWF_SYNCFRAME},
82
{SWF_INITACTION, outputSWF_INITACTION},
83
{SWF_VIDEOFRAME, outputSWF_VIDEOFRAME},
87
static int numOutputs = sizeof (outputs) / sizeof (struct SWFBlockOutput);
89
/* Output basic Flash Types */
93
outputSWF_RGBA (SWF_RGBA * rgb, char *pname)
96
printf ("%2x,", rgb->red);
97
printf ("%2x,", rgb->green);
98
printf ("%2x,", rgb->blue);
99
printf ("%2x)\n", rgb->alpha);
105
outputswfSWF_RECT (SWFOutput out,SWF_RECT * rect)
107
SWFOutput_writeBits(out,rect->Nbits,5);
108
SWFOutput_writeSBits(out,rect->Xmin,rect->Nbits);
109
SWFOutput_writeSBits(out,rect->Xmax,rect->Nbits);
110
SWFOutput_writeSBits(out,rect->Ymin,rect->Nbits);
111
SWFOutput_writeSBits(out,rect->Ymax,rect->Nbits);
116
outputSWF_MATRIX (SWF_MATRIX * matrix, char *name)
118
printf (" Matrix: ");
119
if (matrix->HasScale)
121
printf ("ScaleX %f ", matrix->ScaleX);
122
printf ("ScaleY %f\n", matrix->ScaleY);
124
if (matrix->HasRotate)
126
printf ("RotateSkew0 %f ", matrix->RotateSkew0);
127
printf ("RotateSkew1 %f\n", matrix->RotateSkew1);
129
printf (" TranslateX %6ld ", matrix->TranslateX);
130
printf ("TranslateY %6ld\n", matrix->TranslateY);
134
outputSWF_BUTTONRECORD (SWF_BUTTONRECORD *brec)
136
printf (" BUTTONRECORD: ");
137
printf (" ButtonStateHitTest: %d ", brec->ButtonStateHitTest);
138
printf (" ButtonStateDown: %d ", brec->ButtonStateDown);
139
printf (" ButtonStateOver: %d ", brec->ButtonStateOver);
140
printf (" ButtonStateUp: %d\n", brec->ButtonStateUp);
141
printf (" CharacterID: %d\n", brec->CharacterId);
142
printf (" PlaceDepth: %d\n", brec->PlaceDepth);
146
outputSWF_BUTTONCONDACTION (SWF_BUTTONCONDACTION *bcarec)
152
#if !defined(ACTIONONLY)
153
printf (" BUTTONCONDACTION: ");
154
printf (" CondActionSize: %d\n", bcarec->CondActionSize);
155
printf (" CondIdleToOverDown: %d ", bcarec->CondIdleToOverDown);
156
printf (" CondOutDownToIdle: %d ", bcarec->CondOutDownToIdle);
157
printf (" CondOutDownToOverDown: %d ", bcarec->CondOutDownToOverDown);
158
printf (" CondOverDownToOutDown: %d ", bcarec->CondOverDownToOutDown);
159
printf (" CondOverDownToOverUp: %d ", bcarec->CondOverDownToOverUp);
160
printf (" CondOverUpToOverDown: %d ", bcarec->CondOverUpToOverDown);
161
printf (" CondOverUpToIdle: %d ", bcarec->CondOverUpToIdle);
162
printf (" CondIdleToOverUp: %d ", bcarec->CondIdleToOverUp);
163
printf (" CondKeyPress: %d ", bcarec->CondKeyPress);
164
printf (" CondOverDownToIdle: %d ", bcarec->CondOverDownToIdle);
168
printf(" %d Actions\n", bcarec->numActions);
169
for(i=0;i<bcarec->numActions;i++)
170
outputSWF_ACTION(i,&(bcarec->Actions[i]));
172
printf (" %s\n", decompile5Action(bcarec->numActions,bcarec->Actions,0));
178
outputSWF_CLIPEVENTFLAGS (SWF_CLIPEVENTFLAGS * clipevflags )
180
printf (" ClipEventKeyUp: %d ", clipevflags->ClipEventKeyUp);
181
printf (" ClipEventKeyDown: %d ", clipevflags->ClipEventKeyDown);
182
printf (" ClipEventMouseUp: %d ", clipevflags->ClipEventMouseUp);
183
printf (" ClipEventMouseDown: %d ", clipevflags->ClipEventMouseDown);
184
printf (" ClipEventMouseMove: %d ", clipevflags->ClipEventMouseMove);
185
printf (" ClipEventUnload: %d ", clipevflags->ClipEventUnload);
186
printf (" ClipEventEnterFrame: %d ", clipevflags->ClipEventEnterFrame);
187
printf (" ClipEventLoad: %d ", clipevflags->ClipEventLoad);
188
printf (" ClipEventDragOver: %d ", clipevflags->ClipEventDragOver);
189
printf (" ClipEventRollOut: %d ", clipevflags->ClipEventRollOut);
190
printf (" ClipEventRollOver: %d ", clipevflags->ClipEventRollOver);
191
printf (" ClipEventReleaseOutside: %d ", clipevflags->ClipEventReleaseOutside);
192
printf (" ClipEventRelease: %d ", clipevflags->ClipEventRelease);
193
printf (" ClipEventPress: %d ", clipevflags->ClipEventPress);
194
printf (" ClipEventInitialize: %d ", clipevflags->ClipEventInitialize);
195
printf (" ClipEventData: %d ", clipevflags->ClipEventData);
196
printf (" ClipEventConstruct: %d ", clipevflags->ClipEventConstruct);
197
printf (" ClipEventKeyPress: %d ", clipevflags->ClipEventKeyPress);
198
printf (" ClipEventDragOut: %d ", clipevflags->ClipEventDragOut);
202
outputSWF_CLIPACTIONRECORD (SWF_CLIPACTIONRECORD * carec )
208
#if !defined(ACTIONONLY)
209
outputSWF_CLIPEVENTFLAGS (&carec->EventFlag);
210
printf(" %ld ActionRecordSize\n", carec->ActionRecordSize);
211
printf(" %d KeyCode\n", carec->KeyCode);
214
printf(" %d Actions\n", carec->numActions);
215
for(i=0;i<carec->numActions;i++)
216
outputSWF_ACTION(i,&(carec->Actions[i]));
218
printf (" %s\n", decompile5Action(carec->numActions,carec->Actions,0));
224
outputSWF_CLIPACTIONS (SWF_CLIPACTIONS * clipactions )
227
#if !defined(ACTIONONLY)
228
outputSWF_CLIPEVENTFLAGS (&clipactions->AllEventFlags);
229
printf(" %d NumClipRecords\n", clipactions->NumClipRecords);
231
for(i=0;i<clipactions->NumClipRecords;i++)
232
outputSWF_CLIPACTIONRECORD(&(clipactions->ClipActionRecords[i]));
236
outputSWF_GRADIENTRECORD (SWF_GRADIENTRECORD * gradientrec, char *gname)
238
printf (" Ratio: %d\n", gradientrec->Ratio);
239
outputSWF_RGBA (&gradientrec->Color, "");
243
outputSWF_GRADIENT (SWF_GRADIENT * gradient, char *name)
246
printf (" Gradient: ");
247
printf (" NumGradients: %d\n", gradient->NumGradients);
248
for (i = 0; i < gradient->NumGradients; i++)
249
outputSWF_GRADIENTRECORD (&(gradient->GradientRecords[i]),"");
254
outputSWF_FILLSTYLE (SWF_FILLSTYLE * fillstyle, char *name, int i)
256
printf (" FillStyle: ");
257
printf (" FillStyleType: %x\n", fillstyle->FillStyleType);
258
switch (fillstyle->FillStyleType)
260
case 0x00: /* Solid Fill */
261
outputSWF_RGBA (&fillstyle->Color, "");
263
case 0x10: /* Linear Gradient Fill */
264
case 0x12: /* Radial Gradient Fill */
265
outputSWF_MATRIX (&fillstyle->GradientMatrix,"");
266
outputSWF_GRADIENT (&fillstyle->Gradient,"");
268
case 0x40: /* Repeating Bitmap Fill */
269
case 0x41: /* Clipped Bitmap Fill */
270
case 0x42: /* Non-smoothed Repeating Bitmap Fill */
271
case 0x43: /* Non-smoothed Clipped Bitmap Fill */
272
printf (" BitmapID: %d\n", fillstyle->BitmapId);
273
outputSWF_MATRIX (&fillstyle->BitmapMatrix,"");
279
outputSWF_FILLSTYLEARRAY (SWF_FILLSTYLEARRAY * fillstylearray, char *name)
283
printf (" FillStyleArray: ");
284
printf (" FillStyleCount: %6d ", fillstylearray->FillStyleCount);
285
printf (" FillStyleCountExtended: %6d\n",
286
fillstylearray->FillStyleCountExtended);
288
(fillstylearray->FillStyleCount !=
289
0xff) ? fillstylearray->FillStyleCount : fillstylearray->
290
FillStyleCountExtended;
291
for (i = 0; i < count; i++)
293
outputSWF_FILLSTYLE (&(fillstylearray->FillStyles[i]),"",0);
298
outputSWF_LINESTYLE (SWF_LINESTYLE * fillstyle, char *name, int i)
300
printf (" LineStyle: ");
301
printf (" Width: %d\n", fillstyle->Width);
302
outputSWF_RGBA (&fillstyle->Color, "");
306
outputSWF_LINESTYLEARRAY (SWF_LINESTYLEARRAY * linestylearray, char *name)
311
printf (" LineStyleArray: ");
312
printf (" LineStyleCount: %6d ", linestylearray->LineStyleCount);
313
printf (" LineStyleCountExtended: %6d\n",
314
linestylearray->LineStyleCountExtended);
316
(linestylearray->LineStyleCount !=
317
0xff) ? linestylearray->LineStyleCount : linestylearray->
318
LineStyleCountExtended;
319
for (i = 0; i < count; i++)
321
outputSWF_LINESTYLE (&(linestylearray->LineStyles[i]),"",0);
327
outputswfSWF_SHAPERECORD (SWF_SHAPERECORD * shaperec, SWFOutput out, int fillBits, int lineBits)
329
SWFOutput_writeBits(out,shaperec->EndShape.TypeFlag,1);
330
if (shaperec->EndShape.TypeFlag)
333
SWFOutput_writeBits(out,shaperec->StraightEdge.StraightEdge,1);
334
if (shaperec->StraightEdge.StraightEdge == 1)
336
/* A Straight Edge Record */
337
SWFOutput_writeBits(out,shaperec->StraightEdge.NumBits,4);
338
SWFOutput_writeBits(out,shaperec->StraightEdge.GeneralLineFlag,1);
339
if( shaperec->StraightEdge.GeneralLineFlag ) {
340
SWFOutput_writeSBits(out,shaperec->StraightEdge.DeltaX,shaperec->StraightEdge.NumBits+2);
341
SWFOutput_writeSBits(out,shaperec->StraightEdge.DeltaY,shaperec->StraightEdge.NumBits+2);
343
SWFOutput_writeSBits(out,shaperec->StraightEdge.VertLineFlag,1);
344
if( shaperec->StraightEdge.VertLineFlag ) {
345
SWFOutput_writeSBits(out,shaperec->StraightEdge.VLDeltaY,shaperec->StraightEdge.NumBits+2);
347
SWFOutput_writeSBits(out,shaperec->StraightEdge.VLDeltaX,shaperec->StraightEdge.NumBits+2);
353
/* A Curved Edge Record */
354
SWFOutput_writeBits(out,shaperec->CurvedEdge.NumBits,4);
355
SWFOutput_writeSBits(out,shaperec->CurvedEdge.ControlDeltaX,shaperec->CurvedEdge.NumBits+2);
356
SWFOutput_writeSBits(out,shaperec->CurvedEdge.ControlDeltaY,shaperec->CurvedEdge.NumBits+2);
357
SWFOutput_writeSBits(out,shaperec->CurvedEdge.AnchorDeltaX,shaperec->CurvedEdge.NumBits+2);
358
SWFOutput_writeSBits(out,shaperec->CurvedEdge.AnchorDeltaY,shaperec->CurvedEdge.NumBits+2);
363
/* A Non-Edge Record */
364
if (shaperec->EndShape.EndOfShape == 0)
366
SWFOutput_writeBits(out,shaperec->EndShape.EndOfShape,5);
369
SWFOutput_writeBits(out,shaperec->StyleChange.StateNewStyles,1);
370
SWFOutput_writeBits(out,shaperec->StyleChange.StateLineStyle,1);
371
SWFOutput_writeBits(out,shaperec->StyleChange.StateFillStyle1,1);
372
SWFOutput_writeBits(out,shaperec->StyleChange.StateFillStyle0,1);
373
SWFOutput_writeBits(out,shaperec->StyleChange.StateMoveTo,1);
375
if (shaperec->StyleChange.StateMoveTo)
377
SWFOutput_writeBits(out,shaperec->StyleChange.MoveBits,5);
378
SWFOutput_writeSBits(out,shaperec->StyleChange.MoveDeltaX,shaperec->StyleChange.MoveBits);
379
SWFOutput_writeSBits(out,shaperec->StyleChange.MoveDeltaY,shaperec->StyleChange.MoveBits);
381
if (shaperec->StyleChange.StateFillStyle0) {
382
SWFOutput_writeBits(out,shaperec->StyleChange.FillStyle0,fillBits);
384
if (shaperec->StyleChange.StateFillStyle1) {
385
SWFOutput_writeBits(out,shaperec->StyleChange.FillStyle1,fillBits);
387
if (shaperec->StyleChange.StateLineStyle) {
388
SWFOutput_writeBits(out,shaperec->StyleChange.LineStyle,lineBits);
394
outputswfSWF_SHAPE (SWF_SHAPE * shape)
400
SWFOutput_writeBits(out,shape->NumFillBits,4);
401
SWFOutput_writeBits(out,shape->NumLineBits,4);
402
for (i = 0; i < shape->NumShapeRecords; i++)
404
outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]), out,shape->NumFillBits,shape->NumLineBits);
406
SWFOutput_byteAlign(out);
412
outputSWF_SHAPEWITHSTYLE (SWF_SHAPEWITHSTYLE * shape, int level, char *name)
417
outputSWF_FILLSTYLEARRAY (&(shape->FillStyles),"");
418
outputSWF_LINESTYLEARRAY (&(shape->LineStyles),"");
419
printf (" NumFillBits: %d\n", shape->NumFillBits);
420
printf (" NumLineBits: %d\n", shape->NumLineBits);
421
for (i = 0; i < shape->NumShapeRecords; i++)
423
outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]),name);
429
outputSWF_GLYPHENTRY (SWF_GLYPHENTRY *gerec)
431
printf(" GlyphIndex[0] = %4.4lx ", gerec->GlyphIndex[0] );
432
printf(" GlyphAdvance[0] = %4.4lx\n", gerec->GlyphAdvance[0] );
436
outputSWF_TEXTRECORD (SWF_TEXTRECORD *trec, int level)
439
printf (" TEXTRECORD: ");
440
printf (" TextRecordType: %d ", trec->TextRecordType);
441
printf (" StyleFlagsReserved: %d ", trec->StyleFlagsReserved);
442
printf (" StyleFlagHasFont: %d ", trec->StyleFlagHasFont);
443
printf (" StyleFlagHasColor: %d ", trec->StyleFlagHasColor);
444
printf (" StyleFlagHasYOffset: %d ", trec->StyleFlagHasYOffset);
445
printf (" StyleFlagHasXOffset: %d\n", trec->StyleFlagHasXOffset);
447
if ( trec->TextRecordType == 0 )
450
* parser doesn't initialize any other
451
* member when TextRecordType == 0,
452
* see parseSWF_TEXTRECORD in parser.c
457
if( trec->StyleFlagHasFont )
458
printf (" FontID: %d\n", trec->FontID);
459
if( trec->StyleFlagHasColor ) {
460
outputSWF_RGBA(&trec->TextColor, "" );
462
if( trec->StyleFlagHasYOffset || trec->StyleFlagHasXOffset ) {
463
printf (" XOffset: %d ", trec->XOffset);
464
printf (" YOffset: %d\n", trec->YOffset);
466
if( trec->StyleFlagHasFont )
467
printf (" TextHeight: %d\n", trec->TextHeight);
468
printf (" GlyphCount: %d\n", trec->GlyphCount);
469
for(i=0;i<trec->GlyphCount;i++)
470
outputSWF_GLYPHENTRY( &(trec->GlyphEntries[i]) );
474
/* Output Flash Blocks */
477
outputSWF_CHARACTERSET (SWF_Parserstruct * pblock)
479
//OUT_BEGIN (SWF_CHARACTERSET);
484
outputSWF_DEFINEBITS (SWF_Parserstruct * pblock)
486
//OUT_BEGIN (SWF_DEFINEBITS);
491
outputSWF_DEFINEBITSJPEG2 (SWF_Parserstruct * pblock)
493
//OUT_BEGIN (SWF_DEFINEBITSJPEG2);
498
outputSWF_DEFINEBITSJPEG3 (SWF_Parserstruct * pblock)
500
//OUT_BEGIN (SWF_DEFINEBITSJPEG3);
505
outputSWF_DEFINEBITSPTR (SWF_Parserstruct * pblock)
507
//OUT_BEGIN (SWF_DEFINEBITSPTR);
512
outputSWF_DEFINEBUTTON (SWF_Parserstruct * pblock)
514
//OUT_BEGIN (SWF_DEFINEBUTTON);
519
outputSWF_DEFINEBUTTON2 (SWF_Parserstruct * pblock)
522
OUT_BEGIN (SWF_DEFINEBUTTON2);
524
#if !defined(ACTIONONLY)
525
printf (" CharacterID: %d\n", sblock->Buttonid);
526
printf (" TrackAsMenu: %d\n", sblock->TrackAsMenu);
527
printf (" ActionOffset: %d\n", sblock->ActionOffset);
528
for(i=0;i<sblock->numCharacters;i++) {
529
outputSWF_BUTTONRECORD( &(sblock->Characters[i]) );
532
for(i=0;i<sblock->numActions;i++) {
533
outputSWF_BUTTONCONDACTION( &(sblock->Actions[i]) );
539
outputSWF_DEFINEBUTTONCXFORM (SWF_Parserstruct * pblock)
541
//OUT_BEGIN (SWF_DEFINEBUTTONCXFORM);
546
outputSWF_DEFINEBUTTONSOUND (SWF_Parserstruct * pblock)
548
//OUT_BEGIN (SWF_DEFINEBUTTONSOUND);
553
outputSWF_DEFINECOMMANDOBJ (SWF_Parserstruct * pblock)
555
//OUT_BEGIN (SWF_DEFINECOMMANDOBJ);
560
outputSWF_DEFINEEDITTEXT (SWF_Parserstruct * pblock)
562
OUT_BEGIN (SWF_DEFINEEDITTEXT);
564
printf (" CharacterID: %d\n", sblock->CharacterID);
565
outputSWF_RECT (&(sblock->Bounds));
567
printf (" HasText: %d ", sblock->HasText);
568
printf (" WordWrap: %d ", sblock->WordWrap);
569
printf (" Multiline: %d ", sblock->Multiline);
570
printf (" Password: %d ", sblock->Password);
571
printf (" ReadOnly: %d\n", sblock->ReadOnly);
573
printf (" HasTextColor: %d ", sblock->HasTextColor);
574
printf (" HasMaxLength: %d ", sblock->HasMaxLength);
575
printf (" HasFont: %d ", sblock->HasFont);
576
printf (" AutoSize: %d ", sblock->AutoSize);
577
printf (" HasLayout: %d\n", sblock->HasLayout);
579
printf (" NoSelect: %d ", sblock->NoSelect);
580
printf (" Border: %d ", sblock->Border);
581
printf (" HTML: %d ", sblock->HTML);
582
printf (" UseOutlines: %d\n", sblock->UseOutlines);
586
printf (" FontID: %d ", sblock->FontID);
587
printf (" FontHeight: %d\n", sblock->FontHeight);
589
if (sblock->HasTextColor)
591
outputSWF_RGBA (&sblock->TextColor,"");
593
if (sblock->HasLayout)
595
printf (" Layout:: ");
596
printf (" Align: %d ", sblock->Align);
597
printf (" LeftMargin: %d ", sblock->LeftMargin);
598
printf (" RightMargin: %d ", sblock->RightMargin);
599
printf (" Indent: %d ", sblock->Indent);
600
printf (" Leading: %d\n", sblock->Leading);
602
printf (" VariableName: %s\n", sblock->VariableName);
605
printf (" InitialText: %s\n", sblock->InitialText);
610
outputSWF_DEFINEFONT (SWF_Parserstruct * pblock)
612
//OUT_BEGIN (SWF_DEFINEFONT);
618
outputSWF_DEFINEFONT2 (SWF_Parserstruct * pblock)
620
SWFOutput hdr0,hdr1,offsettbl,*glyphdata;
621
int i,size, glyphbase;
622
OUT_BEGIN (SWF_DEFINEFONT2);
625
glyphdata = calloc(sblock->NumGlyphs,sizeof(SWFOutput *));
627
for (i = 0; i < sblock->NumGlyphs; i++) {
628
glyphdata[i] = outputswfSWF_SHAPE (&(sblock->GlyphShapeTable[i]));
629
size+= SWFOutput_getLength(glyphdata[i]);
633
sblock->FontFlagsWideOffsets=1;
635
if (sblock->FontFlagsWideOffsets) {
636
glyphbase=(sblock->NumGlyphs*4)+4;
637
sblock->OffsetTable.UI32[0]=glyphbase;
638
sblock->CodeTableOffset.UI32=glyphbase;
640
glyphbase=(sblock->NumGlyphs*2)+2;
641
sblock->CodeTableOffset.UI16=glyphbase;
642
sblock->OffsetTable.UI16[0]=glyphbase;
645
for (i = 0; i < sblock->NumGlyphs; i++) {
646
if (sblock->FontFlagsWideOffsets) {
647
sblock->OffsetTable.UI32[i]=sblock->CodeTableOffset.UI32;
648
sblock->CodeTableOffset.UI32=sblock->OffsetTable.UI32[i]+SWFOutput_getLength(glyphdata[i]);
650
sblock->OffsetTable.UI16[i]=sblock->CodeTableOffset.UI16;
651
sblock->CodeTableOffset.UI16=sblock->OffsetTable.UI16[i]+SWFOutput_getLength(glyphdata[i]);
655
offsettbl=newSWFOutput();
656
for (i = 0; i < sblock->NumGlyphs; i++) {
657
if (sblock->FontFlagsWideOffsets) {
658
SWFOutput_writeUInt32(offsettbl,sblock->OffsetTable.UI32[i]);
660
SWFOutput_writeUInt16(offsettbl,sblock->OffsetTable.UI16[i]);
664
/* Now that we have the glyph data, and it's offset, we can start assembling
667
size= 5 /* Initial header through FontNameLen */
668
+(sblock->FontNameLen) /* FontName */
671
hdr1=newSizedSWFOutput(size);
672
SWFOutput_writeUInt16(hdr1,sblock->FontID);
673
SWFOutput_writeBits(hdr1,sblock->FontFlagsHasLayout,1);
674
SWFOutput_writeBits(hdr1,sblock->FontFlagsShiftJis,1);
675
SWFOutput_writeBits(hdr1,sblock->FontFlagsSmallText,1);
676
SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagANSI,1);
677
SWFOutput_writeBits(hdr1,sblock->FontFlagsWideOffsets,1);
678
SWFOutput_writeBits(hdr1,sblock->FontFlagsWideCodes,1);
679
SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsItalics,1);
680
SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsBold,1);
681
SWFOutput_writeUInt8(hdr1,sblock->LanguageCode);
682
SWFOutput_writeUInt8(hdr1,sblock->FontNameLen);
683
SWFOutput_writeBuffer(hdr1,(unsigned char *)sblock->FontName,sblock->FontNameLen);
684
SWFOutput_writeUInt16(hdr1,sblock->NumGlyphs);
686
/* Now, copy these parts into the hdr buffer */
687
SWFOutput_writeToMethod(offsettbl,SWFOutputMethod,hdr1);
688
destroySWFOutput(offsettbl);
689
if (sblock->FontFlagsWideOffsets)
691
SWFOutput_writeUInt32(hdr1,sblock->CodeTableOffset.UI32);
695
SWFOutput_writeUInt16(hdr1,sblock->CodeTableOffset.UI16);
697
for (i = 0; i < sblock->NumGlyphs; i++) {
698
SWFOutput_writeToMethod(glyphdata[i],SWFOutputMethod,hdr1);
699
destroySWFOutput(glyphdata[i]);
703
/* Now, resume the normal linear processing this tag */
705
for (i = 0; i < sblock->NumGlyphs; i++)
707
if( sblock->FontFlagsWideCodes ) {
708
SWFOutput_writeUInt16(hdr1,sblock->CodeTable[i]);
710
SWFOutput_writeUInt8(hdr1,sblock->CodeTable[i]);
714
if( sblock->FontFlagsHasLayout ) {
715
SWFOutput_writeSInt16(hdr1,sblock->FontAscent);
716
SWFOutput_writeSInt16(hdr1,sblock->FontDecent);
717
SWFOutput_writeSInt16(hdr1,sblock->FontLeading);
718
for (i = 0; i < sblock->NumGlyphs; i++) {
719
SWFOutput_writeSInt16(hdr1,sblock->FontAdvanceTable[i]);
721
for (i = 0; i < sblock->NumGlyphs; i++) {
722
outputswfSWF_RECT (hdr1,&(sblock->FontBoundsTable[i]));
723
SWFOutput_byteAlign(hdr1);
725
SWFOutput_writeUInt16(hdr1,sblock->KerningCount);
726
for (i = 0; i < sblock->KerningCount; i++) {
727
if( sblock->FontFlagsWideCodes ) {
728
SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode1);
729
SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode2);
730
SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment);
732
SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode1);
733
SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode2);
734
SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment);
739
/* This code really belongs in outputTAGHeader() */
740
hdr0=newSizedSWFOutput(6);
742
if(SWFOutput_getLength(hdr1) <= 62 ) {
743
SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|SWFOutput_getLength(hdr1));
745
SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|0x3f);
746
SWFOutput_writeUInt32(hdr0,SWFOutput_getLength(hdr1));
749
SWFOutput_writeToMethod(hdr1,SWFOutputMethod,hdr0);
750
destroySWFOutput(hdr1);
757
outputSWF_DEFINEFONTINFO (SWF_Parserstruct * pblock)
759
//OUT_BEGIN (SWF_DEFINEFONTINFO);
764
outputSWF_DEFINELOSSLESS (SWF_Parserstruct * pblock)
766
//OUT_BEGIN (SWF_DEFINELOSSLESS);
771
outputSWF_DEFINELOSSLESS2 (SWF_Parserstruct * pblock)
773
//OUT_BEGIN (SWF_DEFINELOSSLESS2);
778
outputSWF_DEFINEMORPHSHAPE (SWF_Parserstruct * pblock)
780
//OUT_BEGIN (SWF_DEFINEMORPHSHAPE);
785
outputSWF_DEFINESHAPE (SWF_Parserstruct * pblock)
787
OUT_BEGIN (SWF_DEFINESHAPE);
789
printf (" ShapeID: %d\n", sblock->ShapeID);
790
outputSWF_RECT (&(sblock->ShapeBounds));
791
outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),1,"");
795
outputSWF_DEFINESHAPE2 (SWF_Parserstruct * pblock)
797
OUT_BEGIN (SWF_DEFINESHAPE2);
799
printf (" ShapeID: %d\n", sblock->ShapeID);
800
outputSWF_RECT (&(sblock->ShapeBounds));
801
outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),2,"");
806
outputSWF_DEFINESHAPE3 (SWF_Parserstruct * pblock)
808
OUT_BEGIN (SWF_DEFINESHAPE3);
810
printf (" ShapeID: %d\n", sblock->ShapeID);
811
outputSWF_RECT (&(sblock->ShapeBounds));
812
outputSWF_SHAPEWITHSTYLE (&(sblock->Shapes),2,"");
817
outputSWF_DEFINESOUND (SWF_Parserstruct * pblock)
819
//OUT_BEGIN (SWF_DEFINESOUND);
824
outputSWF_DEFINESPRITE (SWF_Parserstruct * pblock)
826
OUT_BEGIN (SWF_DEFINESPRITE);
827
printf(" SpriteId: %d\n", sblock->SpriteId );
828
printf(" FrameCount: %d\n", sblock->FrameCount );
829
printf(" BlockCount: %d\n", sblock->BlockCount );
834
outputSWF_DEFINETEXT (SWF_Parserstruct * pblock)
837
OUT_BEGIN (SWF_DEFINETEXT);
839
printf(" CharacterID: %d\n", sblock->CharacterID );
840
outputSWF_RECT( &sblock->TextBounds );
841
outputSWF_MATRIX( &sblock->TextMatrix, "" );
842
printf(" GlyphBits: %d\n", sblock->GlyphBits );
843
printf(" AdvanceBits: %d\n", sblock->AdvanceBits );
844
printf(" TextRecords: %d\n", sblock->numTextRecords );
845
for(i=0;i<sblock->numTextRecords;i++) {
846
outputSWF_TEXTRECORD(&(sblock->TextRecords[i]), 1 );
852
outputSWF_DEFINETEXT2 (SWF_Parserstruct * pblock)
855
OUT_BEGIN (SWF_DEFINETEXT2);
857
printf(" CharacterID: %d\n", sblock->CharacterID );
858
outputSWF_RECT( &sblock->TextBounds );
859
outputSWF_MATRIX( &sblock->TextMatrix, "" );
860
printf(" GlyphBits: %d\n", sblock->GlyphBits );
861
printf(" AdvanceBits: %d\n", sblock->AdvanceBits );
862
printf(" TextRecords: %d\n", sblock->numTextRecords );
863
for(i=0;i<sblock->numTextRecords;i++) {
864
outputSWF_TEXTRECORD(&(sblock->TextRecords[i]), 2 );
869
outputSWF_DEFINETEXTFORMAT (SWF_Parserstruct * pblock)
871
//OUT_BEGIN (SWF_DEFINETEXTFORMAT);
876
outputSWF_DEFINEVIDEO (SWF_Parserstruct * pblock)
878
//OUT_BEGIN (SWF_DEFINEVIDEO);
883
outputSWF_DEFINEVIDEOSTREAM (SWF_Parserstruct * pblock)
885
//OUT_BEGIN (SWF_DEFINEVIDEOSTREAM);
890
outputSWF_DOACTION (SWF_Parserstruct * pblock)
896
OUT_BEGIN (SWF_DOACTION);
899
printf(" %d Actions\n", sblock->numActions);
900
for(i=0;i<sblock->numActions;i++)
901
outputSWF_ACTION(i,&(sblock->Actions[i]));
903
printf ("%s\n", decompile5Action(sblock->numActions,sblock->Actions,0));
910
outputSWF_ENABLEDEBUGGER (SWF_Parserstruct * pblock)
912
//OUT_BEGIN (SWF_ENABLEDEBUGGER);
917
outputSWF_END (SWF_Parserstruct * pblock)
919
//OUT_BEGIN (SWF_END);
924
outputSWF_EXPORTASSETS (SWF_Parserstruct * pblock)
927
OUT_BEGIN (SWF_EXPORTASSETS);
929
printf (" num assets: %d\n", sblock->Count );
930
for (i = 0; i < sblock->Count; i++)
932
printf (" Asset[%3.3d]: %s\n", sblock->Tags[i],
939
outputSWF_FONTREF (SWF_Parserstruct * pblock)
941
//OUT_BEGIN (SWF_FONTREF);
946
outputSWF_FRAMELABEL (SWF_Parserstruct * pblock)
948
//OUT_BEGIN (SWF_FRAMELABEL);
953
outputSWF_FRAMETAG (SWF_Parserstruct * pblock)
955
//OUT_BEGIN (SWF_FRAMETAG);
960
outputSWF_FREEALL (SWF_Parserstruct * pblock)
962
//OUT_BEGIN (SWF_FREEALL);
967
outputSWF_FREECHARACTER (SWF_Parserstruct * pblock)
969
//OUT_BEGIN (SWF_FREECHARACTER);
974
outputSWF_GENCOMMAND (SWF_Parserstruct * pblock)
976
//OUT_BEGIN (SWF_GENCOMMAND);
981
outputSWF_IMPORTASSETS (SWF_Parserstruct * pblock)
984
OUT_BEGIN (SWF_IMPORTASSETS);
986
printf (" URL: %s\n", sblock->URL );
987
printf (" num assets: %d\n", sblock->Count );
988
for (i = 0; i < sblock->Count; i++)
990
printf (" Asset[%3.3d]: %s\n", sblock->Tags[i],
997
outputSWF_JPEGTABLES (SWF_Parserstruct * pblock)
999
//OUT_BEGIN (SWF_JPEGTABLES);
1004
outputSWF_NAMECHARACTER (SWF_Parserstruct * pblock)
1006
//OUT_BEGIN (SWF_NAMECHARACTER);
1011
outputSWF_PATHSAREPOSTSCRIPT (SWF_Parserstruct * pblock)
1013
//OUT_BEGIN (SWF_PATHSAREPOSTSCRIPT);
1018
outputSWF_PLACEOBJECT (SWF_Parserstruct * pblock)
1020
//OUT_BEGIN (SWF_PLACEOBJECT);
1025
outputSWF_PLACEOBJECT2 (SWF_Parserstruct * pblock)
1027
OUT_BEGIN (SWF_PLACEOBJECT2);
1029
#if !defined(ACTIONONLY)
1030
printf(" PlaceFlagHasClipActions %d\n", sblock->PlaceFlagHasClipActions);
1031
printf(" PlaceFlagHasClipDepth %d\n", sblock->PlaceFlagHasClipDepth);
1032
printf(" PlaceFlagHasName %d\n", sblock->PlaceFlagHasName);
1033
printf(" PlaceFlagHasRatio %d\n", sblock->PlaceFlagHasRatio);
1034
printf(" PlaceFlagHasColorTransform %d\n", sblock->PlaceFlagHasColorTransform);
1035
printf(" PlaceFlagHasMatrix %d\n", sblock->PlaceFlagHasMatrix);
1036
printf(" PlaceFlagHasCharacter %d\n", sblock->PlaceFlagHasCharacter);
1037
printf(" PlaceFlagMove %d\n", sblock->PlaceFlagMove);
1038
printf(" Depth %d\n", sblock->Depth);
1039
if( sblock->PlaceFlagHasCharacter )
1040
printf( " CharacterId: %d\n", sblock->CharacterId );
1041
if( sblock->PlaceFlagHasMatrix )
1042
outputSWF_MATRIX (&(sblock->Matrix), "");
1044
if( sblock->PlaceFlagHasColorTransform )
1045
outputSWF_CXFORMWITHALPHA (&(sblock->ColorTransform), "");
1047
if( sblock->PlaceFlagHasRatio )
1048
printf( " Ratio: %d\n", sblock->Ratio );
1049
if( sblock->PlaceFlagHasName )
1050
printf( " Name: %s\n", sblock->Name );
1051
if( sblock->PlaceFlagHasClipDepth )
1052
printf( " ClipDepth: %d\n", sblock->ClipDepth );
1054
if( sblock->PlaceFlagHasClipActions )
1055
outputSWF_CLIPACTIONS (&(sblock->ClipActions));
1059
outputSWF_PREBUILT (SWF_Parserstruct * pblock)
1061
//OUT_BEGIN (SWF_PREBUILT);
1066
outputSWF_PREBUILTCLIP (SWF_Parserstruct * pblock)
1068
//OUT_BEGIN (SWF_PREBUILTCLIP);
1073
outputSWF_PROTECT (SWF_Parserstruct * pblock)
1075
OUT_BEGIN (SWF_PROTECT);
1077
printf(" Password: %s\n", sblock->Password);
1082
outputSWF_REMOVEOBJECT (SWF_Parserstruct * pblock)
1084
//OUT_BEGIN (SWF_REMOVEOBJECT);
1089
outputSWF_REMOVEOBJECT2 (SWF_Parserstruct * pblock)
1091
//OUT_BEGIN (SWF_REMOVEOBJECT2);
1096
outputSWF_SERIALNUMBER (SWF_Parserstruct * pblock)
1098
//OUT_BEGIN (SWF_SERIALNUMBER);
1103
outputSWF_SETBACKGROUNDCOLOR (SWF_Parserstruct * pblock)
1105
OUT_BEGIN (SWF_SETBACKGROUNDCOLOR);
1107
outputSWF_RGBA (&sblock->rgb, "");
1112
outputSWF_SHOWFRAME (SWF_Parserstruct * pblock)
1114
//OUT_BEGIN (SWF_SHOWFRAME);
1119
outputSWF_SOUNDSTREAMBLOCK (SWF_Parserstruct * pblock)
1121
//OUT_BEGIN (SWF_SOUNDSTREAMBLOCK);
1126
outputSWF_SOUNDSTREAMHEAD (SWF_Parserstruct * pblock)
1128
//OUT_BEGIN (SWF_SOUNDSTREAMHEAD);
1133
outputSWF_SOUNDSTREAMHEAD2 (SWF_Parserstruct * pblock)
1135
//OUT_BEGIN (SWF_SOUNDSTREAMHEAD2);
1140
outputSWF_STARTSOUND (SWF_Parserstruct * pblock)
1142
//OUT_BEGIN (SWF_STARTSOUND);
1147
outputSWF_SYNCFRAME (SWF_Parserstruct * pblock)
1149
//OUT_BEGIN (SWF_SYNCFRAME);
1154
outputSWF_INITACTION (SWF_Parserstruct * pblock)
1160
OUT_BEGIN (SWF_INITACTION);
1163
printf(" %d Actions\n", sblock->numActions);
1164
for(i=0;i<sblock->numActions;i++)
1165
outputSWF_ACTION(i,&(sblock->Actions[i]));
1167
printf ("%s\n", decompile5Action(sblock->numActions,sblock->Actions,0));
1173
outputSWF_VIDEOFRAME (SWF_Parserstruct * pblock)
1175
//OUT_BEGIN (SWF_VIDEOFRAME);
1180
static SWFOutput swfout;
1183
outputHeader (struct Movie *m)
1185
swfout=newSWFOutput();
1189
outputTrailer (struct Movie *m)
1193
out=newSizedSWFOutput(30);
1194
SWFOutput_writeUInt8(out,'F');
1195
SWFOutput_writeUInt8(out,'W');
1196
SWFOutput_writeUInt8(out,'S');
1197
SWFOutput_writeUInt8(out,4);
1198
SWFOutput_writeUInt32(out,SWFOutput_getLength(swfout)+23 /*size of header*/);
1199
SWFOutput_writeBits(out,15,5);
1200
SWFOutput_writeSBits(out,m->frame.xMin,15);
1201
SWFOutput_writeSBits(out,m->frame.xMax,15);
1202
SWFOutput_writeSBits(out,m->frame.yMin,15);
1203
SWFOutput_writeSBits(out,m->frame.yMax,15);
1204
SWFOutput_byteAlign(out);
1205
SWFOutput_writeUInt16(out,m->rate);
1206
SWFOutput_writeUInt16(out,m->nFrames);
1207
SWFOutput_writeToMethod(out,fileOutputMethod,stdout);
1208
SWFOutput_writeToMethod(swfout,fileOutputMethod,stdout);
1209
destroySWFOutput(swfout);
1210
destroySWFOutput(out);
1214
outputBlock (int type, SWF_Parserstruct * blockp,
1215
int offset, int length)
1223
for (i = 0; i < numOutputs; i++)
1225
if (outputs[i].type == type)
1227
blkout=outputs[i].output (blockp);
1228
SWFOutput_writeToMethod(blkout,SWFOutputMethod,swfout);
1229
destroySWFOutput(blkout);