binlex
decompiler.h
1 #include <vector>
2 #include "json.h"
3 
4 #ifndef DECOMPILER_H
5 #define DECOMPILER_H
6 
7 #define DECOMPILER_TYPE_FUNCS 0
8 #define DECOMPILER_TYPE_BLCKS 1
9 #define DECOMPILER_TYPE_UNSET 2
10 #define DECOMPILER_TYPE_ALL 3
11 
12 #define DECOMPILER_MAX_SECTIONS 256
13 
14 using namespace std;
15 using json = nlohmann::json;
16 
17 namespace binlex{
18  class Decompiler{
19  private:
20  struct Section {
21  json traits;
22  vector<uint64_t> visited;
23  };
24  string sha256(const char *trait);
25  float entropy(string trait);
26  vector<char> t2c(string trait);
27  string rs(string s);
28  string rwc(string s);
29  uint trait_size(string s);
30  string rtrim(const std::string &s);
31  string hexdump_be(const void *data, size_t size, bool cont);
32  string hexdump_mem_disp(uint64_t disp);
33  string wildcard_bytes(string bytes, string sub_bytes);
34  string wildcard_all(string bytes);
35  json GetTraits();
36  public:
37  csh handle;
38  cs_err status;
39  uint64_t pc;
40  struct Section sections[DECOMPILER_MAX_SECTIONS];
41  Decompiler();
42  bool Setup(cs_arch arch, cs_mode mode);
43  int x86_64(void *data, size_t data_size, size_t data_offset, uint index);
44  void PrintTraits(bool pretty);
45  void WriteTraits(char *file_path, bool pretty);
46  ~Decompiler();
47  };
48 }
49 #endif
binlex::Decompiler
Definition: decompiler.h:18
binlex
the binlex namespace