00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __DXCUT_CC_H
00018 #define __DXCUT_CC_H
00019
00020 #include <vector>
00021 #include <string>
00022
00023 #include <dxcut/cdxcut>
00024
00025 namespace dxcut {
00026
00027 class ccDexAnnotation;
00028
00029 class ccDexValue {
00030 public:
00031 ccDexValue();
00032 ccDexValue(const ccDexValue&);
00033 ~ccDexValue();
00034 ccDexValue& operator=(const ccDexValue&);
00035
00036 DexValueType type;
00037 dx_byte val_byte;
00038 dx_short val_short;
00039 dx_ushort val_char;
00040 dx_int val_int;
00041 dx_long val_long;
00042 float val_float;
00043 double val_double;
00044 std::string val_str;
00045 std::string val_type;
00046 std::string val_defining_class;
00047 std::string val_name;
00048 std::vector<std::string> val_prototype;
00049 std::vector<ccDexValue> val_array;
00050 ccDexAnnotation* val_annotation;
00051
00052
00053 bool val_boolean;
00054
00055 void copy_from(DexValue* val);
00056 void copy_to(DexValue* val);
00057 DexValue* copy();
00058 };
00059
00060 class ccDexNameValuePair {
00061 public:
00062 std::string name;
00063 ccDexValue value;
00064
00065 void copy_from(DexNameValuePair* nvp);
00066 void copy_to(DexNameValuePair* nvp);
00067 DexNameValuePair* copy();
00068 };
00069
00070 class ccDexAnnotation {
00071 public:
00072 DexAnnotationVisibility visibility;
00073 std::string type;
00074 std::vector<ccDexNameValuePair> parameters;
00075
00076 void copy_from(DexAnnotation* an);
00077 void copy_to(DexAnnotation* an);
00078 DexAnnotation* copy();
00079 };
00080
00081 class ccDexField {
00082 public:
00083 DexAccessFlags access_flags;
00084 std::string type;
00085 std::string name;
00086 std::vector<ccDexAnnotation> annotations;
00087
00088 void copy_from(DexField* fld);
00089 void copy_to(DexField* fld);
00090 DexField* copy();
00091 };
00092
00093 class ccDexDebugInstruction {
00094 public:
00095 dx_ubyte opcode;
00096 dx_uint addr_diff;
00097 dx_uint line_diff;
00098 dx_uint register_num;
00099 std::string name;
00100 std::string type;
00101 std::string sig;
00102
00103 void copy_from(DexDebugInstruction* dbg_insn);
00104 void copy_to(DexDebugInstruction* dbg_insn);
00105 DexDebugInstruction* copy();
00106 };
00107
00108 class ccDexDebugInfo {
00109 public:
00110 dx_uint line_start;
00111 std::vector<std::string> parameter_names;
00112 std::vector<ccDexDebugInstruction> insns;
00113
00114 void copy_from(DexDebugInfo* debug_info);
00115 void copy_to(DexDebugInfo* debug_info);
00116 DexDebugInfo* copy();
00117 };
00118
00119 class ccDexHandler {
00120 public:
00121 std::string type;
00122 dx_uint addr;
00123
00124 void copy_from(DexHandler* handler);
00125 void copy_to(DexHandler* handler);
00126 DexHandler* copy();
00127 };
00128
00129 class ccDexTryBlock {
00130 public:
00131 ccDexTryBlock();
00132 ccDexTryBlock(const ccDexTryBlock&);
00133 ~ccDexTryBlock();
00134 ccDexTryBlock& operator=(const ccDexTryBlock&);
00135
00136 dx_uint start_addr;
00137 dx_ushort insn_count;
00138 std::vector<ccDexHandler> handlers;
00139 ccDexHandler* catch_all_handler;
00140
00141 void copy_from(DexTryBlock* tb);
00142 void copy_to(DexTryBlock* tb);
00143 DexTryBlock* copy();
00144 };
00145
00146 class ccDexInstruction {
00147 public:
00148 dx_ubyte opcode;
00149 dx_ubyte hi_byte;
00150 dx_ulong constant;
00151 dx_int target;
00152 std::string str;
00153 std::string defining_class;
00154 std::string name;
00155 std::string type;
00156 std::vector<std::string> prototype;
00157 dx_uint offset;
00158 dx_int first_key;
00159 std::vector<dx_int> keys;
00160 std::vector<dx_int> targets;
00161 dx_ushort element_width;
00162 std::vector<dx_ubyte> data;
00163 dx_ushort param[2];
00164
00165 void copy_from(DexInstruction* insn);
00166 void copy_to(DexInstruction* insn);
00167 DexInstruction* copy();
00168 };
00169
00170 class ccDexCode {
00171 public:
00172 ccDexCode();
00173 ccDexCode(const ccDexCode&);
00174 ~ccDexCode();
00175 ccDexCode& operator=(const ccDexCode&);
00176
00177 dx_ushort registers_size;
00178 dx_ushort ins_size;
00179 dx_ushort outs_size;
00180 ccDexDebugInfo* debug_information;
00181 std::vector<ccDexTryBlock> tries;
00182 std::vector<ccDexInstruction> insns;
00183
00184 void copy_from(DexCode* code);
00185 void copy_to(DexCode* code);
00186 DexCode* copy();
00187 };
00188
00189 class ccDexMethod {
00190 public:
00191 ccDexMethod();
00192 ccDexMethod(const ccDexMethod&);
00193 ~ccDexMethod();
00194 ccDexMethod& operator=(const ccDexMethod&);
00195
00196 DexAccessFlags access_flags;
00197 std::string name;
00198 std::vector<std::string> prototype;
00199 ccDexCode* code_body;
00200 std::vector<ccDexAnnotation> annotations;
00201 std::vector<std::vector<ccDexAnnotation> > parameter_annotations;
00202
00203 void copy_from(DexMethod* mtd);
00204 void copy_to(DexMethod* mtd);
00205 DexMethod* copy();
00206 };
00207
00208 class ccDexClass {
00209 public:
00210 std::string name;
00211 DexAccessFlags access_flags;
00212 std::string super_class;
00213 std::vector<std::string> interfaces;
00214 std::string source_file;
00215 std::vector<ccDexAnnotation> annotations;
00216 std::vector<ccDexValue> static_values;
00217 std::vector<ccDexField> static_fields;
00218 std::vector<ccDexField> instance_fields;
00219 std::vector<ccDexMethod> direct_methods;
00220 std::vector<ccDexMethod> virtual_methods;
00221
00222 void copy_from(DexClass* cl);
00223 void copy_to(DexClass* cl);
00224 DexClass* copy();
00225 };
00226
00227 class ccOdexData {
00228 public:
00229 std::vector<dx_ubyte> id;
00230 dx_uint flags;
00231 dx_uint odex_version;
00232 dx_uint dex_mod_time;
00233 dx_uint dex_crc;
00234 dx_uint vm_version;
00235 std::vector<std::string> deps;
00236 std::vector<std::vector<dx_ubyte> > dep_shas;
00237 dx_uint aux_format;
00238 dx_uint has_class_lookup;
00239 dx_uint has_register_maps;
00240 dx_uint has_reducing_index_map;
00241 dx_uint has_expanding_index_map;
00242 };
00243
00244 class ccDexFile {
00245 public:
00246 ccDexFile();
00247 ccDexFile(const ccDexFile&);
00248 ~ccDexFile();
00249 ccDexFile& operator=(const ccDexFile&);
00250
00251 std::vector<ccDexClass> classes;
00252 ccOdexData* metadata;
00253
00254 void copy_from(DexFile* f);
00255 void copy_to(DexFile* f);
00256 DexFile* copy();
00257
00258 bool read_file(FILE* f);
00259 bool read_buffer(void* buffer, dx_uint size);
00260 void write_file(FILE* fout);
00261 };
00262
00263 }
00264
00265 #endif // __DXCUT_CC_H