WinRAR archive in RAR4 and RAR5 variants.
Overview
RAR4 files are a sequence of blocks (marker, archive header, file headers, end) with 2-byte CRCs. RAR5 uses variable-length integers and typed headers with 32-bit CRCs. File data can be solid, encrypted (AES) and split into multiple volumes. Compression uses LZ variants with filters (E8/E8E9, Delta, RGB, audio) and PPMd in RAR3.
Where it is used
- Software and media distribution, especially on file-sharing sites.
- Multi-volume backups.
History
- Created by Eugene Roshal in 1993; RAR5 was introduced with WinRAR 5.0 (2013).
Status today
- Proprietary compressor; extraction code is freely available (unrar).
Structures read by the implementation
Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
FileFields.ParseFile buffer h · RarCarver.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| p | 4 | u32 LE | Odified | |
| p | 4 | u32 LE | Crc | |
| q | 4 | u32 LE | Odified | |
| q | 8 | i64 LE | File Time |
Rar4Walker.FileHeaderCrcEnd buffer h · RarCarver.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x1A | 2 | u16 LE | Name Size | |
| p | 2 | u16 LE | Ext |
Rar4Walker.PlausibleFileHeader buffer h · RarCarver.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0xF | 1 | u8 | – | |
| 0x19 | 1 | u8 | – | |
| 0x1A | 2 | u16 LE | Name Size |
Rar4Walker.Process buffer h · RarCarver.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x3 | 2 | u16 LE | Flags | |
| 0xB | 4 | u32 LE | Unpacked | |
| 0x10 | 4 | u32 LE | Crc | |
| 0x14 | 4 | u32 LE | – | |
| 0x18 | 1 | u8 | Ax Version | |
| 0x19 | 1 | u8 | Stored | |
| 0x19 | 1 | u8 | – | |
| 0x24 | 4 | u32 LE | – | |
| p | 2 | u16 LE | Volume Number Value |
Rar4Walker.ReadBlock buffer fixedPart · RarCarver.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x0 | 2 | u16 LE | Stored Crc | |
| 0x2 | 1 | u8 | Type | |
| 0x3 | 2 | u16 LE | Flags | |
| 0x5 | 2 | u16 LE | Header Size |
Rar4Walker.ReadBlock buffer header · RarCarver.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x7 | 4 | u32 LE | Data Size | |
| 0x20 | 4 | u32 LE | – |
KeyCache.ReadV5 buffer head · RarExtractor.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x0 | 4 | u32 LE | – | |
| p + 1 | 16 | bytes | Salt | |
| p + 17 | 8 | bytes | – |
V4Group.ReadV4 buffer first · RarExtractor.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x2 | 1 | u8 | – | |
| 0x5 | 2 | u16 LE | Enc Size |
V4Group.ReadV4 buffer head · RarExtractor.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| 0x0 | 2 | u16 LE | – | |
| 0x2 | 1 | u8 | Type | |
| 0x3 | 2 | u16 LE | Flags | |
| 0x5 | 2 | u16 LE | Size | |
| 0x5 | 2 | u16 LE | Head Size | |
| 0x7 | 4 | u32 LE | Add Size | |
| 0x7 | 4 | u32 LE | Packed | |
| 0xB | 4 | u32 LE | Unpacked | |
| 0x10 | 4 | u32 LE | Crc | |
| 0x14 | 4 | u32 LE | Dos Time | |
| 0x18 | 1 | u8 | Version | |
| 0x19 | 1 | u8 | Ethod | |
| 0x1A | 2 | u16 LE | Name Size | |
| 0x20 | 4 | u32 LE | – | |
| 0x24 | 4 | u32 LE | – |
struct.ParseEncryptionRecord buffer h · RarExtractor.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| q + 1 | 16 | bytes | – | |
| q + 17 | 16 | bytes | – | |
| q + 33 | 8 | bytes | – |
struct.ParseFile buffer h · RarExtractor.cs
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| p | 4 | u32 LE | Odified | |
| p | 4 | u32 LE | Crc |
Other fields read
| Read in | Offset | Size | Type | Field | Notes |
|---|---|---|---|---|---|
| RarVmFilters.Run | pos | 4 | u32 LE | Addr | |
| RarArchiveModule.Probe | 0x0 | 7 | bytes | – | |
| Rar4Walker.EntryName | 0x3 | 2 | u16 LE | – | |
| Rar4Walker.FileName | 0x1A | 2 | u16 LE | Name Size | |
| Rar4Walker.PlausibleSubHeader | 0x1A | 2 | u16 LE | Name Size | |
| Rar5Walker.ReadBlock | 0x0 | 4 | u32 LE | Stored Crc |
Constants
General DecodeTable
| Name | Value | Type | Notes |
|---|---|---|---|
| LDecode | [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112… | int[] | |
| LBits | [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5] | int[] | |
| SDDecode | [0, 4, 8, 16, 32, 64, 128, 192] | int[] | |
| SDBits | [2, 2, 3, 4, 5, 6, 6, 6] | int[] |
General Unpack15
| Name | Value | Type | Notes |
|---|---|---|---|
| DecL1 | [0x8000, 0xa000, 0xc000, 0xd000, 0xe000, 0xea00, 0xee00, 0xf000, 0xf200, 0xf200, 0xffff] | int[] | |
| PosL1 | [0, 0, 0, 2, 3, 5, 7, 11, 16, 20, 24, 32, 32] | int[] | |
| DecL2 | [0xa000, 0xc000, 0xd000, 0xe000, 0xea00, 0xee00, 0xf000, 0xf200, 0xf240, 0xffff] | int[] | |
| PosL2 | [0, 0, 0, 0, 5, 7, 9, 13, 18, 22, 26, 34, 36] | int[] | |
| DecHf0 | [0x8000, 0xc000, 0xe000, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xffff] | int[] | |
| PosHf0 | [0, 0, 0, 0, 0, 8, 16, 24, 33, 33, 33, 33, 33] | int[] | |
| DecHf1 | [0x2000, 0xc000, 0xe000, 0xf000, 0xf200, 0xf200, 0xf7e0, 0xffff] | int[] | |
| PosHf1 | [0, 0, 0, 0, 0, 0, 4, 44, 60, 76, 80, 80, 127] | int[] | |
| DecHf2 | [0x1000, 0x2400, 0x8000, 0xc000, 0xfa00, 0xffff, 0xffff, 0xffff] | int[] | |
| PosHf2 | [0, 0, 0, 0, 0, 0, 2, 7, 53, 117, 233, 0, 0] | int[] | |
| DecHf3 | [0x800, 0x2400, 0xee00, 0xfe80, 0xffff, 0xffff, 0xffff] | int[] | |
| PosHf3 | [0, 0, 0, 0, 0, 0, 0, 2, 16, 218, 251, 0, 0] | int[] | |
| DecHf4 | [0xff00, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff] | int[] | |
| PosHf4 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0] | int[] | |
| ShortLen1 | [1, 3, 4, 4, 5, 6, 7, 8, 8, 4, 4, 5, 6, 6, 4, 0] | int[] | |
| ShortXor1 | [0, 0xa0, 0xd0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xc0, 0x80, 0x90, 0x98, 0x9c, 0xb0] | int[] | |
| ShortLen2 | [2, 3, 3, 3, 4, 4, 5, 6, 6, 4, 4, 5, 6, 6, 4, 0] | int[] | |
| ShortXor2 | [0, 0x40, 0x60, 0xa0, 0xd0, 0xe0, 0xf0, 0xf8, 0xfc, 0xc0, 0x80, 0x90, 0x98, 0x9c, 0xb0] | int[] |
General Unpack20
| Name | Value | Type | Notes |
|---|---|---|---|
| DDecode | [0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1… | int[] | |
| DBits | [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, … | int[] | |
| NC | 298, DC = 48, RC = 28, BC = 19, MC = 257 | int |
General Unpack29
| Name | Value | Type | Notes |
|---|---|---|---|
| DDecode | [0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1… | int[] | |
| DBits | [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, … | int[] | |
| NC | 299, DC = 60, LDC = 17, RC = 28, BC = 20, Huff = NC + DC + LDC + RC | int | |
| VmGlobalAddr | 0x3C000 | uint | |
| VmFixedGlobalSize | 0x40 | int |
General RarRangeDecoder
| Name | Value | Type | Notes |
|---|---|---|---|
| Top | 1u << 24, Bot = 1u << 15 | uint |
General RarVmFilters
| Name | Value | Type | Notes |
|---|---|---|---|
| FileSize | 0x1000000 | uint |
General Rar5Unpack
| Name | Value | Type | Notes |
|---|---|---|---|
| NC | 306 | int | literals + lengths |
| DC | 64 | int | distance slots |
| LDC | 16 | int | low-distance |
| RC | 44 | int | repeat lengths |
| BC | 20 | int | pre-tree |
| HuffTableSize | NC + DC + LDC + RC | int | 430 |
block state Rar5Unpack
| Name | Value | Type | Notes |
|---|---|---|---|
| FilterDelta | 0, FilterE8 = 1, FilterE8E9 = 2, FilterArm = 3 | int | |
| MaxFilterBlockSize | 0x400000 | int |
—- Filters (RAR5: delta, x86 E8/E8E9, ARM) ———————————————— SolidStream
| Name | Value | Type | Notes |
|---|---|---|---|
| fileSize | 0x1000000 | uint |
General RarCarver
| Name | Value | Type | Notes |
|---|---|---|---|
| SignatureV4 | [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00] | byte[] | |
| SignatureV5 | [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00] | byte[] | |
| ResyncBack | 1024 * 1024 | long | |
| ResyncAhead | 16L * 1024 * 1024 | long | |
| ReadBufferSize | 1024 * 1024 | int |
General Walker
| Name | Value | Type | Notes |
|---|---|---|---|
| Sector | ErrorMarker.PatternLength | int |
General Rar5Walker
| Name | Value | Type | Notes |
|---|---|---|---|
| Main | 1, File = 2, Service = 3, Encryption = 4, EndArc = 5 | int |
General RarExtractor
| Name | Value | Type | Notes |
|---|---|---|---|
| SignatureV5 | [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00] | byte[] | |
| SignatureV4 | [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00] | byte[] | |
| Main | 1, FileBlock = 2, Service = 3, Encryption = 4, EndArc = 5 | int |
—————————————————————— RAR 1.5 – 4.x struct
| Name | Value | Type | Notes |
|---|---|---|---|
| V4Main | 0x73, V4File = 0x74, V4Service = 0x7A, V4End = 0x7B | byte |
General RarArchiveModule
| Name | Value | Type | Notes |
|---|---|---|---|
| MagicV5 | [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00] | byte[] | |
| MagicV4 | [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00] | byte[] |
Implementation limits reader
| Class | Name | Value | Notes |
|---|---|---|---|
| RarCarver | MaxResyncs | 64 | |
| RarCarver | MaxHeaderSize | 2 * 1024 * 1024 | |
| RarCarver | MaxEntries | 1_000_000 | |
| RarCarver | MaxNamesInDetails | 25 | |
| RarExtractor | MaxEntries | 2_000_000 | |
| RarExtractor | MaxHeaderSize | 2L * 1024 * 1024 |
RarVmFilter enum
| Name | Value |
|---|---|
| Unknown | (next) |
| E8 | (next) |
| E8E9 | (next) |
| Itanium | (next) |
| Delta | (next) |
| Rgb | (next) |
| Audio | (next) |
| Upcase | (next) |