void dump_print( const tjson::Value &root, std::string &inden, bool bInden ) { if (root.IsString()) { printf("%s\"%s\"", bInden?inden.c_str():"", root.AsString()); } else if (root.IsInteger()) { printf("%s%lld", bInden?inden.c_str():"", root.AsInteger()); } else if (root.IsFloat()) { printf("%s%lf", bInden?inden.c_str():"", root.AsFloat()); } else if (root.IsBool()) { printf("%s%s", bInden?inden.c_str():"", root.AsBool()?"true":"false"); } else if (root.IsNull()) { printf("%s%s", bInden?inden.c_str():"", "null"); } else if (root.IsArray()) { printf("%s%s\n", bInden?inden.c_str():"", "["); inden += " "; for (size_t i = 0; i < root.Size(); i++) { dump_print(root[i], inden, true); if (i != root.Size() - 1) { printf("%s\n", ","); } } inden.resize(inden.size() - 2); printf("\n%s%s", inden.c_str(), "]"); } else if (root.IsObject()) { printf("%s%s\n", bInden?inden.c_str():"", "{"); inden += " "; std::vector<const char*> keys; root.GetKeys(&keys); for (size_t i = 0; i < keys.size(); i++) { printf("%s\"%s\":", inden.c_str(), keys[i]); dump_print(root[keys[i]], inden, false); if (i != keys.size() - 1) { printf("%s\n", ","); } } inden.resize(inden.size() - 2); printf("\n%s%s", inden.c_str(), "}"); } }
static void debug_dump_info_structure(DDRIVE *pdr, dword sector, byte *p) { if (!raw_devio_xfer(pdr, sector, p, 1, TRUE, TRUE)) { rtfs_print_one_string((byte *)"Read failed", PRFLG_NL); } dump_print( "Signature 1 (Should be: 0x41615252):", to_DWORD(p), 16, TRUE); dump_print( "Signature 2 :", to_DWORD(p+0x01e4), 16, TRUE); dump_print( "Free clusters :", to_DWORD(p+0x01e8), 10, TRUE); dump_print( "First Free cluster :", to_DWORD(p+0x01ec), 10, TRUE); dump_print( "Signature 3 :", to_DWORD(p+0x01fe), 16, TRUE); }
void CascDumpIndexEntry( TCascStorage * /* hs */, TDumpContext * dc, PCASC_INDEX_ENTRY pIndexEntry, int /* nDumpLevel */) { if(pIndexEntry != NULL) { ULONGLONG FileOffset = ConvertBytesToInteger_5(pIndexEntry->FileOffsetBE); DWORD ArchIndex = (DWORD)(FileOffset >> 0x1E); DWORD FileSize = ConvertBytesToInteger_4_LE(pIndexEntry->FileSizeLE); // Mask the file offset FileOffset &= 0x3FFFFFFF; dump_print(dc, " data.%03u at 0x%08x (0x%lx bytes)\n", ArchIndex, (DWORD)FileOffset, FileSize); //if(nDumpLevel > 2) //{ // QueryKey.pbData = pIndexEntry->IndexKey; // QueryKey.cbData = MD5_HASH_SIZE; // if(CascOpenFileByIndexKey((HANDLE)hs, &QueryKey, 0, &hFile)) // { // // Make sure that the data file is open and frame header loaded // CascGetFileSize(hFile, NULL); // hf = IsValidFileHandle(hFile); // assert(hf->pStream != NULL); // // Read the header area // FileOffset = hf->HeaderOffset - BLTE_HEADER_DELTA; // FileStream_Read(hf->pStream, &FileOffset, HeaderArea, sizeof(HeaderArea)); // CascCloseFile(hFile); // // Dump the header area // dump_print(dc, " FileSize: %X Rest: %s\n", // ConvertBytesToInteger_4_LE(&HeaderArea[0x10]), // StringFromBinary(&HeaderArea[0x14], 10, szBuffer)); // } //} }
static void TRootHandlerWoW6_Dump( TCascStorage * hs, TDumpContext * dc, // Pointer to an opened file LPBYTE pbRootFile, DWORD cbRootFile, const TCHAR * szListFile, int nDumpLevel) { PCASC_ENCODING_ENTRY pEncodingEntry; CASC_ROOT_BLOCK BlockInfo; PLISTFILE_MAP pListMap; QUERY_KEY EncodingKey; LPBYTE pbRootFileEnd = pbRootFile + cbRootFile; LPBYTE pbFilePointer; char szOneLine[0x100]; DWORD i; // Create the listfile map pListMap = ListFile_CreateMap(szListFile); // Dump the root entries for(pbFilePointer = pbRootFile; pbFilePointer <= pbRootFileEnd; ) { // Validate the root block pbFilePointer = VerifyLocaleBlock(&BlockInfo, pbFilePointer, pbRootFileEnd); if(pbFilePointer == NULL) break; // Dump the locale block dump_print(dc, "Flags: %08X Locales: %08X NumberOfFiles: %u\n" "=========================================================\n", BlockInfo.pLocaleBlockHdr->Flags, BlockInfo.pLocaleBlockHdr->Locales, BlockInfo.pLocaleBlockHdr->NumberOfFiles); // Dump the hashes and encoding keys for(i = 0; i < BlockInfo.pLocaleBlockHdr->NumberOfFiles; i++) { // Dump the entry dump_print(dc, "%08X %08X-%08X %s %s\n", (DWORD)(BlockInfo.FileDataIds[i]), (DWORD)(BlockInfo.pRootEntries[i].FileNameHash >> 0x20), (DWORD)(BlockInfo.pRootEntries[i].FileNameHash), StringFromMD5(BlockInfo.pRootEntries[i].EncodingKey.Value, szOneLine), ListFile_FindName(pListMap, BlockInfo.pRootEntries[i].FileNameHash)); // Find the encoding entry in the encoding table if(nDumpLevel >= DUMP_LEVEL_ENCODING_FILE) { EncodingKey.pbData = BlockInfo.pRootEntries[i].EncodingKey.Value; EncodingKey.cbData = MD5_HASH_SIZE; pEncodingEntry = FindEncodingEntry(hs, &EncodingKey, NULL); CascDumpEncodingEntry(hs, dc, pEncodingEntry, nDumpLevel); } } // Put extra newline dump_print(dc, "\n"); } ListFile_FreeMap(pListMap); }
static dword debug_dump_mbr(byte *pdata, BOOLEAN is_primary) { int i; byte *pentry; byte *ptable; dword return_sector,dw; RTFS_ARGSUSED_INT(is_primary); ptable = pdata + 0x1be; /* The table has four 16 bit partition table entries followed by the signature Each entry in the table has the followin fields byte Name width 0 boot 1 1 s_head 1 2 s_cyl 2 4 p_typ 1 5 e_head 1 6 e_cyl; 2 8 r_sec 4 12 p_size 4 */ return_sector = 0; pentry = ptable; for(i = 0; i < 4; i++) { word w; dw = to_DWORD(pentry+12); /* Print the entry if it has a size */ if (dw) { dump_print("Partition # ---->", i, 10, TRUE); dump_print("Boot == ", *pentry, 16, FALSE); dump_print("Type == ", *(pentry+4), 16, FALSE); dw = to_DWORD(pentry+12); dump_print("Size == ", dw, 10, FALSE); dw = to_DWORD(pentry+8); if (*(pentry+4) == 0x5 || *(pentry+4) == 0xF) { dump_print("Extended Partition starts at == ", dw, 10, TRUE); return_sector = dw; } else dump_print("Start == ", dw, 10, TRUE); dump_print("SHead == ", *(pentry+1), 10, FALSE); w = to_WORD(pentry+2); dump_print("Packed Cyl = ", w, 16, FALSE); dump_print("Sector = ", debug_unpack_sec_field(w), 10, FALSE); dump_print("Cylinder = ", debug_unpack_cyl_field(w), 10, TRUE); dump_print("EHead == ", *(pentry+5), 10, FALSE); w = to_WORD(pentry+6); dump_print("Packed Cyl = ", w, 16, FALSE); dump_print("Sector = ", debug_unpack_sec_field(w), 10, FALSE); dump_print("Cylinder = ", debug_unpack_cyl_field(w), 10, TRUE); dw = to_DWORD(pentry+8); } pentry += 16; } dw = to_WORD(ptable + 64); dump_print("Signature ", dw, 16, TRUE); /* Now for the signature */ return(return_sector); }
static void debug_dump_bpb(DDRIVE *pdr, dword sector, byte *p, int depth) { byte buff[32]; dump_print(" DOS Boot sig (0xe9) : ", (dword ) *p, 16, TRUE); copybuff(buff, p+3, 8); buff[8] = 0; rtfs_print_one_string((byte *) " OEM Name :", 0); rtfs_print_one_string((byte *)buff, PRFLG_NL); dump_print(" Bytes per sector :", (dword) (to_WORD(p+0xb)), 10, TRUE); dump_print(" Sectors per cluster :", (dword) *(p+0xd), 10, TRUE); dump_print(" Reserved sectors :", (dword) (to_WORD(p+0xe)), 10, TRUE); dump_print(" Number of fats :", (dword)*(p+0x10),20, TRUE); dump_print(" Num Root :", (dword) (to_WORD(p+0x11)), 10, TRUE); dump_print(" Total Sector(16) :", (dword) (to_WORD(p+0x13)), 10, TRUE); dump_print(" Media Description :", (dword) *(p+0x15), 16, TRUE); dump_print(" Total Sector(32) :", (dword) (to_DWORD(p+0x20)), 10, TRUE); dump_print(" Sector per track :", (dword) (to_WORD(p+0x18)), 10, TRUE); dump_print(" Heads :", (dword) (to_WORD(p+0x1a)), 10, TRUE); dump_print(" NumHide :", (dword) (to_DWORD(p+0x1c)), 10, TRUE); dump_print(" DOS 4 Ext Sig :", (dword) *(p+0x26), 16, TRUE); dump_print(" DOS 7 Ext Sig :", (dword) *(p+0x42), 16, TRUE); if (*(p+0x26) == 0x29) /* Use MS-DOS 4.0 Extended parameter block for FAT12 and Fat16 */ { rtfs_print_one_string((byte *)" MSDOS-4.0 EPB detected ", PRFLG_NL); dump_print(" Sector per FAT :", (dword) (to_WORD(p+0x16)), 10, TRUE); dump_print(" Drive :", (dword) *(p+0x24), 10, TRUE); dump_print(" Binary Volume :", to_DWORD(p+0x27), 16, TRUE); rtfs_print_one_string((byte *) " Text Volume :", 0); copybuff(buff, p+0x2b, 11); buff[11] = 0; rtfs_print_one_string((byte *) &buff[0], PRFLG_NL); rtfs_print_one_string((byte *) " Filesys Type :", 0); copybuff(buff, p+0x36, 8); buff[8] = 0; rtfs_print_one_string((byte *) &buff[0], PRFLG_NL); } if (*(p+0x42) == 0x29) /* Use MS-DOS 7.0 Extended parameter block FAT32 */ { rtfs_print_one_string((byte *)" MSDOS-7.0 EPB detected ", PRFLG_NL); dump_print(" Sector per FAT :", to_DWORD(p+0x24), 10, TRUE); dump_print(" Flags and Version :", to_DWORD(p+0x28), 16, TRUE); dump_print(" Root Start Cluster :", to_DWORD(p+0x2c), 10, TRUE); dump_print(" Info Sector :", to_WORD(p+0x30), 10, TRUE); dump_print(" BackupBPB Sector :", to_DWORD(p+0x32), 10, TRUE); dump_print(" Drive :", *(p+0x40), 10, TRUE); dump_print(" Binary Volume :", to_DWORD(p+0x43), 16, TRUE); rtfs_print_one_string((byte *) " Text Volume :", 0); copybuff(buff, p+0x47, 11); buff[11] = 0; rtfs_print_one_string((byte *) &buff[0], PRFLG_NL); rtfs_print_one_string((byte *) " Filesys Type :", 0); copybuff(buff, p+0x52, 8); buff[8] = 0; rtfs_print_one_string((byte *) &buff[0], PRFLG_NL); } if (*(p+0x26) != 0x29 && *(p+0x42) != 0x29) { rtfs_print_one_string((byte *)" No valid EB signature found ", PRFLG_NL); } dump_print( " Signature (aa55 ?) :", (dword) (to_WORD(p+0x1fe)), 16, TRUE); /* FAT32 */ if (*(p+0x42) == 0x29) /* Use MS-DOS 7.0 Extended parameter block FAT32 */ { dword info_sector, backup_info_sector, backup_boot_sector; backup_boot_sector = sector + (dword) (to_WORD(p+0x32)); info_sector = sector + (dword) (to_WORD(p+0x30)); backup_info_sector = backup_boot_sector + (dword) (to_WORD(p+0x30)); rtfs_print_one_string((byte *)" Dumping Backup Boot Sector ", PRFLG_NL); if (depth == 0) { debug_dump_bpb(pdr, backup_boot_sector, p, 1); rtfs_print_one_string((byte *)" Dumping Info Sector ", PRFLG_NL); debug_dump_info_structure(pdr, info_sector, p); rtfs_print_one_string((byte *)" Dumping Backup Info Sector ", PRFLG_NL); debug_dump_info_structure(pdr, backup_info_sector, p); } } }
/*! * Affichage du programme et des données * * On affiche les instruction et les données en format hexadécimal, sous une * forme prête à être coupée-collée dans le simulateur. * * Pendant qu'on y est, on produit aussi un dump binaire dans le fichier * dump.prog. Le format de ce fichier est compatible avec l'option -b de * test_simul. * * \param pmach la machine en cours d'exécution */ void dump_memory(Machine *pmach){ //Délégation de l'affichage dump_print(pmach); //Délégation de la production du dump binaire dump_create(pmach); }