void hexdump(unsigned char *buffer, unsigned int size) { int i = 0; while (i < size) { if (i % 16 == 0) { if (i != 0) { print_ascii(buffer + i - 16, 16); } printf("%0*x ", 8 , i); } printf("%0*x ", 2, buffer[i]); i++; } if (i % 16 != 0) { int j; int rem = i % 16; for (j = rem; j < 16; j++) { printf(" "); } print_ascii(buffer + i - rem, rem); } else { print_ascii(buffer + i - 16, 16); } }
void my_showmem16(char *str, int size) { print_addr(str); print_hexa(str, size); print_ascii(str, size); my_putchar('\n'); }
void display_ifd(tiff_t *fp, tiff_ifd_t *ifd) { size_t i, tag_count; tiff_tag_t *tag; tiff_get_ifd_tag_count(fp, ifd, &tag_count); if (tag_count == 0) { return; } printf("%6.6s %4.4s %6.6s %8.8s\n", "tag", "type", "count", "data_value"); printf("==========================================================\n"); for (i = 0; i < tag_count; i++) { int type = 0; tiff_get_tag_indexed(fp, ifd, i, &tag); tiff_get_tag_info(fp, tag, NULL, &type, NULL); switch (type) { case TIFF_TYPE_ASCII: print_ascii(fp, ifd, tag); break; default: print_unknown_tag(fp, tag); break; } } }
ostream& geometry::print(ostream& ost) { if (current_printing_mode() == printing_mode_latex) { print_latex(ost); } else { print_ascii(ost); } return ost; }
/* Print the buffer */ static void buffer_print(void) { unsigned i; move_cursor(0, 0); for (i = 0; i <= max_displayed_line; i++) if (pattern_valid) print_found(buffer[i]); else print_ascii(buffer[i]); status_print(); }
int print_raf_header(FILE *inptr,struct fileheader *fileheader,unsigned long section_id) { int status = -1; int chpr = 0; if(Print_options & section_id) { /* ###%%% for now, the first 60 bytes are "header" */ if(fileheader && (fileheader->probe_magic == PROBE_RAFMAGIC)) { print_ascii(inptr,28,0); chpr += printf(" Model = "); print_ascii(inptr,32,28); status = 0; } else chpr += printf(" NOT AN RAF HEADER"); } chpr = newline(chpr); return(status); }
int break_ciphertext_CBC_padding_oracle(const unsigned char *ciphertext, unsigned char *plaintext, size_t length, oracle_t oracle, const unsigned char *iv) { unsigned char block_1[16], plaintext_2[16], input[32], input_iv[16]; memcpy(input, ciphertext, 16); memcpy(input_iv, iv, 16); int i, j, b; for (i = 15; i >= 0; --i) { for (j = 15; j > i; --j) { input_iv[j] = iv[j] ^ plaintext_2[j] ^ (16 - i); } for (j = 0; j < 256; ++j) { input_iv[i] = iv[i] ^ j ^ (16 - i); if (oracle(input, 16, input_iv)) { plaintext_2[i] = j; break; } } } memcpy(input_iv, iv, 16); memcpy(plaintext, plaintext_2, 16); for (b = 0; b < (length / 16) - 1; ++b) { memcpy(block_1, ciphertext + (16 * b), 16); memcpy(input, ciphertext + (16 * b), 32); for (i = 15; i >= 0; --i) { for (j = 15; j > i; --j) { input[j] = block_1[j] ^ plaintext_2[j] ^ (16 - i); } for (j = 0; j < 256; ++j) { input[i] = block_1[i] ^ j ^ (16 - i); if (oracle(input, 32, input_iv)) { plaintext_2[i] = j; if ((j ^ (16 - i)) != 0) { break; } } } } memcpy(plaintext + 16 * (b + 1), plaintext_2, 16); } print_ascii(plaintext, length); return 0; }
void *ft_print_memory(void *addr, unsigned int size) { int i; i = 0; while (i < size) { print_address(i, 10); ft_putchar(':'); ft_putchar(' '); print_ascii(addr, i, size); print_segment(addr, i, size); i += 16; } return (addr); }
static void pop_print(void) { struct value *value = pop(); if (value != NULL) { switch (value->type) { case BCODE_NONE: break; case BCODE_NUMBER: normalize(value->u.num, 0); print_ascii(stdout, value->u.num); fflush(stdout); break; case BCODE_STRING: fputs(value->u.string, stdout); fflush(stdout); break; } stack_free_value(value); } }
void print_memory(const void *addr, size_t size) { unsigned char *ptr; int i = 0; int count_pass; int tcpt; ptr = (unsigned char *)addr; while (i < (int)size) { count_pass = 0; tcpt = i; while (tcpt < (int)size && count_pass < 16) { print_hex(ptr[tcpt]); tcpt++; count_pass++; if (tcpt < (int)size) { print_hex(ptr[tcpt]); count_pass++; tcpt++; } write(1, " ", 1); } print_pad(calc_pad(count_pass)); count_pass = 0; tcpt = i; while (tcpt < (int)size && count_pass < 16) { print_ascii(ptr[tcpt]); count_pass++; tcpt++; } write(1, "\n", 1); i += count_pass; } }
void print_memory(const void *addr, size_t size) { unsigned char *tmp; size_t loop; size_t i; size_t count; size_t pass; tmp = (unsigned char*)addr; i = 0; count = 0; pass = 0; while (count < size) { loop = 0; while (loop < 16 && i < size) { print_hex(tmp[i++]); ++loop; ++pass; if (loop && (loop & 1) == 0) write(1, " ", 1); } if (loop && loop < 16) print_empty(loop); loop = 0; i = i - pass; while (pass && loop < 16 && i < size) { print_ascii(tmp[i++]); ++loop; } write(1, "\n", 1); count += 16; pass = 0; } }
static int second_try(Elf64_Shdr *shdr, char *strtab, uint8_t *data, int i) { int k; if ((shdr->sh_size != 0 || shdr->sh_type == SHT_SYMTAB || shdr->sh_type == SHT_NOBITS || shdr->sh_type == SHT_STRTAB) && strcmp(".dynstr", &strtab[shdr[i].sh_name]) != 0) return (SUCCESS); k = shdr[i].sh_offset; printf("Contents of section %s:\n", &strtab[shdr[i].sh_name]); while (k < (int)(shdr[i].sh_offset + shdr[i].sh_size)) { print_pos(&strtab[shdr[i].sh_name], shdr + i, k - shdr[i].sh_offset, i); printf(" "); print_hexa(data + k, shdr[i].sh_offset + shdr[i].sh_size - k); print_ascii(data + k, shdr[i].sh_offset + shdr[i].sh_size - k); printf("\n"); k += 16; } return (SUCCESS); }
void agfa1_offset_makervalue(FILE *inptr,unsigned short byteorder, struct ifd_entry *entry_ptr,unsigned long fileoffset_base, struct image_summary *summary_entry,char *parent_name,char*prefix, int indent,int make,int model,int at_offset) { unsigned long max_offset = 0; unsigned long value_offset; unsigned long dumplength,count; unsigned short marker; char *nameoftag; char *fulldirname = NULL; int status = 0; int chpr = 0; if(entry_ptr) { nameoftag = maker_tagname(entry_ptr->tag,make,model); fulldirname = splice(parent_name,".",nameoftag); value_offset = fileoffset_base + entry_ptr->value; count = entry_ptr->count; switch(entry_ptr->tag) { case 0x0209: /* CameraId */ if(at_offset && (PRINT_VALUE_AT_OFFSET)) { print_tag_address(ENTRY,value_offset,indent,prefix); print_makertagid(entry_ptr,23," = ",make,model); } if((PRINT_VALUE)) print_ascii(inptr,entry_ptr->count,value_offset); break; case 0x0100: /* Jpeg Thumbnail */ if(at_offset && (PRINT_SECTION)) { print_tag_address(VALUE_AT_OFFSET,value_offset,indent,prefix); chpr += printf("# Start of JPEG Thumbnail from MakerNote"); chpr += printf(" length %ld",count); } else if(!at_offset && (PRINT_VALUE)) { if(!(PRINT_OFFSET)) chpr += printf("@%lu",value_offset); else chpr = printf("length %lu",count); } if((PRINT_SECTION) || (PRINT_SEGMENT)) chpr = newline(chpr); marker = read_ushort(inptr,TIFF_MOTOROLA,value_offset); max_offset = process_jpeg_segments(inptr,value_offset,marker, count,summary_entry,fulldirname, prefix,indent+SMALLINDENT); if(at_offset) { if((PRINT_SECTION)) { if((status = jpeg_status(0) == JPEG_EARLY_EOI)) chpr = newline(chpr); jpeg_status(status); print_tag_address(VALUE_AT_OFFSET,value_offset + count - 1, indent,"-"); chpr += printf("# End of JPEG Thumbnail from MakerNote"); if((PRINT_ENTRY) && !(PRINT_VALUE)) chpr = newline(chpr); } } print_jpeg_status(); if(marker && summary_entry) { /* The new one is on the end of the chain */ if((summary_entry = last_summary_entry(summary_entry))) { summary_entry->filesubformat |= FILESUBFMT_MNOTE; summary_entry->datatype = MAKER_IFD; summary_entry->subfiletype = THUMBNAIL_TYPE; } } /* make certain we're at the end */ clearerr(inptr); fseek(inptr,value_offset + count,SEEK_SET); break; case 0x0f00: /* Data */ if(at_offset && (PRINT_ENTRY)) { print_tag_address(ENTRY,value_offset,indent,prefix); print_makertagid(entry_ptr,MAKERTAGWIDTH," : ",make,model); chpr += printf(" length %-9lu", count); if(Max_undefined == 0) { if(chpr) printred(" (not dumped, use -U)"); } else { if((Max_undefined == DUMPALL) || (Max_undefined > count)) dumplength = count; else dumplength = Max_undefined; chpr = newline(chpr); hexdump(inptr,value_offset,count,dumplength,12, indent,SUBINDENT); chpr = newline(1); } } else if(!at_offset && (PRINT_VALUE)) { if(!(PRINT_OFFSET)) chpr += printf("@%lu:%lu",value_offset,entry_ptr->count); else chpr = printf("length %lu", entry_ptr->count); if(!(PRINT_VALUE_AT_OFFSET)) chpr += printf(" # UNDEFINED"); } /* make certain we're at the end */ fseek(inptr,value_offset + count,SEEK_SET); break; default: print_generic_offset_makervalue(inptr,byteorder,entry_ptr, fileoffset_base,fulldirname,prefix,indent, make,model,at_offset); break; } if(fulldirname) free(fulldirname); } setcharsprinted(chpr); }
void fat_print_partition(fat_partition *part, bool verbose) { if(verbose) { printf("Boot Sector\n"); printf("OEM ID: "); print_ascii(part->boot_sector->oem_id, sizeof(part->boot_sector->oem_id)); printf("\n"); printf("BIOS Parameter Block\n"); printf("Bytes per Sector: %u\n", part->boot_sector->bpb.bytes_per_sector); printf("Sectors per Cluster: %u\n", part->boot_sector->bpb.sectors_per_cluster); printf("Reserved Sectors: %u\n", part->boot_sector->bpb.reserved_sectors); printf("Number of FATs: %u\n", part->boot_sector->bpb.num_fats); printf("Root Entries (F16): %u\n", part->boot_sector->bpb.root_entries_f16); printf("Total Sectors (16 bit): %u\n", part->boot_sector->bpb.total_sectors_16bit); printf("Media: 0x%02x\n", part->boot_sector->bpb.media_descriptor); printf("Sectors per FAT (F16): %u\n", part->boot_sector->bpb.sectors_per_fat_f16); printf("Sectors per Track: %u\n", part->boot_sector->bpb.sectors_per_track); printf("Number of Heads: %u\n", part->boot_sector->bpb.num_heads); printf("Hidden Sectors: %u\n", part->boot_sector->bpb.hidden_sectors); printf("Total Sectors (32 bit): %u\n", part->boot_sector->bpb.total_sectors_32bit); // FAT32 portion of the BPB if(part->type == PT_FAT32) { printf("Sectors per FAT (F32): %u\n", part->boot_sector->bpb.sectors_per_fat_f32); printf("Flags (F32): %u\n", part->boot_sector->bpb.eflags_f32); printf("Version (F32): %u\n", part->boot_sector->bpb.version_f32); printf("Root Cluster (F32): %u\n", part->boot_sector->bpb.root_cluster_f32); printf("FSINFO Sector (F32): %u\n", part->boot_sector->bpb.fsinfo_sector_f32); printf("Backup Sector (F32): %u\n", part->boot_sector->bpb.backup_sector_f32); printf("Reserved (should all be 0): "); print_hex2(part->boot_sector->bpb.reserved_f32, sizeof(part->boot_sector->bpb.reserved_f32)); } printf("\nExtended BIOS Parameter Block\n"); printf("Physical Drive Num: %u\n", part->boot_sector->ebpb.physical_drive_num); printf("Reserved (should be 0): %u\n", part->boot_sector->ebpb.reserved); printf("Signature: 0x%X\n", part->boot_sector->ebpb.eb_sig); printf("Volume Serial: 0x%X\n", part->boot_sector->ebpb.volume_serial); printf("Volume Label: "); print_ascii(part->boot_sector->ebpb.volume_label, sizeof(part->boot_sector->ebpb.volume_label)); printf("\n"); printf("System ID: "); print_ascii(part->boot_sector->ebpb.system_id, sizeof(part->boot_sector->ebpb.system_id)); printf("\n"); if(part->type == PT_FAT32) { printf("\nFSINFO\n"); printf("Free Cluster Count: %u\n", part->fsinfo->free_cluster_count); printf("Next Free Cluster: %u\n", part->fsinfo->next_free_cluster); } } printf("\n"); // Normal output printf("Reserved Area: Start sector: %i Ending sector: %i Size: %i sectors\n", 0, part->boot_sector->bpb.reserved_sectors-1, part->boot_sector->bpb.reserved_sectors); printf("Sectors per cluster: %i sectors\n", part->boot_sector->bpb.sectors_per_cluster); printf("FAT area: Start sector: %i Ending sector: %i\n", part->boot_sector->bpb.reserved_sectors, fat_data_start_rel(part)-fat_rootdir_size(part)-1); printf("# of FATs: %i\n", part->boot_sector->bpb.num_fats); printf("The size of each FAT: %i sectors\n", fat_sectors_per_fat(part)); printf("The first sector of cluster 2: %i sectors\n", fat_data_start_abs(part)); }
unsigned long process_raf(FILE *inptr,unsigned long offset, struct image_summary *summary_entry, char *parent_name,int indent) { unsigned long start_of_jpeg,jpeg_length,max_offset; unsigned long table1_offset,table2_offset; unsigned long table1_length,table2_length; unsigned long CFA_offset,CFA_length; unsigned long unknown2,CFA_primaryarraywidth,CFA_fullarraywidth; unsigned long Secondary_offset,Secondary_length; unsigned long unknown3,Secondary_arraywidth,Secondary_fullarraywidth; unsigned long unused_value; struct image_summary *tmp_summary_entry; int unused; char *fullname = CNULL; int chpr = 0; unsigned short tag; CFA_primaryarraywidth = Secondary_offset = table1_offset = table2_offset = 0UL; /* Record the primary for the image summary */ if(((summary_entry == NULL) || summary_entry->entry_lock) || (summary_entry->imageformat != IMGFMT_NOIMAGE)) { summary_entry = new_summary_entry(summary_entry,FILEFMT_RAF,IMGFMT_RAF); } if(summary_entry) { summary_entry->imageformat = IMGFMT_RAF; summary_entry->imagesubformat = IMGSUBFMT_CFA; summary_entry->entry_lock = lock_number(summary_entry); } chpr = newline(chpr); /* A short section of zeros; why? */ if((PRINT_SECTION)) { print_tag_address(SECTION,offset,indent,"@"); chpr += printf("<Offset Directory>"); chpr = newline(chpr); } /* Some sort of ID or version? */ print_tag_address(ENTRY,offset,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"HeaderVersion"); } if((PRINT_VALUE)) { chpr += printf(" = "); print_ascii(inptr,4,offset); } chpr = newline(chpr); offset += 4; /* A 20 bytes section of zeros. Unknown */ if((PRINT_SECTION)) { print_tag_address(ENTRY,offset,indent + SMALLINDENT,"@"); if((PRINT_VALUE)) print_ubytes(inptr,20,offset); chpr = newline(chpr); } /* A jpeg reduced resolution image, complete with EXIF */ start_of_jpeg = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC); print_tag_address(ENTRY,RAF_JPEGLOC,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"JpegImageOffset"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",start_of_jpeg); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 4,indent + SMALLINDENT,"@"); jpeg_length = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 4); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"JpegImageLength"); } if((PRINT_VALUE)) chpr += printf(" = %lu",jpeg_length); chpr = newline(chpr); /* An offset to what may be a white balance table */ print_tag_address(ENTRY,RAF_JPEGLOC + 8,indent + SMALLINDENT,"@"); table1_offset = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 8); table1_length = read_ulong(inptr,TIFF_MOTOROLA,HERE); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"Table1Offset"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",table1_offset); chpr = newline(chpr); /* The length of the table; probably also the number of rows in */ /* the CFA array */ print_tag_address(ENTRY,RAF_JPEGLOC + 12,indent + SMALLINDENT,"@"); table1_length = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 12); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"Table1Length"); } if((PRINT_VALUE)) chpr += printf(" = %lu",table1_length); chpr = newline(chpr); /* If there is a second table, this must be an SR Super CCD with */ /* a secondary CFA table containing the data for the secondary */ /* photodiodes. The start offset for the secondary data is offset */ /* one row (2944 bytes) from the start of the primary data, */ /* suggesting that the primary and secondary CFA arrays are */ /* interleaved by rows (of 1472 unsigned shorts) */ table2_offset = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 36); table2_length = read_ulong(inptr,TIFF_MOTOROLA,HERE); if(table2_offset == 0) { print_tag_address(ENTRY,RAF_JPEGLOC + 16,indent + SMALLINDENT,"@"); CFA_offset = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 16); CFA_length = read_ulong(inptr,TIFF_MOTOROLA,HERE); Secondary_length = 0; if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFAOffset"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",CFA_offset); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 20,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFALength"); } if((PRINT_VALUE)) chpr += printf(" = %lu",CFA_length); chpr = newline(chpr); for(unused = 24; unused < 64; unused += 4) { print_tag_address(ENTRY,RAF_JPEGLOC + unused,indent + SMALLINDENT,"@"); unused_value = read_ulong(inptr,TIFF_MOTOROLA,(unsigned long)(RAF_JPEGLOC + unused)); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%s%-2d%*.*s","unused",(unused - 24)/4 + 1,TAGWIDTH-8,TAGWIDTH-8," "); } if((PRINT_VALUE)) chpr += printf(" = %lu",unused_value); chpr = newline(chpr); } } else { /* No secondary; easy. */ CFA_offset = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 16); CFA_length = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 20); print_tag_address(ENTRY,RAF_JPEGLOC + 16,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFA_Offset"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",CFA_offset); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 20,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFA_length"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",CFA_length); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 24,indent + SMALLINDENT,"@"); unknown2 = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 24); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"unknown2"); } if((PRINT_VALUE)) chpr += printf(" = %lu",unknown2); chpr = newline(chpr); CFA_primaryarraywidth = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 28); print_tag_address(ENTRY,RAF_JPEGLOC + 28,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { /* Array width in 16 bit unsigned shorts */ if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFAPrimaryArrayWidth"); } if((PRINT_VALUE)) chpr += printf(" = %lu",CFA_primaryarraywidth); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 32,indent + SMALLINDENT,"@"); CFA_fullarraywidth = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 32); if((PRINT_TAGINFO)) { /* Array width in bytes */ if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFAFullArrayWidth"); } if((PRINT_VALUE)) chpr += printf(" = %lu",CFA_fullarraywidth); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 36,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"Table2Offset"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",table2_offset); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 40,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"Table2Length"); } if((PRINT_VALUE)) chpr += printf(" = %lu",table2_length); chpr = newline(chpr); /* It appears that the secondary CFA data is interlaced by */ /* row with the primary data. */ Secondary_offset = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 44); Secondary_length = read_ulong(inptr,TIFF_MOTOROLA,HERE); print_tag_address(ENTRY,RAF_JPEGLOC + 44,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFASecondaryOffset**"); } if((PRINT_VALUE)) chpr += printf(" = @%lu",Secondary_offset); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 48,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFASecondaryLength**"); } if((PRINT_VALUE)) chpr += printf(" = %lu",Secondary_length); chpr = newline(chpr); unknown3 = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 52); Secondary_arraywidth = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 56); Secondary_fullarraywidth = read_ulong(inptr,TIFF_MOTOROLA,RAF_JPEGLOC + 60); print_tag_address(ENTRY,RAF_JPEGLOC + 52,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"unknown3"); } if((PRINT_VALUE)) chpr += printf(" = %lu",unknown3); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 56,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFASecondaryArrayWidth"); } if((PRINT_VALUE)) chpr += printf(" = %lu",Secondary_arraywidth); chpr = newline(chpr); print_tag_address(ENTRY,RAF_JPEGLOC + 60,indent + SMALLINDENT,"@"); if((PRINT_TAGINFO)) { if((PRINT_LONGNAMES)) chpr += printf("%s.",parent_name); /* I dunno what to call this... */ chpr += printf("%-*.*s",TAGWIDTH,TAGWIDTH,"CFASecondaryFullArrayWidth"); } if((PRINT_VALUE)) chpr += printf(" = %lu",Secondary_fullarraywidth); chpr = newline(chpr); } if((PRINT_SECTION)) { print_tag_address(SECTION,RAF_JPEGLOC + 63,indent,"@"); chpr += printf("</Offset Directory>"); chpr = newline(chpr); } /* Finish the summary entry */ if(summary_entry) { if(summary_entry->length <= 0) summary_entry->length = CFA_length + Secondary_length; if(summary_entry->offset <= 0) summary_entry->offset = CFA_offset; /* Not really compression; just record the presence of the */ /* secondary */ if(Secondary_offset) summary_entry->compression = 1; else summary_entry->compression = 0; /* These aren't really pixel sizes, since the actual number */ /* of columns is half the arraywidth, and the array will have */ /* to be rotated 45 degrees. And then there is the secondary */ /* pixel data... */ /* It's what we know, and post-processing can do what it */ /* wants. */ if(CFA_primaryarraywidth) { summary_entry->pixel_width = CFA_primaryarraywidth; summary_entry->pixel_height = table1_length; summary_entry->primary_width = CFA_primaryarraywidth; summary_entry->primary_height = table1_length; } else { /* No size provided; this is the best we can do. */ summary_entry->pixel_width = (CFA_length + Secondary_length)/table1_length; summary_entry->pixel_height = table1_length; summary_entry->primary_width = summary_entry->pixel_width; summary_entry->primary_height = table1_length; } summary_entry->subfiletype = PRIMARY_TYPE; } /* Now display the offset sections, starting with the jpeg image */ /* (but only if showing sections) */ if((PRINT_SECTION)) { print_tag_address(SECTION,start_of_jpeg,indent,"@"); chpr += printf("#### Start of Jpeg Image, length %lu",jpeg_length); chpr = newline(chpr); } /* Is this really a jpeg section? */ tag = read_ushort(inptr,TIFF_MOTOROLA,start_of_jpeg); if(tag == JPEG_SOI) { /* If so, process it regardless of output options, to pick up */ /* information for the image summary */ fullname = splice(parent_name,".","JPEG"); max_offset = process_jpeg_segments(inptr,start_of_jpeg,JPEG_SOI,jpeg_length, summary_entry,fullname,"@",SMALLINDENT); print_jpeg_status(); if(summary_entry) { /* The jpeg summary entry should be next in the chain; */ /* there may be others following; mark the jpeg entry so */ /* that it will show up in the format summary. */ if((tmp_summary_entry = summary_entry->next_entry)) tmp_summary_entry->filesubformat |= FILESUBFMT_JPEG; } } else dumpsection(inptr,start_of_jpeg,jpeg_length,indent + SMALLINDENT); if((PRINT_SECTION)) { print_tag_address(SECTION,start_of_jpeg + jpeg_length - 1,indent,"@"); chpr += printf("#### End of Jpeg Image, length %lu",jpeg_length); chpr = newline(chpr); print_tag_address(SECTION,table1_offset,indent,"@"); chpr += printf("<Table 1> length %lu",table1_length); chpr = newline(chpr); if((PRINT_VALUE)) dumpsection(inptr,table1_offset,table1_length,indent + SMALLINDENT); print_tag_address(SECTION,table1_offset + table1_length - 1,indent,"@"); chpr += printf("</Table 1>"); chpr = newline(chpr); if(table2_offset) { print_tag_address(SECTION,table2_offset,indent,"@"); chpr += printf("<Table 2> length %lu",table2_length); chpr = newline(chpr); if((PRINT_VALUE)) dumpsection(inptr,table2_offset,table2_length,indent + SMALLINDENT); print_tag_address(SECTION,table2_offset + table2_length - 1,indent,"@"); chpr += printf("</Table 2>"); chpr = newline(chpr); } /* The full CFA, with secondary if present */ print_tag_address(SECTION,CFA_offset,indent,"@"); chpr += printf("<CFA Image> length %lu",CFA_length + Secondary_length); chpr = newline(chpr); if((PRINT_VALUE)) dumpsection(inptr,CFA_offset,CFA_length + Secondary_length,indent + SMALLINDENT); print_tag_address(SECTION,CFA_offset + CFA_length + Secondary_length - 1,indent,"@"); chpr += printf("</CFA Image>"); chpr = newline(chpr); } setcharsprinted(chpr); return(get_filesize(inptr)); }
void print_generic_offset_makervalue(FILE *inptr,unsigned short byteorder, struct ifd_entry *entry_ptr,unsigned long fileoffset_base,char *parent_name, char *prefix,int indent,int make,int model,int at_offset) { unsigned long value_offset; unsigned long dumplength; int chpr = 0; if((value_type_size(entry_ptr->value_type) * entry_ptr->count) > 4) { value_offset = fileoffset_base + entry_ptr->value; if(PRINT_VALUE) { if(at_offset) { print_tag_address(ENTRY,value_offset,indent,prefix); if(entry_ptr->value_type == UNDEFINED) print_makertagid(entry_ptr,MAKERTAGWIDTH," : ",make,model); else print_makertagid(entry_ptr,MAKERTAGWIDTH," = ",make,model); } else { if((PRINT_OFFSET) && (entry_ptr->value_type != UNDEFINED)) chpr += printf(" = "); } switch(entry_ptr->value_type) { case UNDEFINED: /* Could make a pseudo-tag for 'count' in LIST */ /* mode... */ if((PRINT_SECTION) && at_offset && (PRINT_VALUE_AT_OFFSET)) chpr += printf("length %-9lu # UNDEFINED",entry_ptr->count); else { if(!(PRINT_OFFSET)) chpr += printf("@%lu",value_offset); chpr += printf(":%-9lu # UNDEFINED",entry_ptr->count); } if(Max_undefined == 0) { if((PRINT_SECTION)) printred(" (not dumped, use -U)"); } else { /* Even in LIST and REPORT modes */ if((Max_undefined == DUMPALL) || (Max_undefined > entry_ptr->count)) dumplength = entry_ptr->count; else dumplength = Max_undefined; chpr = newline(1); hexdump(inptr,entry_ptr->value + fileoffset_base, entry_ptr->count,dumplength,12, indent,SUBINDENT); } /* make certain we're at the end */ fseek(inptr,entry_ptr->value + fileoffset_base + entry_ptr->count,SEEK_SET); break; case ASCII: print_ascii(inptr,entry_ptr->count,value_offset); break; case BYTE: print_ubytes(inptr,entry_ptr->count,value_offset); break; case SBYTE: print_sbytes(inptr,entry_ptr->count,value_offset); break; case SHORT: print_ushort(inptr,entry_ptr->count,byteorder,value_offset); break; case SSHORT: print_sshort(inptr,entry_ptr->count,byteorder,value_offset); break; case LONG: print_ulong(inptr,entry_ptr->count,byteorder,value_offset); break; case SLONG: print_slong(inptr,entry_ptr->count,byteorder,value_offset); break; case RATIONAL: print_urational(inptr,entry_ptr->count,byteorder,value_offset); break; case SRATIONAL: print_srational(inptr,entry_ptr->count,byteorder,value_offset); break; case FLOAT: print_float(inptr,entry_ptr->count,byteorder,value_offset); break; case DOUBLE: print_double(inptr,entry_ptr->count,byteorder,value_offset); break; default: chpr = printf(" INVALID TYPE %#x",entry_ptr->value_type); break; } } } if(ferror(inptr) || feof(inptr)) clearerr(inptr); setcharsprinted(chpr); }