X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswfaction.c;h=c20e4919a70859359cf05209dd9992530cb0ea66;hb=509560c32d1fb39bf51a6a3dce271f0f6954c5c8;hp=aa2894adc6d8e8991b152ba4059ffb6c96ad0695;hpb=2bbdd7671706b7de8efa6e364f19f462bb428bb0;p=swftools.git diff --git a/lib/modules/swfaction.c b/lib/modules/swfaction.c index aa2894a..c20e491 100644 --- a/lib/modules/swfaction.c +++ b/lib/modules/swfaction.c @@ -13,6 +13,8 @@ #include "../rfxswf.h" +#define MAX_LOOKUP 1024 // make cross references in dumps + struct Action { int version; @@ -229,21 +231,31 @@ int OpAdvance(char c, char*data) return 1+4; //int } else if (type == 8) { return 1+1; //lookup - } + } else return 1; break; } } return 0; } -/* TODO: this should be in swfdump.c */ +/* TODO: * this should be in swfdump.c */ void swf_DumpActions(ActionTAG*atag, char*prefix) { int t; U8*data; char* cp; - if(!prefix) - prefix=""; + int entry = 0; + +#ifdef MAX_LOOKUP + + char * lookup[MAX_LOOKUP]; + memset(lookup,0x00,sizeof(lookup)); + +#endif + + if (!prefix) + prefix=""; + while(atag) { U8 poollen = 0; @@ -264,8 +276,8 @@ void swf_DumpActions(ActionTAG*atag, char*prefix) { switch(*cp) { - case 'f': { - printf(" %d", *(U16*)data); //FIXME: le/be + case 'f': { //frame + printf(" %d", data[0]+256*data[1]); } break; case 'u': { printf(" URL:\"%s\"", data); @@ -278,9 +290,14 @@ void swf_DumpActions(ActionTAG*atag, char*prefix) } break; case 'c': { printf(" String:\"%s\"", data); +#ifdef MAX_LOOKUP + if (entrynext; } + +#ifdef MAX_LOOKUP + for (t=0;tnext; //first one is free while(a && a!=a2) { - if(a != a1) //first one is for free - { - len += ActionTagSize(a); - oplen ++; - } + len += ActionTagSize(a); + oplen ++; a = a->next; } if(!a) @@ -626,7 +661,7 @@ void action_fixjump(ActionMarker m1, ActionMarker m2) if (a1->op == ACTION_IF || a1->op == ACTION_JUMP) { - *(U16*)(a1->data) = len; + *(U16*)(a1->data) = SWAP16(len); } else if(a1->op == ACTION_WAITFORFRAME) { @@ -716,17 +751,17 @@ void action_Call() {swf_AddActionTAG(ACTION_CALL, 0, 0);} void action_End() {swf_AddActionTAG(ACTION_END, 0, 0);} void action_GotoFrame(U16 frame) { - *(U16*)currentatag->tmp = frame; + *(U16*)currentatag->tmp = SWAP16(frame); swf_AddActionTAG(ACTION_GOTOFRAME, (U8*)currentatag->tmp, 2); } void action_Jump(U16 branch) { - *(U16*)currentatag->tmp = branch; + *(U16*)currentatag->tmp = SWAP16(branch); swf_AddActionTAG(ACTION_JUMP, (U8*)currentatag->tmp, 2); } void action_If(U16 branch) { - *(U16*)currentatag->tmp = branch; + *(U16*)currentatag->tmp = SWAP16(branch); swf_AddActionTAG(ACTION_IF, (U8*)currentatag->tmp, 2); } void action_StoreRegister(U8 reg) @@ -751,7 +786,7 @@ void action_WaitForFrame2(U8 skip) } void action_WaitForFrame(U16 frame, U8 skip) { - *(U16*)currentatag->tmp = frame; + *(U16*)currentatag->tmp = SWAP16(frame); *(U8*)¤tatag->tmp[2] = skip; swf_AddActionTAG(ACTION_WAITFORFRAME, (U8*)currentatag->tmp, 3); } @@ -794,21 +829,39 @@ void action_PushString(char*str) void action_PushFloat(float f) { char*ptr = (char*)malloc(5); + U32 fd = *(U32*)&f; ptr[0] = 1; //float - *(float*)&ptr[1] = f; + ptr[1] = fd; + ptr[2] = fd>>8; + ptr[3] = fd>>16; + ptr[4] = fd>>24; swf_AddActionTAG(ACTION_PUSH, (U8*)ptr, 5); } void action_PushDouble(double d) { char*ptr = (char*)malloc(9); + U8*dd = (U8*)&d; ptr[0] = 6; //double - *(double*)&ptr[1] = d; +#ifdef WORDS_BIGENDIAN + ptr[1] = dd[7];ptr[2] = dd[6]; + ptr[3] = dd[5];ptr[4] = dd[4]; + ptr[5] = dd[3];ptr[6] = dd[2]; + ptr[7] = dd[1];ptr[8] = dd[0]; +#else + ptr[1] = dd[0];ptr[2] = dd[1]; + ptr[3] = dd[2];ptr[4] = dd[3]; + ptr[5] = dd[4];ptr[6] = dd[5]; + ptr[7] = dd[6];ptr[8] = dd[7]; +#endif swf_AddActionTAG(ACTION_PUSH, (U8*)ptr, 9); } void action_PushInt(int i) { *(U8*)currentatag->tmp = 7; //int - *(U8*)¤tatag->tmp[1] = i; + currentatag->tmp[1] = i; + currentatag->tmp[2] = i>>8; + currentatag->tmp[3] = i>>16; + currentatag->tmp[4] = i>>24; swf_AddActionTAG(ACTION_PUSH, (U8*)currentatag->tmp, 5); } void action_GotoLabel(char* label) @@ -829,3 +882,30 @@ void action_GetUrl(char* url, char* label) void action_DefineFunction(U8*data, int len) {} void action_Constantpool(char* constantpool) {} void action_With(char*object) {} + +/* + Properties: + + _X 0 + _Y 1 + _xscale 2 + _yscale 3 + _currentframe 4 + _totalframes 5 + _alpha 6 + _visible 7 + _width 8 + _height 9 + _rotation 10 + _target 11 + _framesloaded 12 + _name 13 + _droptarget 14 + _url 15 + _highquality 16 + _focusrect 17 + _soundbuftime 18 + _quality* 19 + _xmouse* 20 + _ymouse* 21 +*/