bool CSerializePrxToIdc::StartPrx(const char* szFilename, const PspModule *mod, u32 iSMask) { u32 addr; fprintf(m_fpOut, "#include <idc.idc>\n\n"); fprintf(m_fpOut, "static main() {\n"); if(iSMask & SERIALIZE_SECTIONS) { fprintf(m_fpOut, " createSegments();\n"); } fprintf(m_fpOut, " createModuleInfo();\n"); if(iSMask & SERIALIZE_EXPORTS) { fprintf(m_fpOut, " createExports(); \n"); } if(iSMask & SERIALIZE_IMPORTS) { fprintf(m_fpOut, " createImports(); \n"); } if(iSMask & SERIALIZE_RELOCS) { fprintf(m_fpOut, " createRelocs(); \n"); } fprintf(m_fpOut, "}\n\n"); fprintf(m_fpOut, "static createModuleInfo() {\n"); addr = mod->addr; MakeDword(m_fpOut, "_module_flags", addr); MakeString(m_fpOut, "_module_name", addr+4); MakeDword(m_fpOut, "_module_gp", addr+32); MakeOffset(m_fpOut, "_module_exports", addr+36); MakeOffset(m_fpOut, "_module_exp_end", addr+40); MakeOffset(m_fpOut, "_module_imports", addr+44); MakeOffset(m_fpOut, "_module_imp_end", addr+48); fprintf(m_fpOut, "}\n\n"); return true; }
bool CSerializePrxToIdc::SerializeExport(int num, const PspLibExport *exp) { char str_export[128]; int iLoop; u32 addr; snprintf(str_export, sizeof(str_export), "export_%d", num); addr = exp->addr; if(exp->stub.name != 0) { MakeOffset(m_fpOut, str_export, addr); MakeString(m_fpOut, BuildName(str_export, "name"), exp->stub.name); } else { MakeDword(m_fpOut, str_export, addr); } MakeDword(m_fpOut, BuildName(str_export, "flags"), addr+4); MakeDword(m_fpOut, BuildName(str_export, "counts"), addr+8); MakeOffset(m_fpOut, BuildName(str_export, "exports"), addr+12); for(iLoop = 0; iLoop < exp->f_count; iLoop++) { MakeDword(m_fpOut, BuildName(str_export, exp->funcs[iLoop].name), exp->funcs[iLoop].nid_addr); MakeOffset(m_fpOut, "", exp->funcs[iLoop].nid_addr + ((exp->v_count + exp->f_count) * 4)); MakeFunction(m_fpOut, exp->funcs[iLoop].name, exp->funcs[iLoop].addr); } for(iLoop = 0; iLoop < exp->v_count; iLoop++) { MakeDword(m_fpOut, BuildName(str_export, exp->vars[iLoop].name), exp->vars[iLoop].nid_addr); MakeOffset(m_fpOut, "", exp->vars[iLoop].nid_addr + ((exp->v_count + exp->f_count) * 4)); } return true; }
bool CDVD::Read(int lsn, int mode) { if(mode != CDVD_MODE_2048) return false; if(lsn < 0) lsn += m_block.count; if(lsn < 0 || lsn >= m_block.count) return false; if(m_cache.pending) { CancelIo(m_hFile); ResetEvent(m_overlapped.hEvent); m_cache.pending = false; } if(lsn >= m_cache.start && lsn < m_cache.start + m_cache.count) { memcpy(&m_buff[24], &m_cache.buff[(lsn - m_cache.start) * 2048], 2048); return true; } m_cache.pending = true; m_cache.start = lsn; m_cache.count = min(CACHE_BLOCK_COUNT, m_block.count - m_cache.start); LARGE_INTEGER offset = MakeOffset(lsn); m_overlapped.Offset = offset.LowPart; m_overlapped.OffsetHigh = offset.HighPart; if(!ReadFile(m_hFile, m_cache.buff, m_cache.count * 2048, NULL, &m_overlapped)) { switch(GetLastError()) { case ERROR_IO_PENDING: break; case ERROR_HANDLE_EOF: return false; } } return true; }