int s;
c->exceptions = list_new();
for(s=0;s<exception_count;s++) {
- exception_t*e = malloc(sizeof(exception_t));
+ abc_exception_t*e = malloc(sizeof(abc_exception_t));
e->from = code_atposition(codelookup, swf_GetU30(tag));
e->to = code_atposition(codelookup, swf_GetU30(tag));
code_write(tag, c->code, pool, file);
swf_SetU30(tag, list_length(c->exceptions));
- exception_list_t*l = c->exceptions;
+ abc_exception_list_t*l = c->exceptions;
while(l) {
// warning: assumes "pos" in each code_t is up-to-date
- swf_SetU30(tag, l->exception->from->pos);
- swf_SetU30(tag, l->exception->to->pos);
- swf_SetU30(tag, l->exception->target->pos);
- swf_SetU30(tag, pool_register_multiname(pool, l->exception->exc_type));
- swf_SetU30(tag, pool_register_multiname(pool, l->exception->var_name));
+ swf_SetU30(tag, l->abc_exception->from->pos);
+ swf_SetU30(tag, l->abc_exception->to->pos);
+ swf_SetU30(tag, l->abc_exception->target->pos);
+ swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->exc_type));
+ swf_SetU30(tag, pool_register_multiname(pool, l->abc_exception->var_name));
l = l->next;
}
code_free(body->code);body->code=0;
traits_free(body->traits);body->traits=0;
- exception_list_t*ee = body->exceptions;
+ abc_exception_list_t*ee = body->exceptions;
while(ee) {
- exception_t*e=ee->exception;ee->exception=0;
+ abc_exception_t*e=ee->abc_exception;ee->abc_exception=0;
e->from = e->to = e->target = 0;
multiname_destroy(e->exc_type);e->exc_type=0;
multiname_destroy(e->var_name);e->var_name=0;
{0x95, "typeof", "", -1, 1, 0, 0},
{0xa7, "urshift", "", -2, 1, 0, 0},
-/* dummy instruction. Warning: this one are not actually supported by flash */
+/* opcodes not documented, but seen in the wild */
+//0x53: seen in builtin.abc- followed by 0x01 (might be the number of stack params)
+{0x53, "xxx1", "", -1, 0, 0, 0},
+{0x01, "xxx2", "", 0, 0, 0, 0},
+
+/* dummy instruction. Warning: this one is not actually supported by flash */
{0xff, "__break__", "", 0, 0, 0, OP_RETURN},
};
opcode_t*op = opcode_get(opcode);
if(!op) {
fprintf(stderr, "Can't parse opcode %02x\n", opcode);
- return head;
+ continue;
}
//printf("%s\n", op->name);fflush(stdout);
NEW(code_t,c);
return 1;
}
-static currentstats_t* code_get_stats(code_t*code, exception_list_t*exceptions)
+static currentstats_t* code_get_stats(code_t*code, abc_exception_list_t*exceptions)
{
code = code_find_start(code);
int num = 0;
free(current);
return 0;
}
- exception_list_t*e = exceptions;
+ abc_exception_list_t*e = exceptions;
while(e) {
- if(e->exception->target)
- callcode(current, e->exception->target->pos, 1, 0);
+ if(e->abc_exception->target)
+ callcode(current, e->abc_exception->target->pos, 1, 0);
e = e->next;
}
}
}
-int code_dump(code_t*c, exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo)
+int code_dump(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo)
{
- exception_list_t*e = exceptions;
+ abc_exception_list_t*e = exceptions;
c = code_find_start(c);
currentstats_t*stats = code_get_stats(c, exceptions);
e = exceptions;
while(e) {
- if(c==e->exception->from)
+ if(c==e->abc_exception->from)
fprintf(fo, "%s TRY {\n", prefix);
- if(c==e->exception->target) {
- char*s1 = multiname_tostring(e->exception->exc_type);
- char*s2 = multiname_tostring(e->exception->var_name);
+ if(c==e->abc_exception->target) {
+ char*s1 = multiname_tostring(e->abc_exception->exc_type);
+ char*s2 = multiname_tostring(e->abc_exception->var_name);
fprintf(fo, "%s CATCH(%s %s)\n", prefix, s1, s2);
free(s1);
free(s2);
e = exceptions;
while(e) {
- if(c==e->exception->to) {
- if(e->exception->target)
- fprintf(fo, "%s } // END TRY (HANDLER: %d)\n", prefix, e->exception->target->pos);
+ if(c==e->abc_exception->to) {
+ if(e->abc_exception->target)
+ fprintf(fo, "%s } // END TRY (HANDLER: %d)\n", prefix, e->abc_exception->target->pos);
else
fprintf(fo, "%s } // END TRY (HANDLER: 00000000)\n", prefix);
}
return 1;
}
-codestats_t* code_get_statistics(code_t*code, exception_list_t*exceptions)
+codestats_t* code_get_statistics(code_t*code, abc_exception_list_t*exceptions)
{
currentstats_t*current = code_get_stats(code, exceptions);
if(!current)
code_t*add_opcode(code_t*atag, U8 op);
code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool, codelookup_t**codelookup);
-int code_dump(code_t*c, exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo);
+int code_dump(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo);
void code_write(TAG*tag, code_t*code, pool_t*pool, abc_file_t*file);
void code_free(code_t*c);
code_t* code_atposition(codelookup_t*l, int pos);
void codelookup_free(codelookup_t*codelookup);
-codestats_t* code_get_statistics(code_t*code, exception_list_t*exceptions);
+codestats_t* code_get_statistics(code_t*code, abc_exception_list_t*exceptions);
void codestats_print(codestats_t*s);
void codestats_free(codestats_t*s);