#include "fxos-cli.h" #include #include #include #include using namespace FxOS; static char const *info_str = "OS type: %s\n" "\n" "Header information:\n" " Bootcode timestamp (DateA) (0x%000008x) : %s\n" " Bootcode checksum (0x%000008x) : 0x%08x\n" //" Serial number (0x%000008x) : %s\n" " OS version (0x%000008x) : %s\n"; static char const *footer_str = "\nFooter information:\n" " Detected footer address : 0x%08x\n" " Langdata entries found : %d\n" " OS date (DateO) (0x%000008x) : %s\n" " OS checksum (0x%000008x) : 0x%08x\n"; static char const *syscall_str = "\nSyscall information:\n" " Syscall table address (0x%000008x) : 0x%08x\n" " Entries that point to valid memory : 0x%x\n" " First seemingly invalid entry : 0x%08x\n" " Syscall entries outside ROM:\n"; static char const *syscall_nonrom_str = " %%%03x -> %08x (%s memory)\n"; void os_info(Target &t) { /* Create an OS analysis over t. If t does not have a ROM mapped, this will fail with an exception */ OS os(t); printf(info_str, (os.type == OS::FX ? "FX" : "CG"), &os.bootcode_timestamp, os.bootcode_timestamp.value.c_str(), &os.bootcode_checksum, os.bootcode_checksum, // &os.serial_number, os.serial_number, &os.version, os.version.value.c_str()); if(os.footer == (uint32_t)-1) { printf("\nFooter could not be found.\n"); } else { printf(footer_str, os.footer, os.langdata, &os.timestamp, os.timestamp.value.c_str(), &os.checksum, os.checksum); } uint32_t syscall_table = os.syscall_table_address(); uint32_t first_noncall = t.read_u32(syscall_table + 4 * os.syscall_count()); printf(syscall_str, (os.type == OS::FX ? 0x8001007c : 0x8002007c), syscall_table, os.syscall_count(), first_noncall); int total = 0; for(int i = 0; i < os.syscall_count(); i++) { uint32_t e = os.syscall(i); MemoryRegion const *r = MemoryRegion::region_for(e); if(!r || r->name == "ROM" || r->name == "ROM_P2") continue; printf(syscall_nonrom_str, i, e, r->name.c_str()); total++; } if(!total) printf(" (none)\n"); }