Recent

Author Topic: How to convert d7zip to Linux support?  (Read 4330 times)

whoami

  • New member
  • *
  • Posts: 6
    • Site của tui
How to convert d7zip to Linux support?
« on: April 28, 2017, 02:21:14 pm »
Hi everyone,

I used d7zip for Delphi and it also works with FreePascal on Windows. But it happens Access Violation error on Linux (Ubuntu). Maybe I was wrong when converting data types. Very grateful if someone test it and convert it.

Code: Pascal  [Select]
  1. {$mode delphi}
  2.  
  3. const
  4.   VT_EMPTY = 0;
  5.   VT_NULL = 1;
  6.   VT_I2 = 2;
  7.   VT_I4 = 3;
  8.   VT_R4 = 4;
  9.   VT_R8 = 5;
  10.   VT_CY = 6;
  11.   VT_DATE = 7;
  12.   VT_BSTR = 8;
  13.   VT_DISPATCH = 9;
  14.   VT_ERROR = 10;
  15.   VT_BOOL = 11;
  16.   VT_VARIANT = 12;
  17.   VT_UNKNOWN = 13;
  18.   VT_DECIMAL = 14;
  19.   VT_I1 = 16;
  20.   VT_UI1 = 17;
  21.   VT_UI2 = 18;
  22.   VT_UI4 = 19;
  23.   VT_I8 = 20;
  24.   VT_UI8 = 21;
  25.   VT_INT = 22;
  26.   VT_UINT = 23;
  27.   VT_VOID = 24;
  28.   VT_HRESULT = 25;
  29.   VT_FILETIME = 64;
  30.  
  31. type
  32.   PVarType = ^TVarType;
  33.   PCardArray = ^TCardArray;
  34.   TCardArray = array[0..MaxInt div SizeOf(Cardinal) - 1] of Cardinal;
  35.  
  36.   WordBool = False..Boolean(65535);
  37.  
  38.   MarshaledAString = ^AnsiChar;
  39.   PMarshaledAString = ^MarshaledAString;
  40.   LPSTR = MarshaledAString;
  41.   {$EXTERNALSYM LPSTR}
  42.   PLPSTR = ^LPSTR;
  43.   {$EXTERNALSYM PLPSTR}
  44.   LPCSTR = MarshaledAString;
  45.   {$EXTERNALSYM LPCSTR}
  46.   LPCTSTR = {$IFDEF UNICODE}MarshaledString{$ELSE}MarshaledAString{$ENDIF};
  47.   {$EXTERNALSYM LPCTSTR}
  48.   LPTSTR = {$IFDEF UNICODE}MarshaledString{$ELSE}MarshaledAString{$ENDIF};
  49.   {$EXTERNALSYM LPTSTR}
  50.   PLPCTSTR = {$IFDEF UNICODE}PMarshaledString{$ELSE}PMarshaledAString{$ENDIF};
  51.   {$EXTERNALSYM LPCTSTR}
  52.   PLPTSTR = {$IFDEF UNICODE}PMarshaledString{$ELSE}PMarshaledAString{$ENDIF};
  53.   {$EXTERNALSYM LPTSTR}
  54.   LPWSTR = PWideChar;
  55.   {$EXTERNALSYM LPWSTR}
  56.   PLPWSTR = ^LPWSTR;
  57.   LPCWSTR = PWideChar;
  58.   {$EXTERNALSYM LPCWSTR}
  59.  
  60.   TOleChar = WideChar;
  61.   POleStr = PWideChar;
  62.   PPOleStr = ^POleStr;
  63.   PBStr = ^TBStr;
  64.   TBStr = POleStr;
  65.  
  66.   ULONG = Cardinal;
  67.   PROPID = ULONG;
  68.   PPropID = ^TPropID;
  69.   TPropID = PROPID;
  70.  
  71.   SHORT = Smallint;
  72.   {$EXTERNALSYM SHORT}
  73.   {$EXTERNALSYM TOleBool}
  74.   TOleBool = WordBool;
  75.   POleBool = ^TOleBool;
  76.   {$EXTERNALSYM SCODE}
  77.   LONG = Longint;
  78.   SCODE = LONG;
  79.  
  80.   LONGLONG = Int64;
  81.   {$EXTERNALSYM LONGLONG}
  82.   PSID = Pointer;
  83.   {$EXTERNALSYM PSID}
  84.   PLargeInteger = ^TLargeInteger;
  85.   _LARGE_INTEGER = record
  86.     case Integer of
  87.     0: (
  88.       LowPart: DWORD;
  89.       HighPart: Longint);
  90.     1: (
  91.       QuadPart: LONGLONG);
  92.   end;
  93.   {$EXTERNALSYM _LARGE_INTEGER}
  94.   {$NODEFINE TLargeInteger}
  95.   TLargeInteger = Int64;
  96.   LARGE_INTEGER = _LARGE_INTEGER;
  97.   {$EXTERNALSYM LARGE_INTEGER}
  98.  
  99.   DWORDLONG = UInt64;
  100.   {$EXTERNALSYM DWORDLONG}
  101.   ULONGLONG = UInt64;
  102.   {$EXTERNALSYM ULONGLONG}
  103.   PULONGLONG = ^UInt64;
  104.   {$EXTERNALSYM PULONGLONG}
  105.   PULargeInteger = ^TULargeInteger;
  106.   _ULARGE_INTEGER = record
  107.     case Integer of
  108.     0: (
  109.       LowPart: DWORD;
  110.       HighPart: DWORD);
  111.     1: (
  112.       QuadPart: ULONGLONG);
  113.   end;
  114.   {$EXTERNALSYM _ULARGE_INTEGER}
  115.   {$NODEFINE TULargeInteger}
  116.   TULargeInteger = UInt64;
  117.   ULARGE_INTEGER = _ULARGE_INTEGER;
  118.   {$EXTERNALSYM ULARGE_INTEGER}
  119.  
  120.   {$EXTERNALSYM PSCODE}
  121.   PSCODE = ^Integer;
  122.  
  123.   PPropVariant = ^TPropVariant;
  124.  
  125.   {$EXTERNALSYM tagCAPROPVARIANT}
  126.   tagCAPROPVARIANT = record
  127.     cElems: ULONG;
  128.     pElems: PPropVariant;
  129.   end;
  130.   {$EXTERNALSYM CAPROPVARIANT}
  131.   CAPROPVARIANT = tagCAPROPVARIANT;
  132.   PCAPROPVARIANT = ^TCAPROPVARIANT;
  133.   TCAPROPVARIANT = tagCAPROPVARIANT;
  134.  
  135.   PFileTime = ^TFileTime;
  136.   _FILETIME = record
  137.     dwLowDateTime: DWORD;
  138.     dwHighDateTime: DWORD;
  139.   end;
  140.   {$EXTERNALSYM _FILETIME}
  141.   TFileTime = _FILETIME;
  142.  
  143.   tagPROPVARIANT = record
  144.     vt: TVarType;
  145.     wReserved1: Word;
  146.     wReserved2: Word;
  147.     wReserved3: Word;
  148.     case Integer of
  149.       VT_I1: (cVal: ShortInt);
  150.       VT_UI1: (bVal: Byte);
  151.       VT_I2: (iVal: SHORT);
  152.       VT_UI2: (uiVal: Word);
  153.       VT_BOOL: (boolVal: TOleBool);
  154.       VT_I4: (lVal: Longint);
  155.       VT_UI4: (ulVal: Cardinal);
  156.       VT_I8: (intVal: Integer);
  157.       VT_UI8: (uintVal: Uint64);
  158.       VT_ERROR: (scode: SCODE);
  159.       VT_I8: (hVal: LARGE_INTEGER);
  160.       VT_UI8: (uhVal: ULARGE_INTEGER);
  161.       VT_BSTR: (bstrVal: TBStr);
  162.   end;
  163.   {$EXTERNALSYM PROPVARIANT}
  164.   PROPVARIANT = tagPROPVARIANT;
  165.   tagVARIANT = VARIANT;
  166.   TPropVariant = tagPROPVARIANT;
  167.  

From trace:

Quote
TApplication.HandleException Access violation
  Stack trace:
  $00007F5E0F9179F9
  $0000000000771B69 line 1186 of sevenzip.pas
  $0000000000771D54 line 1207 of sevenzip.pas

Line 1186:
Code: Pascal  [Select]
  1. CreateObject(ClassID, IInArchive, FInArchive);

Line 1207:
Code: Pascal  [Select]
  1. InArchive.Open(
  2.         strm,
  3.           @MAXCHECK, self as IArchiveOpenCallBack
  4.         )
  5.       );

Windows uses 7z.dll and Linux uses 7z.so. Thanks!
« Last Edit: April 29, 2017, 02:43:47 am by whoami »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7506
Re: How to convert d7zip to Linux support?
« Reply #1 on: April 28, 2017, 02:44:58 pm »
I used d7zip for Delphi and it also works with FreePascal on Windows. But it happens Access Violation error on Linux (Ubuntu). Maybe I was wrong when converting data types. Very grateful if someone test it and convert it.

The code looks like an activex header. So it might be that the Windows DLL is based on activex, and the Linux one a plain C library with different interfaces.

whoami

  • New member
  • *
  • Posts: 6
    • Site của tui
Re: How to convert d7zip to Linux support?
« Reply #2 on: April 28, 2017, 05:12:06 pm »
I used d7zip for Delphi and it also works with FreePascal on Windows. But it happens Access Violation error on Linux (Ubuntu). Maybe I was wrong when converting data types. Very grateful if someone test it and convert it.

The code looks like an activex header. So it might be that the Windows DLL is based on activex, and the Linux one a plain C library with different interfaces.

7-Zip has a command line version for Linux here, I have seen they have added some data types of Windows and ActiveX.

whoami

  • New member
  • *
  • Posts: 6
    • Site của tui
Re: How to convert d7zip to Linux support?
« Reply #3 on: April 29, 2017, 02:43:13 am »
From trace:

Quote
TApplication.HandleException Access violation
  Stack trace:
  $00007F5E0F9179F9
  $0000000000771B69 line 1186 of sevenzip.pas
  $0000000000771D54 line 1207 of sevenzip.pas

Line 1186:
Code: Pascal  [Select]
  1. CreateObject(ClassID, IInArchive, FInArchive);

Line 1207:
Code: Pascal  [Select]
  1. InArchive.Open(
  2.         strm,
  3.           @MAXCHECK, self as IArchiveOpenCallBack
  4.         )
  5.       );