KUNAI Static Analyzer
Kunai is a library for doing static binary analysis of Dalvik.
Loading...
Searching...
No Matches
map_item.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 map_item.hpp
7// The map contains all the different data from the DEX file contained in
8// the data section. Androguard retrieves all the information from here, but
9// in some cases, contains less data than the header.
10#ifndef KUNAI_DEX_PARSER_MAP_ITEM_HPP
11#define KUNAI_DEX_PARSER_MAP_ITEM_HPP
12
13#include "Kunai/Utils/kunaistream.hpp"
14#include <unordered_map>
15
16namespace KUNAI
17{
18namespace DEX
19{
22 class MapList
23 {
24 public:
26 enum type_codes : std::uint16_t
27 {
28 TYPE_HEADER_ITEM = 0x0000,
29 TYPE_STRING_ID_ITEM = 0x0001,
30 TYPE_TYPE_ID_ITEM = 0x0002,
31 TYPE_PROTO_ID_ITEM = 0x0003,
32 TYPE_FIELD_ID_ITEM = 0x0004,
33 TYPE_METHOD_ID_ITEM = 0x0005,
34 TYPE_CLASS_DEF_ITEM = 0x0006,
35 TYPE_CALL_SITE_ID_ITEM = 0x0007,
36 TYPE_METHOD_HANDLE_ITEM = 0x0008,
37 TYPE_MAP_LIST = 0x1000,
38 TYPE_TYPE_LIST = 0x1001,
39 TYPE_ANNOTATION_SET_REF_LIST = 0x1002,
40 TYPE_ANNOTATION_SET_ITEM = 0x1003,
41 TYPE_CLASS_DATA_ITEM = 0x2000,
42 TYPE_CODE_ITEM = 0x2001,
43 TYPE_STRING_DATA_ITEM = 0x2002,
44 TYPE_DEBUG_INFO_ITEM = 0x2003,
45 TYPE_ANNOTATION_ITEM = 0x2004,
46 TYPE_ENCODED_ARRAY_ITEM = 0x2005,
47 TYPE_ANNOTATIONS_DIRECTORY_ITEM = 0x2006,
48 TYPE_HIDDENAPI_CLASS_DATA_ITEM = 0xF000
49 };
50
52 struct map_item
53 {
54 type_codes type;
55 std::uint16_t unused;
56 std::uint32_t size;
57 std::uint32_t offset;
58 };
59
60 private:
62 std::unordered_map<type_codes, map_item> items;
63 public:
65 MapList() = default;
67 ~MapList() = default;
68
72 void parse_map_list(stream::KunaiStream* stream, std::uint32_t map_off);
73
76 const std::unordered_map<type_codes, map_item>& get_map_items() const
77 {
78 return items;
79 }
80
83 std::unordered_map<type_codes, map_item>& get_map_items()
84 {
85 return items;
86 }
87 };
88} // namespace DEX
89} // namespace KUNAI
90
91
92#endif
Class representing the Map List, this map contains different information about different types.
Definition map_item.hpp:23
MapList()=default
Constructor of the MapList.
type_codes
all possible type codes
Definition map_item.hpp:27
~MapList()=default
Destructor of the MapList.
const std::unordered_map< type_codes, map_item > & get_map_items() const
Get the map items from the DEX.
Definition map_item.hpp:76
void parse_map_list(stream::KunaiStream *stream, std::uint32_t map_off)
Parse the map list from the DEX file to create the map.
std::unordered_map< type_codes, map_item > & get_map_items()
Get the map items from the DEX.
Definition map_item.hpp:83
Class to manage an input file stream given for the analysis.
Definition kunaistream.hpp:20
utilities
Definition analysis.hpp:23
Map that store the information of the map.
Definition map_item.hpp:53
std::uint32_t size
not used, do not retrieve it
Definition map_item.hpp:56
std::uint16_t unused
type of the item
Definition map_item.hpp:55
std::uint32_t offset
number of items to be found on the offset
Definition map_item.hpp:57