Przeglądaj źródła

Various 7-Zip related improvements.

Martijn Laan 1 rok temu
rodzic
commit
ca6d2a76e1

+ 3 - 1
Components/Lzma2/Util/7z/7zMain.c

@@ -4,7 +4,7 @@
 /* Changes by Martijn Laan for Inno Setup:
    -Use CP_UTF8 in PrintString
    -Change main to mainW to support Unicode archive names
-   -Add specific error text for SZ_ERROR_NO_ARCHIVE
+   -Add specific error text for SZ_ERROR_ARCHIVE and SZ_ERROR_NO_ARCHIVE
    -Return res on errors instead of always returning 1
    Otherwise unchanged */
 
@@ -879,6 +879,8 @@ int Z7_CDECL mainW(int numargs, WCHAR *args[])
     PrintError("cannot allocate memory");
   else if (res == SZ_ERROR_CRC)
     PrintError("CRC error");
+  else if (res == SZ_ERROR_ARCHIVE)
+    PrintError("archive corrupt");
   else if (res == SZ_ERROR_NO_ARCHIVE)
     PrintError("not an archive");
   else if (res == SZ_ERROR_READ /* || archiveStream.Res != 0 */)

+ 5 - 2
Projects/Src/Compression.SevenZipDecoder.pas

@@ -40,7 +40,10 @@ function __CreateFileA(lpFileName: LPCSTR; dwDesiredAccess, dwShareMode: DWORD;
   lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD;
   hTemplateFile: THandle): THandle; cdecl;
 begin
-  Result := CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
+  { Return an error if we do ever get called which is unwanted because it should
+    use CreateFileW and not CreateFileA }
+  Result := INVALID_HANDLE_VALUE;
+  SetLastError(ERROR_INVALID_FUNCTION);
 end;
 
 function __CreateFileW(lpFileName: LPCWSTR; dwDesiredAccess, dwShareMode: DWORD;
@@ -140,7 +143,7 @@ end;
 
 function _malloc(size: NativeUInt): Pointer; cdecl;
 begin
-  if size > High(NativeInt) then
+  if size > NativeUInt(High(NativeInt)) then
     Result := nil
   else begin
     try

BIN
Projects/Src/Compression.SevenZipDecoder/7zDecode/IS7zDec.obj


+ 1 - 0
README.md

@@ -279,5 +279,6 @@ workflow will be triggered automatically.
 [Projects\Src\Compil32]: <Projects/Src/Compil32>
 [Projects\Src\Compression.LZMADecompressor\Lzma2Decode]: <Projects/Src/Compression.LZMADecompressor/Lzma2Decode>
 [Projects\Src\Compression.LZMA1SmallDecompressor\LzmaDecode]: <Projects/Src/Compression.LZMA1SmallDecompressor/LzmaDecode>
+[Projects\Src\Compression.SevenZipDecoder\7zDecode]: <Projects/Src/Compression.SevenZipDecoder/7zDecode>
 [7-Zip]: https://www.7-zip.org/
 [secret]: https://docs.github.com/en/actions/security-guides/encrypted-secrets

+ 1 - 1
whatsnew.htm

@@ -81,7 +81,7 @@ For conditions of distribution and use, see <a href="files/is/license.txt">LICEN
 </ul>
 <p><span class="head2">Other changes</span></p>
 <ul>
-  <li>Updated the LZMA SDK used by Inno Setup to the latest version, increasing the speed of LZMA and LZMA2 compression (by 10% in a test with default settings) without changing the compression ratio. Compression memory requirements have increased by about 4%.</li>
+  <li>Updated the LZMA SDK used by Inno Setup to the latest version, increasing the speed of LZMA and LZMA2 compression (by 10% in a test with default settings) without changing the compression ratio. Compression memory requirements have increased by about 4%. This also made it possible to add support for extracting 7-Zip archives, see below.</li>
   <li>Updated the key derivation function and encryption algorithm used by Inno Setup to PBKDF2-HMAC-SHA256 and XChaCha20 respectively, increasing security. This code is built-in: the separate ISCrypt.dll "encryption module" is no longer used and will be automatically deleted when you update.</li>
   <li>Added <tt>[Setup]</tt> section directive <tt>EncryptionKeyDerivation</tt> to change the number of PBKDF2-HMAC-SHA256 iterations to use from the default of 200000 to another value.</li>
   <li>Replaced all remaining use of MD5 and SHA-1 hashes with SHA-256 hashes, without removing the MD5 and SHA-1 Pascal Scripting and ISPP support functions.</li>