Пример #1
0
static RList* symbols(RBinFile *arch) {
	r_bin_xbe_obj_t *obj;
	RList *ret = r_list_new();
	int i, found = R_FALSE;
	ut32 thunk_addr[XBE_MAX_THUNK];
	ut32 kt_addr;
	xbe_section sect;

	if (!ret || !arch || !arch->o)
		return NULL;

	obj = arch->o->bin_obj;
	kt_addr = obj->header->kernel_thunk_addr ^ obj->kt_key;
	ret->free = free;

//eprintf ("VA %llx  %llx\n", sym->paddr, sym->vaddr);
	// PA -> VA translation
	for (i = 0; found == R_FALSE && i < obj->header->sections; i++) {
		r_buf_read_at (arch->buf, obj->header->sechdr_addr - \
			obj->header->base + (sizeof (xbe_section) * i), \
			(ut8 *)&sect, sizeof(sect));
		if (kt_addr >= sect.vaddr && kt_addr < sect.vaddr + sect.vsize)
			found = R_TRUE;
	}

	if (found == R_FALSE) {
		free (ret);
		return NULL;
	}

	r_buf_read_at (arch->buf, sect.offset + (kt_addr - sect.vaddr), \
		(ut8 *)&thunk_addr, sizeof (thunk_addr));
	for (i = 0; thunk_addr[i]; i++) {
		RBinSymbol *sym = R_NEW0 (RBinSymbol);
		if (!sym) {
			ret->free(sym);
			return NULL;
		}

		const ut32 thunk_index = thunk_addr[i] ^ 0x80000000;

		// Basic sanity checks
		if (thunk_addr[i]&0x80000000 && thunk_index <= XBE_MAX_THUNK) {
			snprintf(sym->name, R_BIN_SIZEOF_STRINGS, "kt.%s\n", kt_name[thunk_index]);
			sym->vaddr = (obj->header->kernel_thunk_addr ^ obj->kt_key) + (4 * i);
			sym->paddr = sym->vaddr - obj->header->base;
			sym->size = 4;
			sym->ordinal = i;
			r_list_append (ret, sym);
		} else free (sym);
	}
	return ret;
}
Пример #2
0
static RList* symbols(RBinFile *arch) {
	r_bin_xbe_obj_t *obj;
	RList *ret;
	int i, found = false;
	ut32 thunk_addr[XBE_MAX_THUNK];
	ut32 kt_addr;
	xbe_section sect;

	if (!arch || !arch->o)
		return NULL;

	obj = arch->o->bin_obj;
	kt_addr = obj->header->kernel_thunk_addr ^ obj->kt_key;
	ret = r_list_new();
	ret->free = free;

//eprintf ("VA %llx  %llx\n", sym->paddr, sym->vaddr);
	// PA -> VA translation
	eprintf ("sections %d\n", obj->header->sections);
	int limit = obj->header->sections;
	if (limit * (sizeof(xbe_section)) >= arch->buf->length - obj->header->sechdr_addr)
		limit = arch->buf->length;
	for (i = 0; found == false && i < limit; i++) {
		r_buf_read_at (arch->buf, obj->header->sechdr_addr - \
			obj->header->base + (sizeof (xbe_section) * i), \
			(ut8 *)&sect, sizeof(sect));
		if (kt_addr >= sect.vaddr && kt_addr < sect.vaddr + sect.vsize)
			found = true;
	}

	if (found == false) {
		free (ret);
		return NULL;
	}

	i = r_buf_read_at (arch->buf, sect.offset + (kt_addr - sect.vaddr), \
		(ut8 *)&thunk_addr, sizeof (thunk_addr));
	if (i != sizeof (thunk_addr)) {
		free (ret);
		return NULL;
	}
	for (i = 0; thunk_addr[i]; i++) {
		RBinSymbol *sym = R_NEW0 (RBinSymbol);
		if (!sym) {
			ret->free (sym);
			free (ret);
			return NULL;
		}

		const ut32 thunk_index = thunk_addr[i] ^ 0x80000000;

		// Basic sanity checks
		if (thunk_addr[i]&0x80000000 && thunk_index < XBE_MAX_THUNK) {
			sym->name = r_str_newf ("kt.%s", kt_name[thunk_index]);
			sym->vaddr = (obj->header->kernel_thunk_addr ^ obj->kt_key) + (4 * i);
			sym->paddr = sym->vaddr - obj->header->base;
			sym->size = 4;
			sym->ordinal = i;
			r_list_append (ret, sym);
		} else free (sym);
	}
	return ret;
}
Пример #3
0
static RList* symbols(RBinFile *bf) {
	RList *ret = NULL;
	RBinSymbol *ptr[13];
	int i;
	if (!(ret = r_list_new()))
		return NULL;
	ret->free = free;

	for (i = 0; i < 8; i++) {
		if (!(ptr[i] = R_NEW0 (RBinSymbol))) {
			ret->free (ret);
			return NULL;
		}
		ptr[i]->name = r_str_newf ("rst_%i", i*8);
		ptr[i]->paddr = ptr[i]->vaddr = i*8;
		ptr[i]->size = 1;
		ptr[i]->ordinal = i;
		r_list_append (ret, ptr[i]);
	}

	if (!(ptr[8] = R_NEW0 (RBinSymbol)))
		return ret;

	ptr[8]->name = strdup ("Interrupt_Vblank");
	ptr[8]->paddr = ptr[8]->vaddr = 64;
	ptr[8]->size = 1;
	ptr[8]->ordinal = 8;
	r_list_append (ret, ptr[8]);

	if (!(ptr[9] = R_NEW0 (RBinSymbol)))
		return ret;

	ptr[9]->name = strdup ("Interrupt_LCDC-Status");
	ptr[9]->paddr = ptr[9]->vaddr = 72;
	ptr[9]->size = 1;
	ptr[9]->ordinal = 9;
	r_list_append (ret, ptr[9]);

	if (!(ptr[10] = R_NEW0 (RBinSymbol)))
		return ret;

	ptr[10]->name = strdup ("Interrupt_Timer-Overflow");
	ptr[10]->paddr = ptr[10]->vaddr = 80;
	ptr[10]->size = 1;
	ptr[10]->ordinal = 10;
	r_list_append (ret, ptr[10]);

	if (!(ptr[11] = R_NEW0 (RBinSymbol)))
		return ret;

	ptr[11]->name = strdup ("Interrupt_Serial-Transfere");
	ptr[11]->paddr = ptr[11]->vaddr = 88;
	ptr[11]->size = 1;
	ptr[11]->ordinal = 11;
	r_list_append (ret, ptr[11]);

	if (!(ptr[12] = R_NEW0 (RBinSymbol)))
		return ret;

	ptr[12]->name = strdup ("Interrupt_Joypad");
	ptr[12]->paddr = ptr[12]->vaddr = 96;
	ptr[12]->size = 1;
	ptr[12]->ordinal = 12;
	r_list_append (ret, ptr[12]);

	return ret;
}
Пример #4
0
static RList* symbols(RBinFile *arch)
{
	RList *ret = NULL;
	RBinSymbol *ptr[13];
	int i;
	if (!(ret = r_list_new()))
		return NULL;
	ret->free = free;

	for (i = 0; i < 8; i++) {
		if (!(ptr[i] = R_NEW (RBinSymbol))) {
			ret->free (ret);
			return NULL;
		}
		snprintf (ptr[i]->name, R_BIN_SIZEOF_STRINGS, "rst_%i", i*8);
		ptr[i]->paddr = ptr[i]->vaddr = i*8;
		ptr[i]->size = 1;
		ptr[i]->ordinal = i;
		r_list_append (ret, ptr[i]);
	}

	if (!(ptr[8] = R_NEW (RBinSymbol)))
		return ret;

	strncpy (ptr[8]->name, "Interrupt_Vblank", R_BIN_SIZEOF_STRINGS);
	ptr[8]->paddr = ptr[8]->vaddr = 64;
	ptr[8]->size = 1;
	ptr[8]->ordinal = 8;
	r_list_append (ret, ptr[8]);

	if (!(ptr[9] = R_NEW (RBinSymbol)))
		return ret;

	strncpy (ptr[9]->name, "Interrupt_LCDC-Status", R_BIN_SIZEOF_STRINGS);
	ptr[9]->paddr = ptr[9]->vaddr = 72;
	ptr[9]->size = 1;
	ptr[9]->ordinal = 9;
	r_list_append (ret, ptr[9]);

	if (!(ptr[10] = R_NEW (RBinSymbol)))
		return ret;

	strncpy(ptr[10]->name, "Interrupt_Timer-Overflow", R_BIN_SIZEOF_STRINGS);
	ptr[10]->paddr = ptr[10]->vaddr = 80;
	ptr[10]->size = 1;
	ptr[10]->ordinal = 10;
	r_list_append (ret, ptr[10]);

	if (!(ptr[11] = R_NEW (RBinSymbol)))
		return ret;

	strncpy(ptr[11]->name, "Interrupt_Serial-Transfere", R_BIN_SIZEOF_STRINGS);
	ptr[11]->paddr = ptr[11]->vaddr = 88;
	ptr[11]->size = 1;
	ptr[11]->ordinal = 11;
	r_list_append (ret, ptr[11]);

	if (!(ptr[12] = R_NEW (RBinSymbol)))
		return ret;

	strncpy (ptr[12]->name, "Interrupt_Joypad", R_BIN_SIZEOF_STRINGS);
	ptr[12]->paddr = ptr[12]->vaddr = 96;
	ptr[12]->size = 1;
	ptr[12]->ordinal = 12;
	r_list_append (ret, ptr[12]);

	return ret;
}