|
@@ -79,22 +79,26 @@ type
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
end;
|
|
end;
|
|
|
|
|
|
- TArchiveOpenCallback = class(TInterfacedObject, IArchiveOpenCallback,
|
|
|
|
- ICryptoGetTextPassword)
|
|
|
|
|
|
+ TArchiveCallback = class(TInterfacedObject, ICryptoGetTextPassword)
|
|
private
|
|
private
|
|
FPassword: String;
|
|
FPassword: String;
|
|
protected
|
|
protected
|
|
- { IArchiveOpenCallback }
|
|
|
|
- function SetTotal(files, bytes: PUInt64): HRESULT; stdcall;
|
|
|
|
- function SetCompleted(files, bytes: PUInt64): HRESULT; stdcall;
|
|
|
|
- { ICryptoGetTextPassword - queried for on openCallback }
|
|
|
|
|
|
+ { ICryptoGetTextPassword - queried for by 7-Zip both on IArchiveOpenCallback
|
|
|
|
+ and IArchiveExtractCallback instances - note: have not yet seen 7-Zip actually
|
|
|
|
+ call it on an IArchiveOpenCallback instance }
|
|
function CryptoGetTextPassword(out password: WideString): HRESULT; stdcall;
|
|
function CryptoGetTextPassword(out password: WideString): HRESULT; stdcall;
|
|
public
|
|
public
|
|
constructor Create(const Password: String);
|
|
constructor Create(const Password: String);
|
|
end;
|
|
end;
|
|
|
|
|
|
- TArchiveExtractBaseCallback = class(TInterfacedObject, IArchiveExtractCallback,
|
|
|
|
- ICryptoGetTextPassword)
|
|
|
|
|
|
+ TArchiveOpenCallback = class(TArchiveCallback, IArchiveOpenCallback)
|
|
|
|
+ protected
|
|
|
|
+ { IArchiveOpenCallback }
|
|
|
|
+ function SetTotal(files, bytes: PUInt64): HRESULT; stdcall;
|
|
|
|
+ function SetCompleted(files, bytes: PUInt64): HRESULT; stdcall;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ TArchiveExtractBaseCallback = class(TArchiveCallback, IArchiveExtractCallback)
|
|
private
|
|
private
|
|
type
|
|
type
|
|
TResult = record
|
|
TResult = record
|
|
@@ -105,7 +109,6 @@ type
|
|
TArrayOfUInt32 = array of UInt32;
|
|
TArrayOfUInt32 = array of UInt32;
|
|
var
|
|
var
|
|
FInArchive: IInArchive;
|
|
FInArchive: IInArchive;
|
|
- FPassword: String;
|
|
|
|
FLock: TObject;
|
|
FLock: TObject;
|
|
FProgress, FProgressMax: UInt64;
|
|
FProgress, FProgressMax: UInt64;
|
|
FAbort: Boolean;
|
|
FAbort: Boolean;
|
|
@@ -119,8 +122,6 @@ type
|
|
askExtractMode: Int32): HRESULT; virtual; stdcall; abstract;
|
|
askExtractMode: Int32): HRESULT; virtual; stdcall; abstract;
|
|
function PrepareOperation(askExtractMode: Int32): HRESULT; stdcall;
|
|
function PrepareOperation(askExtractMode: Int32): HRESULT; stdcall;
|
|
function SetOperationResult(opRes: TNOperationResult): HRESULT; stdcall;
|
|
function SetOperationResult(opRes: TNOperationResult): HRESULT; stdcall;
|
|
- { ICryptoGetTextPassword - queried for on extractCallback }
|
|
|
|
- function CryptoGetTextPassword(out password: WideString): HRESULT; stdcall;
|
|
|
|
{ Other }
|
|
{ Other }
|
|
function GetIndices: TArrayOfUInt32; virtual; abstract;
|
|
function GetIndices: TArrayOfUInt32; virtual; abstract;
|
|
procedure Extract;
|
|
procedure Extract;
|
|
@@ -202,19 +203,6 @@ begin
|
|
SevenZipError(Format('%s failed: %s', [FunctionName, Msg]), Msg);
|
|
SevenZipError(Format('%s failed: %s', [FunctionName, Msg]), Msg);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function SevenZipSetPassword(const Password: String; out outPassword: WideString): HRESULT;
|
|
|
|
-begin
|
|
|
|
- try
|
|
|
|
- outPassword := Password;
|
|
|
|
- Result := S_OK;
|
|
|
|
- except
|
|
|
|
- on E: EAbort do
|
|
|
|
- Result := E_ABORT
|
|
|
|
- else
|
|
|
|
- Result := E_FAIL;
|
|
|
|
- end;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
const
|
|
const
|
|
varFileTime = 64; { Delphi lacks proper VT_FILETIME support }
|
|
varFileTime = 64; { Delphi lacks proper VT_FILETIME support }
|
|
type
|
|
type
|
|
@@ -370,14 +358,30 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-{ TArchiveOpenCallback }
|
|
|
|
|
|
+{ TArchiveCallback }
|
|
|
|
|
|
-constructor TArchiveOpenCallback.Create(const Password: String);
|
|
|
|
|
|
+constructor TArchiveCallback.Create(const Password: String);
|
|
begin
|
|
begin
|
|
inherited Create;
|
|
inherited Create;
|
|
FPassword := Password;
|
|
FPassword := Password;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TArchiveCallback.CryptoGetTextPassword(
|
|
|
|
+ out password: WideString): HRESULT;
|
|
|
|
+begin
|
|
|
|
+ try
|
|
|
|
+ password := FPassword;
|
|
|
|
+ Result := S_OK;
|
|
|
|
+ except
|
|
|
|
+ on E: EAbort do
|
|
|
|
+ Result := E_ABORT
|
|
|
|
+ else
|
|
|
|
+ Result := E_FAIL;
|
|
|
|
+ end
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+{ TArchiveOpenCallback }
|
|
|
|
+
|
|
function TArchiveOpenCallback.SetCompleted(files,
|
|
function TArchiveOpenCallback.SetCompleted(files,
|
|
bytes: PUInt64): HRESULT;
|
|
bytes: PUInt64): HRESULT;
|
|
begin
|
|
begin
|
|
@@ -390,21 +394,13 @@ begin
|
|
Result := S_OK;
|
|
Result := S_OK;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TArchiveOpenCallback.CryptoGetTextPassword(
|
|
|
|
- out password: WideString): HRESULT;
|
|
|
|
-begin
|
|
|
|
- { Note: have not yet seen 7-Zip actually call this, so maybe it's not really needed }
|
|
|
|
- Result := SevenZipSetPassword(FPassword, password);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
{ TArchiveExtractBaseCallback }
|
|
{ TArchiveExtractBaseCallback }
|
|
|
|
|
|
constructor TArchiveExtractBaseCallback.Create(const InArchive: IInArchive;
|
|
constructor TArchiveExtractBaseCallback.Create(const InArchive: IInArchive;
|
|
const Password: String);
|
|
const Password: String);
|
|
begin
|
|
begin
|
|
- inherited Create;
|
|
|
|
|
|
+ inherited Create(Password);
|
|
FInArchive := InArchive;
|
|
FInArchive := InArchive;
|
|
- FPassword := Password;
|
|
|
|
FLock := TObject.Create;
|
|
FLock := TObject.Create;
|
|
FResult.OpRes := kOK;
|
|
FResult.OpRes := kOK;
|
|
end;
|
|
end;
|
|
@@ -480,12 +476,6 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TArchiveExtractBaseCallback.CryptoGetTextPassword(
|
|
|
|
- out password: WideString): HRESULT;
|
|
|
|
-begin
|
|
|
|
- Result := SevenZipSetPassword(FPassword, password);
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
function ExtractThreadFunc(Parameter: Pointer): Integer;
|
|
function ExtractThreadFunc(Parameter: Pointer): Integer;
|
|
begin
|
|
begin
|
|
const E = TArchiveExtractBaseCallback(Parameter);
|
|
const E = TArchiveExtractBaseCallback(Parameter);
|