有谁解开过rar的格式

PioneerMan 2002-06-05 11:23:14
加精
我现在为了在网络上传输数据,需要自己压缩和解压缩rar格式
有谁解开过rar的格式,或知道哪有解格式的源码
...全文
57 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
PioneerMan 2002-06-06
  • 打赏
  • 举报
回复
同时,我也找到了解压rar格式的源码:
有兴趣的人可以在 Read: www.rarlab.com/rar/unrarsrc.tar.gz
上下载
PioneerMan 2002-06-06
  • 打赏
  • 举报
回复
哈哈 ,我改用winzip的格式,虽然压缩比没有winrar好,但我可以解开,问题算是解决,参与有分送,呵呵
PioneerMan 2002-06-05
  • 打赏
  • 举报
回复
我是要镶嵌到我的程序中
dishou 2002-06-05
  • 打赏
  • 举报
回复
up
liuqiongliu 2002-06-05
  • 打赏
  • 举报
回复
用winrar, 和用winzip一样使用即可。
PioneerMan 2002-06-05
  • 打赏
  • 举报
回复
winne_ll(feiyang)
文章我也看了,但是不是很详细,能不能有源代码,以及怎样解压他,而不是他的文件存储格式
honeycombs 2002-06-05
  • 打赏
  • 举报
回复
有没有解、压原理及算法描述
winne_ll 2002-06-05
  • 打赏
  • 举报
回复
ARCHIVE FORMAT DESCRIBED BELOW IS ONLY VALID FOR VERSIONS SINCE 1.50

RAR archive file format
Archive file consists of variable length blocks. The order of these
blocks may vary, but the first block must be a marker block followed by
an archive header block.

Each block begins with the following fields:

HEAD_CRC 2 bytes CRC of total block or block part
HEAD_TYPE 1 byte Block type
HEAD_FLAGS 2 bytes Block flags
HEAD_SIZE 2 bytes Block size
ADD_SIZE 4 bytes Optional field - added block size

Field ADD_SIZE present only if (HEAD_FLAGS & 0x8000) != 0

Total block size is HEAD_SIZE if (HEAD_FLAGS & 0x8000) == 0
and HEAD_SIZE+ADD_SIZE if the field ADD_SIZE is present - when
(HEAD_FLAGS & 0x8000) != 0.

In each block the followings bits in HEAD_FLAGS have the same meaning:

0x4000 - if set, older RAR versions will ignore the block
and remove it when the archive is updated.
if clear, the block is copied to the new archive
file when the archive is updated;

0x8000 - if set, ADD_SIZE field is present and the full block
size is HEAD_SIZE+ADD_SIZE.

Declared block types:

HEAD_TYPE=0x72 marker block
HEAD_TYPE=0x73 archive header
HEAD_TYPE=0x74 file header
HEAD_TYPE=0x75 comment header
HEAD_TYPE=0x76 extra information
HEAD_TYPE=0x77 subblock
HEAD_TYPE=0x78 recovery record

Comment block is actually used only within other blocks and doesn't
exist separately.

Archive processing is made in the following manner:

1. Read and check marker block
2. Read archive header
3. Read or skip HEAD_SIZE-sizeof(MAIN_HEAD) bytes
4. If end of archive encountered then terminate archive processing,
else read 7 bytes into fields HEAD_CRC, HEAD_TYPE, HEAD_FLAGS,
HEAD_SIZE.
5. Check HEAD_TYPE.
In case block read needed:


if HEAD_TYPE==0x74
read file header ( first 7 bytes already read )
read or skip HEAD_SIZE-sizeof(FILE_HEAD) bytes
read or skip FILE_SIZE bytes
else
read corresponding HEAD_TYPE block:
read HEAD_SIZE-7 bytes
if (HEAD_FLAGS & 0x8000)
read ADD_SIZE bytes
In case block skip needed:
skip HEAD_SIZE-7 bytes
if (HEAD_FLAGS & 0x8000)
skip ADD_SIZE bytes
6. go to 4.


Block Formats


Marker block ( MARK_HEAD )


HEAD_CRC Always 0x6152
2 bytes

HEAD_TYPE Header type: 0x72
1 byte

HEAD_FLAGS Always 0x1a21
2 bytes

HEAD_SIZE Block size = 0x0007
2 bytes

The marker block is actually considered as a fixed byte
sequence: 0x52 0x61 0x72 0x21 0x1a 0x07 0x00


Archive header ( MAIN_HEAD )


HEAD_CRC CRC of fields HEAD_TYPE to RESERVED2
2 bytes

HEAD_TYPE Header type: 0x73
1 byte

HEAD_FLAGS Bit flags:
2 bytes
0x01 - Volume attribute (archive volume)
0x02 - Archive comment present
0x04 - Archive lock attribute
0x08 - Solid attribute (solid archive)
0x10 - Unused
0x20 - Authenticity information present

other bits in HEAD_FLAGS are reserved for
internal use

HEAD_SIZE Archive header total size including archive comments
2 bytes

RESERVED1 Reserved
2 bytes

RESERVED2 Reserved
4 bytes


Comment block present if (HEAD_FLAGS & 0x02) != 0


File header (File in archive)


HEAD_CRC CRC of fields from HEAD_TYPE to FILEATTR
2 bytes and file name

HEAD_TYPE Header type: 0x74
1 byte

HEAD_FLAGS Bit flags:
2 bytes
0x01 - file continued from previous volume
0x02 - file continued in next volume
0x04 - file encrypted with password
0x08 - file comment present
0x10 - information from previous files is used (solid flag)
(for RAR 2.0 and later)

bits 7 6 5 (for RAR 2.0 and later)

0 0 0 - dictionary size 64 Kb
0 0 1 - dictionary size 128 Kb
0 1 0 - dictionary size 256 Kb
0 1 1 - dictionary size 512 Kb
1 0 0 - dictionary size 1024 Kb
1 0 1 - reserved
1 1 0 - reserved
1 1 1 - file is directory

(HEAD_FLAGS & 0x8000) == 1, because full
block size is HEAD_SIZE + PACK_SIZE

HEAD_SIZE File header full size including file name and comments
2 bytes

PACK_SIZE Compressed file size
4 bytes

UNP_SIZE Uncompressed file size
4 bytes

HOST_OS Operating system used for archiving
1 byte 0 - MS DOS
1 - OS/2
2 - Win32
3 - Unix

FILE_CRC File CRC
4 bytes

FTIME Date and time in standard MS DOS format
4 bytes

UNP_VER RAR version needed to extract file
1 byte

METHOD Packing method
1 byte

NAME_SIZE File name size
2 bytes

ATTR File attributes
4 bytes

FILE_NAME File name - string of NAME_SIZE bytes size


Comment block present if (HEAD_FLAGS & 0x08) != 0


Comment block


HEAD_CRC CRC of fields from HEAD_TYPE to COMM_CRC
2 bytes

HEAD_TYPE Header type: 0x75
1 byte

HEAD_FLAGS Bit flags
2 bytes

HEAD_SIZE Comment header size + comment size
2 bytes

UNP_SIZE Uncompressed comment size
2 bytes

UNP_VER RAR version needed to extract comment
1 byte

METHOD Packing method
1 byte

COMM_CRC Comment CRC
2 bytes

COMMENT Comment text


Extra info block


HEAD_CRC Block CRC
2 bytes

HEAD_TYPE Header type: 0x76
1 byte

HEAD_FLAGS Bit flags
2 bytes

HEAD_SIZE Total block size
2 bytes

INFO Other data


Subblock

An object in the archive (the block or header) can be followed
by a subblock. The subblock is dependant upon the main object.
Subblock can be erased or moved to a new version of the archive
when it is updated.

The subblock contains the following fields:

HEAD_CRC Block CRC
2 bytes

HEAD_TYPE Header type: 0x77
1 byte

HEAD_FLAGS Bit flags
2 bytes
(HEAD_FLAGS & 0x8000) == 1, because full
block size is HEAD_SIZE + DATA_SIZE

HEAD_SIZE Total block size
2 bytes

DATA_SIZE Total data size
4 bytes

SUB_TYPE Subblock type
2 bytes

RESERVED Must be 0
1 byte

Other Other fields depending on the subblock type
fields


OS/2 extended attributes subblock


HEAD_CRC Block CRC
2 bytes

HEAD_TYPE Header type: 0x77
1 byte

HEAD_FLAGS Bit flags
2 bytes
(HEAD_FLAGS & 0x8000) == 1, because full
block size is HEAD_SIZE + DATA_SIZE

HEAD_SIZE Total block size
2 bytes

DATA_SIZE Total data size (packed extended attributes size)
4 bytes

SUB_TYPE 0x100
2 bytes

RESERVED Must be 0
1 byte

UNP_SIZE Uncompressed extended attributes size
4 bytes

UNP_VER RAR version needed to extract extended attributes
1 byte

METHOD Packing method
1 byte

EA_CRC Extended attributes CRC
4 bytes


Application notes


1. To process an SFX archive you need to skip the SFX module searching
for the marker block in the archive. There is no marker block sequence (0x52
0x61 0x72 0x21 0x1a 0x07 0x00) in the SFX module itself.

2. The CRC is calculated using the standard polynomial 0xEDB88320. In
case the size of the CRC is less than 4 bytes, only the low order bytes
are used.

3. Packing method encoding:
0x30 - storing
0x31 - fastest compression
0x32 - fast compression
0x33 - normal compression
0x34 - good compression
0x35 - best compression

4. The RAR extraction version number is encoded as 10 * Major version
+ minor version.

以上为RAR的技术文档
ccnuxjg 2002-06-05
  • 打赏
  • 举报
回复
WinRar
PioneerMan 2002-06-05
  • 打赏
  • 举报
回复
我是用来数据传输的
fhbkyo 2002-06-05
  • 打赏
  • 举报
回复
现在压缩软件这么多,用WINRAR吧
不过精神可佳,佩服
PioneerMan 2002-06-05
  • 打赏
  • 举报
回复
有没有谁做过呀

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧