binlex
blelf.h
1 #include <stdio.h>
2 #include <stdlib.h>
3 
4 #ifndef ELF_H
5 #define ELF_H
6 
7 #define ELF_MAX_SECTIONS 32
8 
9 #define ELF_MODE_UNSET 0
10 #define ELF_MODE_X86 1
11 #define ELF_MODE_X86_64 2
12 
13 namespace binlex{
14  class Elf{
15  private:
16  struct Section {
17  uint offset;
18  int size;
19  void *data;
20  };
21  bool is_arch(int arch);
22  bool is_elf();
23  void SetSectionsDefault();
24  unsigned int GetSectionTableSize();
25  bool ReadSectionHeaders();
26  bool GetExecutableData();
27  public:
28  char magic[4] = {0x7F, 0x45, 0x4C, 0x46};
29  FILE *fd = NULL;
30  void *header = NULL;
31  void *sh_table = NULL;
32  char *sh_str = NULL;
33  int mode = ELF_MODE_UNSET;
34  struct Section sections[ELF_MAX_SECTIONS];
35  Elf();
36  bool Setup(int input_mode);
37  bool ReadFile(char *file_path);
38  ~Elf();
39  };
41 }
42 #endif
binlex::Elf
Definition: blelf.h:14
binlex
the binlex namespace