?? decomp_action.h
字號:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <stdarg.h>#include <errno.h>#include <math.h>#include <assert.h>#include <signal.h>#include <setjmp.h>#include <ctype.h>#include "DataTypes.h"#ifndef SWF_READ_H_INCLUDED#define SWF_READ_H_INCLUDED
extern int gIndent;extern int fileOffset;typedef unsigned char boolean;#define true (boolean)1#define false (boolean)0char *indent();void dumpBuffer(unsigned char *buf, int length);#endif /* SWF_READ_H_INCLUDED */#ifndef SWF_ACTION_H_INCLUDED#define SWF_ACTION_H_INCLUDEDtypedef enum{ SWFACTION_END = 0x00, /* v3 actions */ SWFACTION_NEXTFRAME = 0x04, SWFACTION_PREVFRAME = 0x05, SWFACTION_PLAY = 0x06, SWFACTION_STOP = 0x07, SWFACTION_TOGGLEQUALITY = 0x08, SWFACTION_STOPSOUNDS = 0x09, SWFACTION_GOTOFRAME = 0x81, /* >= 0x80 means record has args */ SWFACTION_GETURL = 0x83, SWFACTION_WAITFORFRAME = 0x8A, SWFACTION_SETTARGET = 0x8B, SWFACTION_GOTOLABEL = 0x8C, /* v4 actions */ SWFACTION_ADD = 0x0A, SWFACTION_SUBTRACT = 0x0B, SWFACTION_MULTIPLY = 0x0C, SWFACTION_DIVIDE = 0x0D, SWFACTION_EQUAL = 0x0E, SWFACTION_LESSTHAN = 0x0F, SWFACTION_LOGICALAND = 0x10, SWFACTION_LOGICALOR = 0x11, SWFACTION_LOGICALNOT = 0x12, SWFACTION_STRINGEQ = 0x13, SWFACTION_STRINGLENGTH = 0x14, SWFACTION_SUBSTRING = 0x15, SWFACTION_POP = 0x17, SWFACTION_INT = 0x18, SWFACTION_GETVARIABLE = 0x1C, SWFACTION_SETVARIABLE = 0x1D, SWFACTION_SETTARGETEXPRESSION = 0x20, SWFACTION_STRINGCONCAT = 0x21, SWFACTION_GETPROPERTY = 0x22, SWFACTION_SETPROPERTY = 0x23, SWFACTION_DUPLICATECLIP = 0x24, SWFACTION_REMOVECLIP = 0x25, SWFACTION_TRACE = 0x26, SWFACTION_STARTDRAGMOVIE = 0x27, SWFACTION_STOPDRAGMOVIE = 0x28, SWFACTION_STRINGCOMPARE = 0x29, SWFACTION_RANDOM = 0x30, SWFACTION_MBLENGTH = 0x31, SWFACTION_ORD = 0x32, SWFACTION_CHR = 0x33, SWFACTION_GETTIMER = 0x34, SWFACTION_MBSUBSTRING = 0x35, SWFACTION_MBORD = 0x36, SWFACTION_MBCHR = 0x37, SWFACTION_WAITFORFRAMEEXPRESSION = 0x8D, SWFACTION_PUSHDATA = 0x96, SWFACTION_BRANCHALWAYS = 0x99, SWFACTION_GETURL2 = 0x9A, SWFACTION_BRANCHIFTRUE = 0x9D, SWFACTION_CALLFRAME = 0x9E, SWFACTION_GOTOEXPRESSION = 0x9F, /* v5 actions */ SWFACTION_DELETE = 0x3B, SWFACTION_VAREQUALS = 0x3C, SWFACTION_CALLFUNCTION = 0x3D, SWFACTION_RETURN = 0x3E, SWFACTION_MODULO = 0x3F, SWFACTION_NEW = 0x40, SWFACTION_VAR = 0x41, SWFACTION_INITARRAY = 0x42, SWFACTION_INITOBJECT = 0x43, SWFACTION_TYPEOF = 0x44, SWFACTION_ENUMERATE = 0x46, SWFACTION_NEWADD = 0x47, SWFACTION_NEWLESSTHAN = 0x48, SWFACTION_NEWEQUAL = 0x49, SWFACTION_TONUMBER = 0x4A, SWFACTION_TOSTRING = 0x4B, SWFACTION_DUP = 0x4C, SWFACTION_SWAP = 0x4D, SWFACTION_GETMEMBER = 0x4E, SWFACTION_SETMEMBER = 0x4F, SWFACTION_INCREMENT = 0x50, SWFACTION_DECREMENT = 0x51, SWFACTION_CALLMETHOD = 0x52, SWFACTION_BITWISEAND = 0x60, SWFACTION_BITWISEOR = 0x61, SWFACTION_BITWISEXOR = 0x62, SWFACTION_SHIFTLEFT = 0x63, SWFACTION_SHIFTRIGHT = 0x64, SWFACTION_SHIFTRIGHT2 = 0x65, SWFACTION_SETREGISTER = 0x87, SWFACTION_DECLARENAMES = 0x88, SWFACTION_WITH = 0x94, SWFACTION_DEFINEFUNCTION = 0x9B, SWFACTION_EVAL = 0xFC, SWFACTION_TEMPORARY = 0xFE, /* v6 actions */ SWFACTION_INSTANCEOF = 0x54, SWFACTION_ENUMERATEVALUE = 0x55, SWFACTION_STRICTEQUALS = 0x66, SWFACTION_GREATERTHAN = 0x67, SWFACTION_STRINGGREATERTHAN = 0x68, SWFACTION_STRICTMODE = 0x89, /* v7 actions */ SWFACTION_CAST = 0x2B, SWFACTION_IMPLEMENTS = 0x2C, SWFACTION_EXTENDS = 0x69, SWFACTION_DEFINEFUNCTION2 = 0x8E, SWFACTION_TRY = 0x8F, SWFACTION_THROW = 0x2A} Action;typedef enum{ PROPERTY_X = 0x00, PROPERTY_Y = 0x01, PROPERTY_XSCALE = 0x02, PROPERTY_YSCALE = 0x03, PROPERTY_CURRENTFRAME = 0x04, PROPERTY_TOTALFRAMES = 0x05, PROPERTY_ALPHA = 0x06, PROPERTY_VISIBLE = 0x07, PROPERTY_WIDTH = 0x08, PROPERTY_HEIGHT = 0x09, PROPERTY_ROTATION = 0x0a, PROPERTY_TARGET = 0x0b, PROPERTY_FRAMESLOADED = 0x0c, PROPERTY_NAME = 0x0d, PROPERTY_DROPTARGET = 0x0e, PROPERTY_URL = 0x0f, PROPERTY_XMOUSE = 0x10, PROPERTY_YMOUSE = 0x11, PROPERTY_HIGHQUALITY = 0x12, PROPERTY_FOCUSRECT = 0x13, PROPERTY_SOUNDBUFTIME = 0x14, PROPERTY_QUALITY = 0x15, PROPERTY_WTHIT = 0x16} Property;#define SWF_SETPROPERTY_X 0x0000#define SWF_SETPROPERTY_Y 0x3F80#define SWF_SETPROPERTY_XSCALE 0x4000#define SWF_SETPROPERTY_YSCALE 0x4040#define SWF_SETPROPERTY_ALPHA 0x40C0#define SWF_SETPROPERTY_VISIBILITY 0x40E0#define SWF_SETPROPERTY_ROTATION 0x4120#define SWF_SETPROPERTY_NAME 0x4140#define SWF_SETPROPERTY_HIGHQUALITY 0x4180#define SWF_SETPROPERTY_SHOWFOCUSRECT 0x4188#define SWF_SETPROPERTY_SOUNDBUFFERTIME 0x4190#define SWF_SETPROPERTY_WTHIT 0x4680#define DUPCLIP_NUMBER 0x4000#endif /* SWF_ACTION_H_INCLUDED */void err_debug(int,const char *,...);#define MIN(a,b) ((a)>(b)?(b):(a))typedef unsigned char byte;struct _tree { struct _stack *left; struct _stack *right; Action action; uint8_t flags;};typedef struct _tree *Tree;#define NORMAL 0#define LEFT_CAN_FREE 1#define RIGHT_CAN_FREE 2#define LEFT_IS_LIST 4#define RIGHT_IS_LIST 8#define RIGHT_CANNOT_FREE 16#define LEFT_CANNOT_FREE 32#define RIGHT_IS_REG_ARRAY 64#define LEFT_IS_REG_ARRAY 128#define IS_INIT 0#define IS_TARGET 1#define IS_PROPERTY 2#define IS_EXPRESSION 4#define IS_CONSTANT 8#define IS_ARRAY 16#define IS_VARIABLE 32#define IS_MEMBER 64#define IS_OBJECT 128#define VALUE_STRING 1#define VALUE_INTEGER 2#define VALUE_PROPERTY 4#define VALUE_BOOL 8#define VALUE_DOUBLE 16#define VALUE_NULL 32#define VALUE_UNDEF 64#define VALUE_NUMBER (VALUE_INTEGER | VALUE_DOUBLE)#define LOOP_DO 1#define LOOP_WHILE 2#define LOOP_IF 4#define LOOP_ELSE 8#define LOOP_IFELSE 16#define LOOP_BREAK 32#define LOOP_CONTINUE 64typedef struct { uint8_t flags; uint8_t value_type;}my_type;struct _stack { struct _stack *next; char type; /* (s)tring, (t)ree, (p)roperty, (b)ranch, (i), (d) */ union { char *string; int inum; double dnum; Tree tree; Property prop; } data; int offset; int *target; /* statement number which branches to this statement */ int ntarget; uint8_t loop_flags; uint8_t loop_index; my_type t; int16_t index;};typedef struct _stack *Stack;enum{ FLASM_BIG_ENDIAN, FLASM_LITTLE_ENDIAN};void checkByteOrder();int intVal(Stack );typedef struct { char *ptr; my_type t;}my_dictionary;#define TYPE_VOID 0#define TYPE_DICTIONARY 1#define TYPE_STATEMENTS 2#define TYPE_REGISTER 3struct mem_chain { void *ptr; size_t size; uint8_t type; struct mem_chain *next;};#define DEBUG_COMPILE#define ERR_STACK -101#define ERR_PCODE -121#define ERR_PROPERTY -122#define ERR_TREE -123#define ERR_OPERATE -124#define ERR_REGISTER -125#define ERR_ARGUMENT -126#define ERR_DEPTH -127#define ERR_DATA -128#define ERR_MEMORY -129#define ERR_OTHER -130#define ERR_BRANCH -131#define ERR_INPUT -132#define ERR_CALL -133#define ERR_VALUE -102/*-----------------------Read-part-head--------------------------*/extern unsigned char * action_block;extern ssize_t action_len;extern size_t ptr_offset;//#define my_readUInt8() ((uint8_t)action_block[ptr_offset++])#define my_readSInt8() ((signed char)My_readUInt8())#define my_readSInt16() ((int16_t)(My_readUInt8() + my_readSInt8()*256))#define my_readUInt16() ((uint16_t)(My_readUInt8() + (My_readUInt8()<<8)))#define my_readSInt32() ((int32_t)((int32_t)My_readUInt8() + (My_readUInt8()<<8) + (My_readUInt8()<<16) + (My_readUInt8()<<24)))#define my_readUInt32() ((uint32_t)((uint32_t)(My_readUInt8() + (My_readUInt8()<<8) + (My_readUInt8()<<16) + (My_readUInt8()<<24))))#define block_eof() (ptr_offset>=action_len)#define TEST_SPACE(a) ((action_len-ptr_offset)>=(a))/*-----------------------print-part-head----------------------------*/typedef struct { char *ptr; uint32_t cur; uint32_t len; uint8_t flags;}print_buffer;#define BUFFER_DEF_SIZE 8192#define BUFFER_STEP_SIZE 1024#define BUFFER_MAX_SIZE 4194304#define BUFFER_UN_INIT 0#define BUFFER_INIT 1#define my_len (my_buffer.len)#define my_cur (my_buffer.cur)#define my_ptr (my_buffer.ptr)#define my_flags (my_buffer.flags)#define my_cur_ptr (((char *)my_ptr)+my_cur)#define my_end ((char *)my_ptr+(my_len-1))#define my_remain_len (my_end-my_cur_ptr)#define BUFFER_WILL_FULL (my_cur_ptr>=((char*)my_end-70))#define BUFFER_IS_FULL (my_cur_ptr>=my_end)#define INIT_BUFFER {memset(&my_buffer,0,sizeof(my_buffer));}#define IMPOSSIBLE_BIT_LOCAL 254typedef enum{ BRANCH_NONE = 0, BRANCH_WHILE, BRANCH_DO, BRANCH_IF, BRANCH_ELSE} Branchtype;#define REG_THIS 0#define REG_ARGUMENT 1#define REG_SUPER 2#define REG_ROOT 3#define REG_PARENT 4#define REG_GLOBAL 5#define GLOBAL_REGISTER 0#define FUNCTION2_REGISTER 1#define PRIVATE_REGISTER 2struct register_array { uint16_t flags; uint32_t len; uint16_t owner; Stack *reglist;};typedef struct register_array reg_array;#define MAX_AUTO_REGS 6static int readStatements(ssize_t, Stack **);void decompileStatements(Stack *statements, int n);static void listItem(Stack s, Action parent);static void resolveOffsets(Stack *statements, int nStatements);static void untangleBranches(Stack *statements, int start, int stop,Branchtype type, int indent);static Stack negateExpression(Stack s);int set_dictionary(Stack );my_type * set_my_type(my_type * ,uint8_t ,uint8_t );uint8_t property_type(uint8_t);Stack set_stack(Stack ,uint8_t ,uint8_t);my_type test_descendiblity(Stack ,Action ,Stack );char *over_space(char *);int my_int_comp(const void *,const void *);int mark_loop(Stack *,int);void *Realloc(void *,size_t);void * Malloc(size_t);size_t re_allocate_buffer(size_t);int my_printf(const char *,...);double My_readDouble();char *My_readString();int16_t My_readSInt16();uint16_t My_readUInt16();int32_t My_readSInt32();uint32_t My_readUInt32();uint8_t My_readUInt8();int8_t My_readSInt8();void Warning(const char *, ...);void error(const char *, ...);void clean_proc();static void destroyTree(Stack s);void checkByteOrder();int my_strcmp(char *,char *);int my_strcmp_l(char *,char *);int freeReg(reg_array *);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -