KUNAI Static Analyzer
Kunai is a library for doing static binary analysis of Dalvik.
Loading...
Searching...
No Matches
dalvik_instructions.hpp
1//--------------------------------------------------------------------*- C++ -*-
2// Kunai-static-analyzer: library for doing analysis of dalvik files
3// @author Farenain <kunai.static.analysis@gmail.com>
4// @author Ernesto Java <javaernesto@gmail.com>
5//
6// @file dalvik_instructions.hpp
7// @brief Definition of all the instructions available on the Dalvik
8// Virtual Machine
9#ifndef KUNAI_DEX_DVM_DALVIK_INSTRUCTIONS_HPP
10#define KUNAI_DEX_DVM_DALVIK_INSTRUCTIONS_HPP
11
12#include "Kunai/Utils/kunaistream.hpp"
13#include "Kunai/DEX/parser/parser.hpp"
14#include "Kunai/DEX/DVM/dvm_types.hpp"
15#include "Kunai/DEX/DVM/dalvik_opcodes.hpp"
16
17#include <iostream>
18#include <span>
19#include <string>
20#include <variant>
21
22namespace KUNAI
23{
24namespace DEX
25{
29 enum class dexinsttype_t
30 {
31 DEX_INSTRUCTION00X,
32 DEX_INSTRUCTION10X,
33 DEX_INSTRUCTION12X,
34 DEX_INSTRUCTION11N,
35 DEX_INSTRUCTION11X,
36 DEX_INSTRUCTION10T,
37 DEX_INSTRUCTION20T,
38 DEX_INSTRUCTION20BC,
39 DEX_INSTRUCTION22X,
40 DEX_INSTRUCTION21T,
41 DEX_INSTRUCTION21S,
42 DEX_INSTRUCTION21H,
43 DEX_INSTRUCTION21C,
44 DEX_INSTRUCTION23X,
45 DEX_INSTRUCTION22B,
46 DEX_INSTRUCTION22T,
47 DEX_INSTRUCTION22S,
48 DEX_INSTRUCTION22C,
49 DEX_INSTRUCTION22CS,
50 DEX_INSTRUCTION30T,
51 DEX_INSTRUCTION32X,
52 DEX_INSTRUCTION31I,
53 DEX_INSTRUCTION31T,
54 DEX_INSTRUCTION31C,
55 DEX_INSTRUCTION35C,
56 DEX_INSTRUCTION3RC,
57 DEX_INSTRUCTION45CC,
58 DEX_INSTRUCTION4RCC,
59 DEX_INSTRUCTION51L,
60 DEX_PACKEDSWITCH,
61 DEX_SPARSESWITCH,
62 DEX_FILLARRAYDATA,
63 DEX_DALVIKINCORRECT,
64 DEX_NONE_OP = 99,
65 };
66
69 {
71 dexinsttype_t instruction_type;
72
73 protected:
75 std::span<std::uint8_t> op_codes;
77 std::uint32_t length;
79 std::uint32_t op;
81 std::uint64_t address;
82
83 public:
89 Instruction(std::vector<uint8_t> &bytecode, std::size_t index, dexinsttype_t instruction_type)
90 : instruction_type(instruction_type), length(0), op(0), op_codes({})
91 {
92 }
93
94 Instruction(std::vector<uint8_t> &bytecode, std::size_t index, dexinsttype_t instruction_type, std::uint32_t length)
95 : instruction_type(instruction_type), length(length), op(0)
96 {
100 op_codes = {bytecode.begin() + index, bytecode.begin() + index + length};
101 }
102
104 virtual ~Instruction() = default;
105
108 virtual TYPES::Kind get_kind() const
109 {
111 }
114 virtual dexinsttype_t get_instruction_type() const
115 {
116 return instruction_type;
117 }
118
121 virtual std::uint32_t get_instruction_length() const
122 {
123 return length;
124 }
125
128 virtual std::uint32_t get_instruction_opcode() const
129 {
130 return op;
131 }
132
135 virtual void set_address(std::uint64_t address)
136 {
137 this->address = address;
138 }
139
142 virtual std::uint64_t get_address() const
143 {
144 return address;
145 }
146
149 virtual std::string print_instruction()
150 {
151 return "";
152 }
153
156 virtual void print_instruction(std::ostream &os)
157 {
158 os << "";
159 }
160
163 virtual const std::span<std::uint8_t> &get_opcodes()
164 {
165 return op_codes;
166 }
167
170 virtual bool is_terminator()
171 {
173
174 if (operation == TYPES::Operation::CONDITIONAL_BRANCH_DVM_OPCODE ||
175 operation == TYPES::Operation::UNCONDITIONAL_BRANCH_DVM_OPCODE ||
176 operation == TYPES::Operation::RET_BRANCH_DVM_OPCODE ||
177 operation == TYPES::Operation::MULTI_BRANCH_DVM_OPCODE)
178 return true;
179 return false;
180 }
181
184 virtual bool has_side_effects() const;
185
188 virtual bool may_throw() const;
189 };
190
194 {
195 public:
199 Instruction00x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser) : Instruction(bytecode, index, dexinsttype_t::DEX_INSTRUCTION00X)
200 {
201 }
202 };
203
207 {
208 public:
209 Instruction10x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
210
213 virtual std::string print_instruction()
214 {
216 }
217
220 virtual void print_instruction(std::ostream &os)
221 {
223 }
224 };
225
230 {
232 std::uint8_t vA;
234 std::uint8_t vB;
235
236 public:
237 Instruction12x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
238
241 std::uint8_t get_destination() const
242 {
243 return vA;
244 }
245
248 std::uint8_t get_source() const
249 {
250 return vB;
251 }
252
255 TYPES::Operand get_destination_type() const
256 {
257 return TYPES::Operand::REGISTER;
258 }
259
262 TYPES::Operand get_source_type() const
263 {
264 return TYPES::Operand::REGISTER;
265 }
266
269 virtual std::string print_instruction()
270 {
272 "v" + std::to_string(vA) + ", " +
273 "v" + std::to_string(vB);
274 }
275
278 virtual void print_instruction(std::ostream &os)
279 {
281 "v" + std::to_string(vA) + ", " +
282 "v" + std::to_string(vB);
283 }
284 };
285
290 {
292 std::uint8_t vA;
294 std::int8_t nB;
295
296 public:
297 Instruction11n(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
298
299 std::uint8_t get_destination() const
300 {
301 return vA;
302 }
303
304 std::int8_t get_source() const
305 {
306 return nB;
307 }
308
309 TYPES::Operand get_destination_type() const
310 {
311 return TYPES::Operand::REGISTER;
312 }
313
314 TYPES::Operand get_source_type() const
315 {
316 return TYPES::Operand::LITERAL;
317 }
318
321 virtual std::string print_instruction()
322 {
324 "v" + std::to_string(vA) + ", " +
325 std::to_string(nB);
326 }
327
330 virtual void print_instruction(std::ostream &os)
331 {
333 "v" + std::to_string(vA) + ", " +
334 std::to_string(nB);
335 }
336 };
337
342 {
344 std::uint8_t vAA;
345
346 public:
347 Instruction11x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
348
351 std::uint8_t get_destination() const
352 {
353 return vAA;
354 }
355
358 TYPES::Operand get_destination_type() const
359 {
360 return TYPES::Operand::REGISTER;
361 }
362
365 virtual std::string print_instruction()
366 {
368 "v" + std::to_string(vAA);
369 }
370
373 virtual void print_instruction(std::ostream &os)
374 {
376 "v" + std::to_string(vAA);
377 }
378 };
379
383 {
385 std::int8_t nAA;
386
387 public:
388 Instruction10t(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
389
392 std::int8_t get_jump_offset() const
393 {
394 return nAA;
395 }
396
399 TYPES::Operand get_operand_type() const
400 {
401 return TYPES::Operand::OFFSET;
402 }
403
406 virtual std::string print_instruction()
407 {
409 std::to_string((nAA*2) + static_cast<std::int64_t>(address));
410 }
411
414 virtual void print_instruction(std::ostream &os)
415 {
417 std::to_string((nAA*2) + static_cast<std::int64_t>(address));
418 }
419 };
420
424 {
426 std::int16_t nAAAA;
427
428 public:
429 Instruction20t(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
430
433 std::int16_t get_offset() const
434 {
435 return nAAAA;
436 }
437
440 TYPES::Operand get_operand_type() const
441 {
442 return TYPES::Operand::OFFSET;
443 }
444
447 virtual std::string print_instruction()
448 {
450 std::to_string((nAAAA*2) + static_cast<std::int64_t>(address));
451 }
452
455 virtual void print_instruction(std::ostream &os)
456 {
458 std::to_string((nAAAA*2) + static_cast<std::int64_t>(address));
459 }
460 };
461
465 {
467 std::uint8_t nAA;
469 std::uint16_t nBBBB;
470
471 public:
472 Instruction20bc(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
473
476 std::uint8_t get_type_of_error_data() const
477 {
478 return nAA;
479 }
480
483 TYPES::Operand get_error_operand_type() const
484 {
485 return TYPES::Operand::LITERAL;
486 }
487
490 std::uint16_t get_index_into_table() const
491 {
492 return nBBBB;
493 }
494
495 TYPES::Operand get_index_operand_type() const
496 {
497 return TYPES::Operand::LITERAL;
498 }
499
502 virtual std::string print_instruction()
503 {
505 std::to_string(nAA) + ", kind@" + std::to_string(nBBBB);
506 }
507
510 virtual void print_instruction(std::ostream &os)
511 {
513 std::to_string(nAA) + ", kind@" + std::to_string(nBBBB);
514 }
515 };
516
521 {
523 std::uint8_t vAA;
525 std::uint16_t vBBBB;
526
527 public:
528 Instruction22x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
529
532 std::uint8_t get_destination() const
533 {
534 return vAA;
535 }
536
539 TYPES::Operand get_destination_type() const
540 {
541 return TYPES::Operand::REGISTER;
542 }
543
546 std::uint16_t get_source() const
547 {
548 return vBBBB;
549 }
550
553 TYPES::Operand get_source_type() const
554 {
555 return TYPES::Operand::REGISTER;
556 }
557
560 virtual std::string print_instruction()
561 {
563 "v" + std::to_string(vAA) + ", v" +
564 std::to_string(vBBBB);
565 }
566
569 virtual void print_instruction(std::ostream &os)
570 {
572 "v" + std::to_string(vAA) + ", v" +
573 std::to_string(vBBBB);
574 }
575 };
576
582 {
584 std::uint8_t vAA;
586 std::int16_t nBBBB;
587
588 public:
589 Instruction21t(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
590
593 std::uint8_t get_check_reg() const
594 {
595 return vAA;
596 }
597
600 TYPES::Operand get_check_reg_type() const
601 {
602 return TYPES::Operand::REGISTER;
603 }
604
607 std::int16_t get_jump_offset() const
608 {
609 return nBBBB;
610 }
611
614 TYPES::Operand get_offset_type() const
615 {
616 return TYPES::Operand::OFFSET;
617 }
618
621 virtual std::string print_instruction()
622 {
624 std::to_string(vAA) + ", " +
625 std::to_string(nBBBB);
626 }
627
630 virtual void print_instruction(std::ostream &os)
631 {
633 std::to_string(vAA) + ", " +
634 std::to_string(nBBBB);
635 }
636 };
637
643 {
645 std::uint8_t vAA;
647 std::int16_t nBBBB;
648
649 public:
650 Instruction21s(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
651
654 std::uint8_t get_destination() const
655 {
656 return vAA;
657 }
658
661 TYPES::Operand get_destination_type() const
662 {
663 return TYPES::Operand::REGISTER;
664 }
665
668 std::int16_t get_source() const
669 {
670 return nBBBB;
671 }
672
675 TYPES::Operand get_source_type() const
676 {
677 return TYPES::Operand::LITERAL;
678 }
679
682 virtual std::string print_instruction()
683 {
685 std::to_string(vAA) + ", " +
686 std::to_string(nBBBB);
687 }
688
691 virtual void print_instruction(std::ostream &os)
692 {
694 std::to_string(vAA) + ", " +
695 std::to_string(nBBBB);
696 }
697 };
698
703 {
705 std::uint8_t vAA;
707 std::int64_t nBBBB;
708
709 public:
710 Instruction21h(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
711
714 std::uint8_t get_destination() const
715 {
716 return vAA;
717 }
718
721 TYPES::Operand get_destination_type() const
722 {
723 return TYPES::Operand::REGISTER;
724 }
725
728 std::int64_t get_source() const
729 {
730 return nBBBB;
731 }
732
735 TYPES::Operand get_source_type() const
736 {
737 return TYPES::Operand::LITERAL;
738 }
739
742 virtual std::string print_instruction()
743 {
745 std::to_string(vAA) + ", " +
746 std::to_string(nBBBB);
747 }
748
751 virtual void print_instruction(std::ostream &os)
752 {
754 std::to_string(vAA) + ", " +
755 std::to_string(nBBBB);
756 }
757 };
758
762 {
764 bool is_str = false;
766 bool is_type = false;
768 bool is_fundamental = false;
769 bool is_array = false;
770 bool is_class = false;
771 bool is_unknown = false;
772
774 bool is_field = false;
776 bool is_method = false;
778 bool is_proto = false;
779
781 std::uint8_t vAA;
783 std::uint16_t iBBBB;
785 std::string source_str;
786
788 Parser *parser;
789
790 public:
791 Instruction21c(std::vector<uint8_t> &bytecode, std::size_t index, Parser *parser);
792
795 std::uint8_t get_destination() const
796 {
797 return vAA;
798 }
799
802 TYPES::Operand get_destination_type() const
803 {
804 return TYPES::Operand::REGISTER;
805 }
806
810 std::uint16_t get_source() const
811 {
812 return iBBBB;
813 }
817 TYPES::Operand get_source_type() const
818 {
819 return TYPES::Operand::KIND;
820 }
821
824 const std::string &pretty_print_source() const
825 {
826 return source_str;
827 }
828
831 bool is_source_string() const
832 {
833 return is_str;
834 }
835
839 std::string &get_source_str()
840 {
841 return source_str;
842 }
843
847 {
848 if (is_type)
849 return parser->get_types().get_type_from_order(iBBBB);
850 return nullptr;
851 }
852
856 {
857 if (is_fundamental)
858 return reinterpret_cast<DVMFundamental *>(
859 parser->get_types().get_type_from_order(iBBBB));
860 return nullptr;
861 }
862
866 {
867 if (is_class)
868 return reinterpret_cast<DVMClass *>(
869 parser->get_types().get_type_from_order(iBBBB));
870 return nullptr;
871 }
872
876 {
877 if (is_array)
878 return reinterpret_cast<DVMArray *>(
879 parser->get_types().get_type_from_order(iBBBB));
880 return nullptr;
881 }
882
886 {
887 if (is_field)
888 return parser->get_fields().get_field(iBBBB);
889 return nullptr;
890 }
891
895 {
896 if (is_proto)
897 return parser->get_protos().get_proto_by_order(iBBBB);
898 return nullptr;
899 }
900
904 {
905 if (is_method)
906 return parser->get_methods().get_method(iBBBB);
907 return nullptr;
908 }
909
912 virtual std::string print_instruction()
913 {
915 std::to_string(vAA) + ", " +
916 source_str + " (" + std::to_string(iBBBB) + ")";
917 }
918
921 virtual void print_instruction(std::ostream &os)
922 {
924 std::to_string(vAA) + ", " +
925 source_str + " (" + std::to_string(iBBBB) + ")";
926 }
927 };
928
932 {
934 std::uint8_t vAA;
936 std::uint8_t vBB;
938 std::uint8_t vCC;
939
940 public:
941 Instruction23x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
942
945 std::uint8_t get_destination() const
946 {
947 return vAA;
948 }
949
952 TYPES::Operand get_destination_type() const
953 {
954 return TYPES::Operand::REGISTER;
955 }
956
959 std::uint8_t get_first_source() const
960 {
961 return vBB;
962 }
963
966 TYPES::Operand get_first_source_type() const
967 {
968 return TYPES::Operand::REGISTER;
969 }
970
973 std::uint8_t get_second_source() const
974 {
975 return vCC;
976 }
977
980 TYPES::Operand get_second_source_type() const
981 {
982 return TYPES::Operand::REGISTER;
983 }
984
987 virtual std::string print_instruction()
988 {
990 std::to_string(vAA) + ", v" +
991 std::to_string(vBB) + ", v" +
992 std::to_string(vCC);
993 }
994
997 virtual void print_instruction(std::ostream &os)
998 {
1000 std::to_string(vAA) + ", v" +
1001 std::to_string(vBB) + ", v" +
1002 std::to_string(vCC);
1003 }
1004 };
1005
1011 {
1013 std::uint8_t vAA;
1015 std::uint8_t vBB;
1017 std::int8_t nCC;
1018
1019 public:
1020 Instruction22b(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1021
1024 std::uint8_t get_destination() const
1025 {
1026 return vAA;
1027 }
1028
1031 TYPES::Operand get_destination_type() const
1032 {
1033 return TYPES::Operand::REGISTER;
1034 }
1035
1038 std::uint8_t get_first_operand() const
1039 {
1040 return vBB;
1041 }
1042
1045 TYPES::Operand get_first_operand_type() const
1046 {
1047 return TYPES::Operand::REGISTER;
1048 }
1049
1052 std::int8_t get_second_operand() const
1053 {
1054 return nCC;
1055 }
1056
1059 TYPES::Operand get_second_operand_type() const
1060 {
1061 return TYPES::Operand::LITERAL;
1062 }
1063
1066 virtual std::string print_instruction()
1067 {
1069 std::to_string(vAA) + ", v" +
1070 std::to_string(vBB) + ", " +
1071 std::to_string(nCC);
1072 }
1073
1076 virtual void print_instruction(std::ostream &os)
1077 {
1079 std::to_string(vAA) + ", v" +
1080 std::to_string(vBB) + ", " +
1081 std::to_string(nCC);
1082 }
1083 };
1084
1088 {
1090 std::uint8_t vA;
1092 std::uint8_t vB;
1094 std::int16_t nCCCC;
1095
1096 public:
1097 Instruction22t(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1098
1101 std::uint8_t get_first_operand() const
1102 {
1103 return vA;
1104 }
1105
1108 TYPES::Operand get_first_operand_type() const
1109 {
1110 return TYPES::Operand::REGISTER;
1111 }
1112
1115 std::uint8_t get_second_operand() const
1116 {
1117 return vB;
1118 }
1119
1122 TYPES::Operand get_second_operand_type() const
1123 {
1124 return TYPES::Operand::REGISTER;
1125 }
1126
1129 std::int16_t get_offset() const
1130 {
1131 return nCCCC;
1132 }
1133
1136 TYPES::Operand get_offset_type() const
1137 {
1138 return TYPES::Operand::OFFSET;
1139 }
1140
1143 virtual std::string print_instruction()
1144 {
1146 std::to_string(vA) + ", v" +
1147 std::to_string(vB) + ", " +
1148 std::to_string(nCCCC);
1149 }
1150
1153 virtual void print_instruction(std::ostream &os)
1154 {
1156 std::to_string(vA) + ", v" +
1157 std::to_string(vB) + ", " +
1158 std::to_string(nCCCC);
1159 }
1160 };
1161
1167 {
1169 std::uint8_t vA;
1171 std::uint8_t vB;
1173 std::int16_t nCCCC;
1174
1175 public:
1176 Instruction22s(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1177
1180 std::uint8_t get_destination() const
1181 {
1182 return vA;
1183 }
1184
1187 TYPES::Operand get_destination_type() const
1188 {
1189 return TYPES::Operand::REGISTER;
1190 }
1191
1194 std::uint8_t get_first_operand() const
1195 {
1196 return vB;
1197 }
1198
1201 TYPES::Operand get_first_operand_type() const
1202 {
1203 return TYPES::Operand::REGISTER;
1204 }
1205
1208 std::int16_t get_second_operand() const
1209 {
1210 return nCCCC;
1211 }
1212
1215 TYPES::Operand get_second_operand_type() const
1216 {
1217 return TYPES::Operand::LITERAL;
1218 }
1219
1222 virtual std::string print_instruction()
1223 {
1225 std::to_string(vA) + ", v" +
1226 std::to_string(vB) + ", " +
1227 std::to_string(nCCCC);
1228 }
1229
1232 virtual void print_instruction(std::ostream &os)
1233 {
1235 std::to_string(vA) + ", v" +
1236 std::to_string(vB) + ", " +
1237 std::to_string(nCCCC);
1238 }
1239 };
1240
1247 {
1249 std::uint8_t vA;
1251 std::uint8_t vB;
1253 std::uint16_t iCCCC;
1255 std::string iCCCC_str;
1257 Parser *parser;
1259 bool is_type = false;
1261 bool is_field = false;
1262
1263 public:
1264 Instruction22c(std::vector<uint8_t> &bytecode, std::size_t index, Parser *parser);
1265
1268 std::uint8_t get_destination() const
1269 {
1270 return vA;
1271 }
1272
1275 TYPES::Operand get_destination_type() const
1276 {
1277 return TYPES::Operand::REGISTER;
1278 }
1279
1282 std::uint8_t get_operand() const
1283 {
1284 return vB;
1285 }
1286
1289 TYPES::Operand get_operand_type() const
1290 {
1291 return TYPES::Operand::REGISTER;
1292 }
1293
1296 std::uint16_t get_checked_id() const
1297 {
1298 return iCCCC;
1299 }
1300
1303 TYPES::Operand get_checked_id_type() const
1304 {
1305 return TYPES::Operand::KIND;
1306 }
1307
1310 const std::string &get_checked_value_str() const
1311 {
1312 return iCCCC_str;
1313 }
1314
1318 {
1319 if (is_type)
1320 return parser->get_types().get_type_from_order(iCCCC);
1321 return nullptr;
1322 }
1323
1327 {
1328 if (is_field)
1329 return parser->get_fields().get_field(iCCCC);
1330 return nullptr;
1331 }
1332
1335 virtual std::string print_instruction()
1336 {
1338 std::to_string(vA) + ", v" + std::to_string(vB) + ", " +
1339 iCCCC_str + " (" + std::to_string(iCCCC) + ")";
1340 }
1341
1344 virtual void print_instruction(std::ostream &os)
1345 {
1347 std::to_string(vA) + ", v" + std::to_string(vB) + ", " +
1348 iCCCC_str + " (" + std::to_string(iCCCC) + ")";
1349 }
1350 };
1351
1356 {
1358 std::uint8_t vA;
1360 std::uint8_t vB;
1362 std::uint16_t iCCCC;
1364 std::string iCCCC_str;
1366 bool is_field = false;
1368 Parser *parser;
1369
1370 public:
1371 Instruction22cs(std::vector<uint8_t> &bytecode, std::size_t index, Parser *parser);
1372
1375 std::uint8_t get_register_A() const
1376 {
1377 return vA;
1378 }
1379
1382 TYPES::Operand get_register_A_type() const
1383 {
1384 return TYPES::Operand::REGISTER;
1385 }
1386
1389 std::uint8_t get_register_B() const
1390 {
1391 return vB;
1392 }
1393
1396 TYPES::Operand get_register_B_type() const
1397 {
1398 return TYPES::Operand::REGISTER;
1399 }
1400
1403 std::uint16_t get_field_offset() const
1404 {
1405 return iCCCC;
1406 }
1407
1410 TYPES::Operand get_field_offset_type() const
1411 {
1412 return TYPES::Operand::KIND;
1413 }
1414
1417 const std::string &get_field_string() const
1418 {
1419 return iCCCC_str;
1420 }
1421
1425 {
1426 if (is_field)
1427 return parser->get_fields().get_field(iCCCC);
1428 return nullptr;
1429 }
1430
1433 virtual std::string print_instruction()
1434 {
1436 std::to_string(vA) + ", v" + std::to_string(vB) + ", " +
1437 iCCCC_str + " (" + std::to_string(iCCCC) + ")";
1438 }
1439
1442 virtual void print_instruction(std::ostream &os)
1443 {
1445 std::to_string(vA) + ", v" + std::to_string(vB) + ", " +
1446 iCCCC_str + " (" + std::to_string(iCCCC) + ")";
1447 }
1448 };
1449
1453 {
1455 std::int32_t nAAAAAAAA;
1456
1457 public:
1458 Instruction30t(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1459
1462 std::int32_t get_offset() const
1463 {
1464 return nAAAAAAAA;
1465 }
1466
1469 TYPES::Operand get_offset_type() const
1470 {
1471 return TYPES::Operand::OFFSET;
1472 }
1473
1476 virtual std::string print_instruction()
1477 {
1478 return DalvikOpcodes::get_instruction_name(op) + std::to_string((nAAAAAAAA*2) + static_cast<std::int64_t>(address));
1479 }
1480
1483 virtual void print_instruction(std::ostream &os)
1484 {
1485 os << DalvikOpcodes::get_instruction_name(op) + std::to_string((nAAAAAAAA*2) + static_cast<std::int64_t>(address));
1486 }
1487 };
1488
1492 {
1494 std::uint16_t vAAAA;
1496 std::uint16_t vBBBB;
1497 public:
1498 Instruction32x(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1499
1502 std::uint16_t get_destination() const
1503 {
1504 return vAAAA;
1505 }
1506
1509 TYPES::Operand get_destination_type() const
1510 {
1511 return TYPES::Operand::REGISTER;
1512 }
1513
1516 std::uint16_t get_source() const
1517 {
1518 return vBBBB;
1519 }
1520
1523 TYPES::Operand get_source_type() const
1524 {
1525 return TYPES::Operand::REGISTER;
1526 }
1527
1530 virtual std::string print_instruction()
1531 {
1532 return DalvikOpcodes::get_instruction_name(op) + " v" +
1533 std::to_string(vAAAA) + ", v" + std::to_string(vBBBB);
1534 }
1535
1538 virtual void print_instruction(std::ostream &os)
1539 {
1541 std::to_string(vAAAA) + ", v" + std::to_string(vBBBB);
1542 }
1543 };
1544
1549 {
1551 std::uint8_t vAA;
1553 std::uint32_t nBBBBBBBB;
1554 public:
1555 Instruction31i(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1556
1559 std::uint8_t get_destination() const
1560 {
1561 return vAA;
1562 }
1563
1566 TYPES::Operand get_destination_type() const
1567 {
1568 return TYPES::Operand::REGISTER;
1569 }
1570
1573 std::uint32_t get_source() const
1574 {
1575 return nBBBBBBBB;
1576 }
1577
1580 TYPES::Operand get_source_type() const
1581 {
1582 return TYPES::Operand::LITERAL;
1583 }
1584
1587 virtual std::string print_instruction()
1588 {
1589 return DalvikOpcodes::get_instruction_name(op) + " v" +
1590 std::to_string(vAA) + ", " + std::to_string(nBBBBBBBB);
1591 }
1592
1595 virtual void print_instruction(std::ostream &os)
1596 {
1598 std::to_string(vAA) + ", " + std::to_string(nBBBBBBBB);
1599 }
1600 };
1601
1603 class PackedSwitch;
1604 class SparseSwitch;
1605
1611 {
1612 public:
1616 {
1617 PACKED_SWITCH = 0,
1618 SPARSE_SWITCH,
1619 NONE_SWITCH
1620 };
1621 private:
1623 std::uint8_t vAA;
1625 std::int32_t nBBBBBBBB;
1626
1628 type_of_switch_t type_of_switch;
1629
1631 PackedSwitch * packed_switch = nullptr;
1633 SparseSwitch * sparse_switch = nullptr;
1634 public:
1635 Instruction31t(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1636
1639 std::uint8_t get_ref_register() const
1640 {
1641 return vAA;
1642 }
1643
1646 TYPES::Operand get_ref_register_type() const
1647 {
1648 return TYPES::Operand::REGISTER;
1649 }
1650
1653 std::int32_t get_offset() const
1654 {
1655 return nBBBBBBBB;
1656 }
1657
1660 TYPES::Operand get_offset_type() const
1661 {
1662 return TYPES::Operand::OFFSET;
1663 }
1664
1669 {
1670 return type_of_switch;
1671 }
1672
1676 {
1677 return packed_switch;
1678 }
1679
1683 {
1684 return sparse_switch;
1685 }
1686
1689 void set_packed_switch(PackedSwitch * packed_switch)
1690 {
1691 this->packed_switch = packed_switch;
1692 }
1693
1696 void set_sparse_switch(SparseSwitch * sparse_switch)
1697 {
1698 this->sparse_switch = sparse_switch;
1699 }
1700
1703 virtual std::string print_instruction()
1704 {
1705 return DalvikOpcodes::get_instruction_name(op) + " v" +
1706 std::to_string(vAA) + ", " + std::to_string(nBBBBBBBB);
1707 }
1708
1711 virtual void print_instruction(std::ostream &os)
1712 {
1714 std::to_string(vAA) + ", " + std::to_string(nBBBBBBBB);
1715 }
1716 };
1717
1722 {
1724 std::uint8_t vAA;
1726 std::uint32_t iBBBBBBBB;
1728 std::string str_value;
1729 public:
1730 Instruction31c(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1731
1734 std::uint8_t get_destination() const
1735 {
1736 return vAA;
1737 }
1738
1741 TYPES::Operand get_destination_type() const
1742 {
1743 return TYPES::Operand::REGISTER;
1744 }
1745
1748 std::uint32_t get_string_idx() const
1749 {
1750 return iBBBBBBBB;
1751 }
1752
1755 TYPES::Operand get_string_idx_type() const
1756 {
1757 return TYPES::Operand::OFFSET;
1758 }
1759
1762 const std::string& get_string_value() const
1763 {
1764 return str_value;
1765 }
1766
1769 virtual std::string print_instruction()
1770 {
1771 return DalvikOpcodes::get_instruction_name(op) + " v" +
1772 std::to_string(vAA) + ", \"" + str_value + "\" (" + std::to_string(iBBBBBBBB) + ")";
1773 }
1774
1777 virtual void print_instruction(std::ostream &os)
1778 {
1780 std::to_string(vAA) + ", " + str_value + " (" + std::to_string(iBBBBBBBB) + ")";
1781 }
1782 };
1783
1789 {
1791 std::uint8_t array_size;
1793 std::uint16_t type_index;
1795 bool is_type = false;
1797 bool is_method = false;
1799 std::string type_str;
1801 std::vector<std::uint8_t> registers;
1803 Parser * parser;
1804 public:
1805 Instruction35c(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1806
1809 std::uint8_t get_number_of_registers() const
1810 {
1811 return array_size;
1812 }
1813
1816 const std::vector<std::uint8_t>& get_registers() const
1817 {
1818 return registers;
1819 }
1820
1823 TYPES::Operand get_registers_type()
1824 {
1825 return TYPES::Operand::REGISTER;
1826 }
1827
1830 std::vector<std::uint8_t>& get_registers()
1831 {
1832 return registers;
1833 }
1834
1837 std::uint16_t get_type_idx() const
1838 {
1839 return type_index;
1840 }
1841
1844 TYPES::Operand get_array_type() const
1845 {
1846 return TYPES::Operand::KIND;
1847 }
1848
1852 {
1853 if (is_type)
1854 return parser->get_types().get_type_from_order(type_index);
1855 return nullptr;
1856 }
1857
1858 MethodID * get_method()
1859 {
1860 if (is_method)
1861 return parser->get_methods().get_method(type_index);
1862 return nullptr;
1863 }
1864
1867 virtual std::string print_instruction()
1868 {
1869 std::string instruction = DalvikOpcodes::get_instruction_name(op) + " {";
1870
1871 for(const auto reg : registers)
1872 {
1873 instruction += "v" + std::to_string(reg) + ", ";
1874 }
1875
1876 if (registers.size() > 0)
1877 instruction = instruction.substr(0, instruction.size()-2);
1878
1879 instruction += "}, " + type_str;
1880
1881 return instruction;
1882 }
1883
1886 virtual void print_instruction(std::ostream &os)
1887 {
1888 os << print_instruction();
1889 }
1890 };
1891
1899 {
1901 std::uint8_t array_size;
1903 std::uint16_t index;
1905 bool is_method = false;
1907 bool is_type = false;
1909 std::string index_str;
1912 std::vector<std::uint16_t> registers;
1914 Parser * parser;
1915 public:
1916 Instruction3rc(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
1917
1918 std::uint8_t get_registers_size() const
1919 {
1920 return array_size;
1921 }
1922
1923 std::uint16_t get_index_value() const
1924 {
1925 return index;
1926 }
1927
1928 TYPES::Operand get_index_type() const
1929 {
1930 return TYPES::Operand::KIND;
1931 }
1932
1933 const std::vector<std::uint16_t>& get_registers() const
1934 {
1935 return registers;
1936 }
1937
1938 std::vector<std::uint16_t>& get_registers()
1939 {
1940 return registers;
1941 }
1942
1943 DVMType * get_operand_dvmtype()
1944 {
1945 if (is_type)
1946 return parser->get_types().get_type_from_order(index);
1947 return nullptr;
1948 }
1949
1950 MethodID * get_operand_method()
1951 {
1952 if (is_method)
1953 return parser->get_methods().get_method(index);
1954 return nullptr;
1955 }
1956
1957 std::variant<
1958 DVMType*,
1959 MethodID*,
1960 std::uint16_t> get_operand()
1961 {
1962 if (is_type)
1963 return parser->get_types().get_type_from_order(index);
1964 else if (is_method)
1965 return parser->get_methods().get_method(index);
1966 else
1967 return index;
1968 }
1969
1970 const std::string& get_operand_str() const
1971 {
1972 return index_str;
1973 }
1974
1977 virtual std::string print_instruction()
1978 {
1979 std::string instruction = DalvikOpcodes::get_instruction_name(op) + " {";
1980
1981 for(const auto reg : registers)
1982 {
1983 instruction += "v" + std::to_string(reg) + ", ";
1984 }
1985
1986 if (registers.size() > 0)
1987 instruction = instruction.substr(0, instruction.size()-2);
1988
1989 instruction += "}, " + index_str;
1990
1991 return instruction;
1992 }
1993
1996 virtual void print_instruction(std::ostream &os)
1997 {
1998 os << print_instruction();
1999 }
2000
2001 };
2002
2009 {
2011 std::uint8_t reg_count;
2013 std::vector<std::uint8_t> registers;
2015 std::uint16_t method_reference;
2017 MethodID * method_id;
2019 std::uint16_t prototype_reference;
2021 ProtoID * proto_id;
2022 public:
2023 Instruction45cc(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
2024
2025 std::uint8_t get_number_of_registers() const
2026 {
2027 return reg_count;
2028 }
2029
2030 const std::vector<std::uint8_t>& get_registers() const
2031 {
2032 return registers;
2033 }
2034
2035 std::vector<std::uint8_t>& get_registers()
2036 {
2037 return registers;
2038 }
2039
2040 std::uint16_t get_method_reference() const
2041 {
2042 return method_reference;
2043 }
2044
2045 std::uint16_t get_prototype_reference() const
2046 {
2047 return prototype_reference;
2048 }
2049
2050 MethodID * get_method()
2051 {
2052 return method_id;
2053 }
2054
2055 ProtoID * get_prototype()
2056 {
2057 return proto_id;
2058 }
2059
2062 virtual std::string print_instruction()
2063 {
2064 std::string instruction = DalvikOpcodes::get_instruction_name(op) + " {";
2065
2066 for(const auto reg : registers)
2067 {
2068 instruction += "v" + std::to_string(reg) + ", ";
2069 }
2070
2071 if (registers.size() > 0)
2072 instruction = instruction.substr(0, instruction.size()-2);
2073
2074 instruction += "}, ";
2075
2076 if (method_id)
2077 instruction += method_id->pretty_method() + ", ";
2078 if (proto_id)
2079 instruction += proto_id->get_shorty_idx();
2080
2081 return instruction;
2082 }
2083
2086 virtual void print_instruction(std::ostream &os)
2087 {
2088 os << print_instruction();
2089 }
2090 };
2091
2098 {
2100 std::uint8_t reg_count;
2102 std::vector<std::uint16_t> registers;
2104 std::uint16_t method_reference;
2106 MethodID * method_id;
2108 std::uint16_t prototype_reference;
2110 ProtoID * prototype_id;
2111 public:
2112 Instruction4rcc(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
2113
2114 std::uint8_t get_number_of_registers() const
2115 {
2116 return reg_count;
2117 }
2118
2119 const std::vector<std::uint16_t>& get_registers() const
2120 {
2121 return registers;
2122 }
2123
2124 std::vector<std::uint16_t>& get_registers()
2125 {
2126 return registers;
2127 }
2128
2129 std::uint16_t get_method_reference() const
2130 {
2131 return method_reference;
2132 }
2133
2134 MethodID * get_method()
2135 {
2136 return method_id;
2137 }
2138
2139 std::uint16_t get_prototype_reference() const
2140 {
2141 return prototype_reference;
2142 }
2143
2144 ProtoID * get_prototype()
2145 {
2146 return prototype_id;
2147 }
2148
2151 virtual std::string print_instruction()
2152 {
2153 std::string instruction = DalvikOpcodes::get_instruction_name(op) + " {";
2154
2155 for(const auto reg : registers)
2156 {
2157 instruction += "v" + std::to_string(reg) + ", ";
2158 }
2159
2160 if (registers.size() > 0)
2161 instruction = instruction.substr(0, instruction.size()-2);
2162
2163 instruction += "}, ";
2164
2165 if (method_id)
2166 instruction += method_id->pretty_method() + ", ";
2167 if (prototype_id)
2168 instruction += prototype_id->get_shorty_idx();
2169
2170 return instruction;
2171 }
2172
2175 virtual void print_instruction(std::ostream &os)
2176 {
2177 os << print_instruction();
2178 }
2179 };
2180
2184 {
2186 std::uint8_t vAA;
2188 std::uint8_t vBB;
2190 std::int64_t nBBBBBBBBBBBBBBBB;
2191 public:
2192 Instruction51l(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
2193
2194 std::uint8_t get_first_register() const
2195 {
2196 return vAA;
2197 }
2198
2199 TYPES::Operand get_first_register_type() const
2200 {
2201 return TYPES::Operand::REGISTER;
2202 }
2203
2204 std::uint8_t get_second_register() const
2205 {
2206 return vBB;
2207 }
2208
2209 TYPES::Operand get_second_register_type() const
2210 {
2211 return TYPES::Operand::REGISTER;
2212 }
2213
2214 std::int64_t get_wide_value() const
2215 {
2216 return nBBBBBBBBBBBBBBBB;
2217 }
2218
2219 TYPES::Operand get_wide_value_type() const
2220 {
2221 return TYPES::Operand::LITERAL;
2222 }
2223
2226 virtual std::string print_instruction()
2227 {
2228 return DalvikOpcodes::get_instruction_name(op) + ", {v" + std::to_string(vAA) +
2229 ", v" + std::to_string(vBB) + "}, " + std::to_string(nBBBBBBBBBBBBBBBB);
2230 }
2231
2234 virtual void print_instruction(std::ostream &os)
2235 {
2236 os << DalvikOpcodes::get_instruction_name(op) + ", {v" + std::to_string(vAA) +
2237 ", v" + std::to_string(vBB) + "}, " + std::to_string(nBBBBBBBBBBBBBBBB);
2238 }
2239 };
2240
2244 {
2246 std::uint16_t size;
2248 std::int32_t first_key;
2250 std::vector<std::int32_t> targets;
2251 public:
2252 PackedSwitch(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
2253
2254 std::uint16_t get_number_of_targets() const
2255 {
2256 return size;
2257 }
2258
2259 std::int32_t get_first_key() const
2260 {
2261 return first_key;
2262 }
2263
2264 const std::vector<std::int32_t>& get_targets() const
2265 {
2266 return targets;
2267 }
2268
2269 std::vector<std::int32_t>& get_targets()
2270 {
2271 return targets;
2272 }
2273
2276 virtual std::string print_instruction()
2277 {
2278 std::stringstream output;
2279
2280 output << DalvikOpcodes::get_instruction_name(op) + " (size)" +
2281 std::to_string(size) + " (first/last key)" + std::to_string(first_key) + "[";
2282
2283 for (const auto target : targets)
2284 output << "0x" << std::hex << target << ",";
2285
2286 if (size > 0)
2287 output.seekp(-1, output.cur);
2288
2289 output << "]";
2290 return output.str();
2291 }
2292
2295 virtual void print_instruction(std::ostream &os)
2296 {
2297 os << DalvikOpcodes::get_instruction_name(op) + " (size)" +
2298 std::to_string(size) + " (first/last key)" + std::to_string(first_key) + "[";
2299
2300 for (const auto target : targets)
2301 os << "0x" << std::hex << target << ",";
2302
2303 if (size > 0)
2304 os.seekp(-1, os.cur);
2305
2306 os << "]";
2307 }
2308 };
2309
2314 {
2316 std::uint16_t size;
2318 std::vector<std::tuple<std::int32_t, std::int32_t>> keys_targets;
2319 public:
2320 SparseSwitch(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
2321
2322 std::uint16_t get_size_of_targets() const
2323 {
2324 return size;
2325 }
2326
2327 const std::vector<std::tuple<std::int32_t, std::int32_t>>& get_keys_targets() const
2328 {
2329 return keys_targets;
2330 }
2331
2332 std::vector<std::tuple<std::int32_t, std::int32_t>>& get_keys_targets()
2333 {
2334 return keys_targets;
2335 }
2336
2339 virtual std::string print_instruction()
2340 {
2341 std::stringstream output;
2342
2343 output << DalvikOpcodes::get_instruction_name(op) << " (size)" << size << "[";
2344
2345 for (const auto& key_target : keys_targets)
2346 {
2347 auto key = std::get<0>(key_target);
2348 auto target = std::get<1>(key_target);
2349
2350 if (key < 0)
2351 output << "-0x" << std::hex << key << ":";
2352 else
2353 output << "0x" << std::hex << key << ":";
2354
2355 if (target < 0)
2356 output << "-0x" << std::hex << target << ":";
2357 else
2358 output << "0x" << std::hex << target << ":";
2359
2360 output << ",";
2361 }
2362
2363 if (size > 0)
2364 output.seekp(-1, output.cur);
2365
2366 output << "]";
2367
2368 return output.str();
2369 }
2370
2373 virtual void print_instruction(std::ostream &os)
2374 {
2375 os << DalvikOpcodes::get_instruction_name(op) << " (size)" << size << "[";
2376
2377 for (const auto& key_target : keys_targets)
2378 {
2379 auto key = std::get<0>(key_target);
2380 auto target = std::get<1>(key_target);
2381
2382 if (key < 0)
2383 os << "-0x" << std::hex << key << ":";
2384 else
2385 os << "0x" << std::hex << key << ":";
2386
2387 if (target < 0)
2388 os << "-0x" << std::hex << target << ":";
2389 else
2390 os << "0x" << std::hex << target << ":";
2391 }
2392
2393 if (size > 0)
2394 os.seekp(-1, os.cur);
2395
2396 os << "]";
2397 }
2398 };
2399
2402 {
2403 std::uint16_t element_width;
2404 std::uint32_t size;
2405 std::vector<std::uint8_t> data;
2406 public:
2407 FillArrayData(std::vector<uint8_t> &bytecode, std::size_t index, Parser * parser);
2408
2409 std::uint16_t get_element_width() const
2410 {
2411 return element_width;
2412 }
2413
2414 std::uint32_t get_size_of_data() const
2415 {
2416 return size;
2417 }
2418
2419 const std::vector<std::uint8_t>& get_data() const
2420 {
2421 return data;
2422 }
2423
2424 std::vector<std::uint8_t>& get_data()
2425 {
2426 return data;
2427 }
2428
2431 virtual std::string print_instruction()
2432 {
2433 std::stringstream output;
2434
2435 output << "(width)" << element_width << " (size)" << size << " [";
2436
2437 for (auto byte : data)
2438 {
2439 output << "0x" << std::hex << static_cast<std::uint32_t>(byte) << ",";
2440 }
2441
2442 if (size > 0)
2443 output.seekp(-1, output.cur);
2444
2445 output << "]";
2446
2447 return output.str();
2448 }
2449
2452 virtual void print_instruction(std::ostream &os)
2453 {
2454 os << "(width)" << element_width << " (size)" << size << " [";
2455
2456 for (auto byte : data)
2457 {
2458 os << "0x" << std::hex << static_cast<std::uint32_t>(byte) << ",";
2459 }
2460
2461 if (size > 0)
2462 os.seekp(-1, os.cur);
2463
2464 os << "]";
2465 }
2466 };
2467
2472 {
2473 public:
2474 DalvikIncorrectInstruction(std::vector<uint8_t> &bytecode, std::size_t index, std::uint32_t length)
2475 : Instruction(bytecode, index, dexinsttype_t::DEX_DALVIKINCORRECT, length)
2476 {
2477 }
2478
2481 virtual std::string print_instruction()
2482 {
2483 std::stringstream stream;
2484
2485 stream << "DalvikInvalidInstruction [length: " << length << "][Opcodes: ";
2486
2487 for (const auto val : op_codes)
2488 stream << std::hex << val << " ";
2489
2490 stream.seekp(-1, stream.cur);
2491
2492 stream << "]";
2493
2494 return stream.str();
2495 }
2496
2499 virtual void print_instruction(std::ostream &os)
2500 {
2501 os << "DalvikInvalidInstruction [length: " << length << "][Opcodes: ";
2502
2503 for (const auto val : op_codes)
2504 os << std::hex << val << " ";
2505
2506 os.seekp(-1, os.cur);
2507
2508 os << "]";
2509 }
2510 };
2511} // namespace DEX
2512} // namespace KUNAI
2513
2514#endif
Class that represent the array types.
Definition types.hpp:223
Classes of the DVM.
Definition types.hpp:174
Fundamental types from the DVM, these are the common from many other languages.
Definition types.hpp:83
Represents the base class of a Type in the DVM we have different types.
Definition types.hpp:26
In case there is an incorrect instruction this one holds all the opcodes and the length of previous i...
Definition dalvik_instructions.hpp:2472
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2481
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2499
static const std::string & get_instruction_name(std::uint32_t instruction)
Find the instruction opcode in a map to obtain the instruction name.
static TYPES::Operation get_instruction_operation(std::uint32_t instruction)
Find the instruction operation given an instruction opcode.
static TYPES::Kind get_instruction_type(std::uint32_t instruction)
Find the instruction type given an instruction opcode.
FieldID represent one of the fields from the DEX file.
Definition fields.hpp:28
FieldID * get_field(std::uint32_t pos)
Get one of the fields by its position.
Class present in methods which uses array data.
Definition dalvik_instructions.hpp:2402
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2452
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2431
Useless instruction with opcode of 00 no instruction represents this, it's not either a nop.
Definition dalvik_instructions.hpp:194
Instruction00x(std::vector< uint8_t > &bytecode, std::size_t index, Parser *parser)
Constructor of Instruction00x this instruction does nothing.
Definition dalvik_instructions.hpp:199
Unconditional jump instruction. An offset is given to know where to jump.
Definition dalvik_instructions.hpp:383
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:406
std::int8_t get_jump_offset() const
Get offset of the jump.
Definition dalvik_instructions.hpp:392
TYPES::Operand get_operand_type() const
Get type of operand in this case an offset.
Definition dalvik_instructions.hpp:399
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:414
Instruction for wasting cycles. It represents a nop, it has a length of 2.
Definition dalvik_instructions.hpp:207
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:213
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:220
Instruction for moving a given literal, the instruction has a register and a literal value,...
Definition dalvik_instructions.hpp:290
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:330
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:321
Move single, double-words or objects from invoke results, also save caught exception into given regis...
Definition dalvik_instructions.hpp:342
TYPES::Operand get_destination_type() const
Get the type of operand for the destination.
Definition dalvik_instructions.hpp:358
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:373
std::uint8_t get_destination() const
Get destination register index of the operation.
Definition dalvik_instructions.hpp:351
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:365
Move the contents of one register to another length of the instruction is 2 bytes,...
Definition dalvik_instructions.hpp:230
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:278
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:269
TYPES::Operand get_source_type() const
Get the operand type of the source.
Definition dalvik_instructions.hpp:262
std::uint8_t get_source() const
Get the index of the source register.
Definition dalvik_instructions.hpp:248
TYPES::Operand get_destination_type() const
Get the operand type of the destination.
Definition dalvik_instructions.hpp:255
std::uint8_t get_destination() const
Get the index of the destination register.
Definition dalvik_instructions.hpp:241
opAA, kind@BBBB, where AA indicates a type of error and BBBB and index into the appropiate table
Definition dalvik_instructions.hpp:465
TYPES::Operand get_error_operand_type() const
Get the type of operand for the error operand.
Definition dalvik_instructions.hpp:483
std::uint16_t get_index_into_table() const
Get the index to the appropiate table of the instruction...
Definition dalvik_instructions.hpp:490
std::uint8_t get_type_of_error_data() const
Get the index of the type of error.
Definition dalvik_instructions.hpp:476
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:510
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:502
Another unconditional jump with a bigger offset of 2 bytes for the offset.
Definition dalvik_instructions.hpp:424
TYPES::Operand get_operand_type() const
Get the type of the operand of this instruction (jump)
Definition dalvik_instructions.hpp:440
std::int16_t get_offset() const
Get the offset where to jump with an unconditional jump.
Definition dalvik_instructions.hpp:433
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:455
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:447
Move a reference to a register from a string, type, etc example instruction: const-string vAA,...
Definition dalvik_instructions.hpp:762
std::uint16_t get_source() const
Get the index used as source operand, this is an index to a string, type, etc...
Definition dalvik_instructions.hpp:810
DVMFundamental * get_source_dvmfundamental() const
Check if source is a DVMFundamental and return a pointer.
Definition dalvik_instructions.hpp:855
TYPES::Operand get_destination_type() const
Get the type of the destination.
Definition dalvik_instructions.hpp:802
bool is_source_string() const
Check if source is a string.
Definition dalvik_instructions.hpp:831
std::uint8_t get_destination() const
Get the index of the register for destination.
Definition dalvik_instructions.hpp:795
TYPES::Operand get_source_type() const
Get the type of the source, this time is a KIND the KIND can be various things.
Definition dalvik_instructions.hpp:817
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:912
MethodID * get_source_method() const
check if source is a MethodID and return a pointer
Definition dalvik_instructions.hpp:903
const std::string & pretty_print_source() const
Print a string version of the source.
Definition dalvik_instructions.hpp:824
std::string & get_source_str()
get reference of the string this should be called only if is_str == true
Definition dalvik_instructions.hpp:839
FieldID * get_source_field() const
check if source is a FieldID and return a pointer
Definition dalvik_instructions.hpp:885
DVMArray * get_source_dvmarray() const
check if source is a DVMArray and return a pointer
Definition dalvik_instructions.hpp:875
DVMClass * get_source_dvmclass() const
check if source is a DVMClass and return a pointer
Definition dalvik_instructions.hpp:865
ProtoID * get_source_proto() const
Check if source is a ProtoID and return a pointer.
Definition dalvik_instructions.hpp:894
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:921
DVMType * get_source_dvmtype() const
Check if source is a DVMType and return a pointer.
Definition dalvik_instructions.hpp:846
Move given literal value into specified register. Example: const/high16 vAA, #+BBBB0000 where vAA is ...
Definition dalvik_instructions.hpp:703
TYPES::Operand get_source_type() const
Get the source type of the instruction.
Definition dalvik_instructions.hpp:735
std::uint8_t get_destination() const
Get the index of the destination register.
Definition dalvik_instructions.hpp:714
std::int64_t get_source() const
Get the source value of the instruction.
Definition dalvik_instructions.hpp:728
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:751
TYPES::Operand get_destination_type() const
Get the destination type of the instruction.
Definition dalvik_instructions.hpp:721
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:742
Move given literal value into specified register. Example of instruction: const/16 vAA,...
Definition dalvik_instructions.hpp:643
std::int16_t get_source() const
Get the source value of the instruction.
Definition dalvik_instructions.hpp:668
TYPES::Operand get_destination_type() const
Get the destination type of the instruction.
Definition dalvik_instructions.hpp:661
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:691
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:682
TYPES::Operand get_source_type() const
Get the source type of the instruction.
Definition dalvik_instructions.hpp:675
std::uint8_t get_destination() const
Get the index of the destination register.
Definition dalvik_instructions.hpp:654
Branch to the given destination if the given register's value compares with 0 as specified....
Definition dalvik_instructions.hpp:582
TYPES::Operand get_offset_type() const
Get the type of the offset of the jump.
Definition dalvik_instructions.hpp:614
TYPES::Operand get_check_reg_type() const
Get the type of the checked register.
Definition dalvik_instructions.hpp:600
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:621
std::uint8_t get_check_reg() const
Get the register used for the check in the jump.
Definition dalvik_instructions.hpp:593
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:630
std::int16_t get_jump_offset() const
Get the offset of the jump.
Definition dalvik_instructions.hpp:607
Perform indicated binary operation on the indicated register and literal value, storing result in des...
Definition dalvik_instructions.hpp:1011
std::int8_t get_second_operand() const
Get the value of the second operand.
Definition dalvik_instructions.hpp:1052
std::uint8_t get_destination() const
Get the index value of the destination register.
Definition dalvik_instructions.hpp:1024
TYPES::Operand get_destination_type() const
Get the type of the destination.
Definition dalvik_instructions.hpp:1031
TYPES::Operand get_first_operand_type() const
Get the type of the first operand.
Definition dalvik_instructions.hpp:1045
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1076
TYPES::Operand get_second_operand_type() const
Get the type of the second operand.
Definition dalvik_instructions.hpp:1059
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1066
std::uint8_t get_first_operand() const
Get the first operand of the instruction.
Definition dalvik_instructions.hpp:1038
Store in the given destination 1 if the register provided contains an instance of the given type/fiel...
Definition dalvik_instructions.hpp:1247
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1335
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1344
std::uint8_t get_operand() const
Get the operand checked in the instruction.
Definition dalvik_instructions.hpp:1282
TYPES::Operand get_operand_type() const
Get the type of the operand of the instruction.
Definition dalvik_instructions.hpp:1289
TYPES::Operand get_checked_id_type() const
Get the type of the checked ID.
Definition dalvik_instructions.hpp:1303
std::uint16_t get_checked_id() const
Get the ID of the checked Type/Field.
Definition dalvik_instructions.hpp:1296
DVMType * get_checked_dvmtype() const
Check if checked value is a DVMType and get a pointer.
Definition dalvik_instructions.hpp:1317
std::uint8_t get_destination() const
Get the destination operand for the instruction.
Definition dalvik_instructions.hpp:1268
TYPES::Operand get_destination_type() const
Get the destination operand type.
Definition dalvik_instructions.hpp:1275
const std::string & get_checked_value_str() const
Get a pretty-printed version of the checked value.
Definition dalvik_instructions.hpp:1310
FieldID * get_checked_field()
Check if checked value is a FieldID and get a pointer.
Definition dalvik_instructions.hpp:1326
Format suggested for statically linked field access instructions or Types. Example: op vA,...
Definition dalvik_instructions.hpp:1356
TYPES::Operand get_register_B_type() const
Get the type for the register B.
Definition dalvik_instructions.hpp:1396
std::uint16_t get_field_offset() const
Get the offset for the field.
Definition dalvik_instructions.hpp:1403
FieldID * get_field() const
Check if the idx is from a field and return a FieldID.
Definition dalvik_instructions.hpp:1424
const std::string & get_field_string() const
Get a string representation of the Field.
Definition dalvik_instructions.hpp:1417
TYPES::Operand get_register_A_type() const
Get the type for the register A.
Definition dalvik_instructions.hpp:1382
std::uint8_t get_register_A() const
Get the index of the first register used in the instruction.
Definition dalvik_instructions.hpp:1375
TYPES::Operand get_field_offset_type() const
Get the type for the offset, probably KIND.
Definition dalvik_instructions.hpp:1410
std::uint8_t get_register_B() const
Get the index of the second register used in the instruction.
Definition dalvik_instructions.hpp:1389
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1433
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1442
Perform indicated binary operation on the operands storing finally the result in the destination regi...
Definition dalvik_instructions.hpp:1167
TYPES::Operand get_destination_type() const
Get the type of the operand used for destination.
Definition dalvik_instructions.hpp:1187
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1232
std::uint8_t get_first_operand() const
Get the first operand of the instruction.
Definition dalvik_instructions.hpp:1194
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1222
TYPES::Operand get_first_operand_type() const
Get the type of the first operand of the instruction.
Definition dalvik_instructions.hpp:1201
TYPES::Operand get_second_operand_type() const
Get the type of the second operand of the instruction.
Definition dalvik_instructions.hpp:1215
std::int16_t get_second_operand() const
Get the second operand of the instruction.
Definition dalvik_instructions.hpp:1208
std::uint8_t get_destination() const
Get the destination of the operation.
Definition dalvik_instructions.hpp:1180
Branch to given offset after comparison of two registers. Example if-test vA, vB, +CCCC.
Definition dalvik_instructions.hpp:1088
std::uint8_t get_first_operand() const
Get the first operand of the check.
Definition dalvik_instructions.hpp:1101
TYPES::Operand get_offset_type() const
Get the type of the offset for the jump.
Definition dalvik_instructions.hpp:1136
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1153
std::uint8_t get_second_operand() const
Get the second operand of the check.
Definition dalvik_instructions.hpp:1115
TYPES::Operand get_second_operand_type() const
Get the type of the second operand of the comparison.
Definition dalvik_instructions.hpp:1122
TYPES::Operand get_first_operand_type() const
Get the type of the first operand of the comparison.
Definition dalvik_instructions.hpp:1108
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1143
std::int16_t get_offset() const
Get the offset of the jump in case this is taken.
Definition dalvik_instructions.hpp:1129
Move the contents of one non-object register to another. an instruction like move/from16 vAA,...
Definition dalvik_instructions.hpp:521
TYPES::Operand get_source_type() const
Get the type of operand from the source.
Definition dalvik_instructions.hpp:553
TYPES::Operand get_destination_type() const
Get the type of operand from the destination.
Definition dalvik_instructions.hpp:539
std::uint16_t get_source() const
Get the index of the register of the source.
Definition dalvik_instructions.hpp:546
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:569
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:560
std::uint8_t get_destination() const
Get index of the register of destination.
Definition dalvik_instructions.hpp:532
Perform indicated floating point or long comparison Example: cmpkind vAA, vBB, vCC.
Definition dalvik_instructions.hpp:932
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:997
TYPES::Operand get_second_source_type() const
Get the type of the second source.
Definition dalvik_instructions.hpp:980
std::uint8_t get_destination() const
Get the register for the destination.
Definition dalvik_instructions.hpp:945
TYPES::Operand get_first_source_type() const
Get the type of the first source.
Definition dalvik_instructions.hpp:966
std::uint8_t get_second_source() const
Get the register for the second source.
Definition dalvik_instructions.hpp:973
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:987
TYPES::Operand get_destination_type() const
Get the type of the destination.
Definition dalvik_instructions.hpp:952
std::uint8_t get_first_source() const
Get the register for the first source.
Definition dalvik_instructions.hpp:959
Unconditional jump to indicated offset Example: goto/32 +AAAAAAAA.
Definition dalvik_instructions.hpp:1453
std::int32_t get_offset() const
Get the offset of the jump.
Definition dalvik_instructions.hpp:1462
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1476
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1483
TYPES::Operand get_offset_type() const
Get the type of the offset.
Definition dalvik_instructions.hpp:1469
Move a reference to string specified by given index into the specified register. Example: const-strin...
Definition dalvik_instructions.hpp:1722
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1777
TYPES::Operand get_string_idx_type() const
Get the type from the string operand.
Definition dalvik_instructions.hpp:1755
std::uint32_t get_string_idx() const
Get the index of the string operand.
Definition dalvik_instructions.hpp:1748
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1769
const std::string & get_string_value() const
Get the value from the string pointed in the instruction.
Definition dalvik_instructions.hpp:1762
std::uint8_t get_destination() const
Get the destination register for the string.
Definition dalvik_instructions.hpp:1734
TYPES::Operand get_destination_type() const
Get the destination type of the operand.
Definition dalvik_instructions.hpp:1741
Instructions between a register and a literal value of 32 bits. Example: const vAA,...
Definition dalvik_instructions.hpp:1549
TYPES::Operand get_source_type() const
Get the source operand type of the instruction.
Definition dalvik_instructions.hpp:1580
TYPES::Operand get_destination_type() const
Get the destination operand type of the instruction.
Definition dalvik_instructions.hpp:1566
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1587
std::uint8_t get_destination() const
Get the destination operand of the instruction.
Definition dalvik_instructions.hpp:1559
std::uint32_t get_source() const
Get the source operand of the instruction.
Definition dalvik_instructions.hpp:1573
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1595
Fill given array with indicated data. Reference must be an array of primitives. Also used for specify...
Definition dalvik_instructions.hpp:1611
SparseSwitch * get_sparse_switch()
Get the pointer to sparse switch in case it exists.
Definition dalvik_instructions.hpp:1682
void set_sparse_switch(SparseSwitch *sparse_switch)
Set the pointer to the SparseSwitch.
Definition dalvik_instructions.hpp:1696
std::uint8_t get_ref_register() const
get the register used as reference for switch/array
Definition dalvik_instructions.hpp:1639
TYPES::Operand get_ref_register_type() const
Get the type of the reference register.
Definition dalvik_instructions.hpp:1646
PackedSwitch * get_packed_switch()
Get the pointer to a packed switch in case it exists.
Definition dalvik_instructions.hpp:1675
type_of_switch_t get_type_of_switch() const
Get the type of switch in case the instruction is a switch.
Definition dalvik_instructions.hpp:1668
TYPES::Operand get_offset_type() const
Return the type of the offset.
Definition dalvik_instructions.hpp:1660
std::int32_t get_offset() const
Return the offset to the table with packed data.
Definition dalvik_instructions.hpp:1653
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1703
type_of_switch_t
Enum specifying the type of switch for the data table.
Definition dalvik_instructions.hpp:1616
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1711
void set_packed_switch(PackedSwitch *packed_switch)
Set the pointer to the PackedSwitch.
Definition dalvik_instructions.hpp:1689
Binary operation between registers of 16 bits Example: move/16 vAAAA, vBBBB.
Definition dalvik_instructions.hpp:1492
TYPES::Operand get_source_type() const
Get the type of the source operand.
Definition dalvik_instructions.hpp:1523
TYPES::Operand get_destination_type() const
Get the type of the destination operand.
Definition dalvik_instructions.hpp:1509
std::uint16_t get_source() const
Get the source operand of the instruction.
Definition dalvik_instructions.hpp:1516
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1530
std::uint16_t get_destination() const
Get the destination operand of the instruction.
Definition dalvik_instructions.hpp:1502
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1538
Construct array of given type and size, filling it with supplied contents. Type must be an array type...
Definition dalvik_instructions.hpp:1789
const std::vector< std::uint8_t > & get_registers() const
Get a constant reference to the vector with the registers.
Definition dalvik_instructions.hpp:1816
TYPES::Operand get_registers_type()
Get the type of the registers operand.
Definition dalvik_instructions.hpp:1823
std::vector< std::uint8_t > & get_registers()
Get a reference to the vector with the registers.
Definition dalvik_instructions.hpp:1830
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1886
DVMType * get_dvmtype()
Get the DVMType of the array type.
Definition dalvik_instructions.hpp:1851
std::uint8_t get_number_of_registers() const
Get the number of registers from the instruction.
Definition dalvik_instructions.hpp:1809
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1867
std::uint16_t get_type_idx() const
Get the idx of the type.
Definition dalvik_instructions.hpp:1837
TYPES::Operand get_array_type() const
Get the type of the array.
Definition dalvik_instructions.hpp:1844
Construct array of given type and size, filling it with supplied contents. Example instructions: op {...
Definition dalvik_instructions.hpp:1899
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:1996
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:1977
Invoke indicated signature polymorphic method. The result (if any) may be stored with an appropiate m...
Definition dalvik_instructions.hpp:2009
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2062
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2086
Invoke the method handle indicated, this time it can provide with a range of arguments given by a siz...
Definition dalvik_instructions.hpp:2098
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2175
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2151
Move given literal value into specified register pair Example: const-wide vAA, #+BBBBBBBBBBBBBBBB.
Definition dalvik_instructions.hpp:2184
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2234
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2226
Base class for the Instructions of the Dalvik Bytecode.
Definition dalvik_instructions.hpp:69
virtual ~Instruction()=default
Destructor of the instruction.
virtual std::uint32_t get_instruction_length() const
Get the length of the instruction.
Definition dalvik_instructions.hpp:121
virtual std::uint64_t get_address() const
Get the address of the instruction.
Definition dalvik_instructions.hpp:142
virtual dexinsttype_t get_instruction_type() const
Get the instruction type from the enum.
Definition dalvik_instructions.hpp:114
virtual TYPES::Kind get_kind() const
Get the kind of instruction, use a DalvikOpcodes function.
Definition dalvik_instructions.hpp:108
Instruction(std::vector< uint8_t > &bytecode, std::size_t index, dexinsttype_t instruction_type)
Constructor of the Instruction, here is applied the parsing of the opcodes.
Definition dalvik_instructions.hpp:89
virtual std::uint32_t get_instruction_opcode() const
Get the opcode of the instruction.
Definition dalvik_instructions.hpp:128
virtual bool has_side_effects() const
Instruction has or can have some side effect.
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:156
std::uint32_t op
op code from the instruction
Definition dalvik_instructions.hpp:79
std::uint64_t address
address of the instruction
Definition dalvik_instructions.hpp:81
std::uint32_t length
Length of the instruction.
Definition dalvik_instructions.hpp:77
virtual void set_address(std::uint64_t address)
Set the address of the instruction.
Definition dalvik_instructions.hpp:135
Instruction(std::vector< uint8_t > &bytecode, std::size_t index, dexinsttype_t instruction_type, std::uint32_t length)
Definition dalvik_instructions.hpp:94
virtual bool may_throw() const
May throw an exception.
virtual bool is_terminator()
Check if the instruction is a terminator (branch, ret, multibranch)
Definition dalvik_instructions.hpp:170
virtual const std::span< std::uint8_t > & get_opcodes()
Return the op codes in raw from the instruction.
Definition dalvik_instructions.hpp:163
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:149
std::span< std::uint8_t > op_codes
Opcodes of the instruction.
Definition dalvik_instructions.hpp:75
MethodID represents a single method from DEX file.
Definition methods.hpp:28
std::string & pretty_method()
Get a string representation of the method.
MethodID * get_method(std::uint32_t pos)
Get one of the methods by its position.
Packed Switch instruction present in methods which make use of this kind of data.
Definition dalvik_instructions.hpp:2244
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2295
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2276
Definition parser.hpp:29
Methods & get_methods()
get a reference to the methods
Definition parser.hpp:153
Fields & get_fields()
get a reference to the fields
Definition parser.hpp:146
Protos & get_protos()
get a reference to the prototypes
Definition parser.hpp:139
Types & get_types()
get a reference to the types object
Definition parser.hpp:125
Store the information of a ProtoID, this is a string with the return type, the list of parameters and...
Definition protos.hpp:54
const std::string & get_shorty_idx() const
Get constant reference to shorty_idx string.
Definition protos.hpp:91
ProtoID * get_proto_by_order(std::uint32_t pos)
Given a position in the vector of protos, return a ProtoID.
Sparse switch instruction present in methods which make use of this kind of data, this contain the ke...
Definition dalvik_instructions.hpp:2314
virtual void print_instruction(std::ostream &os)
Print the instruction on a given stream.
Definition dalvik_instructions.hpp:2373
virtual std::string print_instruction()
Return a string with the representation of the instruction.
Definition dalvik_instructions.hpp:2339
DVMType * get_type_from_order(std::uint32_t pos)
Get a type given position.
utilities
Definition analysis.hpp:23