1 /* 2 * Copyright (c) 2018 Virtuozzo International GmbH 3 * 4 * This work is licensed under the terms of the GNU GPL, version 2 or later. 5 */ 6 7 #ifndef ELF2DMP_QEMU_ELF_H 8 #define ELF2DMP_QEMU_ELF_H 9 10 #include "elf.h" 11 12 typedef struct QEMUCPUSegment { 13 uint32_t selector; 14 uint32_t limit; 15 uint32_t flags; 16 uint32_t pad; 17 uint64_t base; 18 } QEMUCPUSegment; 19 20 typedef struct QEMUCPUState { 21 uint32_t version; 22 uint32_t size; 23 uint64_t rax, rbx, rcx, rdx, rsi, rdi, rsp, rbp; 24 uint64_t r8, r9, r10, r11, r12, r13, r14, r15; 25 uint64_t rip, rflags; 26 QEMUCPUSegment cs, ds, es, fs, gs, ss; 27 QEMUCPUSegment ldt, tr, gdt, idt; 28 uint64_t cr[5]; 29 uint64_t kernel_gs_base; 30 } QEMUCPUState; 31 32 int is_system(QEMUCPUState *s); 33 34 typedef struct QEMU_Elf { 35 GMappedFile *gmf; 36 size_t size; 37 void *map; 38 QEMUCPUState **state; 39 size_t state_nr; 40 int has_kernel_gs_base; 41 } QEMU_Elf; 42 43 int QEMU_Elf_init(QEMU_Elf *qe, const char *filename); 44 void QEMU_Elf_exit(QEMU_Elf *qe); 45 46 Elf64_Phdr *elf64_getphdr(void *map); 47 Elf64_Half elf_getphdrnum(void *map); 48 49 #endif /* ELF2DMP_QEMU_ELF_H */ 50