forked from facebook/redex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickData.h
76 lines (63 loc) · 1.68 KB
/
QuickData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include "Util.h"
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
class MappedFile;
/**
* [Header]
* uint32_t number of dexes (D)
* uint32_t dex_identifiers_offset
* [DexInfo] [0]
* uint32_t size of FieldOffsets table for this dex
* uint32_t start offset of FieldOffsets table for this dex
* ...
* [DexInfo] [D]
* [FieldOffsets] [0]
* uint16_t[0]
* ...
* uint16_t[F_0]
* ...
* [FieldOffsets] [D]
* uint16_t[0]
* ...
* uint16_t[F_D]
* [DexIdentifier] [0]
* uint32_t length of location (L)
* char[L] non zero terminated string with Canary class name for that dex
* [DexIdentifier] [D]
*/
class QuickData {
UNCOPYABLE(QuickData);
public:
// Read Mode
explicit QuickData(const char* location);
// Write Mode
QuickData() = default;
void add_field_offset(const std::string& dex,
const uint32_t field_idx,
const uint16_t offset);
uint16_t get_field_offset(const std::string& dex,
const uint32_t field_idx) const;
void serialize(const std::shared_ptr<FILE*>& fd);
private:
std::map<std::string, uint32_t> dex_to_field_offset_size;
std::unordered_map<std::string, std::unordered_map<uint32_t, uint16_t>>
dex_to_field_idx_to_offset;
struct Header {
uint32_t dexes_num;
uint32_t dex_identifiers_offset;
};
struct DexInfo {
uint32_t field_offsets_size;
uint32_t field_offsets_off;
};
void load_data(const char* location);
};