90 likes | 249 Views
Comp 335 – File Structures. Hexadecimal Dumps Interpreting File Contents. What is a Hexadecimal Dump?. It is a common way to view the actual contents of a file or memory. The contents are displayed in hexadecimal because this is easier to view than the actual binary code.
E N D
Comp 335 – File Structures Hexadecimal Dumps Interpreting File Contents
What is a Hexadecimal Dump? • It is a common way to view the actual contents of a file or memory. • The contents are displayed in hexadecimal because this is easier to view than the actual binary code. • It will be a useful tool in this class to examine file structures within binary files.
What is a Hexadecimal Dump? HEX DUMP FOR FILE: somedata.dat 00000000: 54 68 69 73 20 69 73 0D 0A 73 61 6D 70 6C 65 20 This is..sample 00000010: 74 65 78 74 0D 0A 77 69 74 68 20 6E 75 6D 62 65 text..with numbe 00000020: 72 73 20 31 35 0D 0A 61 6E 64 20 33 36 2E 0D 0A rs 15..and 36... • Parts of a Hexadecimal Dump: • Title Line – gives the name of the file dumped • Byte Address – given in hex in increments of 16 bytes • Data – each byte is written in hex, 16 bytes on a line • ASCII translation – if byte is readable ASCII, it will be displayed, otherwise • a ‘.’ is displayed
Hexadecimal Review • Base 16 • Uses digits 0 – 9 • Uses letters A – F • A: 10 • B: 11 • C: 12 • D: 13 • E: 14 • F: 15
Hexadecimal Review • 1610 would be 1016 • (1 X 161) + (0 X 160) = 16 + 0 = 16 • 4510 would be 2D16 • (2 X 161) + (13 X 160) = 32 + 13 = 45
Hexadecimal Questions • What is 1AE16 in Decimal? (1 X 162) + (10 X 161) + (14 X 160) 256 + 160 + 14 = 430 • What is 37510 in Hexadecimal? 375 - 256 = 119 (162 place – 1) 119 – 112 = 7 (161 place – 7) 7 – 7 = 0 (160 place – 7) Answer: 17716
Hex to Binary • It takes 4 binary digits to represent one hex number. 0000 – 0 0001 – 1 0010 – 2 0011 – 3 0100 – 4 0101 – 5 0110 – 6 0111 – 7 1000 - 8 1001 – 9 1010 – A 1011 – B 1100 – C 1101 – D 1110 – E 1111 – F • Hex dumps represent each byte in a file as a two digit hex number. • Example: OD16 would be 0000 11012
Hex to Binary Questions • Convert A816 to Binary 1010 10002 • Convert 0110 11112 to Hexadecimal 6F16
Another Look at a Hex Dump HEX DUMP FOR FILE: somedata.dat 00000000: 54 68 69 73 20 69 73 0D 0A 73 61 6D 70 6C 65 20 This is..sample 00000010: 74 65 78 74 0D 0A 77 69 74 68 20 6E 75 6D 62 65 text..with numbe 00000020: 72 73 20 31 35 0D 0A 61 6E 64 20 33 36 2E 0D 0A rs 15..and 36... The above dump was generated from a simple ASCII file created in the Windows Notepad application shown below. This is sample text with numbers 15 and 36.