1 #ifndef DUMPUTIL_H 2 #define DUMPUTIL_H 3 #define MIN_DUMP_SIZE (1024*1024) 4 typedef struct { 5 union { 6 const uint8_t *pb; 7 const uint32_t *pw; 8 }; 9 size_t size; 10 unsigned words; 11 unsigned base; 12 } dump_t; 13 unsigned ptr_to_offset(dump_t *dump,unsigned ptr); 14 unsigned offset_to_ptr(dump_t *dump,unsigned off); 15 int find_cstring(dump_t *dump, unsigned *pos, const char *string); 16 int find_word_aligned(dump_t *dump, unsigned *index, uint32_t word); 17 uint32_t get_word(dump_t *dump,unsigned off); 18 uint32_t deref_word_ptr(dump_t *dump,unsigned off); 19 uint8_t deref_byte_ptr(dump_t *dump,unsigned off); 20 const char* deref_string_ptr(dump_t *dump,unsigned off); 21 int load_dump(const char *dumpname,const char *base, dump_t *dump); 22 #endif 23