void hexdump(const void *data, int size) { unsigned char *buf = (void *) data; char alpha[17]; int i; for (i = 0; i < size; i++) { /* if (!(i % 16)) wrap_log("\t\t%08X", (unsigned int) buf + i); */ if (((void *) (buf + i)) < ((void *) data)) { wrap_log(" "); alpha[i % 16] = '.'; } else { wrap_log(" %02X", buf[i]); if (isprint(buf[i]) && (buf[i] < 0xA0)) alpha[i % 16] = buf[i]; else alpha[i % 16] = '.'; } if ((i % 16) == 15) { alpha[16] = 0; wrap_log("\t|%s|\n", alpha); } } if (i % 16) { for (i %= 16; i < 16; i++) { wrap_log(" "); alpha[i] = '.'; if (i == 15) { alpha[16] = 0; wrap_log("\t|%s|\n", alpha); } } } }
Handle wrap_fbm_init_ex(u32 max_frame_num,u32 min_frame_num,u32 size_y[],u32 size_u[],u32 size_v[],u32 size_alpha[],_3d_mode_e out_3d_mode,pixel_format_e format,void* parent) { Handle result; wrap_log("func\tfbm_init_ex\t0\t0x%08x\t0x%08x\t0x%08x\t0x%08x\n",size_y[0],size_u[0],size_v[0],size_alpha[0]); wrap_log("func\tfbm_init_ex\t1\t0x%08x\t0x%08x\t0x%08x\t0x%08x\n",size_y[1],size_u[1],size_v[1],size_alpha[1]); result = ORIG_IFBM.fbm_init_ex(max_frame_num,min_frame_num,size_y,size_u,size_v,size_alpha,out_3d_mode,format,parent); return result; }
s32 wrap_ve_wait_intr(void ) { wrap_log("func\tve_wait_intr\tenter\n"); s32 result; result = ORIG_IVE.ve_wait_intr(); wrap_log("func\tve_wait_intr\texit\n"); return result; }
void* wrap_mem_palloc(u32 size,u32 align) { wrap_log("func\tmem_palloc\tenter\n"); void* result; result = ORIG_IOS.mem_palloc(size,align); wrap_log("func\tmem_palloc\texit\n"); return result; }
void *malloc(size_t size) { void *ret; wrap_log("malloc(0x%x)", size); ret = __libc_malloc(size); wrap_log(" = %p\n", ret); return ret; }
void *realloc(void *ptr, size_t size) { void *ret; wrap_log("realloc(%p, 0x%x)", ptr, size); ret = __libc_realloc(ptr, size); wrap_log(" = %p\n", ret); return ret; }
vresult_e libve_decode(u8 keyframe_only, u8 skip_bframe, u64 cur_time, Handle libve) { vresult_e result; if (!libve_decode_orig) { libve_decode_orig = libve_dlsym(__func__); } wrap_log("func\tlibve_decode enter\tkeyframe_only\t0x%08x\tskip_bframe\t0x%08x\tcur_time\t0x%08x\n",keyframe_only,skip_bframe,cur_time); result = libve_decode_orig(keyframe_only,skip_bframe,cur_time,libve); wrap_log("func\tlibve_decode exit\t%08x\n",result); return result; }
vresult_e libve_set_vbv(void* vbv, void* libve) { vresult_e result; if (!libve_set_vbv_orig) { libve_set_vbv_orig = libve_dlsym(__func__); } wrap_log("func\tlibve_set_vbv\tenter\n"); result = libve_set_vbv_orig(vbv,libve); wrap_log("func\tlibve_set_vbv\texit\n"); return result; }
void wrap_libve_init() { /* wrap IVE */ if (&IVE) { wrap_log("info\twrap_libve_init\tIVE\n"); memcpy(&ORIG_IVE,&IVE,sizeof(IVEControl_t)); IVE.ve_get_memtype = &wrap_ve_get_memtype; IVE.ve_reset_hardware = &wrap_ve_reset_hardware; IVE.ve_get_reg_base_addr = &wrap_ve_get_reg_base_addr; IVE.ve_enable_clock = &wrap_ve_enable_clock; IVE.ve_wait_intr = &wrap_ve_wait_intr; IVE.ve_enable_intr = &wrap_ve_enable_intr; } /* wrap IOS */ if (&IOS) { wrap_log("info\twrap_libve_init\tIOS\n"); memcpy(&ORIG_IOS,&IOS,sizeof(IOS_t)); IOS.mem_alloc = &wrap_mem_alloc; IOS.mem_get_phy_addr = &wrap_mem_get_phy_addr; IOS.mem_free = &wrap_mem_free; IOS.mem_set = &wrap_mem_set; IOS.mem_cpy = &wrap_mem_cpy; IOS.mem_flush_cache = &wrap_mem_flush_cache; IOS.mem_pfree = &wrap_mem_pfree; IOS.sys_sleep = &wrap_sys_sleep; IOS.mem_palloc = &wrap_mem_palloc; } /* wrap IFBM */ if (&IFBM) { wrap_log("info\twrap_libve_init\tIFBM\n"); memcpy(&ORIG_IFBM,&IFBM,sizeof(IFBM_t)); IFBM.fbm_request_frame = &wrap_fbm_request_frame; IFBM.fbm_share_frame = &wrap_fbm_share_frame; IFBM.fbm_return_frame = &wrap_fbm_return_frame; IFBM.fbm_release = &wrap_fbm_release; IFBM.fbm_init_ex = &wrap_fbm_init_ex; } /* wrap IVBV */ if (&IVBV) { wrap_log("info\twrap_libve_init\tIVBV\n"); memcpy(&ORIG_IVBV,&IVBV,sizeof(IVBV_t)); IVBV.vbv_get_base_addr = &wrap_vbv_get_base_addr; IVBV.vbv_request_bitstream_frame = &wrap_vbv_request_bitstream_frame; IVBV.vbv_return_bitstream_frame = &wrap_vbv_return_bitstream_frame; IVBV.vbv_get_size = &wrap_vbv_get_size; IVBV.vbv_flush_bitstream_frame = &wrap_vbv_flush_bitstream_frame; } }
Handle libve_open(vconfig_t* config, vstream_info_t* stream_info, void* parent) { Handle result; if (!libve_open_orig) { libve_open_orig = libve_dlsym(__func__); } wrap_log("func\tlibve_open\tenter\n"); result = libve_open_orig(config,stream_info,parent); dump_stream_info(stream_info); libve_handle = result; wrap_log("func\tlibve_open\texit\n"); return result; }
memtype_e wrap_ve_get_memtype(void ) { memtype_e result; result = ORIG_IVE.ve_get_memtype(); wrap_log("func\tve_get_memtype\t0x%08x\n"),(unsigned int)result; return result; }
u32 wrap_vbv_get_size(Handle vbv) { u32 result; result = ORIG_IVBV.vbv_get_size(vbv); wrap_log("func\tvbv_get_size\t0x%08x\n",result); return result; }
u32 wrap_mem_get_phy_addr(u32 virtual_addr) { u32 result; result = ORIG_IOS.mem_get_phy_addr(virtual_addr); wrap_log("func\tmem_get_phy_addr\t0x%08x\t0x%08x\n",virtual_addr,result); return result; }
void* wrap_mem_alloc(u32 size) { void* result; result = ORIG_IOS.mem_alloc(size); wrap_log("func\tmem_alloc\t0x%08x\t0x%08x\n",(unsigned int)result,size); return result; }
void wrap_mem_set(void* mem,u32 value,u32 size) { wrap_log("func\tmem_set\t0x%08x\t0x%08x\t0x%08x\n",(unsigned int)mem,value,size); mappings_unprotect_all(); ORIG_IOS.mem_set(mem,value,size); mappings_protect_all(); }
vstream_data_t* wrap_vbv_request_bitstream_frame(Handle vbv) { vstream_data_t* r; r = ORIG_IVBV.vbv_request_bitstream_frame(vbv); //wrap_log("vbv_request_bistream_frame\t0x%08x\t0x%16lx\t0x%16lx\t0x%08x\t0x%08x\n",r->length,r->pts,r->pcr,r->valid,r->id); wrap_log("func\tvbv_request_bitstream_frame\t0x%08x\t0x%016llx\n",r->data,r->pts); return r; }
Handle libve_get_fbm (Handle ve) { if (!libve_get_fbm_orig) { libve_get_fbm_orig = libve_dlsym(__func__); } wrap_log("func\tlibve_get_fbm\n"); return libve_get_fbm_orig(ve); }
void wrap_ve_enable_clock(u8 enable,u32 frequency) { wrap_log("func\tve_enable_clock\n"); ORIG_IVE.ve_enable_clock(enable,frequency); //wrap_log("ve_enable_clock\texit\n"); }
void wrap_ve_enable_intr(u8 enable) { wrap_log("func\tve_enable_intr\tenter\n"); ORIG_IVE.ve_enable_intr(enable); wrap_log("func\tve_enable_intr\texit\n"); }
void wrap_vbv_flush_bitstream_frame(vstream_data_t* stream,Handle vbv) { wrap_log("func\tvbv_flush_bitstream_frame\t0x%08x\t0x%16lx\t0x%16lx\t0x%08x\t0x%08x\n",stream->length,stream->pts,stream->pcr,stream->valid,stream->id); ORIG_IVBV.vbv_flush_bitstream_frame(stream,vbv); }
void wrap_vbv_return_bitstream_frame(vstream_data_t* stream,Handle vbv) { wrap_log("func\tvbv_return_bitstream_frame\tenter\n"); ORIG_IVBV.vbv_return_bitstream_frame(stream,vbv); wrap_log("func\tvbv_return_bitstream_frame\texit\n"); }
void wrap_mem_flush_cache(u8* mem,u32 size) { wrap_log("func\tmem_flush_cache\tenter\n"); ORIG_IOS.mem_flush_cache(mem,size); wrap_log("func\tmem_flush_cache\texit\n"); }
void wrap_fbm_release(Handle h,void* parent) { wrap_log("func\tfbm_release\tenter\n"); ORIG_IFBM.fbm_release(h,parent); wrap_log("func\tfbm_release\texit\n"); }
void wrap_fbm_return_frame(vpicture_t* frame,u8 valid,Handle h) { ORIG_IFBM.fbm_return_frame(frame,valid,h); wrap_log("func\tfbm_return_frame\t0x%08x\t0x%08x\t0x%08x\n",frame->id,frame->pts); wrap_log("func\tfbm_return_frame\t0x%08x\t0x%08x\t0x%08x\n",frame->y,frame->u,frame->v,frame->alpha); }
void wrap_sys_sleep(u32 ms) { wrap_log("func\tsys_sleep\tenter\n"); ORIG_IOS.sys_sleep(ms); wrap_log("func\tsys_sleep\texit\n"); }
void wrap_mem_pfree(void* p) { wrap_log("func\tmem_pfree\tenter\n"); ORIG_IOS.mem_pfree(p); wrap_log("func\tmem_pfree\texit\n"); }
void free(void *ptr) { wrap_log("free(%p)\n", ptr); __libc_free(ptr); }
void wrap_mem_cpy(void* dst,void* src,u32 size) { wrap_log("func\tmem_cpy\t0x%08x\t0x%08x\t0x%08x\n",(unsigned int) dst,(unsigned int)src,size); hexdump(src,size); ORIG_IOS.mem_cpy(dst,src,size); }
static void dump_ctx(struct CgCtx *ctx) { int i; wrap_log("unknown00 = %08x\n", ctx->unknown00); wrap_log("error: %s\n", ctx->error ? ctx->error : "<no error>"); wrap_log("log: %s\n", ctx->log ? ctx->log : "<no log>"); wrap_log("binary (%d bytes) =\n", ctx->binary_size); hexdump(ctx->binary, ctx->binary_size); wrap_log("unknown20 = %08x\n", ctx->unknown20); wrap_log("unknown24 = %p\n", ctx->unknown24); wrap_log("unknown28 = %zu\n", ctx->unknown28); hexdump(ctx->unknown24, ctx->unknown28); wrap_log("unknown32 = %p\n", ctx->unknown32); wrap_log("unknown36 = %08x\n", ctx->unknown36); wrap_log("unknown40 = %08x\n", ctx->unknown40); wrap_log("unknown44 = &unknown%d (%p)\n", (int)ctx->unknown44 - (int)ctx, ctx->unknown44); wrap_log("unknown48 = %08x\n", ctx->unknown48); wrap_log("unknown52 = %08x\n", ctx->unknown52); // wrap_log("unknown56 = %p\n", ctx->unknown56); // hexdump(ctx->unknown56, 0x100); wrap_log("unknown60 = %08x\n", ctx->unknown60); wrap_log("unknown64 = %08x\n", ctx->unknown64); wrap_log("unknown68 = %08x\n", ctx->unknown68); wrap_log("unknown72 = %08x\n", ctx->unknown72); wrap_log("unknown76 = %08x\n", ctx->unknown76); }
void wrap_fbm_share_frame(vpicture_t* frame,Handle h) { wrap_log("func\tfbm_share_frame\tenter\n"); ORIG_IFBM.fbm_share_frame(frame,h); wrap_log("func\tfbm_share_frame\texit\n"); }