CompiledExpr FieldExpr::compile() { if (this->protected_data->internal_type == 0) { std::string compiled_value( get_field_name() + " == '" + this->protected_data->value + "'"); return CompiledExpr(get_compiled_expr_type(), compiled_value.c_str()); } else if (this->protected_data->internal_type == 1) { return CompiledExpr(get_compiled_expr_type(), this->protected_data->function->compile(get_field_name().c_str())); } }
void Class::printField() { for(int i=0;i<fields_count; i++) { printf("[%d] ", i); print_access(get_field_flags(i)); printf("%s:", get_field_name(i)); printf("%s\n", get_field_type(i)); } }
//'finfo': field info. static void dumpf_field(DexFile * df, DexField * finfo, INT indent) { if (g_tfile == NULL) { return; } CHAR const* fname = get_field_name(df, finfo); CHAR const* tname = get_field_type_name(df, finfo); IS_TRUE0(fname && tname); while (indent-- >= 0) { fprintf(g_tfile, " "); } fprintf(g_tfile, "%dth, %s, TYPE:%s", finfo->fieldIdx, fname, tname); fflush(g_tfile); }
int Class::get_field_index(char *name) { int index = -1; for(int i=0; i<fields_count; i++) { if(strcmp((char *)name, (char *)get_field_name(i)) == 0) { index = i; break; } } return index; }
/** * \brief Remove the value in the selected field. */ void bf::item_field_edit::delete_selected_field() { long index = GetFocusedItem(); if ( index != wxNOT_FOUND ) { std::string name; if ( get_field_name(index, name) ) { m_last_edited_field = name; delete_item_field_event event ( name, delete_item_field_event::delete_field_event_type, GetId() ); event.SetEventObject(this); if ( ProcessEvent(event) ) update_value(index); } } } // item_field_edit::delete_selected_field()
/** * \brief Event sent when the user activates an item. * \param event The event. */ void bf::item_field_edit::on_item_activated( wxListEvent& event ) { std::string name; if ( get_field_name(event.GetIndex(), name) ) create_field_editor( name ); else { if ( m_hidden.find(name) == m_hidden.end() ) m_hidden.insert(name); else m_hidden.erase(name); DeleteAllItems(); enumerate_properties(); update_values(); if ( event.GetIndex() < GetItemCount() ) Select( event.GetIndex() ); } } // item_field_edit::on_item_activated()
// Adds a field to the buffer static void add_field(char *instring, int section, long offset) { int i; char field[MAX_FIELD_WIDTH+1]; // Extract field name get_field_name(field,instring); // See if field already exists for (i=0;i<NUM_FIELD_BUFFERS;i++) if (field_buffers[i].section==section) if (stricmp(field_buffers[i].name,field)==0) return; // Increment current_field_buffer current_field_buffer++; if (current_field_buffer>NUM_FIELD_BUFFERS) current_field_buffer=0; // Set buffer information strcpy(field_buffers[current_field_buffer].name,field); field_buffers[current_field_buffer].section=section; field_buffers[current_field_buffer].offset=offset; }
/** * \brief Update the displayed value of a field. * \param index The index of the field in the view. */ void bf::item_field_edit::update_value( long index ) { std::string name; if( get_field_name(index, name) ) { wxListItem prop; prop.SetId(index); GetItem(prop); const type_field& f = get_common_field(name); const bool has_val = group_has_value(f); prop.SetText( get_common_value_as_text(f) ); prop.SetColumn(1); SetItem(prop); if ( f.get_required() ) set_required_color(index, has_val); else set_default_value_color(index, has_val); } } // item_field_edit::update_value()
//finfo: field-info in class. CHAR const* get_field_name(DexFile * df, DexField * finfo) { //Get field's name via nameIdx in symbol table. return get_field_name(df, finfo->fieldIdx); }
//Dump LIR stmts stored in fu->lirList array. void dump_lir2(LIR * lir, DexFile * df, INT pos) { if (g_tfile == NULL || lir == NULL) return; if (pos < 0) { fprintf(g_tfile, "%s", LIR_name(lir)); } else { fprintf(g_tfile, "(%dth)%s", pos, LIR_name(lir)); } switch (LIR_opcode(lir)) { case LOP_NOP: break; case LOP_CONST: switch (LIR_dt(lir)) { case LIR_JDT_unknown: fprintf(g_tfile, ", INT"); if (is_s4(LIR_int_imm(lir)) && LIR_res(lir) < 16) { //AB fprintf(g_tfile, ", v%d <- %d", LIR_res(lir), (INT)LIR_int_imm(lir)); } else if (is_s16(LIR_int_imm(lir))) { //AABBBB fprintf(g_tfile, ", v%d <- %d", LIR_res(lir), (INT)LIR_int_imm(lir)); } else { //AABBBBBBBB fprintf(g_tfile, ", v%d <- %d", LIR_res(lir), (INT)LIR_int_imm(lir)); } break; case LIR_JDT_wide: fprintf(g_tfile, ", %s", get_dt_name(lir)); if (is_swide16(LIR_int_imm(lir))) { //AABBBB fprintf(g_tfile, ", (v%d,v%d) <- %d", LIR_res(lir), LIR_res(lir) + 1, (INT)LIR_int_imm(lir)); } else if (is_swide32(LIR_int_imm(lir))) { //AABBBBBBBB fprintf(g_tfile, ", (v%d,v%d) <- %d", LIR_res(lir), LIR_res(lir) + 1, (INT)LIR_int_imm(lir)); } else { //AABBBBBBBBBBBBBBBB fprintf(g_tfile, ", (v%d,v%d) <- %lld", LIR_res(lir), LIR_res(lir) + 1, LIR_int_imm(lir)); } break; default: /* It seems dex does not distinguish float and integer const. And regard float as 32bit integer, double will be 64bit integer. */ IS_TRUE0(0); } break; case LOP_RETURN: { switch (LIR_dt(lir)) { case LIR_JDT_unknown: //return preg. fprintf(g_tfile, ", INT"); fprintf(g_tfile, ", v%d", LIR_res(lir)); break; case LIR_JDT_void: //No return value. break; case LIR_JDT_object: //return object. fprintf(g_tfile, ", obj_ptr:v%d", LIR_res(lir)); break; case LIR_JDT_wide: fprintf(g_tfile, ", %s", get_dt_name(lir)); fprintf(g_tfile, ", (v%d,v%d)", LIR_res(lir), LIR_res(lir) + 1); break; default: IS_TRUE0(0); } } break; case LOP_THROW: //AA //Throws an exception object. //The reference of the exception object is in vx. fprintf(g_tfile, ", v%d", LIR_res(lir)); break; case LOP_MONITOR_ENTER : fprintf(g_tfile, ", v%d", LIR_res(lir)); break; case LOP_MONITOR_EXIT : break; case LOP_MOVE_RESULT : { //Move function return value to regisiter. //AA LIRAOp * p = (LIRAOp*)lir; switch (LIR_dt(lir)) { case LIR_JDT_unknown: //lexOpcode = lc_mov_result32; break; fprintf(g_tfile, ", INT"); fprintf(g_tfile, ", retval -> v%d", LIR_res(lir)); break; case LIR_JDT_wide: //lexOpcode = lc_mov_result64; break; fprintf(g_tfile, ", %s", get_dt_name(lir)); fprintf(g_tfile, ", retval -> (v%d,v%d)", LIR_res(lir), LIR_res(lir) + 1); break; case LIR_JDT_object: //lexOpcode = lc_mov_result_object; break; fprintf(g_tfile, ", obj-ptr"); fprintf(g_tfile, ", retval -> v%d", LIR_res(lir)); break; } } break; case LOP_MOVE_EXCEPTION : //AA fprintf(g_tfile, ", v%d", LIR_res(lir)); break; case LOP_GOTO : //AABBBBBBBB { LIRGOTOOp * p = (LIRGOTOOp*)lir; fprintf(g_tfile, ", (lirIdx)%dth", p->target); } break; case LOP_MOVE : switch (LIR_dt(lir)) { case LIR_JDT_unknown: fprintf(g_tfile, ", INT"); if ((LIR_op0(lir) | LIR_res(lir)) < 16) { //AB fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } else if (LIR_res(lir) < 256) { //AABBBB fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } else { //AAAABBBB fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } break; case LIR_JDT_wide: fprintf(g_tfile, ", %s", get_dt_name(lir)); if ((LIR_op0(lir) | LIR_res(lir)) < 16) { //AB fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d)", LIR_res(lir), LIR_res(lir) + 1, LIR_op0(lir), LIR_op0(lir) + 1); } else if (LIR_res(lir) < 256) { //AABBBB fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d)", LIR_res(lir), LIR_res(lir) + 1, LIR_op0(lir), LIR_op0(lir) + 1); } else { //AAAABBBB fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d)", LIR_res(lir), LIR_res(lir) + 1, LIR_op0(lir), LIR_op0(lir) + 1); } break; case LIR_JDT_object: fprintf(g_tfile, ", obj-ptr"); if ((LIR_op0(lir) | LIR_res(lir)) < 16) { //AB fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } else if (LIR_res(lir) < 256) { //AABBBB fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } else { //AAAABBBB fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } break; } break; case LOP_NEG : //AB case LOP_NOT : //AB fprintf(g_tfile, ", %s", get_dt_name(lir)); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d)", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1); } else { fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); } break; case LOP_CONVERT : //AB switch (LIR_dt(lir)) { case LIR_convert_i2l: fprintf(g_tfile, ", INT->LONG"); fprintf(g_tfile, ", (v%d,v%d) <- v%d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir)); break; case LIR_convert_i2f: fprintf(g_tfile, ", INT->FLOAT"); break; case LIR_convert_i2d: fprintf(g_tfile, ", INT->DOUBLE"); fprintf(g_tfile, ", (v%d,v%d) <- v%d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir)); break; case LIR_convert_l2i: fprintf(g_tfile, ", LONG->INT"); fprintf(g_tfile, ", v%d <- (v%d,v%d)", LIR_res(lir), LIR_op0(lir), LIR_op0(lir)+1); break; case LIR_convert_l2f: fprintf(g_tfile, ", LONG->FLOAT"); fprintf(g_tfile, ", v%d <- (v%d,v%d)", LIR_res(lir), LIR_op0(lir), LIR_op0(lir)+1); break; case LIR_convert_l2d: fprintf(g_tfile, ", LONG->DOUBLE"); fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d)", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1); break; case LIR_convert_f2i: fprintf(g_tfile, ", FLOAT->INT"); break; case LIR_convert_f2l: fprintf(g_tfile, ", FLOAT->LONG"); fprintf(g_tfile, ", (v%d,v%d) <- v%d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir)); break; case LIR_convert_f2d: fprintf(g_tfile, ", FLOAT->DOUBLE"); fprintf(g_tfile, ", (v%d,v%d) <- v%d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir)); break; case LIR_convert_d2i: fprintf(g_tfile, ", DOUBLE->INT"); fprintf(g_tfile, ", v%d <- (v%d,v%d)", LIR_res(lir), LIR_op0(lir), LIR_op0(lir)+1); break; case LIR_convert_d2l: fprintf(g_tfile, ", DOUBLE->LONG"); fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d)", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1); break; case LIR_convert_d2f: fprintf(g_tfile, ", DOUBLE->FLOAT"); fprintf(g_tfile, ", v%d <- (v%d,v%d)", LIR_res(lir), LIR_op0(lir), LIR_op0(lir)+1); break; case LIR_convert_i2b: fprintf(g_tfile, ", INT->BOOL"); fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); break; case LIR_convert_i2c: fprintf(g_tfile, ", INT->CHAR"); fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); break; case LIR_convert_i2s: fprintf(g_tfile, ", INT->SHORT"); fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); break; default: IS_TRUE0(0); } break; case LOP_ADD_ASSIGN : case LOP_SUB_ASSIGN : case LOP_MUL_ASSIGN : case LOP_DIV_ASSIGN : case LOP_REM_ASSIGN : case LOP_AND_ASSIGN : case LOP_OR_ASSIGN : case LOP_XOR_ASSIGN : case LOP_SHL_ASSIGN : case LOP_SHR_ASSIGN : case LOP_USHR_ASSIGN: fprintf(g_tfile, ", %s", get_dt_name(lir)); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d), (v%d,v%d)", LIR_res(lir), LIR_res(lir)+1, LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1); } else { fprintf(g_tfile, ", v%d <- v%d, v%d", LIR_res(lir), LIR_res(lir), LIR_op0(lir)); } break; case LOP_ARRAY_LENGTH: //AABBBB //Calculates the number of elements of the array referenced by vy //and puts the length value into vx. fprintf(g_tfile, ", v%d <- v%d", LIR_res(lir), LIR_op0(lir)); break; case LOP_IFZ : //AABBBB switch (LIR_dt(lir)) { case LIR_cond_EQ: fprintf(g_tfile, ", =="); break; case LIR_cond_NE: fprintf(g_tfile, ", !="); break; case LIR_cond_LT: fprintf(g_tfile, ", <"); break; case LIR_cond_GE: fprintf(g_tfile, ", >="); break; case LIR_cond_GT: fprintf(g_tfile, ", >"); break; case LIR_cond_LE: fprintf(g_tfile, ", <="); break; } if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d), 0, (lirIdx)%dth", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir)); } else { fprintf(g_tfile, ", v%d, 0, (lirIdx)%dth", LIR_res(lir), LIR_op0(lir)); } break; case LOP_NEW_INSTANCE: //AABBBB //LIR_op0(lir) is class-type-id, not class-declaration-id. IS_TRUE0(df); fprintf(g_tfile, ", (obj_ptr)v%d <- (clsname<%d>)%s", LIR_res(lir), LIR_op0(lir), get_class_name(df, LIR_op0(lir))); break; case LOP_CONST_STRING: //AABBBB or AABBBBBBBB IS_TRUE0(df); fprintf(g_tfile, ", v%d <- (strofst<%d>)\"%s\"", LIR_res(lir), LIR_op0(lir), dexStringById(df, LIR_op0(lir))); break; case LOP_CONST_CLASS : //AABBBB //const-class vx,type_id //Moves the class object of a class identified by //type_id (e.g. Object.class) into vx. fprintf(g_tfile, ", v%d <- (clsname<%d>)%s", LIR_res(lir), LIR_op0(lir), dexStringByTypeIdx(df, LIR_op0(lir))); break; case LOP_SGET : //AABBBB fprintf(g_tfile, ", %s", get_dt_name(lir)); IS_TRUE0(df); fprintf(g_tfile, ", v%d <- (ofst<%d>)%s::%s", LIR_res(lir), LIR_op0(lir), get_field_class_name(df, LIR_op0(lir)), get_field_name(df, LIR_op0(lir))); break; case LOP_CHECK_CAST : //AABBBB IS_TRUE0(df); fprintf(g_tfile, ", v%d '%s'", LIR_res(lir), dexStringByTypeIdx(df, LIR_op0(lir))); break; case LOP_SPUT : { //AABBBB LIRABOp * p = (LIRABOp*)lir; fprintf(g_tfile, ", %s", get_dt_name(lir)); IS_TRUE0(df); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) -> %s::%s", LIR_res(lir), LIR_res(lir)+1, get_field_class_name(df, LIR_op0(lir)), get_field_name(df, LIR_op0(lir))); } else { fprintf(g_tfile, ", v%d -> %s::%s", LIR_res(lir), get_field_class_name(df, LIR_op0(lir)), get_field_name(df, LIR_op0(lir))); } } break; case LOP_APUT : //AABBCC fprintf(g_tfile, ", %s", get_dt_name(lir)); IS_TRUE0(df); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) -> (array_base_ptr)v%d, (array_elem)v%d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), (UINT)LIR_op1(lir)); } else { fprintf(g_tfile, ", v%d -> (array_base_ptr)v%d, (array_elem)v%d", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir)); } break; case LOP_AGET : //AABBCC fprintf(g_tfile, ", %s", get_dt_name(lir)); IS_TRUE0(df); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) <- (array_base_ptr)v%d, (array_elem)v%d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), (UINT)LIR_op1(lir)); } else { fprintf(g_tfile, ", v%d <- (array_base_ptr)v%d, (array_elem)v%d", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir)); } break; case LOP_CMPL : case LOP_CMP_LONG : //AABBCC IS_TRUE0(df); switch (LIR_dt(lir)) { case LIR_CMP_float: fprintf(g_tfile, ", FLOAT"); fprintf(g_tfile, ", v%d, v%d, %d", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir)); break; case LIR_CMP_double: fprintf(g_tfile, ", DOUBLE"); fprintf(g_tfile, ", (v%d,v%d), (v%d,v%d), %d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1, (UINT)LIR_op1(lir)); break; default: IS_TRUE0(0); } break; case LOP_ADD : case LOP_SUB : case LOP_MUL : case LOP_DIV : case LOP_REM : case LOP_AND : case LOP_OR : case LOP_XOR : case LOP_SHL : case LOP_SHR : case LOP_USHR : { fprintf(g_tfile, ", %s", get_dt_name(lir)); LIRABCOp * p = (LIRABCOp*)lir; if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d), (v%d,v%d)", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1, (UINT)LIR_op1(lir), (UINT)LIR_op1(lir)+1); } else { fprintf(g_tfile, ", v%d <- v%d, v%d", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir)); } } break; case LOP_IF : //ABCCCC switch (LIR_dt(lir)) { case LIR_cond_EQ: fprintf(g_tfile, ", =="); break; case LIR_cond_NE: fprintf(g_tfile, ", !="); break; case LIR_cond_LT: fprintf(g_tfile, ", <"); break; case LIR_cond_GE: fprintf(g_tfile, ", >="); break; case LIR_cond_GT: fprintf(g_tfile, ", >"); break; case LIR_cond_LE: fprintf(g_tfile, ", <="); break; } fprintf(g_tfile, ", v%d, v%d, (lirIdx)%dth", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir)); break; case LOP_ADD_LIT : //AABBCC, AABBCCCC case LOP_SUB_LIT : //AABBCC, AABBCCCC case LOP_MUL_LIT : //AABBCC, AABBCCCC case LOP_DIV_LIT : //AABBCC, AABBCCCC case LOP_REM_LIT : //AABBCC, AABBCCCC case LOP_AND_LIT : //AABBCC, AABBCCCC case LOP_OR_LIT : //AABBCC, AABBCCCC case LOP_XOR_LIT : //AABBCC, AABBCCCC case LOP_SHL_LIT : //AABBCC case LOP_SHR_LIT : //AABBCC case LOP_USHR_LIT : //AABBCC { fprintf(g_tfile, ", %s", get_dt_name(lir)); LIRABCOp * p = (LIRABCOp*)lir; if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) <- (v%d,v%d),", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), LIR_op0(lir)+1); } else { fprintf(g_tfile, ", v%d <- v%d,", LIR_res(lir), LIR_op0(lir)); } if (is_s8((INT)LIR_op1(lir))) { //8bit imm fprintf(g_tfile, "(lit8)%d", (INT)LIR_op1(lir)); } else if (is_s16((INT)LIR_op1(lir))) { //16bit imm fprintf(g_tfile, "(lit16)%d", (INT)LIR_op1(lir)); } else { IS_TRUE0(0); } } break; case LOP_IPUT : fprintf(g_tfile, ", %s", get_dt_name(lir)); //ABCCCC IS_TRUE0(df); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) -> (obj_ptr)v%d, (ofst<%d>)%s::%s", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), (UINT)LIR_op1(lir), get_field_class_name(df, (UINT)LIR_op1(lir)), get_field_name(df, (UINT)LIR_op1(lir))); } else { fprintf(g_tfile, ", v%d -> (obj_ptr)v%d, (ofst<%d>)%s::%s", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir), get_field_class_name(df, (UINT)LIR_op1(lir)), get_field_name(df, (UINT)LIR_op1(lir))); } break; case LOP_IGET : fprintf(g_tfile, ", %s", get_dt_name(lir)); //ABCCCC IS_TRUE0(df); if (is_wide(lir)) { fprintf(g_tfile, ", (v%d,v%d) <- (obj_ptr)v%d, (ofst<%d>)%s::%s", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), (UINT)LIR_op1(lir), get_field_class_name(df, (UINT)LIR_op1(lir)), get_field_name(df, (UINT)LIR_op1(lir))); } else { fprintf(g_tfile, ", v%d <- (obj_ptr)v%d, (ofst<%d>)%s::%s", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir), get_field_class_name(df, (UINT)LIR_op1(lir)), get_field_name(df, (UINT)LIR_op1(lir))); } break; case LOP_INSTANCE_OF: fprintf(g_tfile, ", (pred)v%d <- v%d, (clsname<%d>)'%s'", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir), dexStringByTypeIdx(df, (UINT)LIR_op1(lir))); break; case LOP_NEW_ARRAY : //ABCCCC //new-array v%d(res) <- v%d(op0), LCAnimal(op1) fprintf(g_tfile, ", %s", get_dt_name(lir)); //ABCCCC IS_TRUE0(df); fprintf(g_tfile, ", v%d <- (num_of_elem)v%d, (elem_type<%d>)'%s'", LIR_res(lir), LIR_op0(lir), (UINT)LIR_op1(lir), dexStringByTypeIdx(df, (UINT)LIR_op1(lir))); break; case LOP_TABLE_SWITCH: { LIRSwitchOp * p = (LIRSwitchOp*)lir; IS_TRUE0(LIR_dt(p) == 0x1); fprintf(g_tfile, ", v%d", p->value); USHORT * pdata = p->data; //data[0]: flag to indicate switch-table type: // 0x1 TABLE_SWITCH, 0x2 LOOKUP_SWITCH USHORT f = pdata[0]; IS_TRUE0(f == 0x100); //data[1]: the number of CASE entry. USHORT num_of_case = pdata[1]; //data[2..3]: the base value of case-table UINT base_val = *((UINT*)(&pdata[2])); fprintf(g_tfile, ", basev:%d", base_val); //((BYTE*)data)[4..num_of_case*4]: // the position of the index table is at current instruction. if (num_of_case > 0) { UINT * pcase_entry = (UINT*)&pdata[4]; fprintf(g_tfile, " tgtidx:"); for (USHORT i = 0; i < num_of_case; i++) { UINT idx_of_insn = pcase_entry[i]; fprintf(g_tfile, "%d", idx_of_insn); if (i != num_of_case - 1) { fprintf(g_tfile, ","); } } } } break; case LOP_LOOKUP_SWITCH: { LIRSwitchOp * p = (LIRSwitchOp*)lir; IS_TRUE0(LIR_dt(p) == 0x2); fprintf(g_tfile, ", v%d", p->value); USHORT * pdata = p->data; //pdata[0]: flag to indicate switch-table type: // 0x1 TABLE_SWITCH, 0x2 LOOKUP_SWITCH UINT f = pdata[0]; IS_TRUE0(f == 0x200); //pdata[1]: the number of CASE entry. UINT num_of_case = pdata[1]; if (num_of_case > 0) { BYTE * tp = (BYTE*)pdata; //((BYTE*)pdata)[4..4+num_of_case*4-1]: the case-value buffer. UINT * pcase_value = (UINT*)&tp[4]; //((BYTE*)pdata)[4+num_of_case*4, 4+num_of_case*8-1]: // the position of the index table is at current instruction. UINT * pcase_entry = (UINT*)&tp[4 + num_of_case * 4]; fprintf(g_tfile, " val2idx("); for (UINT i = 0; i < num_of_case; i++) { UINT idx_of_insn = pcase_entry[i]; fprintf(g_tfile, "%d:%d", pcase_value[i], idx_of_insn); if (i != num_of_case - 1) { fprintf(g_tfile, ","); } } fprintf(g_tfile, ")"); } } break; case LOP_FILL_ARRAY_DATA: { fprintf(g_tfile, ", %s", get_dt_name(lir)); //AABBBBBBBB //pdata[0]: the magic number of code //0x100 PACKED_SWITCH, 0x200 SPARSE_SWITCH, 0x300 FILL_ARRAY_DATA LIRSwitchOp * r = (LIRSwitchOp*)lir; UInt16 const* pdata = (UInt16 const*)r->data; IS_TRUE0(pdata[0] == 0x300); //pdata[1]: size of each element. //pdata[2]: the number of element. UINT size_of_elem = pdata[1]; UINT num_of_elem = pdata[2]; UINT data_size = num_of_elem * size_of_elem; //fprintf(g_tfile, ", (elem_sz<%d>), (elem_num<%d>), (data_ptr)0x%x", fprintf(g_tfile, ", (elem_sz<%d>), (elem_num<%d>)", size_of_elem, num_of_elem); } break; case LOP_INVOKE: { /* ABCCCCDDDD the layout clarifies: A(p4), B(argc), CCCC(method_id), DDDD(p0, p1, p2, p3) where p0,p1,p2,p3,p4 are five parameters. AABBBBCCCC the layout clarifies: AA(argc), BBBB(method_id), CCCC(p0,p1,...p(argc-1)) */ LIRInvokeOp * r = (LIRInvokeOp*)lir; UINT flags = LIR_dt(lir); UINT flag1 = flags & 0x0F; UINT flag2 = flags & 0xF0; IS_TRUE(flag1 != 0, ("means LIR is LOP_FILLED_NEW_ARRAY")); DexMethodId const* method_id = dexGetMethodId(df, r->ref); IS_TRUE0(method_id); CHAR const* method_name = dexStringById(df, method_id->nameIdx); CHAR const* class_name = dexStringByTypeIdx(df, method_id->classIdx); IS_TRUE0(method_name); DexProtoId const* proto_id = dexGetProtoId(df, method_id->protoIdx); CHAR const* shorty_name = dexStringById(df, proto_id->shortyIdx); fprintf(g_tfile, ", %s::%s", class_name, method_name); UINT k = LIR_dt(lir); bool is_range = HAVE_FLAG((k & 0xf0), LIR_Range); if (is_range) { switch (k & 0x0f) { case LIR_invoke_unknown: IS_TRUE0(0); break; case LIR_invoke_virtual: fprintf(g_tfile, ", virtual-range"); break; case LIR_invoke_direct: fprintf(g_tfile, ", direct-range"); break; case LIR_invoke_super: fprintf(g_tfile, ", super-range"); break; case LIR_invoke_interface: fprintf(g_tfile, ", interface-range"); break; case LIR_invoke_static: fprintf(g_tfile, ", static-range"); break; default: IS_TRUE0(0); } } else { switch (k & 0x0f) { case LIR_invoke_unknown: IS_TRUE0(0); break; case LIR_invoke_virtual: fprintf(g_tfile, ", virtual"); break; case LIR_invoke_direct: fprintf(g_tfile, ", direct"); break; case LIR_invoke_super: fprintf(g_tfile, ", super"); break; case LIR_invoke_interface: fprintf(g_tfile, ", interface"); break; case LIR_invoke_static: fprintf(g_tfile, ", static"); break; default: IS_TRUE0(0); } } if (r->argc != 0) { fprintf(g_tfile, ", arg("); for (USHORT i = 0; i < r->argc; i++) { fprintf(g_tfile, "v%d", r->args[i]); if (i != r->argc-1) { fprintf(g_tfile, ","); } } fprintf(g_tfile, ")"); } } break; case LOP_FILLED_NEW_ARRAY: { /* AABBBBCCCC or ABCCCCDEFG e.g: A(argc), B,D,E,F,G(parampters), CCCC(class_tyid) */ LIRInvokeOp * r = (LIRInvokeOp*)lir; UINT flags = LIR_dt(lir); CHAR const* class_name = dexStringByTypeIdx(df, r->ref); IS_TRUE0(class_name); fprintf(g_tfile, ", %s", class_name); if (r->argc != 0) { fprintf(g_tfile, ", arg("); for (USHORT i = 0; i < r->argc; i++) { fprintf(g_tfile, "v%d", r->args[i]); if (i != r->argc-1) { fprintf(g_tfile, ","); } } fprintf(g_tfile, ")"); } } break; case LOP_CMPG: //AABBCC IS_TRUE0(df); switch (LIR_dt(lir)) { case LIR_CMP_float: fprintf(g_tfile, ", FLOAT"); fprintf(g_tfile, ", v%d, v%d, %d", LIR_res(lir), LIR_op0(lir), (INT)LIR_op1(lir)); break; case LIR_CMP_double: fprintf(g_tfile, ", DOUBLE"); fprintf(g_tfile, ", (v%d,v%d), v%d, %d", LIR_res(lir), LIR_res(lir)+1, LIR_op0(lir), (INT)LIR_op1(lir)); break; default: IS_TRUE0(0); } break; case LOP_PHI: IS_TRUE0(0); break; default: IS_TRUE0(0); } //end switch fflush(g_tfile); }