Baseer 0.2.0
Baseer is an advanced binary analysis tool designed to provide deep insights into any file.
Loading...
Searching...
No Matches
bx_elf_utils.h
1#ifndef BX_ELF_UTILS
2#define BX_ELF_UTILS
3
5#include "../../baseer.h"
6#include <elf.h>
7#include<string.h>
8#include "udis86.h"
9
10
11#define META_LABEL_WIDTH -10
12
13
14typedef struct {
15 const char *name;
16 const char *desc;
17 const char *color;
19
22const char* elf_machine_to_str(unsigned int machine);
23const char* sh_type_to_str(unsigned int sh_type);
24const char* elf_type_to_str(unsigned int type);
25const char *type_p_to_str(unsigned int p_type);
26void print_highlight_asm(const char *asm_instructions);
27void print_disasm(unsigned char *ptr, size_t size, unsigned long long offset, unsigned char bit_type);
28void print_symbols_with_disasm_32bit(bparser* parser, Elf32_Ehdr* elf, Elf32_Shdr* shdrs, Elf32_Shdr *symtab, Elf32_Shdr *strtab);
29void print_symbols_with_disasm_64bit(bparser* parser, Elf64_Ehdr* elf, Elf64_Shdr* shdrs, Elf64_Shdr *symtab, Elf64_Shdr *strtab);
30
31void display_byte(const unsigned char *byte);
32void display_byte_char(const unsigned char *byte);
33void format_sh_flags(uint64_t sh_flags, char *buf, size_t size);
34void print_symbols_32bit(bparser* parser, Elf32_Ehdr* elf, Elf32_Shdr* shdrs, Elf32_Shdr *symtab, Elf32_Shdr *strtab);
35void print_symbols_64bit(bparser* parser, Elf64_Ehdr* elf, Elf64_Shdr* shdrs, Elf64_Shdr *symtab, Elf64_Shdr *strtab);
36void print_hex_header(unsigned long long offset);
37void print_section_header_metadata_32bit(unsigned int id, const char *name, const char *type_str, const char *flags, Elf32_Shdr *shdrs);
38void print_section_header_metadata_64bit(unsigned int id, const char *name, const char *type_str, const char *flags, Elf64_Shdr *shdrs);
39void print_program_header_metadata_32bit(unsigned int id, const char *type_str, const char *flags, Elf32_Phdr* phdr);
40void print_program_header_metadata_64bit(unsigned int id, const char *type_str, const char *flags, Elf64_Phdr* phdr);
41void print_body_bytes(unsigned char *ptr, size_t size, unsigned long long offset, int disasm, unsigned char bit_type);
42void format_p_flags(uint32_t p_flags, char *buf, size_t size);
43
44// bool is_metadata_section(const char* name);
45#endif // !BX_ELF_UTILS
Core file handling and execution API for Baseer.
Binary parser abstraction supporting memory and streaming files.
void format_sh_flags(uint64_t sh_flags, char *buf, size_t size)
Format ELF section header flags into a colored string.
Definition bx_elf_utils.c:764
void print_symbols_with_disasm_64bit(bparser *parser, Elf64_Ehdr *elf, Elf64_Shdr *shdrs, Elf64_Shdr *symtab, Elf64_Shdr *strtab)
Print ELF64 symbols along with disassembly for functions.
Definition bx_elf_utils.c:1026
void print_hex_header(unsigned long long offset)
Print the hex dump header row.
Definition bx_elf_utils.c:1077
void print_disasm(unsigned char *ptr, size_t size, unsigned long long offset, unsigned char bit_type)
Disassemble a block of machine code and print the assembly with highlighting.
Definition bx_elf_utils.c:1386
void print_body_bytes(unsigned char *ptr, size_t size, unsigned long long offset, int disasm, unsigned char bit_type)
Print a block of bytes in hex and ASCII format, optionally disassembling executable instructions.
Definition bx_elf_utils.c:1316
void print_highlight_asm(const char *line)
Print an assembly instruction line with syntax highlighting.
Definition bx_elf_utils.c:725
void print_program_header_legend(void)
Print legends for ELF program header types and flags with color highlighting.
Definition bx_elf_utils.c:157
const char * type_p_to_str(unsigned int p_type)
Converts a program header type (p_type) to a human-readable string with color.
Definition bx_elf_utils.c:378
void print_symbols_with_disasm_32bit(bparser *parser, Elf32_Ehdr *elf, Elf32_Shdr *shdrs, Elf32_Shdr *symtab, Elf32_Shdr *strtab)
Print ELF32 symbols along with disassembly for functions.
Definition bx_elf_utils.c:968
void display_byte_char(const unsigned char *byte)
Display a single byte as a printable character with color coding.
Definition bx_elf_utils.c:452
void print_program_header_metadata_32bit(unsigned int id, const char *type_str, const char *flags, Elf32_Phdr *phdr)
Print metadata of a 32-bit ELF program header (segment).
Definition bx_elf_utils.c:1224
void print_symbols_32bit(bparser *parser, Elf32_Ehdr *elf, Elf32_Shdr *shdrs, Elf32_Shdr *symtab, Elf32_Shdr *strtab)
Print all symbols from a 32-bit ELF file (with colors).
Definition bx_elf_utils.c:823
void print_program_header_metadata_64bit(unsigned int id, const char *type_str, const char *flags, Elf64_Phdr *phdr)
Print metadata of a 64-bit ELF program header (segment).
Definition bx_elf_utils.c:1266
void print_symbols_64bit(bparser *parser, Elf64_Ehdr *elf, Elf64_Shdr *shdrs, Elf64_Shdr *symtab, Elf64_Shdr *strtab)
Print all symbols from a 64-bit ELF file (with colors).
Definition bx_elf_utils.c:897
const char * sh_type_to_str(unsigned int sh_type)
Converts an ELF section header type to a human-readable string with color.
Definition bx_elf_utils.c:284
const char * elf_machine_to_str(unsigned int machine)
Convert ELF e_machine value to human-readable string.
Definition bx_elf_utils.c:217
void print_section_header_legend(void)
Print legends for ELF section header types and flags with color highlighting.
Definition bx_elf_utils.c:56
void print_section_header_metadata_32bit(unsigned int id, const char *name, const char *type_str, const char *flags, Elf32_Shdr *shdrs)
Print metadata of a 32-bit ELF section header.
Definition bx_elf_utils.c:1134
const char * elf_type_to_str(unsigned int type)
Converts an ELF file type to a human-readable string.
Definition bx_elf_utils.c:345
void print_section_header_metadata_64bit(unsigned int id, const char *name, const char *type_str, const char *flags, Elf64_Shdr *shdrs)
Print metadata of a 64-bit ELF section header.
Definition bx_elf_utils.c:1180
void display_byte(const unsigned char *byte)
Display a single byte in hexadecimal with color coding.
Definition bx_elf_utils.c:424
void format_p_flags(uint32_t p_flags, char *buf, size_t size)
Format ELF program header flags into a colored string.
Definition bx_elf_utils.c:1424
Parser object.
Definition bparser.h:19
Definition bx_elf_utils.h:14