mORMot icon indicating copy to clipboard operation
mORMot copied to clipboard

PasXip.pas issue.

Open ijbranch opened this issue 1 year ago • 7 comments

Hi Team, I recently started to play in 64 bit. Normally I was 32 bit exclusive. I ran up against an issue with paszip.pas, used in a couple of places in various 3rd Party libraries. I kept geting an error at line 4341 or thereabouts: file_ := INVALID_HANDLE_VALUE; Tracing, I found variable file_ was defined at line around 3963 as a DWORD: file_: dword; This is fine in 32bit but problematic in 64bit. The solution was to change the declaration to: file_: THandle; Now paszip.pas builds without issue in both 32 & 64 bit. HTH in some way..

Regards, Ian

ijbranch avatar Dec 01 '24 21:12 ijbranch

Please try with the above commit, and close if it is OK for you.

I tried to fix all wrong occurrences of DWORD in this unit.

synopse avatar Dec 02 '24 11:12 synopse

Builds & runs OK. Thank you. Ian

ijbranch avatar Dec 02 '24 17:12 ijbranch

I was still experiencing issues with 64bit. Examining INVALID_HANDLE_VALUE at the error line I found it to be a rediculous value: 1811674407373709551615. Doing some research I found that INVALID_HANDLE_VALUE seems to be generally assigned a value of -1. I made this change in PasZip:

{$WARNINGS OFF} {$Q-,R-} // Turn range checking and overflow checking off

{ $D-,L-}

{$I Synopse.inc}

interface

uses {$IFDEF MSWINDOWS} Windows, {$ELSE} Types, {$ENDIF MSWINDOWS} SysUtils;

////////////////////////////////////////////////////////////////////// const // This const add on 09/12/2024. INVALID_HANDLE_VALUE = THandle(-1); // Add the constant here /////////////////////////////////////////////////////////////////////

type {$IFDEF HASCODEPAGE} RawByteZip = RawByteString; TZipName = type AnsiString(437); {$ELSE} RawByteZip = AnsiString; TZipName = AnsiString; {$ENDIF HASCODEPAGE}

I will advise if I have any more issues.

ijbranch avatar Dec 09 '24 00:12 ijbranch

Please try with the above commit.

Using a function like in mORMot 2 seems a cleaner way.

synopse avatar Dec 09 '24 08:12 synopse

No problem. Either way seems to work.
I will let you know after some more testing.

ijbranch avatar Dec 09 '24 09:12 ijbranch

These variables must also be THandle types:

  • file_, map: dword; here https://github.com/synopse/mORMot/blob/master/PasZip.pas#L249
  • Handle: integer; here https://github.com/synopse/mORMot/blob/master/PasZip.pas#L298

P.S. Also, there may be errors related to the fact that the variables used to store the size/offset have a Cardinal type (for files >2GB).

zedxxx avatar Dec 09 '24 18:12 zedxxx

About the use of cardinal, this would need to support the Zip64 format, which is clearly out of scope of this small unit (it is a bit complex to implement).

We have mormot.core.zip.pas for full zip support, including the Zip64 format.

synopse avatar Dec 10 '24 18:12 synopse

No reaction.

Closing.

synopse avatar Nov 24 '25 08:11 synopse

Apologies. I lost track of this. All good.

ijbranch avatar Nov 24 '25 08:11 ijbranch

Apologies. I lost track of this. All good.

ijbranch avatar Nov 24 '25 08:11 ijbranch