How to identify dam...
 
Notifications
Clear all

How to identify damaged blocks inside a PNG file?

3 Posts
2 Users
0 Likes
961 Views
(@exerceo)
Posts: 12
Eminent Member
Topic starter
 

I have found a PNG file and a duplicate on a USB flash drive by HAMA from 8 years ago. As one might expect from long unused flash storage, the files are damaged. In particular, HAMA is a low-quality flash storage vendor, as I would later find out. These files in particular are unimportant, but for curiousity and to help others who find this thread, I would like to find out a way to complete the PNG files from each other, since those originally identical files are presumably damaged in different locations. This means that the intact parts from each file could be merged into one complete undamaged file. In order to do that, one would need to know which blocks of data in each PNG file is damaged.

In Microsoft Paint and the Windows image viewer, the two PNG files are shown with glitch artefacts, meaning these programs try to show as much of the PNG files as possible in spite of the damage, but in Microsoft Edge, the part starting at the first damage is completely white, therefore invisible. On Linux, xviewer and Mozilla Firefox refuse to open those PNG files at all.

The fact that Microsoft Edge shows nothing after the first damaged part where as Microsoft Paint and the Windows image viewer do suggests that the PNG format has some internal verification mechanism, since otherwise Microsoft Edge would not know at which point the file is damaged, starting at the top of the invisible area.

When viewed in Microsoft Paint or the Windows image viewer, the glitches start at different locations between the two files, suggesting that they are damaged in different locations.

Some flash storage devices refuse to return sectors with damaged data and return an I/O error instead (SanDisk, in my experience), and some devices return a block with only null bytes (Intenso SD cards). This would make it easy to identify the location of damaged data. However, HAMA flash storage returns the damaged data without identifying it as such, meaning there is no way to spot damaged data on device level or byte level, meaning it needs to be spotted on file level, through the internal mechanisms of the PNG format.

After knowing which blocks of a PNG file is damaged, the intact parts can simply be manually merged inside a byte editor.

Is there any tool to find out which parts of a PNG file are damaged?

 
Posted : 13/12/2022 9:20 am
(@mscotgrove)
Posts: 938
Prominent Member
 

I think you are describing two possible problems.

If blocks are 'damaged' but read correctly, then in effect it is a corrupted file.  For this you would need to parse/validate the file.  This is obviously format dependant.  It may be useful to know that the corruption might be a full block, or always ends at the end of a block/sector.

The second issue is blocks that do not read correctly.  For these, in my software, I fill the blocks with fixed data (in my case 0x5A 0x5A...) though I have seen 0xDE 0xAD  (DEAD) as another fill. Any pattern you do not expect to find in data, so avoid padding with zeros.  I then have a program that reads/merges both files and ideally does not choose a dud sector.   I have often used this to read CDs on multiple drives and get the best results. This approach is not format or file system dependant

 
Posted : 13/12/2022 8:07 pm
(@exerceo)
Posts: 12
Eminent Member
Topic starter
 

Posted by: @mscotgrove

For this you would need to parse/validate the file.  This is obviously format dependant.

And this is what I am trying to achieve.

Posted by: @mscotgrove

For these, in my software, I fill the blocks with fixed data (in my case 0x5A 0x5A...)

The problem is that it is not known which blocks contain damaged data, but as I described in the original post, PNG appears to have some internal mechanism to verify which parts are damaged. I would like to find out how to use this mechanism to identify which bytes inside the PNG file are damaged. Does any tool for this purpose exist? I could not find anything online.

 
Posted : 14/12/2022 8:24 am
Share: