From fb0e5ff9b020f0df1e2ac24744624567a9f50c6d Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Fri, 4 Mar 2022 16:44:33 +0100 Subject: [PATCH 1/4] Fix/add details about the ExtTime structure --- docs/unrar.html | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/docs/unrar.html b/docs/unrar.html index 72667ca..8800bd3 100755 --- a/docs/unrar.html +++ b/docs/unrar.html @@ -153,7 +153,7 @@ PackSize 4 bytes UnpSize 4 bytes HostOS 1 byte FileCRC 4 bytes -FileTime 4 bytes +FileTime (mtime) 4 bytes (MS-DOS date/time format) UnpVer 1 byte Method 1 byte NameSize 2 bytes @@ -171,39 +171,63 @@ Packed Data (Total Packed Size) bytes
ExtTime Structure
+ +

This structure has 4 sections representing additional time data.

+

The first 16 bits contain a set of flags, 4 bits for each section.

+

Each flag contains:

+ + +

Each section contains:

+ + +

Follow the following pseudo-code to read in the ExtTime Structure.

-

TODO: Fill in details of what this structure represents.

+const one_second = 10000000; // 1 second in 100ns intervals => 1E7
 var extTimeFlags = readBits(16)
 
 mtime:
 mtime_rmode = extTimeFlags >> 12
 if ((mtime_rmode & 8)==0) goto ctime
 mtime_count = mtime_rmode & 0x3
-mtime_reminder = readBits(8*mtime_count);
+mtime_remainder = readBits(8*mtime_count);
+if ((mtime_rmode & 4)!=0) mtime_remainder += one_second
 
 ctime:
 ctime_rmode = extTimeFlags >> 8
 if ((ctime_rmode & 8)==0) goto atime
-Set ctime to readBits(16)
+Set ctime to readBits(32)
 ctime_count = ctime_rmode & 0x3
-ctime_reminder = readBits(8*ctime_count)
+ctime_remainder = readBits(8*ctime_count)
+if ((ctime_rmode & 4)!=0) ctime_remainder += one_second
 
 atime:
 atime_rmode = extTimeFlags >> 4
 if ((atime_rmode & 8)==0) goto arctime
-Set atime to readBits(16)
+Set atime to readBits(32)
 atime_count = atime_rmode & 0x3
-atime_reminder = readBits(8*atime_count)
+atime_remainder = readBits(8*atime_count)
+if ((atime_rmode & 4)!=0) atime_remainder += one_second
 
 arctime:
 arctime_rmode = extTimeFlags
 if ((arctime_rmode & 8)==0) goto done_exttime
-Set arctime to readBits(16)
+Set arctime to readBits(32)
 arctime_count = arctime_rmode & 0x3
-arctime_reminder = readBits(8*arctime_count)
+arctime_remainder = readBits(8*arctime_count)
+if ((arctime_rmode & 4)!=0) arctime_remainder += one_second
 
 done_exttime
 
@@ -555,4 +579,4 @@ ZeroCount 4 bits (only present if BitLength is 15) - \ No newline at end of file + From 412130bce0ae7b5d5130f23766581b4df2a7d40d Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Fri, 4 Mar 2022 22:55:57 +0100 Subject: [PATCH 2/4] Fix wrong flag bit order --- docs/unrar.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/unrar.html b/docs/unrar.html index 8800bd3..c5ee39d 100755 --- a/docs/unrar.html +++ b/docs/unrar.html @@ -178,11 +178,11 @@ Packed Data (Total Packed Size) bytes

Each flag contains:

Each section contains:

From cbcf2c49061839c2da6daf25348c5d187c02ea03 Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Sat, 5 Mar 2022 18:18:48 +0100 Subject: [PATCH 3/4] Add more details on how to parse the remainders Also add me as contributor ;) --- docs/unrar.html | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/unrar.html b/docs/unrar.html index c5ee39d..4c422e3 100755 --- a/docs/unrar.html +++ b/docs/unrar.html @@ -190,6 +190,10 @@ Packed Data (Total Packed Size) bytes
  • 4 bytes containing an MS-DOS date/time (except for mtime, which is part of FILE_HEAD)
  • 0 to 3 bytes containing fractions of seconds in 100ns increments
  • +
      +
    • They form a 24-bit integer, sorted from most significant to least significant bits
    • +
    • If fewer than 3 bytes are present, the remaining least significant bits are to be padded with zeroes in order to complete 24-bits
    • +

Follow the following pseudo-code to read in the ExtTime Structure.

@@ -202,31 +206,43 @@ var extTimeFlags = readBits(16) mtime_rmode = extTimeFlags >> 12 if ((mtime_rmode & 8)==0) goto ctime mtime_count = mtime_rmode & 0x3 -mtime_remainder = readBits(8*mtime_count); +mtime_remainder = 0 +for (var i = 0; i < mtime_count; i++) { + mtime_remainder = (readBits(8) << 16) | (mtime_remainder >> 8) +} if ((mtime_rmode & 4)!=0) mtime_remainder += one_second ctime: ctime_rmode = extTimeFlags >> 8 if ((ctime_rmode & 8)==0) goto atime -Set ctime to readBits(32) +ctime = readBits(32) ctime_count = ctime_rmode & 0x3 -ctime_remainder = readBits(8*ctime_count) +ctime_remainder = 0 +for (var i = 0; i < ctime_count; i++) { + ctime_remainder = (readBits(8) << 16) | (ctime_remainder >> 8) +} if ((ctime_rmode & 4)!=0) ctime_remainder += one_second atime: atime_rmode = extTimeFlags >> 4 if ((atime_rmode & 8)==0) goto arctime -Set atime to readBits(32) +atime = readBits(32) atime_count = atime_rmode & 0x3 -atime_remainder = readBits(8*atime_count) +atime_remainder = 0 +for (var i = 0; i < atime_count; i++) { + atime_remainder = (readBits(8) << 16) | (atime_remainder >> 8) +} if ((atime_rmode & 4)!=0) atime_remainder += one_second arctime: arctime_rmode = extTimeFlags if ((arctime_rmode & 8)==0) goto done_exttime -Set arctime to readBits(32) +arctime = readBits(32) arctime_count = arctime_rmode & 0x3 -arctime_remainder = readBits(8*arctime_count) +arctime_remainder = 0 +for (var i = 0; i < arctime_count; i++) { + arctime_remainder = (readBits(8) << 16) | (arctime_remainder >> 8) +} if ((arctime_rmode & 4)!=0) arctime_remainder += one_second done_exttime @@ -575,6 +591,7 @@ ZeroCount 4 bits (only present if BitLength is 15)
  • Eugene Roshal <roshal@rarlab.com> - creator and owner of the RAR format
  • Jeff Schiller <codedread@gmail.com> - creator of this document as part of the bitjs project
  • +
  • Andre Brait <andrebrait@gmail.com> - for documenting the ExtTime structure
From 81194d04a2885d0fbe2c86334e07bc7eadb50aac Mon Sep 17 00:00:00 2001 From: Andre Brait Date: Sat, 5 Mar 2022 18:25:03 +0100 Subject: [PATCH 4/4] Fix remainder byte order --- docs/unrar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/unrar.html b/docs/unrar.html index 4c422e3..a3cda38 100755 --- a/docs/unrar.html +++ b/docs/unrar.html @@ -191,7 +191,7 @@ Packed Data (Total Packed Size) bytes
  • 4 bytes containing an MS-DOS date/time (except for mtime, which is part of FILE_HEAD)
  • 0 to 3 bytes containing fractions of seconds in 100ns increments
    • -
    • They form a 24-bit integer, sorted from most significant to least significant bits
    • +
    • They form a 24-bit integer, sorted from least significant to most significant bits
    • If fewer than 3 bytes are present, the remaining least significant bits are to be padded with zeroes in order to complete 24-bits