Invalid Rar Header: 80 #142

Closed
opened 2026-01-29 22:07:19 +00:00 by claunia · 2 comments
Owner

Originally created by @supershowwei on GitHub (Oct 28, 2016).

I have a RAR file.

It can not be decompressed.

attached is the rar file: a.zip

Originally created by @supershowwei on GitHub (Oct 28, 2016). I have a RAR file. It can not be decompressed. attached is the rar file: [a.zip](https://github.com/adamhathcock/sharpcompress/files/557527/a.zip)
claunia added the question label 2026-01-29 22:07:19 +00:00
Author
Owner

@elgonzo commented on GitHub (Dec 10, 2016):

In all likelihood not a bug.

The file in the attached zip achive is a self-extracting RAR file. In other words, it is an executable file and not a 'pure' RAR archive. As such, this files does not begin with a RAR signature, but with the typical data structure of a PE32 binary executable image.

Of course, somewhere inside this file is the RAR archive data, beginning with a proper RAR archive signature (or so it should). However, by default SharpCompress expects the archive signature at the beginning of the file and does not search for it somewhere else in the file. (This default behavior does not allow SharpCompress to identify files such as self-extracting archives.)

To read such a self-extracting RAR file, you need to tell SharpCompress explicitly that it should search for the archive signature inside the file if it is not found right at the beginning of the file. This is accomplished by passing a ReaderOptions object with its ReaderOptions.LookForHeader property set to true to either the ReaderFactory.Open or ArchiveFactory.Open method; similar as in this C# example:

var arc = ArchiveFactory.Open(
    archiveFile,
    new ReaderOptions() { LookForHeader = true }
);
@elgonzo commented on GitHub (Dec 10, 2016): In all likelihood not a bug. The file in the attached zip achive is a self-extracting RAR file. In other words, it is an executable file and not a 'pure' RAR archive. As such, this files does not begin with a RAR signature, but with the typical data structure of a PE32 binary executable image. Of course, somewhere inside this file is the RAR archive data, beginning with a proper RAR archive signature (or so it should). However, by default SharpCompress expects the archive signature at the beginning of the file and does not search for it somewhere else in the file. (This default behavior does not allow SharpCompress to identify files such as self-extracting archives.) To read such a self-extracting RAR file, you need to tell SharpCompress explicitly that it should search for the archive signature inside the file if it is not found right at the beginning of the file. This is accomplished by passing a **ReaderOptions** object with its _ReaderOptions.LookForHeader_ property set to `true` to either the _ReaderFactory.Open_ or _ArchiveFactory.Open_ method; similar as in this C# example: ```C# var arc = ArchiveFactory.Open( archiveFile, new ReaderOptions() { LookForHeader = true } ); ```
Author
Owner

@supershowwei commented on GitHub (Dec 11, 2016):

thanks for reply and explanation.

i ask the provider of rar file, the file is a exe binary file created by WinRAR.

the provider change the extension to .rar that avoid confusing.

thanks your help again.

@supershowwei commented on GitHub (Dec 11, 2016): thanks for reply and explanation. i ask the provider of rar file, the file is a exe binary file created by WinRAR. the provider change the extension to .rar that avoid confusing. thanks your help again.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#142