10 case M_TYPE_DLL:
return "Library module (DLL)";
11 case M_TYPE_PDD:
return "Physical Device Driver";
12 case M_TYPE_VDD:
return "Virtual Device Driver";
13 default:
return "Unknown";
18 switch (
bin->header->os) {
19 case 1:
return "OS/2";
20 case 2:
return "Windows";
21 case 3:
return "DOS 4.x";
22 case 4:
return "Windows 386";
23 case 5:
return "IBM Microkernel Personality Neutral";
24 default:
return "Unknown";
29 switch (
bin->header->cpu) {
30 case 1:
return "80286";
31 case 2:
return "80386";
32 case 3:
return "80486";
33 case 0x20:
return "N10";
34 case 0x21:
return "N11";
35 case 0x40:
return "R3000";
36 case 0x41:
return "R6000";
37 case 0x42:
return "R4000";
38 default:
return "Unknown";
43 switch (
bin->header->cpu) {
105 LE_entry_bundle_entry
e;
131 if ((
header.objnum - 1) <
bin->header->objcnt) {
140 if ((
header.objnum - 1) <
bin->header->objcnt) {
149 if ((
header.objnum - 1) <
bin->header->objcnt) {
199 end =
h->nrestab +
h->cbnrestab;
236 if ((
bin->header->startobj - 1) <
bin->header->objcnt) {
237 entry->vaddr = (
ut64)
bin->objtbl[
bin->header->startobj - 1].reloc_base_addr +
bin->header->eip;
275 if (!rz_buf_read_ble16_at(
bin->
buf,
offset, &iter_n,
h->worder)) {
281 if (!rz_buf_read_ble16_at(
bin->
buf,
offset, &data_size,
h->worder)) {
290 while (iter_n && bytes_left > 0) {
292 for (
i = 0;
i < iter_n;
i++) {
301 s->vsize = data_size;
305 tot_size += data_size;
309 bytes_left -=
sizeof(
ut16) * 2 + data_size;
313 if (!rz_buf_read_ble16_at(
bin->
buf,
offset, &iter_n,
h->worder)) {
318 if (!rz_buf_read_ble16_at(
bin->
buf,
offset, &data_size,
h->worder)) {
323 if (tot_size < h->pagesize) {
331 s->vsize =
h->pagesize - tot_size;
344 ut32 pages_start_off =
h->datapage;
346 for (
i = 0;
i <
h->objcnt;
i++) {
370 if (!
entry->page_tbl_entries) {
374 ut32 page_size_sum = 0;
376 ut32 objmaptbloff =
h->objmap +
bin->headerOff;
378 for (j = 0; j <
entry->page_tbl_entries; j++) {
388 int cur_idx =
entry->page_tbl_idx + j - 1;
389 ut64 page_entry_off = objpageentrysz * cur_idx + objmaptbloff;
394 RZ_LOG_WARN(
"Cannot read out of bounds page table entry.\n");
408 s->paddr = (
offset - 1) *
h->pagesize + pages_start_off;
409 if (
entry->page_tbl_idx + j ==
h->mpages) {
410 page.
size =
h->pageshift;
412 page.
size =
h->pagesize;
418 page_size_sum +=
h->pagesize;
422 RZ_LOG_WARN(
"Compressed page not handled: %s",
s->name);
424 s->paddr = ((
ut64)page.
offset <<
h->pageshift) + pages_start_off;
427 s->vsize =
h->pagesize;
428 s->vaddr = sec->
vaddr + page_size_sum;
433 page_size_sum +=
s->vsize;
435 if (
entry->page_tbl_entries) {
443 char *modname =
NULL;
445 while (ordinal > 0) {
462 const ut64 fix_rec_tbl_off = (
ut64)
h->frectab +
bin->headerOff;
464 if (!rz_buf_read_ble32_at(
bin->
buf, (
ut64)
h->fpagetab +
bin->headerOff + cur_page *
sizeof(
ut32), &tmp_offset,
h->worder)) {
474 if (!rz_buf_read_ble32_at(
bin->
buf, (
ut64)
h->fpagetab +
bin->headerOff + (cur_page + 1) *
sizeof(
ut32), &tmp_end,
h->worder)) {
480 ut64 end = tmp_end + fix_rec_tbl_off;
483 ut64 cur_page_offset = cur_section ? cur_section->
vaddr : 0;
484 while (cur_page < h->mpages) {
486 bool rel_appended =
false;
492 if (ret !=
sizeof(
header)) {
493 RZ_LOG_WARN(
"Cannot read out of bounds relocation.\n");
550 if ((ordinal - 1) <
bin->header->objcnt) {
551 rel->
addend =
bin->objtbl[ordinal - 1].reloc_base_addr;
591 if (!rz_buf_read_ble32_offset(
bin->
buf, &
offset, &ordinal,
h->worder)) {
616 if (!rz_buf_read_ble32_offset(
bin->
buf, &
offset, &nameoff,
h->worder)) {
631 imp->
name =
rz_str_newf(
"%s.%s", mod_name ? mod_name :
"", proc_name ? proc_name :
"");
642 if (!rz_buf_read_ble32_offset(
bin->
buf, &
offset, &additive,
h->worder)) {
665 if (!rz_buf_read_ble32_at(
bin->
buf, cur_page_offset +
source, &fixupinfo,
h->worder)) {
669 ut64 base_target_address = rel->
addend - (fixupinfo & 0xFFFFF);
671 if (!rz_buf_read_ble32_at(
bin->
buf, cur_page_offset +
source, &fixupinfo,
h->worder)) {
676 new->
addend = base_target_address + (fixupinfo & 0xFFFFF);
678 source = (fixupinfo >> 20) & 0xFFF;
679 }
while (
source != 0xFFF);
696 if (cur_page >=
h->mpages) {
699 ut64 at =
h->fpagetab +
bin->headerOff;
701 if (!rz_buf_read_ble32_at(
bin->
buf, at + cur_page *
sizeof(
ut32), &
w0,
h->worder)) {
705 if (!rz_buf_read_ble32_at(
bin->
buf, at + (cur_page + 1) *
sizeof(
ut32), &
w1,
h->worder)) {
709 end = fix_rec_tbl_off +
w1;
712 cur_page_offset = cur_section ? cur_section->
vaddr : 0;
778 if (!memcmp(&magic,
"MZ", 2)) {
811 if (!memcmp(
"LE",
h->magic, 2)) {
826 for (
ut32 i = 0;
i <
h->objcnt;
i++) {
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
RZ_API void rz_bin_import_free(RzBinImport *imp)
RZ_API void rz_bin_section_free(RzBinSection *bs)
RZ_API void rz_bin_reloc_free(RzBinReloc *reloc)
RzList * entries(RzBinFile *bf)
RzList * sections(RzBinFile *bf)
static ut32 next_idx(ut32 idx)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RzList * rz_bin_le_get_symbols(rz_bin_le_obj_t *bin)
RzList * rz_bin_le_get_imports(rz_bin_le_obj_t *bin)
void rz_bin_le_free(rz_bin_le_obj_t *bin)
static void __create_iter_sections(RzList *l, rz_bin_le_obj_t *bin, RzBinSection *sec, LE_object_page_entry *page, ut64 vaddr, int cur_page)
RzList * rz_bin_le_get_libs(rz_bin_le_obj_t *bin)
static RzBinSymbol * le_get_symbol(rz_bin_le_obj_t *bin, ut64 *offset)
RzList * le_get_entries(rz_bin_le_obj_t *bin)
const char * le_get_module_type(rz_bin_le_obj_t *bin)
const char * le_get_arch(rz_bin_le_obj_t *bin)
static char * le_read_nonnull_str_at(RzBuffer *buf, ut64 *offset)
static bool le_init_header(rz_bin_le_obj_t *bin, RzBuffer *buf)
static void le_get_symbols_at(rz_bin_le_obj_t *bin, RzList *syml, RzList *entl, ut64 offset, ut64 end)
RzList * rz_bin_le_get_entrypoints(rz_bin_le_obj_t *bin)
char * le_get_modname_by_ord(rz_bin_le_obj_t *bin, ut32 ordinal)
RzList * rz_bin_le_get_sections(rz_bin_le_obj_t *bin)
RzList * rz_bin_le_get_relocs(rz_bin_le_obj_t *bin)
static bool read_le_header_aux(rz_bin_le_obj_t *bin, RzBuffer *buf)
const char * le_get_cpu_type(rz_bin_le_obj_t *bin)
rz_bin_le_obj_t * rz_bin_le_new_buf(RzBuffer *buf)
const char * le_get_os_type(rz_bin_le_obj_t *bin)
#define F_TARGET_TYPE_MASK
#define F_SOURCE_TYPE_MASK
struct LE_entry_bundle_header_s LE_entry_bundle_header
#define ENTRY_PARAM_COUNT_MASK
#define F_TARGET_ADDITIVE
#define ENTRY_PARAMETER_TYPING_PRESENT
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * calloc(size_t number, size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define header(is_bt, len_min, ret_op)
while(len< limit &&buf1[len]==buf2[len])++len
static void repeat(struct parse *, sopno, int, int)
#define rz_return_if_fail(expr)
#define RZ_BIN_BIND_GLOBAL_STR
#define RZ_BIN_TYPE_FUNC_STR
#define rz_buf_read_le16_at(b, addr, result)
#define rz_buf_read_le16_offset(b, offset, result)
RZ_API bool rz_buf_read8_at(RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *result)
Read a byte at the specified address in the buffer.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
#define rz_buf_read_be32_at(b, addr, result)
#define rz_buf_read_le32_offset(b, offset, result)
#define rz_buf_read8_offset(b, offset, result)
void(* RzListFree)(void *ptr)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
ut64 paddr
the paddr where the value should be patched into
ut64 vaddr
the vaddr where the value should be patched into
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()