binlex
decompiler_rev.h
1 #include <vector>
2 #include <capstone/capstone.h>
3 #include "common.h"
4 
5 #ifndef DECOMPILER_REV_H
6 #define DECOMPILER_REV_H
7 
8 #define DECOMPILER_REV_MAX_SECTIONS 256
9 
10 using namespace std;
11 using json = nlohmann::json;
12 
13 namespace binlex {
15  private:
16  json GetTraits();
17  public:
18  struct Section {
19  csh handle;
20  cs_err status;
21  json traits;
22  uint offset;
23  uint64_t pc;
24  size_t code_size;
25  size_t data_size;
26  size_t data_offset;
27  void *data;
28  const uint8_t *code;
29  uint b_edges;
30  uint f_edges;
31  bool b_end;
32  bool f_end;
33  uint b_count;
34  uint b_insn_count;
35  uint f_insn_count;
36  string b_trait;
37  string b_bytes;
38  string f_trait;
39  string f_bytes;
40  vector<uint64_t> blocks;
41  vector<uint64_t> functions;
42  vector<uint64_t> visited;
43  };
44  struct Section sections[DECOMPILER_REV_MAX_SECTIONS];
45  Common common;
46  DecompilerREV();
47  bool Setup(cs_arch arch, cs_mode mode, uint index);
48  void ClearBlock(uint index);
49  void ClearTrait(uint index);
50  void AddEdges(uint count, uint index);
51  void CollectBlockTrait(uint index);
52  void CollectFunctionTrait(uint index);
53  void PrintTraits(bool pretty);
54  void WriteTraits(char *file_path, bool pretty);
55  uint Decompile(void *data, size_t data_size, size_t data_offset, uint index);
56  void Seek(uint offset, uint index);
57  ~DecompilerREV();
58 
59  };
60 }
61 #endif
binlex::DecompilerREV
Definition: decompiler_rev.h:14
binlex::Common
Definition: common.h:10
binlex::DecompilerREV::Section
Definition: decompiler_rev.h:18
binlex
the binlex namespace