update to 0.6.6

This commit is contained in:
Razor12911 2022-11-11 11:12:43 +02:00
parent fb6bcfa239
commit 5c4cd7a5b0
35 changed files with 1673 additions and 4019 deletions

View File

@ -1,8 +1,28 @@
ES_R41 (0.6.6)
- fixed issues with exporting precompression database
- fixed issues with deduplication feature consuming a lot of system memory
- fixed oodle codec from auto enabling selkie method
- fixed reflate related checksum issues due to false positives
ES_R40 (0.6.5)
- updated oodle scanner
- remove xdelta support from oodle and lzo codecs (crc mismatch often generates large diff files)
ES_R39 (0.6.4)
- fixed issues with lzo2a and lzo1c codecs
ES_R38 (0.6.3)
- added universal lz4f scanner
- fixed issues with database feature
- fixed issues with executable plugin support
- updated lzo codecs
ES_R37 (0.6.2) ES_R37 (0.6.2)
- added feature to inject libraries to main executable - added feature to inject libraries to main executable
ES_R36 (0.6.1) ES_R36 (0.6.1)
- added fast lzma2 compression for portable mode - added fast lzma2 compression for portable mode
- fixed issues with wav stream detection
- fixed minor issue with stream deduplication feature - fixed minor issue with stream deduplication feature
ES_R35 (0.6.0) ES_R35 (0.6.0)

132
common/LibImport.pas Normal file
View File

@ -0,0 +1,132 @@
unit LibImport;
interface
uses
MemoryModule,
WinAPI.Windows,
System.SysUtils, System.Classes, System.Character;
type
TLibImport = class
private
FIsMemoryLib: Boolean;
FDLLLoaded: Boolean;
FDLLStream: TResourceStream;
FDLLHandle: NativeUInt;
public
constructor Create(ALibrary: String);
destructor Destroy; override;
function GetProcAddr(AProcName: PAnsiChar): Pointer;
property Loaded: Boolean read FDLLLoaded;
end;
procedure InjectLib(Source, Dest: String);
implementation
function ResourceExists(ResName: String): Boolean;
begin
Result := FindResourceEx(HInstance, RT_RCDATA, PWideChar(ResName), 0) <> 0;
end;
function FileToResourceName(FileName: String): String;
var
I: Integer;
begin
Result := ChangeFileExt(ExtractFileName(FileName), '').ToUpper;
for I := 1 to Result.Length do
if not Result[I].IsLetterOrDigit then
Result[I] := '_';
end;
procedure UpdateFileResource(Source, Dest, ResName: string);
var
Stream: TFileStream;
hDestRes: THandle;
lpData: Pointer;
cbData: DWORD;
begin
Stream := TFileStream.Create(Source, fmOpenRead or fmShareDenyNone);
try
Stream.Seek(0, soFromBeginning);
cbData := Stream.Size;
if cbData > 0 then
begin
GetMem(lpData, cbData);
try
Stream.ReadBuffer(lpData^, cbData);
hDestRes := BeginUpdateResource(PChar(Dest), False);
if hDestRes <> 0 then
if UpdateResource(hDestRes, RT_RCDATA, PWideChar(ResName), 0, lpData,
cbData) then
begin
if not EndUpdateResource(hDestRes, False) then
RaiseLastOSError;
end
else
RaiseLastOSError
else
RaiseLastOSError;
finally
FreeMem(lpData);
end;
end;
finally
Stream.Free;
end;
end;
constructor TLibImport.Create(ALibrary: String);
var
LResName: String;
begin
inherited Create;
FDLLLoaded := False;
LResName := FileToResourceName(ALibrary);
FIsMemoryLib := ResourceExists(LResName);
if FIsMemoryLib then
begin
FDLLStream := TResourceStream.Create(HInstance, LResName, RT_RCDATA);
FDLLHandle := NativeUInt(MemoryLoadLibary(FDLLStream.Memory));
FDLLLoaded := Assigned(Pointer(FDLLHandle));
end
else
begin
FDLLHandle := LoadLibrary(PWideChar(ALibrary));
FDLLLoaded := FDLLHandle >= 32;
end;
end;
destructor TLibImport.Destroy;
begin
if FIsMemoryLib then
begin
if FDLLLoaded then
MemoryFreeLibrary(Pointer(FDLLHandle));
FDLLStream.Free;
end
else if FDLLLoaded then
FreeLibrary(FDLLHandle);
inherited Destroy;
end;
function TLibImport.GetProcAddr(AProcName: PAnsiChar): Pointer;
begin
if not FDLLLoaded then
Result := nil
else if FIsMemoryLib then
Result := MemoryGetProcAddress(Pointer(FDLLHandle), AProcName)
else
Result := GetProcAddress(FDLLHandle, AProcName);
end;
procedure InjectLib(Source, Dest: String);
var
LResName: String;
begin
LResName := FileToResourceName(Source);
UpdateFileResource(Source, Dest, LResName);
end;
end.

View File

@ -220,6 +220,7 @@ function WaitForAny(const Tasks: array of TTask): Integer;
var var
I: Integer; I: Integer;
begin begin
Result := -1;
while True do while True do
begin begin
for I := Low(Tasks) to High(Tasks) do for I := Low(Tasks) to High(Tasks) do

View File

@ -221,17 +221,20 @@ type
FIncSize = 64 * 1024 * 1024; FIncSize = 64 * 1024 * 1024;
private private
FStream: TFileStream; FStream: TFileStream;
FLastPosition, FLastSize: NativeInt;
FMapHandle: THandle; FMapHandle: THandle;
FMapName: String; FMapName: String;
FMapBuffer: Pointer; FMapBuffer: Pointer;
function CalcSize(ASize: NativeInt): NativeInt; function CalcSize(ASize: NativeInt): NativeInt;
procedure IncMemory(ANewSize: NativeInt = 0); procedure IncMemory(ANewSize: NativeInt = 0);
procedure Flush(AForceFlush: Boolean = False);
public public
constructor Create(const AMapName: String; AFileName: string); overload; constructor Create(const AMapName: String; AFileName: string); overload;
constructor Create(const AMapName: String; ASize: NativeInt); overload; constructor Create(const AMapName: String; ASize: NativeInt); overload;
destructor Destroy; override; destructor Destroy; override;
procedure SetSize(const NewSize: Int64); override; procedure SetSize(const NewSize: Int64); override;
function Write(const Buffer; Count: LongInt): LongInt; override; function Write(const Buffer; Count: LongInt): LongInt; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
end; end;
TDownloadStream = class(TStream) TDownloadStream = class(TStream)
@ -253,33 +256,41 @@ type
TBufferedStream = class(TStream) TBufferedStream = class(TStream)
private private
FStream: TStream;
FReadMode: Boolean; FReadMode: Boolean;
FMemory: PByte; FMemory: PByte;
FBufferSize: Integer; FBufferSize: Integer;
FBufPos, FBufSize: Integer; FBufPos, FBufSize: Integer;
public public
Instance: TStream;
constructor Create(Stream: TStream; ReadMode: Boolean; constructor Create(Stream: TStream; ReadMode: Boolean;
BufferSize: Integer = 65536); BufferSize: Integer = 65536);
destructor Destroy; override; destructor Destroy; override;
function Read(var Buffer; Count: Integer): Integer; override; function Read(var Buffer; Count: Integer): Integer; override;
function Write(const Buffer; Count: Integer): Integer; override; function Write(const Buffer; Count: Integer): Integer; override;
procedure Flush;
end; end;
{ TGPUMemoryStream = class(TStream) TProcessStream = class(TStream)
private private
FMemory: Pointer; FInput, FOutput: TStream;
FSize, FPosition: NativeInt; FTask: TTask;
protected FProcessInfo: TProcessInformation;
procedure SetPointer(Ptr: Pointer; const Size: NativeInt); FStdinr, FStdinw: THandle;
FStdoutr, FStdoutw: THandle;
FExecutable, FCommandLine, FWorkDir: String;
procedure ExecReadTask;
procedure ExecWriteTask;
public public
function Read(var Buffer; Count: longint): longint; override; constructor Create(AExecutable, ACommandLine, AWorkDir: String;
function Read(Buffer: TBytes; Offset, Count: longint): longint; override; AInput: TStream = nil; AOutput: TStream = nil);
function Seek(const Offset: int64; Origin: TSeekOrigin): int64; override; destructor Destroy; override;
procedure SaveToStream(Stream: TStream); virtual; function Read(var Buffer; Count: LongInt): LongInt; override;
procedure SaveToFile(const FileName: string); function Write(const Buffer; Count: LongInt): LongInt; override;
property Memory: Pointer read FMemory; function Execute: Boolean;
end; } procedure Wait;
function Done: Boolean;
function Running: Boolean;
end;
TDataStore = class(TObject) TDataStore = class(TObject)
public public
@ -311,7 +322,7 @@ type
FDone, FFirstRead, FLastRead: Boolean; FDone, FFirstRead, FLastRead: Boolean;
public public
constructor Create(AInput: TStream; ADynamic: Boolean; constructor Create(AInput: TStream; ADynamic: Boolean;
ASlots, ASize: NativeInt; ATempFile: String = ''); ASlots, ASize: NativeInt; ATempFile: String = 'datastore.tmp');
destructor Destroy; override; destructor Destroy; override;
procedure ChangeInput(AInput: TStream); procedure ChangeInput(AInput: TStream);
function Read(Index: Integer; Position: NativeInt; var Buffer; function Read(Index: Integer; Position: NativeInt; var Buffer;
@ -490,8 +501,6 @@ function GetCmdStr(CommandLine: String; Index: Integer;
KeepQuotes: Boolean = False): string; KeepQuotes: Boolean = False): string;
function GetCmdCount(CommandLine: String): Integer; function GetCmdCount(CommandLine: String): Integer;
procedure UpdateFileResource(Source, Dest, ResName: string);
implementation implementation
function GetBits(Data: Int64; Index: TInt64_BitIndex; function GetBits(Data: Int64; Index: TInt64_BitIndex;
@ -1367,6 +1376,8 @@ var
begin begin
inherited Create(False); inherited Create(False);
FStream := nil; FStream := nil;
FLastPosition := FPosition;
FLastSize := 0;
FMapHandle := 0; FMapHandle := 0;
FMapBuffer := nil; FMapBuffer := nil;
LExists := FileExists(AFileName); LExists := FileExists(AFileName);
@ -1399,6 +1410,8 @@ var
begin begin
inherited Create(False); inherited Create(False);
FStream := nil; FStream := nil;
FLastPosition := FPosition;
FLastSize := 0;
FMapHandle := 0; FMapHandle := 0;
FMapBuffer := nil; FMapBuffer := nil;
FMapName := AMapName; FMapName := AMapName;
@ -1416,6 +1429,7 @@ end;
destructor TSharedMemoryStream.Destroy; destructor TSharedMemoryStream.Destroy;
begin begin
Flush(True);
UnMapViewOfFile(FMapBuffer); UnMapViewOfFile(FMapBuffer);
CloseHandle(FMapHandle); CloseHandle(FMapHandle);
if Assigned(FStream) then if Assigned(FStream) then
@ -1455,6 +1469,27 @@ begin
[FMapName, SysErrorMessage(GetLastError)]); [FMapName, SysErrorMessage(GetLastError)]);
FMapBuffer := MapViewOfFile(FMapHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0); FMapBuffer := MapViewOfFile(FMapHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
Update(FMapBuffer, LSize); Update(FMapBuffer, LSize);
FLastPosition := FPosition;
end;
procedure TSharedMemoryStream.Flush(AForceFlush: Boolean);
var
LAddr: Pointer;
LSize: NativeInt;
begin
if AForceFlush or (FLastSize >= FIncSize) or
(InRange(FPosition, FLastPosition, FLastPosition + FLastSize) = False) then
begin
if (FLastSize > 0) and Assigned(FMapBuffer) then
begin
LAddr := PByte(FMapBuffer) + FLastPosition;
LSize := Min(FLastSize, FSize - FLastPosition);
if LSize > 0 then
FlushViewOfFile(LAddr, FLastSize);
end;
FLastPosition := FPosition;
FLastSize := 0;
end;
end; end;
procedure TSharedMemoryStream.SetSize(const NewSize: Int64); procedure TSharedMemoryStream.SetSize(const NewSize: Int64);
@ -1469,6 +1504,15 @@ begin
if FPosition + Count > FMaxSize then if FPosition + Count > FMaxSize then
IncMemory(FPosition + Count); IncMemory(FPosition + Count);
Result := inherited Write(Buffer, Count); Result := inherited Write(Buffer, Count);
Flush;
Inc(FLastSize, Result);
end;
function TSharedMemoryStream.Seek(const Offset: Int64;
Origin: TSeekOrigin): Int64;
begin
Result := inherited Seek(Offset, Origin);
FLastPosition := FPosition;
end; end;
constructor TDownloadStream.Create(Url: string); constructor TDownloadStream.Create(Url: string);
@ -1540,26 +1584,22 @@ constructor TBufferedStream.Create(Stream: TStream; ReadMode: Boolean;
BufferSize: Integer); BufferSize: Integer);
begin begin
inherited Create; inherited Create;
FStream := Stream; Instance := Stream;
FReadMode := ReadMode; FReadMode := ReadMode;
GetMem(FMemory, BufferSize); GetMem(FMemory, BufferSize);
FBufferSize := BufferSize; FBufferSize := BufferSize;
FBufPos := 0; FBufPos := 0;
if FReadMode then if FReadMode then
FBufSize := FStream.Read(FMemory^, FBufferSize) FBufSize := Instance.Read(FMemory^, FBufferSize)
else else
FBufSize := 0; FBufSize := 0;
end; end;
destructor TBufferedStream.Destroy; destructor TBufferedStream.Destroy;
begin begin
if FReadMode = False then Flush;
begin
FStream.WriteBuffer(FMemory^, FBufSize);
FBufSize := 0;
end;
FreeMem(FMemory); FreeMem(FMemory);
FStream.Free; Instance.Free;
inherited Destroy; inherited Destroy;
end; end;
@ -1599,7 +1639,7 @@ begin
if FBufPos = FBufSize then if FBufPos = FBufSize then
begin begin
FBufPos := 0; FBufPos := 0;
FBufSize := FStream.Read(FMemory^, FBufferSize); FBufSize := Instance.Read(FMemory^, FBufferSize);
end; end;
end; end;
Result := Count - FCount; Result := Count - FCount;
@ -1622,12 +1662,12 @@ begin
FDest := FMemory + FBufSize; FDest := FMemory + FBufSize;
if (FBufSize = 0) and (FCount >= FBufferSize) then if (FBufSize = 0) and (FCount >= FBufferSize) then
begin begin
FStream.WriteBuffer(FSrc^, FBufferSize); Instance.WriteBuffer(FSrc^, FBufferSize);
Dec(FCount, FBufferSize); Dec(FCount, FBufferSize);
end end
else if (FBufSize = FBufferSize) then else if (FBufSize = FBufferSize) then
begin begin
FStream.WriteBuffer(FMemory^, FBufSize); Instance.WriteBuffer(FMemory^, FBufSize);
FBufSize := 0; FBufSize := 0;
end end
else else
@ -1655,6 +1695,190 @@ begin
Result := Count - FCount; Result := Count - FCount;
end; end;
procedure TBufferedStream.Flush;
begin
if FReadMode = False then
begin
Instance.WriteBuffer(FMemory^, FBufSize);
FBufSize := 0;
end;
end;
constructor TProcessStream.Create(AExecutable, ACommandLine, AWorkDir: String;
AInput: TStream; AOutput: TStream);
begin
inherited Create;
FInput := AInput;
FOutput := AOutput;
FExecutable := AExecutable;
FCommandLine := ACommandLine;
FWorkDir := AWorkDir;
FTask := TTask.Create;
end;
destructor TProcessStream.Destroy;
begin
CloseHandleEx(FStdinr);
CloseHandleEx(FStdinw);
CloseHandleEx(FStdoutr);
CloseHandleEx(FStdoutw);
CloseHandleEx(FProcessInfo.hProcess);
FTask.Free;
inherited Destroy;
end;
function TProcessStream.Read(var Buffer; Count: LongInt): LongInt;
var
BytesRead: DWORD;
begin
Result := 0;
if Assigned(FOutput) then
raise EReadError.CreateRes(@SReadError);
if ReadFile(FStdoutr, Buffer, Count, BytesRead, nil) then
Result := BytesRead;
end;
function TProcessStream.Write(const Buffer; Count: LongInt): LongInt;
var
BytesWritten: DWORD;
Res: Boolean;
begin
Result := 0;
if Assigned(FInput) then
raise EWriteError.CreateRes(@SWriteError);
if WriteFile(FStdinw, Buffer, Count, BytesWritten, nil) then
Result := BytesWritten;
end;
procedure TProcessStream.ExecReadTask;
const
BufferSize = 65536;
var
Buffer: array [0 .. BufferSize - 1] of Byte;
BytesRead: DWORD;
begin
while ReadFile(FStdoutr, Buffer[0], Length(Buffer), BytesRead, nil) and
(BytesRead > 0) do
FOutput.WriteBuffer(Buffer[0], BytesRead);
CloseHandleEx(FStdoutr);
end;
procedure TProcessStream.ExecWriteTask;
const
BufferSize = 65536;
var
Buffer: array [0 .. BufferSize - 1] of Byte;
BytesWritten: DWORD;
begin
BytesWritten := FInput.Read(Buffer[0], BufferSize);
while WriteFile(FStdinw, Buffer[0], BytesWritten, BytesWritten, nil) and
(BytesWritten > 0) do
BytesWritten := FInput.Read(Buffer[0], BufferSize);
CloseHandleEx(FStdinw);
end;
function TProcessStream.Execute: Boolean;
const
PipeSecurityAttributes: TSecurityAttributes =
(nLength: sizeof(PipeSecurityAttributes); bInheritHandle: True);
var
StartupInfo: TStartupInfo;
dwExitCode: DWORD;
LWorkDir: PChar;
LStream: THandleStream;
begin
Result := False;
CreatePipe(FStdinr, FStdinw, @PipeSecurityAttributes, 0);
CreatePipe(FStdoutr, FStdoutw, @PipeSecurityAttributes, 0);
SetHandleInformation(FStdinw, HANDLE_FLAG_INHERIT, 0);
SetHandleInformation(FStdoutr, HANDLE_FLAG_INHERIT, 0);
ZeroMemory(@StartupInfo, sizeof(StartupInfo));
StartupInfo.cb := sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_HIDE;
StartupInfo.hStdInput := FStdinr;
StartupInfo.hStdOutput := FStdoutw;
StartupInfo.hStdError := 0;
ZeroMemory(@FProcessInfo, sizeof(FProcessInfo));
if FWorkDir <> '' then
LWorkDir := Pointer(FWorkDir)
else
LWorkDir := Pointer(GetCurrentDir);
if CreateProcess(nil, PChar('"' + FExecutable + '" ' + FCommandLine), nil,
nil, True, NORMAL_PRIORITY_CLASS, nil, LWorkDir, StartupInfo, FProcessInfo)
then
begin
CloseHandleEx(FProcessInfo.hThread);
CloseHandleEx(FStdinr);
CloseHandleEx(FStdoutw);
if Assigned(FOutput) and not Assigned(FInput) then
begin
FTask.Perform(ExecReadTask);
FTask.Start;
Result := True;
end
else if Assigned(FInput) and not Assigned(FOutput) then
begin
FTask.Perform(ExecWriteTask);
FTask.Start;
Result := True;
end
else if Assigned(FInput) and Assigned(FOutput) then
begin
FTask.Perform(ExecReadTask);
FTask.Start;
LStream := THandleStream.Create(FStdinw);
try
CopyStream(FInput, LStream);
finally
LStream.Free;
CloseHandleEx(FStdinw);
FTask.Wait;
end;
WaitForSingleObject(FProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(FProcessInfo.hProcess, dwExitCode);
CloseHandleEx(FProcessInfo.hProcess);
if FTask.Status <> TThreadStatus.tsErrored then
FTask.RaiseLastError;
Result := dwExitCode = 0;
end;
end
else
begin
CloseHandleEx(FStdinr);
CloseHandleEx(FStdinw);
CloseHandleEx(FStdoutr);
CloseHandleEx(FStdoutw);
RaiseLastOSError;
end;
end;
procedure TProcessStream.Wait;
begin
WaitForSingleObject(FProcessInfo.hProcess, INFINITE);
end;
function TProcessStream.Done: Boolean;
var
dwExitCode: DWORD;
begin
Result := False;
CloseHandleEx(FStdinw);
CloseHandleEx(FStdoutr);
FTask.Wait;
WaitForSingleObject(FProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(FProcessInfo.hProcess, dwExitCode);
CloseHandleEx(FProcessInfo.hProcess);
if FTask.Status <> TThreadStatus.tsErrored then
FTask.RaiseLastError;
Result := dwExitCode = 0;
end;
function TProcessStream.Running: Boolean;
begin
Result := WaitForSingleObject(FProcessInfo.hProcess, 0) = WAIT_TIMEOUT;
end;
constructor TDataStore1.Create(AInput: TStream; ADynamic: Boolean; constructor TDataStore1.Create(AInput: TStream; ADynamic: Boolean;
ASlots, ASize: NativeInt; ATempFile: String); ASlots, ASize: NativeInt; ATempFile: String);
var var
@ -3069,6 +3293,8 @@ begin
if AnsiContainsStr(S, 'p') or AnsiContainsStr(S, '%') then if AnsiContainsStr(S, 'p') or AnsiContainsStr(S, '%') then
begin begin
Result := Round((CPUCount * StrToInt(Copy(S, 1, Length(S) - 1))) / 100); Result := Round((CPUCount * StrToInt(Copy(S, 1, Length(S) - 1))) / 100);
if Result < 1 then
Result := 1;
exit; exit;
end; end;
Result := StrToInt64(S); Result := StrToInt64(S);
@ -3344,10 +3570,10 @@ begin
FileWriteBuffer(hstdinw, InBuff^, InSize); FileWriteBuffer(hstdinw, InBuff^, InSize);
finally finally
CloseHandleEx(hstdinw); CloseHandleEx(hstdinw);
end;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE); WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode); GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode);
CloseHandleEx(ProcessInfo.hProcess); CloseHandleEx(ProcessInfo.hProcess);
end;
Result := dwExitCode = 0; Result := dwExitCode = 0;
end end
else else
@ -3399,10 +3625,10 @@ begin
Output(@Buffer[0], BytesRead); Output(@Buffer[0], BytesRead);
finally finally
CloseHandleEx(hstdoutr); CloseHandleEx(hstdoutr);
end;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE); WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode); GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode);
CloseHandleEx(ProcessInfo.hProcess); CloseHandleEx(ProcessInfo.hProcess);
end;
Result := dwExitCode = 0; Result := dwExitCode = 0;
end end
else else
@ -3429,7 +3655,7 @@ var
dwExitCode: DWORD; dwExitCode: DWORD;
LWorkDir: PChar; LWorkDir: PChar;
begin begin
Result := True; Result := False;
CreatePipe(hstdinr, hstdinw, @PipeSecurityAttributes, 0); CreatePipe(hstdinr, hstdinw, @PipeSecurityAttributes, 0);
CreatePipe(hstdoutr, hstdoutw, @PipeSecurityAttributes, 0); CreatePipe(hstdoutr, hstdoutw, @PipeSecurityAttributes, 0);
SetHandleInformation(hstdinw, HANDLE_FLAG_INHERIT, 0); SetHandleInformation(hstdinw, HANDLE_FLAG_INHERIT, 0);
@ -3461,10 +3687,10 @@ begin
finally finally
CloseHandleEx(hstdinw); CloseHandleEx(hstdinw);
CloseHandleEx(hstdoutr); CloseHandleEx(hstdoutr);
end;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE); WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode); GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode);
CloseHandleEx(ProcessInfo.hProcess); CloseHandleEx(ProcessInfo.hProcess);
end;
Result := dwExitCode = 0; Result := dwExitCode = 0;
end end
else else
@ -3506,7 +3732,7 @@ var
LTask: TTask; LTask: TTask;
LDone: Boolean; LDone: Boolean;
begin begin
Result := True; Result := False;
CreatePipe(hstdinr, hstdinw, @PipeSecurityAttributes, 0); CreatePipe(hstdinr, hstdinw, @PipeSecurityAttributes, 0);
CreatePipe(hstdoutr, hstdoutw, @PipeSecurityAttributes, 0); CreatePipe(hstdoutr, hstdoutw, @PipeSecurityAttributes, 0);
SetHandleInformation(hstdinw, HANDLE_FLAG_INHERIT, 0); SetHandleInformation(hstdinw, HANDLE_FLAG_INHERIT, 0);
@ -3544,6 +3770,9 @@ begin
end; end;
CloseHandleEx(hstdoutr); CloseHandleEx(hstdoutr);
end; end;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode);
CloseHandleEx(ProcessInfo.hProcess);
if Assigned(LTask) then if Assigned(LTask) then
if LTask.Status <> TThreadStatus.tsErrored then if LTask.Status <> TThreadStatus.tsErrored then
try try
@ -3576,7 +3805,8 @@ begin
while Idx <= Index do while Idx <= Index do
begin begin
Quoted := False; Quoted := False;
while (I <= CommandLine.Length) and (CommandLine[I] = ' ') do while (I <= CommandLine.Length) and
((CommandLine[I] = ' ') or (CommandLine[I] = #09)) do
Inc(I); Inc(I);
if I > CommandLine.Length then if I > CommandLine.Length then
break; break;
@ -3617,41 +3847,4 @@ begin
Inc(Result); Inc(Result);
end; end;
procedure UpdateFileResource(Source, Dest, ResName: string);
var
Stream: TFileStream;
hDestRes: THandle;
lpData: Pointer;
cbData: DWORD;
begin
Stream := TFileStream.Create(Source, fmOpenRead or fmShareDenyNone);
try
Stream.Seek(0, soFromBeginning);
cbData := Stream.Size;
if cbData > 0 then
begin
GetMem(lpData, cbData);
try
Stream.Read(lpData^, cbData);
hDestRes := BeginUpdateResource(PChar(Dest), False);
if hDestRes <> 0 then
if UpdateResource(hDestRes, RT_RCDATA, PWideChar(ResName), 0, lpData,
cbData) then
begin
if not EndUpdateResource(hDestRes, False) then
RaiseLastOSError
end
else
RaiseLastOSError
else
RaiseLastOSError;
finally
FreeMem(lpData);
end;
end;
finally
Stream.Free;
end;
end;
end. end.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ type
TEncodeOptions = record TEncodeOptions = record
ChunkSize, Threads: Integer; ChunkSize, Threads: Integer;
Method: String; Method: String;
Format: String; BlockSize: Integer;
end; end;
procedure PrintHelp; procedure PrintHelp;
@ -104,6 +104,14 @@ begin
S := ReplaceText(S, 'p', '%'); S := ReplaceText(S, 'p', '%');
S := ReplaceText(S, '%', '%*' + CPUCount.ToString); S := ReplaceText(S, '%', '%*' + CPUCount.ToString);
Options.Threads := Max(1, Round(ExpParse.Evaluate(S))); Options.Threads := Max(1, Round(ExpParse.Evaluate(S)));
S := ArgParse.AsString('-c', 0, '1792mb');
S := ReplaceText(S, 'KB', '* 1024^1');
S := ReplaceText(S, 'MB', '* 1024^2');
S := ReplaceText(S, 'GB', '* 1024^3');
S := ReplaceText(S, 'K', '* 1024^1');
S := ReplaceText(S, 'M', '* 1024^2');
S := ReplaceText(S, 'G', '* 1024^3');
Options.BlockSize := Round(ExpParse.Evaluate(S));
finally finally
ArgParse.Free; ArgParse.Free;
ExpParse.Free; ExpParse.Free;
@ -161,7 +169,7 @@ var
CountPos: NativeInt; CountPos: NativeInt;
BaseDir: String; BaseDir: String;
LList: TArray<String>; LList: TArray<String>;
LSInfo: PScanInfo; LSInfo: TScanInfo;
LEntry: TEntryStruct; LEntry: TEntryStruct;
LBytes: TBytes; LBytes: TBytes;
Hash: Cardinal; Hash: Cardinal;
@ -171,6 +179,7 @@ var
OStream, MStream: TMemoryStream; OStream, MStream: TMemoryStream;
DataStore: TDataStore1; DataStore: TDataStore1;
Tasks: TArray<TTask>; Tasks: TArray<TTask>;
NStream: TArray<TMemoryStream>;
InfoStore: TArray<TListEx<TEntryStruct>>; InfoStore: TArray<TListEx<TEntryStruct>>;
begin begin
SetLength(SearchInfo, $10000); SetLength(SearchInfo, $10000);
@ -189,6 +198,13 @@ begin
else else
BaseDir := ExtractFilePath(TPath.GetFullPath(Input1)); BaseDir := ExtractFilePath(TPath.GetFullPath(Input1));
LList := GetFileList([Input1], True); LList := GetFileList([Input1], True);
SetLength(Tasks, Options.Threads);
SetLength(Tasks, Options.Threads);
for I := Low(Tasks) to High(Tasks) do
begin
Tasks[I] := TTask.Create(I);
NStream[I] := TMemoryStream.Create;
end;
for I := Low(LList) to High(LList) do for I := Low(LList) to High(LList) do
begin begin
if InRange(FileSize(LList[I]), MinSize1, Integer.MaxValue) then if InRange(FileSize(LList[I]), MinSize1, Integer.MaxValue) then
@ -201,23 +217,22 @@ begin
WordRec(A).Bytes[1] := Buffer[1]; WordRec(A).Bytes[1] := Buffer[1];
B := Buffer[MinSize1 - 1]; B := Buffer[MinSize1 - 1];
J := MinSize1; J := MinSize1;
New(LSInfo); LSInfo.CRCSize := J;
LSInfo^.CRCSize := J; LSInfo.ActualSize := FileSize(LList[I]);
LSInfo^.ActualSize := FileSize(LList[I]); LSInfo.CRC1 := Utils.Hash32(0, @Buffer[0], J);
LSInfo^.CRC1 := Utils.Hash32(0, @Buffer[0], J); LSInfo.CRC2 := LSInfo.CRC1;
LSInfo^.CRC2 := LSInfo^.CRC1; while (J > 0) and (LSInfo.CRCSize < Options.ChunkSize) do
while (J > 0) and (LSInfo^.CRCSize < Options.ChunkSize) do
begin begin
J := Read(Buffer[0], Min(Options.ChunkSize - LSInfo^.CRCSize, J := Read(Buffer[0], Min(Options.ChunkSize - LSInfo.CRCSize,
BufferSize)); BufferSize));
Inc(LSInfo^.CRCSize, J); Inc(LSInfo.CRCSize, J);
LSInfo^.CRC2 := Utils.Hash32(LSInfo^.CRC2, @Buffer[0], J); LSInfo.CRC2 := Utils.Hash32(LSInfo.CRC2, @Buffer[0], J);
end; end;
Insert(LSInfo, SearchInfo[A, B], Length(SearchInfo[A, B]));
Inc(SearchCount[A, B]);
finally finally
Free; Free;
end; end;
Insert(LSInfo^, SearchInfo[A, B], Length(SearchInfo[A, B]));
Inc(SearchCount[A, B]);
end end
else if FileSize(LList[I]) < MinSize1 then else if FileSize(LList[I]) < MinSize1 then
WriteLn(ErrOutput, Format('Skipped %s (Smaller than %d)', WriteLn(ErrOutput, Format('Skipped %s (Smaller than %d)',
@ -226,9 +241,10 @@ begin
WriteLn(ErrOutput, Format('Skipped %s (Larger than %d)', WriteLn(ErrOutput, Format('Skipped %s (Larger than %d)',
[ReplaceText(LList[I], BaseDir, ''), Integer.MaxValue])); [ReplaceText(LList[I], BaseDir, ''), Integer.MaxValue]));
end; end;
for I := Low(Tasks) to High(Tasks) do
NStream[I].Free;
DataStore := TDataStore1.Create(nil, True, Options.Threads, DataStore := TDataStore1.Create(nil, True, Options.Threads,
Options.ChunkSize); Options.ChunkSize);
SetLength(Tasks, Options.Threads);
SetLength(InfoStore, Options.Threads); SetLength(InfoStore, Options.Threads);
OStream := TMemoryStream.Create; OStream := TMemoryStream.Create;
MStream := TMemoryStream.Create; MStream := TMemoryStream.Create;
@ -242,10 +258,9 @@ begin
OStream.Position := OStream.Size; OStream.Position := OStream.Size;
Found1 := False; Found1 := False;
try try
for I := Low(Tasks) to High(Tasks) do for I := Low(InfoStore) to High(InfoStore) do
begin begin
InfoStore[I] := TListEx<TEntryStruct>.Create(EntryStructCmp); InfoStore[I] := TListEx<TEntryStruct>.Create(EntryStructCmp);
Tasks[I] := TTask.Create(I);
Tasks[I].Perform( Tasks[I].Perform(
procedure(X: IntPtr) procedure(X: IntPtr)
var var
@ -378,15 +393,18 @@ begin
if Found1 then if Found1 then
OStream.SaveToFile(Output); OStream.SaveToFile(Output);
finally finally
for I := Low(Tasks) to High(Tasks) do for I := Low(InfoStore) to High(InfoStore) do
begin begin
InfoStore[I].Free; InfoStore[I].Free;
Tasks[I].Free; Tasks[I].Free;
NStream[I].Free;
end; end;
DataStore.Free; DataStore.Free;
OStream.Free; OStream.Free;
MStream.Free; MStream.Free;
end; end;
for I := Low(InfoStore) to High(InfoStore) do
Tasks[I].Free;
end; end;
end. end.

View File

@ -10,6 +10,11 @@ resourcestring
SPrecompSep1 = '+'; SPrecompSep1 = '+';
SPrecompSep2 = ':'; SPrecompSep2 = ':';
SPrecompSep3 = ','; SPrecompSep3 = ',';
SPrecompSep4 = '/';
SPrecompSep5 = '/';
XTOOL_MAPSUF1 = '-tmp';
XTOOL_MAPSUF2 = '_mapped.io';
XTOOL_MAPSUF3 = '.tmp';
const const
XTOOL_DB = $31445458; XTOOL_DB = $31445458;

View File

@ -3,6 +3,7 @@ unit BrunsliDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -39,41 +40,31 @@ var
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
S: String;
procedure Init; procedure Init;
begin begin
S := 'brunsli.dll'; Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'brunsli.dll');
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + S)); if Lib.Loaded then
if DLLHandle >= 32 then
begin begin
@brunsli_alloc_JPEGData := GetProcAddress(DLLHandle, @brunsli_alloc_JPEGData := Lib.GetProcAddr('brunsli_alloc_JPEGData');
'brunsli_alloc_JPEGData'); @brunsli_free_JPEGData := Lib.GetProcAddr('brunsli_free_JPEGData');
@brunsli_free_JPEGData := GetProcAddress(DLLHandle, @brunsli_GetMaximumEncodedSize :=
'brunsli_free_JPEGData'); Lib.GetProcAddr('brunsli_GetMaximumEncodedSize');
@brunsli_GetMaximumEncodedSize := GetProcAddress(DLLHandle, @brunsli_ReadJpeg := Lib.GetProcAddr('brunsli_ReadJpeg');
'brunsli_GetMaximumEncodedSize'); @brunsli_EncodeJpeg := Lib.GetProcAddr('brunsli_EncodeJpeg');
@brunsli_ReadJpeg := GetProcAddress(DLLHandle, 'brunsli_ReadJpeg'); @brunsli_DecodeJpeg := Lib.GetProcAddr('brunsli_DecodeJpeg');
@brunsli_EncodeJpeg := GetProcAddress(DLLHandle, 'brunsli_EncodeJpeg'); @brunsli_alloc_JPEGOutput := Lib.GetProcAddr('brunsli_alloc_JPEGOutput');
@brunsli_DecodeJpeg := GetProcAddress(DLLHandle, 'brunsli_DecodeJpeg'); @brunsli_free_JPEGOutput := Lib.GetProcAddr('brunsli_free_JPEGOutput');
@brunsli_alloc_JPEGOutput := GetProcAddress(DLLHandle, @brunsli_WriteJpeg := Lib.GetProcAddr('brunsli_WriteJpeg');
'brunsli_alloc_JPEGOutput');
@brunsli_free_JPEGOutput := GetProcAddress(DLLHandle,
'brunsli_free_JPEGOutput');
@brunsli_WriteJpeg := GetProcAddress(DLLHandle, 'brunsli_WriteJpeg');
DLLLoaded := Assigned(brunsli_alloc_JPEGData) and DLLLoaded := Assigned(brunsli_alloc_JPEGData) and
Assigned(brunsli_alloc_JPEGOutput); Assigned(brunsli_alloc_JPEGOutput);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
FreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -3,6 +3,7 @@ unit FLACDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -121,68 +122,60 @@ var
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
procedure Init; procedure Init;
begin begin
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) +
'libFLAC_dynamic.dll')); 'libFLAC_dynamic.dll');
if DLLHandle >= 32 then if Lib.Loaded then
begin begin
@FLAC__stream_encoder_new := GetProcAddress(DLLHandle, @FLAC__stream_encoder_new := Lib.GetProcAddr('FLAC__stream_encoder_new');
'FLAC__stream_encoder_new'); @FLAC__stream_encoder_set_verify :=
@FLAC__stream_encoder_set_verify := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_encoder_set_verify');
'FLAC__stream_encoder_set_verify'); @FLAC__stream_encoder_set_channels :=
@FLAC__stream_encoder_set_channels := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_encoder_set_channels');
'FLAC__stream_encoder_set_channels');
@FLAC__stream_encoder_set_compression_level := @FLAC__stream_encoder_set_compression_level :=
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_set_compression_level'); Lib.GetProcAddr('FLAC__stream_encoder_set_compression_level');
@FLAC__stream_encoder_set_bits_per_sample := @FLAC__stream_encoder_set_bits_per_sample :=
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_set_bits_per_sample'); Lib.GetProcAddr('FLAC__stream_encoder_set_bits_per_sample');
@FLAC__stream_encoder_set_sample_rate := @FLAC__stream_encoder_set_sample_rate :=
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_set_sample_rate'); Lib.GetProcAddr('FLAC__stream_encoder_set_sample_rate');
@FLAC__stream_encoder_set_total_samples_estimate := @FLAC__stream_encoder_set_total_samples_estimate :=
GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_encoder_set_total_samples_estimate');
'FLAC__stream_encoder_set_total_samples_estimate'); @FLAC__stream_encoder_init_stream :=
@FLAC__stream_encoder_init_stream := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_encoder_init_stream');
'FLAC__stream_encoder_init_stream'); @FLAC__stream_encoder_init_file :=
@FLAC__stream_encoder_init_file := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_encoder_init_file');
'FLAC__stream_encoder_init_file');
@FLAC__stream_encoder_process_interleaved := @FLAC__stream_encoder_process_interleaved :=
GetProcAddress(DLLHandle, 'FLAC__stream_encoder_process_interleaved'); Lib.GetProcAddr('FLAC__stream_encoder_process_interleaved');
@FLAC__stream_encoder_finish := GetProcAddress(DLLHandle, @FLAC__stream_encoder_finish :=
'FLAC__stream_encoder_finish'); Lib.GetProcAddr('FLAC__stream_encoder_finish');
@FLAC__stream_encoder_delete := GetProcAddress(DLLHandle, @FLAC__stream_encoder_delete :=
'FLAC__stream_encoder_delete'); Lib.GetProcAddr('FLAC__stream_encoder_delete');
@FLAC__stream_decoder_new := GetProcAddress(DLLHandle, @FLAC__stream_decoder_new := Lib.GetProcAddr('FLAC__stream_decoder_new');
'FLAC__stream_decoder_new'); @FLAC__stream_decoder_init_stream :=
@FLAC__stream_decoder_init_stream := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_decoder_init_stream');
'FLAC__stream_decoder_init_stream'); @FLAC__stream_decoder_init_file :=
@FLAC__stream_decoder_init_file := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_decoder_init_file');
'FLAC__stream_decoder_init_file'); @FLAC__stream_decoder_get_channels :=
@FLAC__stream_decoder_get_channels := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_decoder_get_channels');
'FLAC__stream_decoder_get_channels');
@FLAC__stream_decoder_get_bits_per_sample := @FLAC__stream_decoder_get_bits_per_sample :=
GetProcAddress(DLLHandle, 'FLAC__stream_decoder_get_bits_per_sample'); Lib.GetProcAddr('FLAC__stream_decoder_get_bits_per_sample');
@FLAC__stream_decoder_process_until_end_of_stream := @FLAC__stream_decoder_process_until_end_of_stream :=
GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_decoder_process_until_end_of_stream');
'FLAC__stream_decoder_process_until_end_of_stream'); @FLAC__stream_decoder_finish :=
@FLAC__stream_decoder_finish := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_decoder_finish');
'FLAC__stream_decoder_finish'); @FLAC__stream_decoder_delete :=
@FLAC__stream_decoder_delete := GetProcAddress(DLLHandle, Lib.GetProcAddr('FLAC__stream_decoder_delete');
'FLAC__stream_decoder_delete');
DLLLoaded := Assigned(FLAC__stream_encoder_new) and DLLLoaded := Assigned(FLAC__stream_encoder_new) and
Assigned(FLAC__stream_decoder_new); Assigned(FLAC__stream_decoder_new);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
FreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -3,7 +3,7 @@ unit FLZMA2DLL;
interface interface
uses uses
MemoryModule, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes, System.Types; System.SysUtils, System.Classes, System.Types;
@ -24,6 +24,82 @@ type
pos: size_t; pos: size_t;
end; end;
type
FL2_cParameter = (
(* compression parameters *)
FL2_p_compressionLevel,
(* Update all compression parameters according to pre-defined cLevel table
* Default level is FL2_CLEVEL_DEFAULT==6.
* Setting FL2_p_highCompression to 1 switches to an alternate cLevel table. *)
FL2_p_highCompression,
(* Maximize compression ratio for a given dictionary size.
* Levels 1..10 = dictionaryLog 20..29 (1 Mb..512 Mb).
* Typically provides a poor speed/ratio tradeoff. *)
FL2_p_dictionaryLog,
(* Maximum allowed back-reference distance, expressed as power of 2.
* Must be clamped between FL2_DICTLOG_MIN and FL2_DICTLOG_MAX.
* Default = 24 *)
FL2_p_dictionarySize, (* Same as above but expressed as an absolute value.
* Must be clamped between FL2_DICTSIZE_MIN and FL2_DICTSIZE_MAX.
* Default = 16 Mb *)
FL2_p_overlapFraction,
(* The radix match finder is block-based, so some overlap is retained from
* each block to improve compression of the next. This value is expressed
* as n / 16 of the block size (dictionary size). Larger values are slower.
* Values above 2 mostly yield only a small improvement in compression.
* A large value for a small dictionary may worsen multithreaded compression.
* Default = 2 *)
FL2_p_resetInterval,
(* For multithreaded decompression. A dictionary reset will occur
* after each dictionarySize * resetInterval bytes of input.
* Default = 4 *)
FL2_p_bufferResize,
(* Buffering speeds up the matchfinder. Buffer resize determines the percentage of
* the normal buffer size used, which depends on dictionary size.
* 0=50, 1=75, 2=100, 3=150, 4=200. Higher number = slower, better
* compression, higher memory usage. A CPU with a large memory cache
* may make effective use of a larger buffer.
* Default = 2 *)
FL2_p_hybridChainLog,
(* Size of the hybrid mode HC3 hash chain, as a power of 2.
* Resulting table size is (1 << (chainLog+2)) bytes.
* Larger tables result in better and slower compression.
* This parameter is only used by the hybrid "ultra" strategy.
* Default = 9 *)
FL2_p_hybridCycles,
(* Number of search attempts made by the HC3 match finder.
* Used only by the hybrid "ultra" strategy.
* More attempts result in slightly better and slower compression.
* Default = 1 *)
FL2_p_searchDepth,
(* Match finder will resolve string matches up to this length. If a longer
* match exists further back in the input, it will not be found.
* Default = 42 *)
FL2_p_fastLength, (* Only useful for strategies >= opt.
* Length of match considered "good enough" to stop search.
* Larger values make compression stronger and slower.
* Default = 48 *)
FL2_p_divideAndConquer,
(* Split long chains of 2-byte matches into shorter chains with a small overlap
* for further processing. Allows buffering of all chains at length 2.
* Faster, less compression. Generally a good tradeoff.
* Default = enabled *)
FL2_p_strategy, (* 1 = fast; 2 = optimized, 3 = ultra (hybrid mode).
* The higher the value of the selected strategy, the more complex it is,
* resulting in stronger and slower compression.
* Default = ultra *)
FL2_p_literalCtxBits, (* lc value for LZMA2 encoder
* Default = 3 *)
FL2_p_literalPosBits, (* lp value for LZMA2 encoder
* Default = 0 *)
FL2_p_posBits, (* pb value for LZMA2 encoder
* Default = 2 *)
FL2_p_omitProperties,
(* Omit the property byte at the start of the stream. For use within 7-zip *)
(* or other containers which store the property byte elsewhere. *)
(* A stream compressed under this setting cannot be decoded by this library. *)
FL2_cParameter_Force32 = $40000000);
var var
FL2_compress: function(dst: Pointer; dstCapacity: size_t; const src: Pointer; FL2_compress: function(dst: Pointer; dstCapacity: size_t; const src: Pointer;
srcSize: size_t; compressionLevel: Integer): size_t cdecl; srcSize: size_t; compressionLevel: Integer): size_t cdecl;
@ -63,13 +139,20 @@ var
input: PFL2_inBuffer): size_t cdecl; input: PFL2_inBuffer): size_t cdecl;
FL2_endStream: function(fcs: Pointer; output: PFL2_outBuffer): size_t cdecl; FL2_endStream: function(fcs: Pointer; output: PFL2_outBuffer): size_t cdecl;
FL2_isError: function(code: size_t): Cardinal cdecl; FL2_isError: function(code: size_t): Cardinal cdecl;
FL2_CStream_setParameter: function(fcs: Pointer; param: FL2_cParameter;
value: size_t): size_t cdecl;
FL2_CStream_getParameter: function(fcs: Pointer; param: FL2_cParameter)
: size_t cdecl;
FL2_setDStreamMemoryLimitMt: procedure(fds: Pointer; limit: size_t)cdecl;
DLLLoaded: boolean = False; DLLLoaded: boolean = False;
type type
TLZMACRec = record TLZMACRec = record
Threads: Integer; Threads: Integer;
Level: Integer; Level: Integer;
HighCompress: boolean;
procedure Parse(S: String); procedure Parse(S: String);
end; end;
@ -86,8 +169,9 @@ type
FProp: TLZMACRec; FProp: TLZMACRec;
FOutput: TStream; FOutput: TStream;
FBuffer: array [0 .. FBufferSize - 1] of Byte; FBuffer: array [0 .. FBufferSize - 1] of Byte;
FInitialized: boolean;
public public
constructor Create(AOutput: TStream; AConfig: String = 't50p'); constructor Create(AOutput: TStream; AConfig: String);
destructor Destroy; override; destructor Destroy; override;
function Write(const Buffer; Count: LongInt): LongInt; override; function Write(const Buffer; Count: LongInt): LongInt; override;
end; end;
@ -113,8 +197,7 @@ uses
Utils; Utils;
var var
DLLStream: TResourceStream; Lib: TLibImport;
DLLHandle: TMemoryModule;
procedure TLZMACRec.Parse(S: string); procedure TLZMACRec.Parse(S: string);
var var
@ -122,7 +205,8 @@ var
I, J: Integer; I, J: Integer;
begin begin
Threads := 1; Threads := 1;
Level := 5; Level := 6;
HighCompress := False;
List := DecodeStr(S, ':'); List := DecodeStr(S, ':');
for I := Low(List) to High(List) do for I := Low(List) to High(List) do
begin begin
@ -130,6 +214,8 @@ begin
Threads := ConvertToThreads(List[I].Substring(1)); Threads := ConvertToThreads(List[I].Substring(1));
if List[I].StartsWith('l', True) then if List[I].StartsWith('l', True) then
Level := List[I].Substring(1).ToInteger; Level := List[I].Substring(1).ToInteger;
if List[I].StartsWith('hi', True) then
HighCompress := List[I].Substring(2).ToBoolean;
end; end;
end; end;
@ -148,15 +234,22 @@ begin
end; end;
constructor TLZMACompressStream.Create(AOutput: TStream; AConfig: String); constructor TLZMACompressStream.Create(AOutput: TStream; AConfig: String);
var
LConfig: String;
begin begin
inherited Create; inherited Create;
FProp.Parse(AConfig); LConfig := AConfig;
if LConfig = '' then
LConfig := 't50p';
FProp.Parse(LConfig);
FOutput := AOutput; FOutput := AOutput;
if FProp.Threads > 1 then if FProp.Threads > 1 then
FCtx := FL2_createCStreamMt(FProp.Threads, 0) FCtx := FL2_createCStreamMt(FProp.Threads, 0)
else else
FCtx := FL2_createCStream; FCtx := FL2_createCStream;
FL2_initCStream(FCtx, FProp.Level); FL2_CStream_setParameter(FCtx, FL2_cParameter.FL2_p_highCompression,
Integer(FProp.HighCompress));
FInitialized := False;
end; end;
destructor TLZMACompressStream.Destroy; destructor TLZMACompressStream.Destroy;
@ -164,6 +257,8 @@ var
Oup: FL2_outBuffer; Oup: FL2_outBuffer;
Res: size_t; Res: size_t;
begin begin
if FInitialized then
begin
Oup.dst := @FBuffer[0]; Oup.dst := @FBuffer[0];
Oup.size := FBufferSize; Oup.size := FBufferSize;
Oup.pos := 0; Oup.pos := 0;
@ -172,6 +267,7 @@ begin
FOutput.WriteBuffer(FBuffer[0], Oup.pos); FOutput.WriteBuffer(FBuffer[0], Oup.pos);
Oup.pos := 0; Oup.pos := 0;
until Res = 0; until Res = 0;
end;
FL2_freeCCtx(FCtx); FL2_freeCCtx(FCtx);
inherited Destroy; inherited Destroy;
end; end;
@ -182,6 +278,11 @@ var
Oup: FL2_outBuffer; Oup: FL2_outBuffer;
begin begin
Result := 0; Result := 0;
if not FInitialized then
begin
FL2_initCStream(FCtx, FProp.Level);
FInitialized := True;
end;
Inp.src := PByte(@Buffer); Inp.src := PByte(@Buffer);
Inp.size := Count; Inp.size := Count;
Inp.pos := 0; Inp.pos := 0;
@ -200,12 +301,23 @@ begin
end; end;
constructor TLZMADecompressStream.Create(AInput: TStream; AConfig: String); constructor TLZMADecompressStream.Create(AInput: TStream; AConfig: String);
var
LConfig: String;
LSize: Int64;
begin begin
inherited Create; inherited Create;
FProp.Parse(AConfig); LConfig := AConfig;
if LConfig = '' then
LConfig := 't50p';
FProp.Parse(LConfig);
FInput := AInput; FInput := AInput;
LSize := 0;
LSize := LSize.MaxValue;
if FProp.Threads > 1 then if FProp.Threads > 1 then
FCtx := FL2_createDStreamMt(FProp.Threads) begin
FCtx := FL2_createDStreamMt(FProp.Threads);
FL2_setDStreamMemoryLimitMt(FCtx, LSize);
end
else else
FCtx := FL2_createDStream; FCtx := FL2_createDStream;
FL2_initDStream(FCtx); FL2_initDStream(FCtx);
@ -255,50 +367,44 @@ end;
procedure Init; procedure Init;
begin begin
DLLStream := TResourceStream.Create(HInstance, 'fast_lzma2', RT_RCDATA); Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'fast-lzma2.dll');
DLLHandle := MemoryLoadLibary(DLLStream.Memory); if Lib.Loaded then
if Assigned(DLLHandle) then
begin begin
@FL2_compress := MemoryGetProcAddress(DLLHandle, 'FL2_compress'); @FL2_compress := Lib.GetProcAddr('FL2_compress');
@FL2_compressMt := MemoryGetProcAddress(DLLHandle, 'FL2_compressMt'); @FL2_compressMt := Lib.GetProcAddr('FL2_compressMt');
@FL2_decompress := MemoryGetProcAddress(DLLHandle, 'FL2_decompress'); @FL2_decompress := Lib.GetProcAddr('FL2_decompress');
@FL2_decompressMt := MemoryGetProcAddress(DLLHandle, 'FL2_decompressMt'); @FL2_decompressMt := Lib.GetProcAddr('FL2_decompressMt');
@FL2_createCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_createCCtx'); @FL2_createCCtx := Lib.GetProcAddr('FL2_createCCtx');
@FL2_createCCtxMt := MemoryGetProcAddress(DLLHandle, 'FL2_createCCtxMt'); @FL2_createCCtxMt := Lib.GetProcAddr('FL2_createCCtxMt');
@FL2_freeCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_freeCCtx'); @FL2_freeCCtx := Lib.GetProcAddr('FL2_freeCCtx');
@FL2_compressCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_compressCCtx'); @FL2_compressCCtx := Lib.GetProcAddr('FL2_compressCCtx');
@FL2_createDCtx := MemoryGetProcAddress(DLLHandle, 'FL2_createDCtx'); @FL2_createDCtx := Lib.GetProcAddr('FL2_createDCtx');
@FL2_createDCtxMt := MemoryGetProcAddress(DLLHandle, 'FL2_createDCtxMt'); @FL2_createDCtxMt := Lib.GetProcAddr('FL2_createDCtxMt');
@FL2_freeDCtx := MemoryGetProcAddress(DLLHandle, 'FL2_freeDCtx'); @FL2_freeDCtx := Lib.GetProcAddr('FL2_freeDCtx');
@FL2_decompressDCtx := MemoryGetProcAddress(DLLHandle, @FL2_decompressDCtx := Lib.GetProcAddr('FL2_decompressDCtx');
'FL2_decompressDCtx'); @FL2_createCStream := Lib.GetProcAddr('FL2_createCStream');
@FL2_createCStream := MemoryGetProcAddress(DLLHandle, 'FL2_createCStream'); @FL2_createCStreamMt := Lib.GetProcAddr('FL2_createCStreamMt');
@FL2_createCStreamMt := MemoryGetProcAddress(DLLHandle, @FL2_freeCStream := Lib.GetProcAddr('FL2_freeCStream');
'FL2_createCStreamMt'); @FL2_initCStream := Lib.GetProcAddr('FL2_initCStream');
@FL2_freeCStream := MemoryGetProcAddress(DLLHandle, 'FL2_freeCStream'); @FL2_compressStream := Lib.GetProcAddr('FL2_compressStream');
@FL2_initCStream := MemoryGetProcAddress(DLLHandle, 'FL2_initCStream'); @FL2_createDStream := Lib.GetProcAddr('FL2_createDStream');
@FL2_compressStream := MemoryGetProcAddress(DLLHandle, @FL2_createDStreamMt := Lib.GetProcAddr('FL2_createDStreamMt');
'FL2_compressStream'); @FL2_freeDStream := Lib.GetProcAddr('FL2_freeDStream');
@FL2_createDStream := MemoryGetProcAddress(DLLHandle, 'FL2_createDStream'); @FL2_initDStream := Lib.GetProcAddr('FL2_initDStream');
@FL2_createDStreamMt := MemoryGetProcAddress(DLLHandle, @FL2_decompressStream := Lib.GetProcAddr('FL2_decompressStream');
'FL2_createDStreamMt'); @FL2_endStream := Lib.GetProcAddr('FL2_endStream');
@FL2_freeDStream := MemoryGetProcAddress(DLLHandle, 'FL2_freeDStream'); @FL2_isError := Lib.GetProcAddr('FL2_isError');
@FL2_initDStream := MemoryGetProcAddress(DLLHandle, 'FL2_initDStream'); @FL2_CStream_setParameter := Lib.GetProcAddr('FL2_CStream_setParameter');
@FL2_decompressStream := MemoryGetProcAddress(DLLHandle, @FL2_CStream_getParameter := Lib.GetProcAddr('FL2_CStream_getParameter');
'FL2_decompressStream'); @FL2_setDStreamMemoryLimitMt :=
@FL2_endStream := MemoryGetProcAddress(DLLHandle, 'FL2_endStream'); Lib.GetProcAddr('FL2_setDStreamMemoryLimitMt');
@FL2_isError := MemoryGetProcAddress(DLLHandle, 'FL2_isError');
DLLLoaded := Assigned(FL2_compress) and Assigned(FL2_decompress); DLLLoaded := Assigned(FL2_compress) and Assigned(FL2_decompress);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
MemoryFreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -0,0 +1,52 @@
unit GrittibanzliDLL;
interface
uses
WinAPI.Windows,
System.SysUtils, System.Classes;
var
Grittibanzli: function(const src: Pointer; srcSize: Cardinal; dst1: Pointer;
dst1Capacity: PCardinal; dst2: Pointer; dst2Capacity: PCardinal)
: boolean cdecl;
Ungrittibanzli: function(const src1: Pointer; src1Size: Cardinal;
const src2: Pointer; src2Size: Cardinal; dst: Pointer;
dstCapacity: PCardinal): boolean cdecl;
DLLLoaded: boolean = False;
implementation
var
DLLHandle: THandle;
procedure Init;
begin
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
'grittibanzli_dll.dll'));
if DLLHandle >= 32 then
begin
@Grittibanzli := GetProcAddress(DLLHandle, '__Grittibanzli');
@Ungrittibanzli := GetProcAddress(DLLHandle, '__Ungrittibanzli');
DLLLoaded := Assigned(Grittibanzli) and Assigned(Ungrittibanzli);
end
else
DLLLoaded := False;
end;
procedure Deinit;
begin
if not DLLLoaded then
exit;
FreeLibrary(DLLHandle);
end;
initialization
Init;
finalization
Deinit;
end.

View File

@ -3,6 +3,7 @@ unit JoJpegDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -32,30 +33,25 @@ var
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
procedure Init; procedure Init;
begin begin
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'jojpeg_dll.dll');
'jojpeg_dll.dll')); if Lib.Loaded then
if DLLHandle >= 32 then
begin begin
@jojpeg_Init := GetProcAddress(DLLHandle, 'jojpeg_Init'); @jojpeg_Init := Lib.GetProcAddr('jojpeg_Init');
@jojpeg_Quit := GetProcAddress(DLLHandle, 'jojpeg_Quit'); @jojpeg_Quit := Lib.GetProcAddr('jojpeg_Quit');
@jojpeg_Loop := GetProcAddress(DLLHandle, 'jojpeg_Loop'); @jojpeg_Loop := Lib.GetProcAddr('jojpeg_Loop');
@jojpeg_Getvalue := GetProcAddress(DLLHandle, 'jojpeg_Getvalue'); @jojpeg_Getvalue := Lib.GetProcAddr('jojpeg_Getvalue');
@jojpeg_Addbuf := GetProcAddress(DLLHandle, 'jojpeg_Addbuf'); @jojpeg_Addbuf := Lib.GetProcAddr('jojpeg_Addbuf');
DLLLoaded := Assigned(jojpeg_Init); DLLLoaded := Assigned(jojpeg_Init);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
FreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -3,13 +3,23 @@ unit LZ4DLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils; System.SysUtils, System.Math;
const const
LZ4F_VERSION = 100; LZ4F_VERSION = 100;
type type
PLZ4_streamDecode_t = ^LZ4_streamDecode_t;
LZ4_streamDecode_t = array [0 .. 1 shl 9 - 1] of byte;
PLZ4_stream_t = ^LZ4_stream_t;
LZ4_stream_t = array [0 .. 1 shl 9 - 1] of byte;
PLZ4_streamHC_t = ^LZ4_streamHC_t;
LZ4_streamHC_t = array [0 .. 1 shl 9 - 1] of byte;
LZ4F_errorCode_t = type size_t; LZ4F_errorCode_t = type size_t;
LZ4F_blockSizeID_t = (LZ4F_default = 0, LZ4F_max64KB = 4, LZ4F_max256KB = 5, LZ4F_blockSizeID_t = (LZ4F_default = 0, LZ4F_max64KB = 4, LZ4F_max256KB = 5,
@ -83,67 +93,65 @@ var
LZ4F_getFrameInfo: function(dctx: LZ4F_dctx; LZ4F_getFrameInfo: function(dctx: LZ4F_dctx;
out frameInfoPtr: LZ4F_frameInfo_t; srcBuffer: Pointer; out frameInfoPtr: LZ4F_frameInfo_t; srcBuffer: Pointer;
out srcSizePtr: size_t): size_t cdecl; out srcSizePtr: size_t): size_t cdecl;
LZ4_createStreamDecode: function: PLZ4_streamDecode_t cdecl;
LZ4_freeStreamDecode: function(LZ4_stream: PLZ4_streamDecode_t)
: Integer cdecl;
LZ4_decompress_safe_continue: function(LZ4_stream: PLZ4_streamDecode_t;
const src: Pointer; dst: Pointer; srcSize: Integer; dstCapacity: Integer)
: Integer cdecl;
LZ4_createStream: function: PLZ4_stream_t cdecl;
LZ4_freeStream: function(streamPtr: PLZ4_stream_t): Integer cdecl;
LZ4_resetStream: procedure(streamHCPtr: PLZ4_stream_t)cdecl;
LZ4_compress_fast_continue: function(streamPtr: PLZ4_stream_t;
const src: Pointer; dst: Pointer; srcSize: Integer; maxDstSize: Integer;
acceleration: Integer): Integer cdecl;
LZ4_createStreamHC: function: PLZ4_streamHC_t cdecl;
LZ4_freeStreamHC: function(streamHCPtr: PLZ4_streamHC_t): Integer cdecl;
LZ4_resetStreamHC: procedure(streamHCPtr: PLZ4_streamHC_t;
compressionLevel: Integer)cdecl;
LZ4_compress_HC_continue: function(streamHCPtr: PLZ4_streamHC_t;
const src: Pointer; dst: Pointer; srcSize: Integer; maxDstSize: Integer)
: Integer cdecl;
DLLLoaded: Boolean = False; DLLLoaded: Boolean = False;
function LZ4F_decompress_safe(source: Pointer; dest: Pointer; function LZ4F_decompress_safe(source: Pointer; dest: Pointer;
compressedSize: Integer; maxDecompressedSize: Integer): Integer; sourceSize: Integer; destSize: Integer; compressedSize: PInteger = nil;
blockSize: PInteger = nil): Integer;
function LZ4_compress_block(src, dst: Pointer;
srcSize, dstCapacity: Integer): Integer;
implementation implementation
var
DLLHandle: THandle;
procedure Init(Filename: String);
begin
if DLLLoaded then
Exit;
DLLHandle := 0;
DLLHandle := LoadLibrary(PWideChar(ExtractFilePath(ParamStr(0)) + Filename));
if DLLHandle >= 32 then
begin
@LZ4_decompress_safe := GetProcAddress(DLLHandle, 'LZ4_decompress_safe');
@LZ4_decompress_fast := GetProcAddress(DLLHandle, 'LZ4_decompress_fast');
@LZ4_compress_default := GetProcAddress(DLLHandle, 'LZ4_compress_default');
@LZ4_compress_fast := GetProcAddress(DLLHandle, 'LZ4_compress_fast');
@LZ4_compress_HC := GetProcAddress(DLLHandle, 'LZ4_compress_HC');
@LZ4_compressHC2 := GetProcAddress(DLLHandle, 'LZ4_compressHC2');
@LZ4F_compressFrame := GetProcAddress(DLLHandle, 'LZ4F_compressFrame');
@LZ4F_compressFrameBound := GetProcAddress(DLLHandle,
'LZ4F_compressFrameBound');
@LZ4F_createDecompressionContext := GetProcAddress(DLLHandle,
'LZ4F_createDecompressionContext');
@LZ4F_freeDecompressionContext := GetProcAddress(DLLHandle,
'LZ4F_freeDecompressionContext');
@LZ4F_decompress := GetProcAddress(DLLHandle, 'LZ4F_decompress');
@LZ4F_getFrameInfo := GetProcAddress(DLLHandle, 'LZ4F_getFrameInfo');
DLLLoaded := Assigned(LZ4_decompress_safe);
end
else
DLLLoaded := False;
end;
procedure Deinit;
begin
if not DLLLoaded then
Exit;
FreeLibrary(DLLHandle);
end;
function LZ4F_decompress_safe(source: Pointer; dest: Pointer; function LZ4F_decompress_safe(source: Pointer; dest: Pointer;
compressedSize: Integer; maxDecompressedSize: Integer): Integer; sourceSize: Integer; destSize: Integer; compressedSize: PInteger;
blockSize: PInteger): Integer;
var var
ctx: LZ4F_dctx; ctx: LZ4F_dctx;
srcSizePtr, dstSizePtr: size_t; fi: LZ4F_frameInfo_t;
srcSizePtr, dstSizePtr, srcSizePtr2: size_t;
begin begin
Result := 0; Result := 0;
if Assigned(compressedSize) then
compressedSize^ := 0;
if Assigned(blockSize) then
blockSize^ := 4;
if NativeUInt(LZ4F_createDecompressionContext(ctx)) = 0 then if NativeUInt(LZ4F_createDecompressionContext(ctx)) = 0 then
try try
srcSizePtr := compressedSize; srcSizePtr := sourceSize;
dstSizePtr := maxDecompressedSize; dstSizePtr := destSize;
try try
FillChar(fi, SizeOf(LZ4F_frameInfo_t), 0);
srcSizePtr2 := sourceSize;
if LZ4F_decompress(ctx, dest, dstSizePtr, source, srcSizePtr, nil) = 0 if LZ4F_decompress(ctx, dest, dstSizePtr, source, srcSizePtr, nil) = 0
then then
begin
LZ4F_getFrameInfo(ctx, fi, source, srcSizePtr2);
if Assigned(compressedSize) then
compressedSize^ := srcSizePtr;
if Assigned(blockSize) then
blockSize^ := Max(4, Integer(fi.blockSizeID));
Result := dstSizePtr; Result := dstSizePtr;
end;
finally finally
LZ4F_freeDecompressionContext(ctx); LZ4F_freeDecompressionContext(ctx);
end; end;
@ -151,6 +159,157 @@ begin
end; end;
end; end;
function LZ4_compress_block(src, dst: Pointer;
srcSize, dstCapacity: Integer): Integer;
const
blockSize = 64 * 1024;
const
BuffSize = 256 * 1024;
var
Buff: array [0 .. BuffSize - 1] of byte;
ctx: PLZ4_stream_t;
Pos1, Pos2, Res: Integer;
X, Y: Integer;
begin
Result := 0;
ctx := LZ4_createStream;
LZ4_resetStream(ctx);
Pos1 := 0;
Pos2 := 0;
try
while (Pos1 < srcSize) and (Pos2 < dstCapacity) do
begin
X := Min(srcSize - Pos1, blockSize);
Y := dstCapacity - Pos2;
Res := LZ4_compress_fast_continue(ctx, PByte(src) + Pos1, @Buff[0], X,
BuffSize, 1);
if Res <= 0 then
begin
LZ4_freeStream(ctx);
exit(-Pos2);
end;
Move(Buff[0], (PByte(dst) + Pos2)^, Res);
Inc(Pos1, X);
Inc(Pos2, Res);
end;
finally
LZ4_freeStream(ctx);
end;
Result := Pos2;
end;
function UnravelEncode(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
OutSize: Integer): Integer;
const
blockSize = 65536;
var
ctx: PLZ4_streamHC_t;
Pos1, Pos2, Res: Integer;
X, Y: Integer;
begin
Result := 0;
ctx := LZ4_createStreamHC;
LZ4_resetStreamHC(ctx, 9);
Pos1 := 0;
Pos2 := 0;
try
while (Pos1 < InSize) do
begin
X := Min(InSize - Pos1, blockSize);
Y := OutSize - (Pos2 + Integer.Size);
Res := LZ4_compress_HC_continue(ctx, PByte(InBuff) + Pos1,
PByte(OutBuff) + Pos2 + Integer.Size, X, Y);
if Res <= 0 then
begin
LZ4_freeStreamHC(ctx);
exit(-Pos2);
end;
PInteger(PByte(OutBuff) + Pos2)^ := Res;
Inc(Pos1, X);
Inc(Pos2, Res + Integer.Size);
end;
finally
LZ4_freeStreamHC(ctx);
end;
Result := Pos2;
end;
function UnravelDecode(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
OutSize: Integer): Integer;
const
blockSize = 65536;
var
ctx: PLZ4_streamDecode_t;
Pos1, Pos2, Res: Integer;
begin
Result := 0;
ctx := LZ4_createStreamDecode;
Pos1 := 0;
Pos2 := 0;
try
while (Pos1 < InSize) and (Pos2 < OutSize) do
begin
Res := LZ4_decompress_safe_continue(ctx, PByte(InBuff) + Pos1 +
Integer.Size, PByte(OutBuff) + Pos2, PInteger(PByte(InBuff) + Pos1)^,
Min(OutSize - Pos2, blockSize));
if Res <= 0 then
begin
LZ4_freeStreamDecode(ctx);
exit(-Pos2);
end;
Inc(Pos1, PInteger(PByte(InBuff) + Pos1)^ + Integer.Size);
Inc(Pos2, Res);
end;
finally
LZ4_freeStreamDecode(ctx);
end;
Result := Pos2;
end;
var
Lib: TLibImport;
procedure Init(Filename: String);
begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
if Lib.Loaded then
begin
@LZ4_decompress_safe := Lib.GetProcAddr('LZ4_decompress_safe');
@LZ4_decompress_fast := Lib.GetProcAddr('LZ4_decompress_fast');
@LZ4_compress_default := Lib.GetProcAddr('LZ4_compress_default');
@LZ4_compress_fast := Lib.GetProcAddr('LZ4_compress_fast');
@LZ4_compress_HC := Lib.GetProcAddr('LZ4_compress_HC');
@LZ4_compressHC2 := Lib.GetProcAddr('LZ4_compressHC2');
@LZ4F_compressFrame := Lib.GetProcAddr('LZ4F_compressFrame');
@LZ4F_compressFrameBound := Lib.GetProcAddr('LZ4F_compressFrameBound');
@LZ4F_createDecompressionContext :=
Lib.GetProcAddr('LZ4F_createDecompressionContext');
@LZ4F_freeDecompressionContext :=
Lib.GetProcAddr('LZ4F_freeDecompressionContext');
@LZ4F_decompress := Lib.GetProcAddr('LZ4F_decompress');
@LZ4F_getFrameInfo := Lib.GetProcAddr('LZ4F_getFrameInfo');
@LZ4_createStreamDecode := Lib.GetProcAddr('LZ4_createStreamDecode');
@LZ4_freeStreamDecode := Lib.GetProcAddr('LZ4_freeStreamDecode');
@LZ4_decompress_safe_continue :=
Lib.GetProcAddr('LZ4_decompress_safe_continue');
@LZ4_createStream := Lib.GetProcAddr('LZ4_createStream');
@LZ4_freeStream := Lib.GetProcAddr('LZ4_freeStream');
@LZ4_resetStream := Lib.GetProcAddr('LZ4_resetStream');
@LZ4_compress_fast_continue :=
Lib.GetProcAddr('LZ4_compress_fast_continue');
@LZ4_createStreamHC := Lib.GetProcAddr('LZ4_createStreamHC');
@LZ4_freeStreamHC := Lib.GetProcAddr('LZ4_freeStreamHC');
@LZ4_resetStreamHC := Lib.GetProcAddr('LZ4_resetStreamHC');
@LZ4_compress_HC_continue := Lib.GetProcAddr('LZ4_compress_HC_continue');
DLLLoaded := Assigned(LZ4_decompress_safe);
end;
end;
procedure Deinit;
begin
Lib.Free;
end;
const const
DLLParam = '--lz4='; DLLParam = '--lz4=';

View File

@ -3,6 +3,7 @@ unit LZODLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils; System.SysUtils;
@ -60,83 +61,36 @@ var
dst: Pointer; dst_len: PNativeUInt; wrkmem: Pointer): integer; cdecl; dst: Pointer; dst_len: PNativeUInt; wrkmem: Pointer): integer; cdecl;
lzo2a_decompress_safe: function(const src: Pointer; src_len: NativeUInt; lzo2a_decompress_safe: function(const src: Pointer; src_len: NativeUInt;
dst: Pointer; dst_len: PNativeUInt): integer cdecl; dst: Pointer; dst_len: PNativeUInt): integer cdecl;
lzopro_lzo1x_w03_15_compress: function(const src: Pointer;
src_len: NativeUInt; dst: Pointer; dst_len: PNativeUInt; wrkmem: Pointer)
: integer; cdecl;
lzopro_lzo1x_99_compress: function(const src; src_len: integer; var dst;
var dst_len; var cb; compression_level: integer): integer; cdecl;
DLLLoaded: Boolean = False; DLLLoaded: Boolean = False;
function lzo1x_99_compress(const src: Pointer; src_len: NativeUInt;
dst: Pointer; dst_len: PNativeUInt; compression_level: integer): integer;
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
procedure nfree(self: Pointer; ptr: Pointer); cdecl;
begin
FreeMem(ptr);
end;
function nalloc(self: Pointer; items, size: LongWord): Pointer; cdecl;
var
p: Pointer;
begin
GetMem(p, size * items);
Result := p;
end;
procedure nprogress(self: Pointer; a, b: LongWord; c: integer); cdecl;
begin
end;
function lzo1x_99_compress(const src: Pointer; src_len: NativeUInt;
dst: Pointer; dst_len: PNativeUInt; compression_level: integer): integer;
var
mycb: lzo_callback_t;
begin
mycb.nalloc := nalloc;
mycb.nfree := nfree;
mycb.nprogress := nprogress;
Result := lzopro_lzo1x_99_compress(src^, src_len, dst^, dst_len^, mycb,
compression_level);
end;
procedure Init(Filename: String); procedure Init(Filename: String);
begin begin
if DLLLoaded then Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
Exit; if Lib.Loaded then
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Filename));
if DLLHandle >= 32 then
begin begin
@lzo1x_1_compress := GetProcAddress(DLLHandle, 'lzo1x_1_compress'); @lzo1x_1_compress := Lib.GetProcAddr('lzo1x_1_compress');
@lzo1x_1_11_compress := GetProcAddress(DLLHandle, 'lzo1x_1_11_compress'); @lzo1x_1_11_compress := Lib.GetProcAddr('lzo1x_1_11_compress');
@lzo1x_1_12_compress := GetProcAddress(DLLHandle, 'lzo1x_1_12_compress'); @lzo1x_1_12_compress := Lib.GetProcAddr('lzo1x_1_12_compress');
@lzo1x_1_15_compress := GetProcAddress(DLLHandle, 'lzo1x_1_15_compress'); @lzo1x_1_15_compress := Lib.GetProcAddr('lzo1x_1_15_compress');
@lzo1x_999_compress := GetProcAddress(DLLHandle, 'lzo1x_999_compress'); @lzo1x_999_compress := Lib.GetProcAddr('lzo1x_999_compress');
@lzo1x_999_compress_level := GetProcAddress(DLLHandle, @lzo1x_999_compress_level := Lib.GetProcAddr('lzo1x_999_compress_level');
'lzo1x_999_compress_level'); @lzo1x_decompress_safe := Lib.GetProcAddr('lzo1x_decompress_safe');
@lzo1x_decompress_safe := GetProcAddress(DLLHandle, @lzo1c_999_compress := Lib.GetProcAddr('lzo1c_999_compress');
'lzo1x_decompress_safe'); @lzo1c_decompress_safe := Lib.GetProcAddr('lzo1c_decompress_safe');
@lzo1c_999_compress := GetProcAddress(DLLHandle, 'lzo1c_999_compress'); @lzo2a_999_compress := Lib.GetProcAddr('lzo2a_999_compress');
@lzo1c_decompress_safe := GetProcAddress(DLLHandle, @lzo2a_decompress_safe := Lib.GetProcAddr('lzo2a_decompress_safe');
'lzo1c_decompress_safe');
@lzo2a_999_compress := GetProcAddress(DLLHandle, 'lzo2a_999_compress');
@lzo2a_decompress_safe := GetProcAddress(DLLHandle,
'lzo2a_decompress_safe');
DLLLoaded := Assigned(lzo1x_decompress_safe); DLLLoaded := Assigned(lzo1x_decompress_safe);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
Exit;
FreeLibrary(DLLHandle);
end; end;
const const

View File

@ -3,6 +3,7 @@ unit OodleDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Types, System.IOUtils; System.SysUtils, System.Types, System.IOUtils;
@ -72,57 +73,42 @@ function OodleLZ_GetCompressedBufferSizeNeeded(compressor: Byte;
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
OldCompress, OldCompressOptions_GetDefault, OldCompress, OldCompressOptions_GetDefault,
OldGetCompressedBufferSizeNeeded: Boolean; OldGetCompressedBufferSizeNeeded: Boolean;
DLLs: TStringDynArray;
procedure Init(Filename: String); procedure Init(Filename: String);
var var
I: Integer; I: Integer;
C: Cardinal; C: Cardinal;
begin begin
if DLLLoaded then Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
Exit; if not Lib.Loaded then
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'oo2core*.dll', for I := 3 to 9 do
TSearchOption.soTopDirectoryOnly);
Insert(ExtractFilePath(ParamStr(0)) + Filename, DLLs, 0);
for I := Low(DLLs) to High(DLLs) do
begin begin
DLLHandle := LoadLibrary(PChar(DLLs[I])); Lib.Free;
if DLLHandle >= 32 then Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'oo2core_' +
I.ToString + '_win64.dll');
if Lib.Loaded then
break; break;
end; end;
if DLLHandle < 32 then if not Lib.Loaded then
for I := 3 to 9 do
begin begin
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'oo2ext*.dll', Lib.Free;
TSearchOption.soTopDirectoryOnly); Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'oo2ext_' +
for I := Low(DLLs) to High(DLLs) do I.ToString + '_win64.dll');
begin if Lib.Loaded then
DLLHandle := LoadLibrary(PChar(DLLs[I]));
if DLLHandle >= 32 then
break; break;
end; end;
end; if Lib.Loaded then
if DLLHandle < 32 then
begin begin
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'oodle2*.dll', Oodle_CheckVersion := Lib.GetProcAddr('Oodle_CheckVersion');
TSearchOption.soTopDirectoryOnly);
for I := Low(DLLs) to High(DLLs) do
begin
DLLHandle := LoadLibrary(PChar(DLLs[I]));
if DLLHandle >= 32 then
break;
end;
end;
if DLLHandle >= 32 then
begin
Oodle_CheckVersion := GetProcAddress(DLLHandle, 'Oodle_CheckVersion');
if not Assigned(Oodle_CheckVersion) then if not Assigned(Oodle_CheckVersion) then
for I := 0 to 32 do for I := 0 to 32 do
begin begin
@Oodle_CheckVersion := GetProcAddress(DLLHandle, @Oodle_CheckVersion :=
PChar('_Oodle_CheckVersion@' + (I * 2).ToString)); Lib.GetProcAddr(PAnsiChar('_Oodle_CheckVersion@' + (I * 2).ToString));
if Assigned(Oodle_CheckVersion) then if Assigned(Oodle_CheckVersion) then
break; break;
end; end;
@ -131,61 +117,57 @@ begin
OldCompress := LongRec(C).Hi < $2E06; OldCompress := LongRec(C).Hi < $2E06;
OldGetCompressedBufferSizeNeeded := LongRec(C).Hi < $2E08; OldGetCompressedBufferSizeNeeded := LongRec(C).Hi < $2E08;
OldCompressOptions_GetDefault := LongRec(C).Hi < $2E08; OldCompressOptions_GetDefault := LongRec(C).Hi < $2E08;
@OodleLZ_Compress_1 := GetProcAddress(DLLHandle, 'OodleLZ_Compress'); @OodleLZ_Compress_1 := Lib.GetProcAddr('OodleLZ_Compress');
if not Assigned(OodleLZ_Compress_1) then if not Assigned(OodleLZ_Compress_1) then
for I := 0 to 32 do for I := 0 to 32 do
begin begin
@OodleLZ_Compress_1 := GetProcAddress(DLLHandle, @OodleLZ_Compress_1 :=
PChar('_OodleLZ_Compress@' + (I * 2).ToString)); Lib.GetProcAddr(PAnsiChar('_OodleLZ_Compress@' + (I * 2).ToString));
if Assigned(OodleLZ_Compress_1) then if Assigned(OodleLZ_Compress_1) then
break; break;
end; end;
@OodleLZ_Compress_2 := @OodleLZ_Compress_1; @OodleLZ_Compress_2 := @OodleLZ_Compress_1;
OodleLZ_Decompress := GetProcAddress(DLLHandle, 'OodleLZ_Decompress'); OodleLZ_Decompress := Lib.GetProcAddr('OodleLZ_Decompress');
if not Assigned(OodleLZ_Decompress) then if not Assigned(OodleLZ_Decompress) then
for I := 0 to 32 do for I := 0 to 32 do
begin begin
@OodleLZ_Decompress := GetProcAddress(DLLHandle, @OodleLZ_Decompress :=
PChar('_OodleLZ_Decompress@' + (I * 2).ToString)); Lib.GetProcAddr(PAnsiChar('_OodleLZ_Decompress@' + (I * 2).ToString));
if Assigned(OodleLZ_Decompress) then if Assigned(OodleLZ_Decompress) then
break; break;
end; end;
OodleLZ_CompressOptions_GetDefault_1 := GetProcAddress(DLLHandle, OodleLZ_CompressOptions_GetDefault_1 :=
'OodleLZ_CompressOptions_GetDefault'); Lib.GetProcAddr('OodleLZ_CompressOptions_GetDefault');
if not Assigned(OodleLZ_CompressOptions_GetDefault_1) then if not Assigned(OodleLZ_CompressOptions_GetDefault_1) then
for I := 0 to 32 do for I := 0 to 32 do
begin begin
@OodleLZ_CompressOptions_GetDefault_1 := @OodleLZ_CompressOptions_GetDefault_1 :=
GetProcAddress(DLLHandle, PChar('_OodleLZ_CompressOptions_GetDefault@' Lib.GetProcAddr(PAnsiChar('_OodleLZ_CompressOptions_GetDefault@' +
+ (I * 2).ToString)); (I * 2).ToString));
if Assigned(OodleLZ_CompressOptions_GetDefault_1) then if Assigned(OodleLZ_CompressOptions_GetDefault_1) then
break; break;
end; end;
@OodleLZ_CompressOptions_GetDefault_2 := @OodleLZ_CompressOptions_GetDefault_2 :=
@OodleLZ_CompressOptions_GetDefault_1; @OodleLZ_CompressOptions_GetDefault_1;
OodleLZ_GetCompressedBufferSizeNeeded_1 := OodleLZ_GetCompressedBufferSizeNeeded_1 :=
GetProcAddress(DLLHandle, 'OodleLZ_GetCompressedBufferSizeNeeded'); Lib.GetProcAddr('OodleLZ_GetCompressedBufferSizeNeeded');
if not Assigned(OodleLZ_GetCompressedBufferSizeNeeded_1) then if not Assigned(OodleLZ_GetCompressedBufferSizeNeeded_1) then
for I := 0 to 32 do for I := 0 to 32 do
begin begin
@OodleLZ_GetCompressedBufferSizeNeeded_1 := @OodleLZ_GetCompressedBufferSizeNeeded_1 :=
GetProcAddress(DLLHandle, Lib.GetProcAddr(PAnsiChar('_OodleLZ_GetCompressedBufferSizeNeeded@' +
PChar('_OodleLZ_GetCompressedBufferSizeNeeded@' + (I * 2).ToString)); (I * 2).ToString));
if Assigned(OodleLZ_GetCompressedBufferSizeNeeded_1) then if Assigned(OodleLZ_GetCompressedBufferSizeNeeded_1) then
break; break;
end; end;
@OodleLZ_GetCompressedBufferSizeNeeded_2 := @OodleLZ_GetCompressedBufferSizeNeeded_2 :=
@OodleLZ_GetCompressedBufferSizeNeeded_1; @OodleLZ_GetCompressedBufferSizeNeeded_1;
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
Exit;
FreeLibrary(DLLHandle);
end; end;
function OodleLZ_Compress(compressor: Integer; rawBuf: Pointer; function OodleLZ_Compress(compressor: Integer; rawBuf: Pointer;
@ -228,7 +210,7 @@ var
initialization initialization
DLLFile := 'oodle.dll'; DLLFile := 'oo2core_9_win64.dll';
for I := 1 to ParamCount do for I := 1 to ParamCount do
if ParamStr(I).StartsWith(DLLParam) then if ParamStr(I).StartsWith(DLLParam) then
begin begin

View File

@ -3,6 +3,7 @@ unit PackJPGDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -25,35 +26,28 @@ var
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
procedure Init; procedure Init;
begin begin
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'packjpg_dll.dll');
'packjpg_dll.dll')); if Lib.Loaded then
if DLLHandle >= 32 then
begin begin
@pjglib_convert_stream2stream := GetProcAddress(DLLHandle, @pjglib_convert_stream2stream :=
'pjglib_convert_stream2stream'); Lib.GetProcAddr('pjglib_convert_stream2stream');
@pjglib_convert_file2file := GetProcAddress(DLLHandle, @pjglib_convert_file2file := Lib.GetProcAddr('pjglib_convert_file2file');
'pjglib_convert_file2file'); @pjglib_convert_stream2mem := Lib.GetProcAddr('pjglib_convert_stream2mem');
@pjglib_convert_stream2mem := GetProcAddress(DLLHandle, @pjglib_init_streams := Lib.GetProcAddr('pjglib_init_streams');
'pjglib_convert_stream2mem'); @pjglib_version_info := Lib.GetProcAddr('pjglib_version_info');
@pjglib_init_streams := GetProcAddress(DLLHandle, 'pjglib_init_streams'); @pjglib_short_name := Lib.GetProcAddr('pjglib_short_name');
@pjglib_version_info := GetProcAddress(DLLHandle, 'pjglib_version_info');
@pjglib_short_name := GetProcAddress(DLLHandle, 'pjglib_short_name');
DLLLoaded := Assigned(pjglib_init_streams) and DLLLoaded := Assigned(pjglib_init_streams) and
Assigned(pjglib_convert_stream2stream); Assigned(pjglib_convert_stream2stream);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
FreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -3,6 +3,7 @@ unit PreflateDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -18,27 +19,22 @@ var
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
procedure Init; procedure Init;
begin begin
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'preflate_dll.dll');
'preflate_dll.dll')); if Lib.Loaded then
if DLLHandle >= 32 then
begin begin
@preflate_decode := GetProcAddress(DLLHandle, 'decode'); @preflate_decode := Lib.GetProcAddr('decode');
@preflate_reencode := GetProcAddress(DLLHandle, 'reencode'); @preflate_reencode := Lib.GetProcAddr('reencode');
DLLLoaded := Assigned(preflate_decode) and Assigned(preflate_reencode); DLLLoaded := Assigned(preflate_decode) and Assigned(preflate_reencode);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
FreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -3,6 +3,7 @@ unit ReflateDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -25,41 +26,35 @@ var
implementation implementation
var var
DLLHandle1, DLLHandle2: THandle; Lib1, Lib2: TLibImport;
procedure Init; procedure Init;
begin begin
DLLHandle1 := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Lib1 := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'RAW2HIF_DLL.DLL');
'RAW2HIF_DLL.DLL')); Lib2 := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'HIF2RAW_DLL.DLL');
DLLHandle2 := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + if Lib1.Loaded and Lib2.Loaded then
'HIF2RAW_DLL.DLL'));
if (DLLHandle1 >= 32) and (DLLHandle2 >= 32) then
begin begin
@raw2hif_Alloc := GetProcAddress(DLLHandle1, 'raw2hif_Alloc'); @raw2hif_Alloc := Lib1.GetProcAddr('raw2hif_Alloc');
@raw2hif_Free := GetProcAddress(DLLHandle1, 'raw2hif_Free'); @raw2hif_Free := Lib1.GetProcAddr('raw2hif_Free');
@raw2hif_Init := GetProcAddress(DLLHandle1, 'raw2hif_Init'); @raw2hif_Init := Lib1.GetProcAddr('raw2hif_Init');
@raw2hif_Loop := GetProcAddress(DLLHandle1, 'raw2hif_Loop'); @raw2hif_Loop := Lib1.GetProcAddr('raw2hif_Loop');
@raw2hif_getoutlen := GetProcAddress(DLLHandle1, 'raw2hif_getoutlen'); @raw2hif_getoutlen := Lib1.GetProcAddr('raw2hif_getoutlen');
@raw2hif_getou2len := GetProcAddress(DLLHandle1, 'raw2hif_getou2len'); @raw2hif_getou2len := Lib1.GetProcAddr('raw2hif_getou2len');
@raw2hif_addbuf := GetProcAddress(DLLHandle1, 'raw2hif_addbuf'); @raw2hif_addbuf := Lib1.GetProcAddr('raw2hif_addbuf');
@hif2raw_Alloc := GetProcAddress(DLLHandle2, 'hif2raw_Alloc'); @hif2raw_Alloc := Lib2.GetProcAddr('hif2raw_Alloc');
@hif2raw_Free := GetProcAddress(DLLHandle2, 'hif2raw_Free'); @hif2raw_Free := Lib2.GetProcAddr('hif2raw_Free');
@hif2raw_Init := GetProcAddress(DLLHandle2, 'hif2raw_Init'); @hif2raw_Init := Lib2.GetProcAddr('hif2raw_Init');
@hif2raw_Loop := GetProcAddress(DLLHandle2, 'hif2raw_Loop'); @hif2raw_Loop := Lib2.GetProcAddr('hif2raw_Loop');
@hif2raw_getoutlen := GetProcAddress(DLLHandle2, 'hif2raw_getoutlen'); @hif2raw_getoutlen := Lib2.GetProcAddr('hif2raw_getoutlen');
@hif2raw_addbuf := GetProcAddress(DLLHandle2, 'hif2raw_addbuf'); @hif2raw_addbuf := Lib2.GetProcAddr('hif2raw_addbuf');
DLLLoaded := Assigned(raw2hif_Alloc) and Assigned(hif2raw_Alloc); DLLLoaded := Assigned(raw2hif_Alloc) and Assigned(hif2raw_Alloc);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib1.Free;
exit; Lib2.Free;
FreeLibrary(DLLHandle1);
FreeLibrary(DLLHandle2);
end; end;
initialization initialization

View File

@ -3,7 +3,7 @@ unit XDeltaDLL;
interface interface
uses uses
MemoryModule, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -37,34 +37,25 @@ var
implementation implementation
uses
Utils;
var var
DLLStream: TResourceStream; Lib: TLibImport;
DLLHandle: TMemoryModule;
procedure Init; procedure Init;
begin begin
DLLStream := TResourceStream.Create(HInstance, 'xdelta3_dll', RT_RCDATA); Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'xdelta3_dll.dll');
DLLHandle := MemoryLoadLibary(DLLStream.Memory); if Lib.Loaded then
if Assigned(DLLHandle) then
begin begin
DLLLoaded := True; DLLLoaded := True;
@xd3_encode := MemoryGetProcAddress(DLLHandle, 'xd3_encode'); @xd3_encode := Lib.GetProcAddr('xd3_encode');
Assert(@xd3_encode <> nil); Assert(@xd3_encode <> nil);
@xd3_decode := MemoryGetProcAddress(DLLHandle, 'xd3_decode'); @xd3_decode := Lib.GetProcAddr('xd3_decode');
Assert(@xd3_decode <> nil); Assert(@xd3_decode <> nil);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
exit;
MemoryFreeLibrary(DLLHandle);
end; end;
initialization initialization

View File

@ -3,6 +3,7 @@ unit ZLibDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Types, System.IOUtils, System.ZLib; System.SysUtils, System.Types, System.IOUtils, System.ZLib;
@ -86,55 +87,8 @@ function inflateReset(var strm: z_stream): integer;
implementation implementation
var var
DLLHandle: THandle; Lib: TLibImport;
WinAPIDLL: boolean; WinAPIDLL: boolean;
DLLs: TStringDynArray;
procedure Init(Filename: String);
var
I: integer;
begin
if DLLLoaded then
Exit;
DLLs := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), 'zlib*.dll',
TSearchOption.soTopDirectoryOnly);
Insert(ExtractFilePath(ParamStr(0)) + 'zlib.dll', DLLs, Length(DLLs));
Insert(ExtractFilePath(ParamStr(0)) + Filename, DLLs, 0);
for I := Low(DLLs) to High(DLLs) do
begin
DLLHandle := LoadLibrary(PChar(DLLs[I]));
if (DLLHandle >= 32) and Assigned(GetProcAddress(DLLHandle, 'zlibVersion'))
then
break;
end;
if DLLHandle >= 32 then
begin
DLLLoaded := True;
@_zlibVersion := GetProcAddress(DLLHandle, 'zlibVersion');
@_zlibCompileFlags := GetProcAddress(DLLHandle, 'zlibCompileFlags');
DLLLoaded := Assigned(_zlibVersion) and Assigned(_zlibCompileFlags);
if DLLLoaded then
begin
WinAPIDLL := _zlibCompileFlags and $400 = $400;
if WinAPIDLL then
begin
@s_deflateInit2_ := GetProcAddress(DLLHandle, 'deflateInit2_');
@s_deflate := GetProcAddress(DLLHandle, 'deflate');
@s_deflateEnd := GetProcAddress(DLLHandle, 'deflateEnd');
@s_deflateReset := GetProcAddress(DLLHandle, 'deflateReset');
end
else
begin
@c_deflateInit2_ := GetProcAddress(DLLHandle, 'deflateInit2_');
@c_deflate := GetProcAddress(DLLHandle, 'deflate');
@c_deflateEnd := GetProcAddress(DLLHandle, 'deflateEnd');
@c_deflateReset := GetProcAddress(DLLHandle, 'deflateReset');
end;
end;
end
else
DLLLoaded := False;
end;
function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel,
strategy: integer): integer; strategy: integer): integer;
@ -192,11 +146,49 @@ begin
Result := System.ZLib.inflateReset(strm); Result := System.ZLib.inflateReset(strm);
end; end;
procedure Init(Filename: String);
begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
begin
Lib.Free;
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'zlibwapi.dll');
end;
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
begin
Lib.Free;
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'zlib1.dll');
end;
if Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion')) then
begin
DLLLoaded := True;
@_zlibVersion := Lib.GetProcAddr('zlibVersion');
@_zlibCompileFlags := Lib.GetProcAddr('zlibCompileFlags');
DLLLoaded := Assigned(_zlibVersion) and Assigned(_zlibCompileFlags);
if DLLLoaded then
begin
WinAPIDLL := _zlibCompileFlags and $400 = $400;
if WinAPIDLL then
begin
@s_deflateInit2_ := Lib.GetProcAddr('deflateInit2_');
@s_deflate := Lib.GetProcAddr('deflate');
@s_deflateEnd := Lib.GetProcAddr('deflateEnd');
@s_deflateReset := Lib.GetProcAddr('deflateReset');
end
else
begin
@c_deflateInit2_ := Lib.GetProcAddr('deflateInit2_');
@c_deflate := Lib.GetProcAddr('deflate');
@c_deflateEnd := Lib.GetProcAddr('deflateEnd');
@c_deflateReset := Lib.GetProcAddr('deflateReset');
end;
end;
end;
end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
Exit;
FreeLibrary(DLLHandle);
end; end;
const const

View File

@ -3,6 +3,7 @@ unit ZSTDDLL;
interface interface
uses uses
LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils; System.SysUtils;
@ -142,54 +143,45 @@ begin
end; end;
var var
DLLHandle: THandle; Lib: TLibImport;
procedure Init(Filename: String); procedure Init(Filename: String);
begin begin
if DLLLoaded then Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
Exit; if Lib.Loaded then
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Filename));
if DLLHandle >= 32 then
begin begin
@ZSTD_compress := GetProcAddress(DLLHandle, 'ZSTD_compress'); @ZSTD_compress := Lib.GetProcAddr('ZSTD_compress');
@ZSTD_compress2 := GetProcAddress(DLLHandle, 'ZSTD_compress2'); @ZSTD_compress2 := Lib.GetProcAddr('ZSTD_compress2');
@ZSTD_decompress := GetProcAddress(DLLHandle, 'ZSTD_decompress'); @ZSTD_decompress := Lib.GetProcAddr('ZSTD_decompress');
@ZSTD_findFrameCompressedSize := GetProcAddress(DLLHandle, @ZSTD_findFrameCompressedSize :=
'ZSTD_findFrameCompressedSize'); Lib.GetProcAddr('ZSTD_findFrameCompressedSize');
@ZSTD_findDecompressedSize := GetProcAddress(DLLHandle, @ZSTD_findDecompressedSize := Lib.GetProcAddr('ZSTD_findDecompressedSize');
'ZSTD_findDecompressedSize'); @ZSTD_createCCtx := Lib.GetProcAddr('ZSTD_createCCtx');
@ZSTD_createCCtx := GetProcAddress(DLLHandle, 'ZSTD_createCCtx'); @ZSTD_freeCCtx := Lib.GetProcAddr('ZSTD_freeCCtx');
@ZSTD_freeCCtx := GetProcAddress(DLLHandle, 'ZSTD_freeCCtx'); @ZSTD_CCtx_reset := Lib.GetProcAddr('ZSTD_CCtx_reset');
@ZSTD_CCtx_reset := GetProcAddress(DLLHandle, 'ZSTD_CCtx_reset'); @ZSTD_CCtx_setParameter := Lib.GetProcAddr('ZSTD_CCtx_setParameter');
@ZSTD_CCtx_setParameter := GetProcAddress(DLLHandle, @ZSTD_createDCtx := Lib.GetProcAddr('ZSTD_createDCtx');
'ZSTD_CCtx_setParameter'); @ZSTD_freeDCtx := Lib.GetProcAddr('ZSTD_freeDCtx');
@ZSTD_createDCtx := GetProcAddress(DLLHandle, 'ZSTD_createDCtx'); @ZSTD_createCDict := Lib.GetProcAddr('ZSTD_createCDict');
@ZSTD_freeDCtx := GetProcAddress(DLLHandle, 'ZSTD_freeDCtx'); @ZSTD_freeCDict := Lib.GetProcAddr('ZSTD_freeCDict');
@ZSTD_createCDict := GetProcAddress(DLLHandle, 'ZSTD_createCDict'); @ZSTD_compressCCtx := Lib.GetProcAddr('ZSTD_compressCCtx');
@ZSTD_freeCDict := GetProcAddress(DLLHandle, 'ZSTD_freeCDict'); @ZSTD_createDDict := Lib.GetProcAddr('ZSTD_createDDict');
@ZSTD_compressCCtx := GetProcAddress(DLLHandle, 'ZSTD_compressCCtx'); @ZSTD_freeDDict := Lib.GetProcAddr('ZSTD_freeDDict');
@ZSTD_createDDict := GetProcAddress(DLLHandle, 'ZSTD_createDDict'); @ZSTD_decompressDCtx := Lib.GetProcAddr('ZSTD_decompressDCtx');
@ZSTD_freeDDict := GetProcAddress(DLLHandle, 'ZSTD_freeDDict'); @ZSTD_compress_usingCDict := Lib.GetProcAddr('ZSTD_compress_usingCDict');
@ZSTD_decompressDCtx := GetProcAddress(DLLHandle, 'ZSTD_decompressDCtx'); @ZSTD_decompress_usingDDict :=
@ZSTD_compress_usingCDict := GetProcAddress(DLLHandle, Lib.GetProcAddr('ZSTD_decompress_usingDDict');
'ZSTD_compress_usingCDict'); @ZSTD_initCStream := Lib.GetProcAddr('ZSTD_initCStream');
@ZSTD_decompress_usingDDict := GetProcAddress(DLLHandle, @ZSTD_compressStream := Lib.GetProcAddr('ZSTD_compressStream');
'ZSTD_decompress_usingDDict'); @ZSTD_flushStream := Lib.GetProcAddr('ZSTD_flushStream');
@ZSTD_initCStream := GetProcAddress(DLLHandle, 'ZSTD_initCStream'); @ZSTD_endStream := Lib.GetProcAddr('ZSTD_endStream');
@ZSTD_compressStream := GetProcAddress(DLLHandle, 'ZSTD_compressStream');
@ZSTD_flushStream := GetProcAddress(DLLHandle, 'ZSTD_flushStream');
@ZSTD_endStream := GetProcAddress(DLLHandle, 'ZSTD_endStream');
DLLLoaded := Assigned(ZSTD_compress) and Assigned(ZSTD_decompress); DLLLoaded := Assigned(ZSTD_compress) and Assigned(ZSTD_decompress);
end end;
else
DLLLoaded := False;
end; end;
procedure Deinit; procedure Deinit;
begin begin
if not DLLLoaded then Lib.Free;
Exit;
FreeLibrary(DLLHandle);
end; end;
const const

View File

@ -274,7 +274,6 @@ begin
S := ReplaceText(S, '<insize>', StreamInfo^.OldSize.ToString); S := ReplaceText(S, '<insize>', StreamInfo^.OldSize.ToString);
S := ReplaceText(S, '<outsize>', StreamInfo^.NewSize.ToString); S := ReplaceText(S, '<outsize>', StreamInfo^.NewSize.ToString);
Res := 0; Res := 0;
Res := 0;
if ContainsText(S, '<fileres>') and Funcs^.GetResource(StreamInfo^.Resource, if ContainsText(S, '<fileres>') and Funcs^.GetResource(StreamInfo^.Resource,
nil, @Res) and (Res > 0) then nil, @Res) and (Res > 0) then
begin begin
@ -680,7 +679,7 @@ var
Bytes: TBytes; Bytes: TBytes;
Ini: TMemIniFile; Ini: TMemIniFile;
SL: TStringList; SL: TStringList;
ExeStruct: PExeStruct; ExeStruct: TExeStruct;
Y, Z: Integer; Y, Z: Integer;
List: TStringDynArray; List: TStringDynArray;
@ -699,80 +698,84 @@ begin
GetCmdStr(Ini.ReadString(SL[I], 'Decode', ''), 0)) then GetCmdStr(Ini.ReadString(SL[I], 'Decode', ''), 0)) then
for K := Low(List) to High(List) do for K := Low(List) to High(List) do
begin begin
New(ExeStruct);
Insert(List[K], Codec.Names, Length(Codec.Names)); Insert(List[K], Codec.Names, Length(Codec.Names));
ExeStruct^.Name := List[K]; ExeStruct.Name := List[K];
Bytes := BytesOf(ExeStruct^.Name); Bytes := BytesOf(ExeStruct.Name);
ExeStruct^.ID := Utils.Hash32(0, @Bytes[0], Length(Bytes)); ExeStruct.ID := Utils.Hash32(0, @Bytes[0], Length(Bytes));
for X := 0 to 1 do for X := 0 to 1 do
begin begin
ExeStruct^.IsLib[X] := False; ExeStruct.IsLib[X] := False;
if X = 0 then if X = 0 then
S1 := Ini.ReadString(SL[I], 'Encode', '') S1 := Ini.ReadString(SL[I], 'Encode', '')
else else
S1 := Ini.ReadString(SL[I], 'Decode', ''); S1 := Ini.ReadString(SL[I], 'Decode', '');
S1 := ReplaceText(S1, '<codec>', List[K]); S1 := ReplaceText(S1, '<codec>', List[K]);
ExeStruct^.Exec[X] := ExtractFilePath(Utils.GetModuleName) + ExeStruct.Exec[X] := ExtractFilePath(Utils.GetModuleName) +
GetCmdStr(S1, 0); GetCmdStr(S1, 0);
ExeStruct^.Param[X] := ''; ExeStruct.Param[X] := '';
ExeStruct^.Mode[X] := 0; ExeStruct.Mode[X] := 0;
for J := 1 to GetCmdCount(S1) - 1 do for J := 1 to GetCmdCount(S1) - 1 do
begin begin
S2 := GetCmdStr(S1, J); S2 := GetCmdStr(S1, J);
if ContainsText(S2, '<library>') then if ContainsText(S2, '<library>') then
begin begin
SetBits(ExeStruct^.Mode[X], STDIO_MODE, 0, 2); SetBits(ExeStruct.Mode[X], STDIO_MODE, 0, 2);
ExeStruct^.IsLib[X] := True; ExeStruct.IsLib[X] := True;
continue; continue;
end end
else if ContainsText(S2, '<stdin>') or ContainsText(S2, '[stdin]') else if ContainsText(S2, '<stdin>') or ContainsText(S2, '[stdin]')
then then
begin begin
SetBits(ExeStruct^.Mode[X], 1, 0, 1); SetBits(ExeStruct.Mode[X], 1, 0, 1);
continue; continue;
end end
else if ContainsText(S2, '<stdout>') or ContainsText(S2, '[stdout]') else if ContainsText(S2, '<stdout>') or ContainsText(S2, '[stdout]')
then then
begin begin
SetBits(ExeStruct^.Mode[X], 1, 1, 1); SetBits(ExeStruct.Mode[X], 1, 1, 1);
continue; continue;
end end
else if ContainsText(S2, '<filein>') or ContainsText(S2, '[filein]') else if ContainsText(S2, '<filein>') or ContainsText(S2, '[filein]')
then then
begin begin
S3 := IfThen(X = 0, FILE_IN, FILE_OUT); S3 := IfThen(X = 0, FILE_IN, FILE_OUT);
SetBits(ExeStruct^.Mode[X], 0, 0, 1); SetBits(ExeStruct.Mode[X], 0, 0, 1);
if ContainsText(S2, '<filein>') then if ContainsText(S2, '<filein>') then
ExeStruct^.InFile[X] := ExtractStr('<filein>', S2) ExeStruct.InFile[X] := ExtractStr('<filein>', S2)
else else
ExeStruct^.InFile[X] := ExtractStr('[filein]', S2); ExeStruct.InFile[X] := ExtractStr('[filein]', S2);
S2 := ReplaceText(S2, ExeStruct^.InFile[X], S3); S2 := ReplaceText(S2, ExeStruct.InFile[X], S3);
ExeStruct^.InFile[X] := ReplaceText(ExeStruct^.InFile[X], ExeStruct.InFile[X] := ReplaceText(ExeStruct.InFile[X],
'<filein>', S3); '<filein>', S3);
ExeStruct^.InFile[X] := ReplaceText(ExeStruct^.InFile[X], ExeStruct.InFile[X] := ReplaceText(ExeStruct.InFile[X],
'[filein]', S3); '[filein]', S3);
S2 := ExeStruct.InFile[X];
if ContainsText(S2, '[filein]') then
continue;
end end
else if ContainsText(S2, '<fileout>') or else if ContainsText(S2, '<fileout>') or
ContainsText(S2, '[fileout]') then ContainsText(S2, '[fileout]') then
begin begin
S3 := IfThen(X = 0, FILE_OUT, FILE_IN); S3 := IfThen(X = 0, FILE_OUT, FILE_IN);
SetBits(ExeStruct^.Mode[X], 0, 1, 1); SetBits(ExeStruct.Mode[X], 0, 1, 1);
if ContainsText(S2, '<fileout>') then if ContainsText(S2, '<fileout>') then
ExeStruct^.OutFile[X] := ExtractStr('<fileout>', S2) ExeStruct.OutFile[X] := ExtractStr('<fileout>', S2)
else else
ExeStruct^.OutFile[X] := ExtractStr('[fileout]', S2); ExeStruct.OutFile[X] := ExtractStr('[fileout]', S2);
S2 := ReplaceText(S2, ExeStruct^.OutFile[X], S3); ExeStruct.OutFile[X] := ReplaceText(ExeStruct.OutFile[X],
ExeStruct^.OutFile[X] := ReplaceText(ExeStruct^.OutFile[X],
'<fileout>', S3); '<fileout>', S3);
ExeStruct^.OutFile[X] := ReplaceText(ExeStruct^.OutFile[X], ExeStruct.OutFile[X] := ReplaceText(ExeStruct.OutFile[X],
'[fileout]', S3); '[fileout]', S3);
S2 := ExeStruct.OutFile[X];
if ContainsText(S2, '[fileout]') then
continue;
end; end;
S2 := IfThen((Pos(' ', S2) > 0) or (S2 = ''), '"' + S2 + '"', S2); S2 := IfThen((Pos(' ', S2) > 0) or (S2 = ''), '"' + S2 + '"', S2);
ExeStruct^.Param[X] := ExeStruct^.Param[X] + ' ' + S2; ExeStruct.Param[X] := ExeStruct.Param[X] + ' ' + S2;
end; end;
ExeStruct^.Param[X] := Trim(ExeStruct^.Param[X]); ExeStruct.Param[X] := Trim(ExeStruct.Param[X]);
end; end;
Insert(ExeStruct^, CodecExe, Length(CodecExe)); Insert(ExeStruct, CodecExe, Length(CodecExe));
end; end;
end; end;
SL.Free; SL.Free;

View File

@ -3,9 +3,11 @@ unit PrecompLZ4;
interface interface
uses uses
LZ4DLL, XDeltaDLL, LZ4DLL,
lz4,
Utils, Utils,
PrecompUtils, PrecompUtils,
WinAPI.Windows,
System.SysUtils, System.StrUtils, System.Classes, System.Math; System.SysUtils, System.StrUtils, System.Classes, System.Math;
var var
@ -163,7 +165,8 @@ procedure LZ4Scan1(Instance, Depth: Integer; Input: PByte;
Funcs: PPrecompFuncs); Funcs: PPrecompFuncs);
var var
Buffer: PByte; Buffer: PByte;
X, Y: Integer; Pos: NativeInt;
X, Y, Z: Integer;
SI: _StrInfo1; SI: _StrInfo1;
DI1, DI2: TDepthInfo; DI1, DI2: TDepthInfo;
DS: TPrecompStr; DS: TPrecompStr;
@ -173,8 +176,10 @@ begin
if DS <> '' then if DS <> '' then
begin begin
X := IndexTextW(@DS[0], LZ4Codecs); X := IndexTextW(@DS[0], LZ4Codecs);
if (X < 0) or (DI1.OldSize <> SizeEx) then if X < 0 then
exit; exit;
if DI1.OldSize = 0 then
DI1.OldSize := SizeEx;
if not CodecAvailable[X] then if not CodecAvailable[X] then
exit; exit;
Y := Max(DI1.NewSize, L_MAXSIZE); Y := Max(DI1.NewSize, L_MAXSIZE);
@ -212,6 +217,71 @@ begin
end; end;
if BoolArray(CodecEnabled, False) then if BoolArray(CodecEnabled, False) then
exit; exit;
Buffer := Funcs^.Allocator(Instance, L_MAXSIZE);
Pos := 0;
while Pos < Size do
begin
if CodecEnabled[LZ4_CODEC] or
(CodecEnabled[LZ4HC_CODEC] and (SOList[Instance][LZ4HC_CODEC].Count = 1))
then
begin
Y := LZ4_decompress_safe(Input + Pos, Buffer, SizeEx - Pos, L_MAXSIZE);
if Abs(Y) > 256 then
begin
try
X := LZ4_decompress_generic(Input + Pos, Buffer, SizeEx - Pos, Abs(Y),
Integer(endOnOutputSize));
except
X := 0;
end;
// X := Abs(X);
Y := Abs(Y);
if (Round(X * 1.4) < Y) and (X < Y) and (X > 256) then
begin
Output(Instance, Buffer, Y);
SI.Position := Pos;
SI.OldSize := X;
SI.NewSize := Y;
SI.Option := 0;
if CodecEnabled[LZ4_CODEC] then
SetBits(SI.Option, LZ4_CODEC, 0, 5)
else
SetBits(SI.Option, LZ4HC_CODEC, 0, 5);
SI.Status := TStreamStatus.None;
Funcs^.LogScan1(LZ4Codecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize);
Add(Instance, @SI, nil, nil);
Inc(Pos, 256);
continue;
end;
end;
end;
if CodecEnabled[LZ4F_CODEC] then
if PCardinal(Input + Pos)^ = $184D2204 then
begin
Y := LZ4F_decompress_safe(Input + Pos, Buffer, SizeEx - Pos,
L_MAXSIZE, @X, @Z);
if (X < Y) then
begin
Output(Instance, Buffer, Y);
SI.Position := Pos;
SI.OldSize := X;
SI.NewSize := Y;
SI.Option := 0;
SetBits(SI.Option, LZ4F_CODEC, 0, 5);
SetBits(SI.Option, Z - 4, 12, 2);
SetBits(SI.Option, 0, 14, 1);
SetBits(SI.Option, LAcceleration, 15, 7);
SI.Status := TStreamStatus.None;
Funcs^.LogScan1(LZ4Codecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize);
Add(Instance, @SI, nil, nil);
Inc(Pos, SI.OldSize);
continue;
end;
end;
Inc(Pos);
end;
end; end;
function LZ4Scan2(Instance, Depth: Integer; Input: Pointer; Size: NativeInt; function LZ4Scan2(Instance, Depth: Integer; Input: Pointer; Size: NativeInt;
@ -271,7 +341,7 @@ begin
if GetBits(StreamInfo^.Option, 5, 7) <> I then if GetBits(StreamInfo^.Option, 5, 7) <> I then
continue; continue;
if (StreamInfo^.Status = TStreamStatus.Database) and if (StreamInfo^.Status = TStreamStatus.Database) and
(GetBits(StreamInfo^.Option, 1, 31) = 0) then (GetBits(StreamInfo^.Option, 31, 1) = 0) then
begin begin
Res1 := StreamInfo^.OldSize; Res1 := StreamInfo^.OldSize;
Result := True; Result := True;
@ -283,6 +353,8 @@ begin
begin begin
Params := 'a' + GetBits(StreamInfo^.Option, 15, 7).ToString; Params := 'a' + GetBits(StreamInfo^.Option, 15, 7).ToString;
if not Result then if not Result then
{ Res1 := LZ4_compress_block(NewInput, Buffer,
StreamInfo^.NewSize, Y); }
Res1 := LZ4_compress_fast(NewInput, Buffer, StreamInfo^.NewSize, Y, Res1 := LZ4_compress_fast(NewInput, Buffer, StreamInfo^.NewSize, Y,
GetBits(StreamInfo^.Option, 15, 7)); GetBits(StreamInfo^.Option, 15, 7));
end; end;
@ -314,7 +386,7 @@ begin
StreamInfo^.OldSize); StreamInfo^.OldSize);
Funcs^.LogProcess(LZ4Codecs[GetBits(StreamInfo^.Option, 0, 5)], Funcs^.LogProcess(LZ4Codecs[GetBits(StreamInfo^.Option, 0, 5)],
PChar(Params), StreamInfo^.OldSize, StreamInfo^.NewSize, Res1, Result); PChar(Params), StreamInfo^.OldSize, StreamInfo^.NewSize, Res1, Result);
if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then if Result or (StreamInfo^.Status >= TStreamStatus.Predicted) then
break; break;
end; end;
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or

View File

@ -3,7 +3,7 @@ unit PrecompLZO;
interface interface
uses uses
LZODLL, XDeltaDLL, LZODLL,
Utils, Utils,
PrecompUtils, PrecompUtils,
System.SysUtils, System.Classes, System.Math; System.SysUtils, System.Classes, System.Math;
@ -14,19 +14,25 @@ var
implementation implementation
const const
LZOCodecs: array of PChar = ['lzo1x']; LZOCodecs: array of PChar = ['lzo1x', 'lzo2a', 'lzo1c'];
CODEC_COUNT = 1; CODEC_COUNT = 3;
LZO1X_CODEC = 0; LZO1X_CODEC = 0;
LZO2A_CODEC = 1;
LZO1C_CODEC = 2;
const const
L_WORKMEM = 524288; L_WORKMEM = 524288;
L_MAXSIZE = 16 * 1024 * 1024; L_MAXSIZE = 16 * 1024 * 1024;
LZO1X_999 = 0; LZO1X_999 = 999;
LZO2A_999 = 999;
LZO1C_999 = 999;
var var
SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList; SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList;
WrkMem: array of array [0 .. L_WORKMEM - 1] of Byte; WrkMem: array of array [0 .. L_WORKMEM - 1] of Byte;
LZO1XVariant: Integer = LZO1X_999; LZO1XVariant: Integer = LZO1X_999;
LZO2AVariant: Integer = LZO2A_999;
LZO1CVariant: Integer = LZO1C_999;
CodecAvailable, CodecEnabled: TArray<Boolean>; CodecAvailable, CodecEnabled: TArray<Boolean>;
type type
@ -39,7 +45,7 @@ type
var var
LZOSB: array of Byte = [$11, $00, $00]; LZOSB: array of Byte = [$11, $00, $00];
function GetLZOSI(InBuff: Pointer; InSize: Integer; OutBuff: Pointer; function GetLZO1XSI(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
OutSize: Integer; StreamInfo: PLZOSI): Boolean; OutSize: Integer; StreamInfo: PLZOSI): Boolean;
const const
MinSize = 256; MinSize = 256;
@ -123,11 +129,25 @@ begin
begin begin
CodecEnabled[LZO1X_CODEC] := True; CodecEnabled[LZO1X_CODEC] := True;
if Funcs^.GetParam(Command, X, 'v') = '999' then if Funcs^.GetParam(Command, X, 'v') = '999' then
LZO1XVariant := 0; LZO1XVariant := 999;
if Funcs^.GetParam(Command, X, 'l') <> '' then if Funcs^.GetParam(Command, X, 'l') <> '' then
for I := Low(SOList) to High(SOList) do for I := Low(SOList) to High(SOList) do
SOList[I][LZO1X_CODEC].Update SOList[I][LZO1X_CODEC].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
end
else if (CompareText(S, LZOCodecs[LZO2A_CODEC]) = 0) and LZODLL.DLLLoaded
then
begin
CodecEnabled[LZO2A_CODEC] := True;
if Funcs^.GetParam(Command, X, 'v') = '999' then
LZO2AVariant := 999;
end
else if (CompareText(S, LZOCodecs[LZO1C_CODEC]) = 0) and LZODLL.DLLLoaded
then
begin
CodecEnabled[LZO1C_CODEC] := True;
if Funcs^.GetParam(Command, X, 'v') = '999' then
LZO1CVariant := 999;
end; end;
Inc(X); Inc(X);
end; end;
@ -135,9 +155,14 @@ begin
for I := 1 to 9 do for I := 1 to 9 do
Insert(I, Options, Length(Options)); Insert(I, Options, Length(Options));
for X := Low(SOList) to High(SOList) do for X := Low(SOList) to High(SOList) do
for Y := Low(SOList[X]) to High(SOList[X]) do if SOList[X, LZO1X_CODEC].Count = 0 then
if SOList[X, Y].Count = 0 then SOList[X, LZO1X_CODEC].Update(Options);
SOList[X, Y].Update(Options); for X := Low(SOList) to High(SOList) do
if SOList[X, LZO2A_CODEC].Count = 0 then
SOList[X, LZO2A_CODEC].Update([1]);
for X := Low(SOList) to High(SOList) do
if SOList[X, LZO1C_CODEC].Count = 0 then
SOList[X, LZO1C_CODEC].Update([1]);
end; end;
procedure LZOFree(Funcs: PPrecompFuncs); procedure LZOFree(Funcs: PPrecompFuncs);
@ -164,11 +189,29 @@ begin
if (CompareText(S, LZOCodecs[LZO1X_CODEC]) = 0) and LZODLL.DLLLoaded then if (CompareText(S, LZOCodecs[LZO1X_CODEC]) = 0) and LZODLL.DLLLoaded then
begin begin
SetBits(Option^, LZO1X_CODEC, 0, 5); SetBits(Option^, LZO1X_CODEC, 0, 5);
SetBits(Option^, LZO1XVariant, 12, 5); SetBits(Option^, LZO1XVariant, 12, 12);
if Funcs^.GetParam(Command, I, 'l') <> '' then if Funcs^.GetParam(Command, I, 'l') <> '' then
SetBits(Option^, StrToInt(Funcs^.GetParam(Command, I, 'l')), 5, 7); SetBits(Option^, StrToInt(Funcs^.GetParam(Command, I, 'l')), 5, 7);
if Funcs^.GetParam(Command, I, 'v') = '999' then if Funcs^.GetParam(Command, I, 'v') = '999' then
SetBits(Option^, 0, 12, 5); SetBits(Option^, 999, 12, 12);
Result := True;
end
else if (CompareText(S, LZOCodecs[LZO2A_CODEC]) = 0) and LZODLL.DLLLoaded
then
begin
SetBits(Option^, LZO2A_CODEC, 0, 5);
SetBits(Option^, LZO2AVariant, 12, 12);
if Funcs^.GetParam(Command, I, 'v') = '999' then
SetBits(Option^, 999, 12, 12);
Result := True;
end
else if (CompareText(S, LZOCodecs[LZO1C_CODEC]) = 0) and LZODLL.DLLLoaded
then
begin
SetBits(Option^, LZO1C_CODEC, 0, 5);
SetBits(Option^, LZO1CVariant, 12, 12);
if Funcs^.GetParam(Command, I, 'v') = '999' then
SetBits(Option^, 999, 12, 12);
Result := True; Result := True;
end; end;
Inc(I); Inc(I);
@ -203,6 +246,12 @@ begin
LZO1X_CODEC: LZO1X_CODEC:
if not lzo1x_decompress_safe(Input, DI1.OldSize, Buffer, @Res) = 0 then if not lzo1x_decompress_safe(Input, DI1.OldSize, Buffer, @Res) = 0 then
Res := 0; Res := 0;
LZO2A_CODEC:
if not lzo2a_decompress_safe(Input, DI1.OldSize, Buffer, @Res) = 0 then
Res := 0;
LZO1C_CODEC:
if not lzo1c_decompress_safe(Input, DI1.OldSize, Buffer, @Res) = 0 then
Res := 0;
end; end;
if (Res > DI1.OldSize) then if (Res > DI1.OldSize) then
begin begin
@ -212,6 +261,14 @@ begin
SI.NewSize := Res; SI.NewSize := Res;
SI.Option := 0; SI.Option := 0;
SetBits(SI.Option, X, 0, 5); SetBits(SI.Option, X, 0, 5);
case X of
LZO1X_CODEC:
SetBits(SI.Option, LZO1XVariant, 12, 12);
LZO2A_CODEC:
SetBits(SI.Option, LZO2AVariant, 12, 12);
LZO1C_CODEC:
SetBits(SI.Option, LZO1CVariant, 12, 12);
end;
if System.Pos(SPrecompSep2, DI1.Codec) > 0 then if System.Pos(SPrecompSep2, DI1.Codec) > 0 then
SI.Status := TStreamStatus.Predicted SI.Status := TStreamStatus.Predicted
else else
@ -232,13 +289,15 @@ begin
Pos := 0; Pos := 0;
while Pos < Size do while Pos < Size do
begin begin
if GetLZOSI(Input + Pos, SizeEx - Pos, Buffer, L_MAXSIZE, @LZOSI) then if GetLZO1XSI(Input + Pos, SizeEx - Pos, Buffer, L_MAXSIZE, @LZOSI) then
begin begin
Output(Instance, Buffer, LZOSI.DSize); Output(Instance, Buffer, LZOSI.DSize);
SI.Position := Pos; SI.Position := Pos;
SI.OldSize := LZOSI.CSize; SI.OldSize := LZOSI.CSize;
SI.NewSize := LZOSI.DSize; SI.NewSize := LZOSI.DSize;
SI.Option := 0; SI.Option := 0;
SetBits(SI.Option, LZO1X_CODEC, 0, 5);
SetBits(SI.Option, LZO1XVariant, 12, 12);
SI.Status := TStreamStatus.None; SI.Status := TStreamStatus.None;
Funcs^.LogScan1(LZOCodecs[GetBits(SI.Option, 0, 5)], SI.Position, Funcs^.LogScan1(LZOCodecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize); SI.OldSize, SI.NewSize);
@ -269,6 +328,14 @@ begin
if not lzo1x_decompress_safe(Input, StreamInfo^.OldSize, Buffer, @Res) = 0 if not lzo1x_decompress_safe(Input, StreamInfo^.OldSize, Buffer, @Res) = 0
then then
Res := 0; Res := 0;
LZO2A_CODEC:
if not lzo2a_decompress_safe(Input, StreamInfo^.OldSize, Buffer, @Res) = 0
then
Res := 0;
LZO1C_CODEC:
if not lzo1c_decompress_safe(Input, StreamInfo^.OldSize, Buffer, @Res) = 0
then
Res := 0;
end; end;
if Res > StreamInfo^.OldSize then if Res > StreamInfo^.OldSize then
begin begin
@ -303,7 +370,7 @@ begin
if GetBits(StreamInfo^.Option, 5, 7) <> I then if GetBits(StreamInfo^.Option, 5, 7) <> I then
continue; continue;
if (StreamInfo^.Status = TStreamStatus.Database) and if (StreamInfo^.Status = TStreamStatus.Database) and
(GetBits(StreamInfo^.Option, 1, 31) = 0) then (GetBits(StreamInfo^.Option, 31, 1) = 0) then
begin begin
Res1 := StreamInfo^.OldSize; Res1 := StreamInfo^.OldSize;
Result := True; Result := True;
@ -313,19 +380,38 @@ begin
Res1 := StreamInfo^.NewSize; Res1 := StreamInfo^.NewSize;
case X of case X of
LZO1X_CODEC: LZO1X_CODEC:
case GetBits(StreamInfo^.Option, 12, 5) of case GetBits(StreamInfo^.Option, 12, 12) of
LZO1X_999: LZO1X_999:
begin begin
Params := 'l' + I.ToString + ':' + 'v' + Params := 'l' + I.ToString + ':' + 'v' +
GetBits(StreamInfo^.Option, 12, 5).ToString; GetBits(StreamInfo^.Option, 12, 12).ToString;
if not Result then if not Result then
if not lzo1x_999_compress_level(NewInput, StreamInfo^.NewSize, if not lzo1x_999_compress_level(NewInput, StreamInfo^.NewSize,
Buffer, @Res1, @WrkMem[Instance, 0], nil, 0, nil, I) = 0 then Buffer, @Res1, @WrkMem[Instance, 0], nil, 0, nil, I) = 0 then
Res1 := 0; Res1 := 0;
end; end;
{ if not lzo1x_1_compress(NewInput, StreamInfo^.NewSize, Buffer, end;
LZO2A_CODEC:
case GetBits(StreamInfo^.Option, 12, 12) of
LZO2A_999:
begin
Params := 'v' + GetBits(StreamInfo^.Option, 12, 12).ToString;
if not Result then
if not lzo2a_999_compress(NewInput, StreamInfo^.NewSize, Buffer,
@Res1, @WrkMem[Instance, 0]) = 0 then @Res1, @WrkMem[Instance, 0]) = 0 then
Res1 := 0; } Res1 := 0;
end;
end;
LZO1C_CODEC:
case GetBits(StreamInfo^.Option, 12, 12) of
LZO1C_999:
begin
Params := 'v' + GetBits(StreamInfo^.Option, 12, 12).ToString;
if not Result then
if not lzo1c_999_compress(NewInput, StreamInfo^.NewSize, Buffer,
@Res1, @WrkMem[Instance, 0]) = 0 then
Res1 := 0;
end;
end; end;
end; end;
if not Result then if not Result then
@ -333,10 +419,10 @@ begin
StreamInfo^.OldSize); StreamInfo^.OldSize);
Funcs^.LogProcess(LZOCodecs[GetBits(StreamInfo^.Option, 0, 5)], Funcs^.LogProcess(LZOCodecs[GetBits(StreamInfo^.Option, 0, 5)],
PChar(Params), StreamInfo^.OldSize, StreamInfo^.NewSize, Res1, Result); PChar(Params), StreamInfo^.OldSize, StreamInfo^.NewSize, Res1, Result);
if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then if Result or (StreamInfo^.Status >= TStreamStatus.Predicted) then
break; break;
end; end;
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or { if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or
(SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then (SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
begin begin
Buffer := Funcs^.Allocator(Instance, Res1 + Max(StreamInfo^.OldSize, Res1)); Buffer := Funcs^.Allocator(Instance, Res1 + Max(StreamInfo^.OldSize, Res1));
@ -351,7 +437,7 @@ begin
SOList[Instance][X].Add(I); SOList[Instance][X].Add(I);
Result := True; Result := True;
end; end;
end; end; }
if Result then if Result then
begin begin
SetBits(StreamInfo^.Option, I, 5, 7); SetBits(StreamInfo^.Option, I, 5, 7);
@ -377,17 +463,37 @@ begin
Res1 := StreamInfo.NewSize; Res1 := StreamInfo.NewSize;
case X of case X of
LZO1X_CODEC: LZO1X_CODEC:
case GetBits(StreamInfo.Option, 12, 5) of case GetBits(StreamInfo.Option, 12, 12) of
LZO1X_999: LZO1X_999:
begin begin
Params := 'l' + GetBits(StreamInfo.Option, 5, 7).ToString + ':' + Params := 'l' + GetBits(StreamInfo.Option, 5, 7).ToString + ':' +
'v' + GetBits(StreamInfo.Option, 12, 5).ToString; 'v' + GetBits(StreamInfo.Option, 12, 12).ToString;
if not lzo1x_999_compress_level(Input, StreamInfo.NewSize, Buffer, if not lzo1x_999_compress_level(Input, StreamInfo.NewSize, Buffer,
@Res1, @WrkMem[Instance, 0], nil, 0, nil, @Res1, @WrkMem[Instance, 0], nil, 0, nil,
GetBits(StreamInfo.Option, 5, 7)) = 0 then GetBits(StreamInfo.Option, 5, 7)) = 0 then
Res1 := 0; Res1 := 0;
end; end;
end; end;
LZO2A_CODEC:
case GetBits(StreamInfo.Option, 12, 12) of
LZO2A_999:
begin
Params := 'v' + GetBits(StreamInfo.Option, 12, 12).ToString;
if not lzo2a_999_compress(Input, StreamInfo.NewSize, Buffer, @Res1,
@WrkMem[Instance, 0]) = 0 then
Res1 := 0;
end;
end;
LZO1C_CODEC:
case GetBits(StreamInfo.Option, 12, 12) of
LZO1C_999:
begin
Params := 'v' + GetBits(StreamInfo.Option, 12, 12).ToString;
if not lzo2a_999_compress(Input, StreamInfo.NewSize, Buffer, @Res1,
@WrkMem[Instance, 0]) = 0 then
Res1 := 0;
end;
end;
end; end;
Funcs^.LogRestore(LZOCodecs[GetBits(StreamInfo.Option, 0, 5)], PChar(Params), Funcs^.LogRestore(LZOCodecs[GetBits(StreamInfo.Option, 0, 5)], PChar(Params),
StreamInfo.OldSize, StreamInfo.NewSize, Res1, True); StreamInfo.OldSize, StreamInfo.NewSize, Res1, True);

View File

@ -104,7 +104,7 @@ var
DBFile: String = ''; DBFile: String = '';
ExtDir: String = ''; ExtDir: String = '';
UseDB: Boolean = False; UseDB: Boolean = False;
StoreDD: Boolean = False; StoreDD: Integer = -2;
VERBOSE: Boolean = False; VERBOSE: Boolean = False;
EXTRACT: Boolean = False; EXTRACT: Boolean = False;
DupSysMem: Int64 = 0; DupSysMem: Int64 = 0;
@ -183,26 +183,31 @@ begin
S := ReplaceText(S, 'p', '%'); S := ReplaceText(S, 'p', '%');
S := ReplaceText(S, '%', '%*' + CPUCount.ToString); S := ReplaceText(S, '%', '%*' + CPUCount.ToString);
Options.Threads := Max(1, Round(ExpParse.Evaluate(S))); Options.Threads := Max(1, Round(ExpParse.Evaluate(S)));
Options.Depth := EnsureRange(Succ(ArgParse.AsInteger('-d')), 1, 10); Options.Depth := EnsureRange(Succ(ArgParse.AsInteger('-d', 0, 0)), 1, 10);
Options.LowMem := ArgParse.AsBoolean('-lm'); Options.LowMem := ArgParse.AsBoolean('-lm');
UseDB := ArgParse.AsBoolean('--dbase'); UseDB := ArgParse.AsBoolean('-db') or ArgParse.AsBoolean('--dbase');
Options.DBaseFile := ArgParse.AsString('--dbase='); Options.DBaseFile := ArgParse.AsString('--dbase=');
if Options.DBaseFile <> '' then if Options.DBaseFile <> '' then
UseDB := True; UseDB := True;
StoreDD := ArgParse.AsBoolean('--dedup'); StoreDD := -2;
if ArgParse.AsBoolean('-dd') or ArgParse.AsBoolean('--dedup') then
StoreDD := -1;
if FileExists(ExtractFilePath(Utils.GetModuleName) + 'srep.exe') then
StoreDD := ArgParse.AsInteger('--dedup=', 0, StoreDD);
S := ArgParse.AsString('--diff=', 0, '5p'); S := ArgParse.AsString('--diff=', 0, '5p');
S := ReplaceText(S, 'p', '%'); S := ReplaceText(S, 'p', '%');
DIFF_TOLERANCE := Max(0.00, ExpParse.Evaluate(S)); DIFF_TOLERANCE := Max(0.00, ExpParse.Evaluate(S));
VERBOSE := ArgParse.AsBoolean('--verbose'); VERBOSE := ArgParse.AsBoolean('-v') or ArgParse.AsBoolean('--verbose');
Options.ExtractDir := ArgParse.AsString('--extract='); Options.ExtractDir := ArgParse.AsString('--extract=');
if Options.ExtractDir <> '' then if Options.ExtractDir <> '' then
EXTRACT := DirectoryExists(Options.ExtractDir); EXTRACT := DirectoryExists(Options.ExtractDir);
Options.DoCompress := ArgParse.AsBoolean('--compress'); Options.DoCompress := ArgParse.AsBoolean('--compress') and
FLZMA2DLL.DLLLoaded;
S := ArgParse.AsString('--compress='); S := ArgParse.AsString('--compress=');
S := ReplaceText(S, SPrecompSep3, SPrecompSep2); S := ReplaceText(S, SPrecompSep3, SPrecompSep2);
Options.CompressCfg := S; Options.CompressCfg := S;
if Options.CompressCfg <> '' then if Options.CompressCfg <> '' then
Options.DoCompress := True; Options.DoCompress := FLZMA2DLL.DLLLoaded;
finally finally
ArgParse.Free; ArgParse.Free;
ExpParse.Free; ExpParse.Free;
@ -1191,7 +1196,7 @@ begin
for I := Low(DBInfo) to High(DBInfo) do for I := Low(DBInfo) to High(DBInfo) do
DBCount[I] := 0; DBCount[I] := 0;
end; end;
if StoreDD then if StoreDD > -2 then
begin begin
SetLength(DDInfo, $10000); SetLength(DDInfo, $10000);
SetLength(DDCount1, $10000); SetLength(DDCount1, $10000);
@ -1409,6 +1414,7 @@ var
BlockSize: Int64; BlockSize: Int64;
UI32: UInt32; UI32: UInt32;
I, J, K, X: Integer; I, J, K, X: Integer;
S: String;
W: Word; W: Word;
I64: Int64; I64: Int64;
LastStream, LastPos: Int64; LastStream, LastPos: Int64;
@ -1420,8 +1426,11 @@ var
begin begin
if (Depth = 0) then if (Depth = 0) then
begin begin
if StoreDD then if StoreDD > -2 then
TempOutput := TPrecompVMStream.Create TempOutput := TBufferedStream.Create
(TFileStream.Create
(LowerCase(ChangeFileExt(ExtractFileName(Utils.GetModuleName),
'-dd.tmp')), fmCreate or fmShareDenyNone), False, 4194304)
else else
TempOutput := Output; TempOutput := Output;
end end
@ -1525,7 +1534,7 @@ begin
begin begin
Inc(StreamCount); Inc(StreamCount);
DupBool := False; DupBool := False;
if (Depth = 0) and StoreDD then if (Depth = 0) and (StoreDD > -2) then
DupBool := not FindOrAddDD(StreamInfo, @DupIdx2, @DupCount); DupBool := not FindOrAddDD(StreamInfo, @DupIdx2, @DupCount);
if DupBool then if DupBool then
begin begin
@ -1580,7 +1589,7 @@ begin
while J >= 0 do while J >= 0 do
begin begin
DupBool := False; DupBool := False;
if (Depth = 0) and StoreDD then if (Depth = 0) and (StoreDD > -2) then
DupBool := FindDD(StreamInfo, @DupIdx2, @DupCount); DupBool := FindDD(StreamInfo, @DupIdx2, @DupCount);
if (DupBool = False) or (DupIdx1 = DupIdx2) then if (DupBool = False) or (DupIdx1 = DupIdx2) then
begin begin
@ -1663,9 +1672,9 @@ begin
with WorkStream[0] do with WorkStream[0] do
begin begin
Position := 0; Position := 0;
for W := 0 to $10000 - 1 do for W := Low(DBInfo) to High(DBInfo) do
begin begin
J := DBCount[I]; J := DBCount[W];
if J > 0 then if J > 0 then
begin begin
WriteBuffer(W, W.Size); WriteBuffer(W, W.Size);
@ -1682,7 +1691,7 @@ begin
Free; Free;
end; end;
end; end;
if StoreDD then if StoreDD > -2 then
begin begin
with WorkStream[0] do with WorkStream[0] do
begin begin
@ -1703,8 +1712,36 @@ begin
end; end;
Output.WriteBuffer(UI32, UI32.Size); Output.WriteBuffer(UI32, UI32.Size);
Output.WriteBuffer(WorkStream[0].Memory^, WorkStream[0].Position); Output.WriteBuffer(WorkStream[0].Memory^, WorkStream[0].Position);
try
EncFree;
finally
end;
S := TFileStream(TBufferedStream(TempOutput).Instance).Filename;
TBufferedStream(TempOutput).Flush;
if StoreDD >= 0 then
begin
with TProcessStream.Create(ExtractFilePath(Utils.GetModuleName) +
'srep.exe', '-m' + StoreDD.ToString + 'f ' + S + ' -', GetCurrentDir,
nil, Output) do
try
if Execute then
begin
Wait;
Done;
end;
finally
Free;
end;
end
else
Output.CopyFrom(TempOutput, 0); Output.CopyFrom(TempOutput, 0);
TempOutput.Free; TempOutput.Free;
DeleteFile(S);
end
else
try
EncFree;
finally
end; end;
end; end;
end; end;
@ -1776,7 +1813,7 @@ procedure PrecompOutput2(Instance: Integer; const Buffer: Pointer;
begin begin
with ComVars2[CurDepth[Instance]] do with ComVars2[CurDepth[Instance]] do
DecOutput[Instance].WriteBuffer(Buffer^, Size); DecOutput[Instance].WriteBuffer(Buffer^, Size);
if StoreDD and (CurDepth[Instance] = 0) then if (StoreDD > -2) and (CurDepth[Instance] = 0) then
if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index)) then if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index)) then
DataMgr.Write(DDIndex1, Buffer, Size); DataMgr.Write(DDIndex1, Buffer, Size);
end; end;
@ -1821,7 +1858,7 @@ begin
end end
else else
begin begin
if StoreDD and (Depth = 0) then if (StoreDD > -2) and (Depth = 0) then
begin begin
Inc(DDIndex1); Inc(DDIndex1);
if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index)) if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index))
@ -1886,7 +1923,7 @@ begin
end end
else else
begin begin
if StoreDD and (Depth = 0) then if (StoreDD > -2) and (Depth = 0) then
if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index)) if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index))
then then
Inc(DDIndex2); Inc(DDIndex2);
@ -2039,11 +2076,12 @@ var
CurrPos: Int64; CurrPos: Int64;
UI32: UInt32; UI32: UInt32;
I, J: Integer; I, J: Integer;
LStream: TProcessStream;
begin begin
if Depth = 0 then if Depth = 0 then
begin begin
UI32 := 0; UI32 := 0;
if StoreDD then if (StoreDD > -2) then
begin begin
Input.ReadBuffer(UI32, UI32.Size); Input.ReadBuffer(UI32, UI32.Size);
SetLength(DDList2, UI32); SetLength(DDList2, UI32);
@ -2057,6 +2095,15 @@ begin
end; end;
with ComVars2[Depth] do with ComVars2[Depth] do
begin begin
if (Depth = 0) and (StoreDD >= 0) then
begin
LStream := TProcessStream.Create(ExtractFilePath(Utils.GetModuleName) +
'srep.exe', '-d -s - -', GetCurrentDir, Input, nil);
if not LStream.Execute then
raise EReadError.CreateRes(@SReadError);
DecInput[Index] := TBufferedStream.Create(LStream, True, 4194304);
end
else
DecInput[Index] := Input; DecInput[Index] := Input;
DecOutput[Index] := Output; DecOutput[Index] := Output;
DecInput[Index].ReadBuffer(StreamCount[Index]^, StreamCount[Index]^.Size); DecInput[Index].ReadBuffer(StreamCount[Index]^, StreamCount[Index]^.Size);
@ -2137,7 +2184,7 @@ begin
if IsErrored(Tasks) then if IsErrored(Tasks) then
for I := Low(Tasks) to High(Tasks) do for I := Low(Tasks) to High(Tasks) do
Tasks[I].RaiseLastError; Tasks[I].RaiseLastError;
if StoreDD and (Depth = 0) then if (StoreDD > -2) and (Depth = 0) then
begin begin
Inc(DDIndex1); Inc(DDIndex1);
if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index)) if ((DDIndex2 < DDCount2) and (DDIndex1 = DDList2[DDIndex2].Index))
@ -2168,6 +2215,15 @@ begin
CopyStreamEx(DecInput[Index], DecOutput[Index], UI32); CopyStreamEx(DecInput[Index], DecOutput[Index], UI32);
DecInput[Index].ReadBuffer(StreamCount[Index]^, StreamCount[Index]^.Size); DecInput[Index].ReadBuffer(StreamCount[Index]^, StreamCount[Index]^.Size);
end; end;
if (Depth = 0) and (StoreDD >= 0) then
begin
with LStream do
begin
Wait;
Done;
end;
DecInput[Index].Free;
end;
end; end;
end; end;
@ -2294,7 +2350,7 @@ begin
if Options.DoCompress then if Options.DoCompress then
LOutput.Free; LOutput.Free;
try try
EncFree; // EncFree;
finally finally
Stopwatch.Stop; Stopwatch.Stop;
end; end;

View File

@ -5,7 +5,7 @@ unit PrecompMedia;
interface interface
uses uses
BrunsliDLL, FLACDLL, PackJPGDLL, JoJpegDLL, XDeltaDLL, BrunsliDLL, FLACDLL, PackJPGDLL, JoJpegDLL,
Utils, Utils,
PrecompUtils, PrecompUtils,
System.SysUtils, System.Classes, System.Math; System.SysUtils, System.Classes, System.Math;

View File

@ -3,26 +3,11 @@ unit PrecompOodle;
interface interface
uses uses
OodleDLL, XDeltaDLL, OodleDLL,
Utils, Utils,
PrecompUtils, PrecompUtils,
System.SysUtils, System.Classes, System.Types, System.Math; System.SysUtils, System.Classes, System.Types, System.Math;
{ 8C 07 - 0:LZH
8C 00 - 1:LZHLW
8C 01 - 2:LZNIB
CC 07 - 3:None
8C 02 - 4:LZB16
8C 03 - 5:LZBLW
8C 04 - 6:LZA
8C 05 - 7:LZNA
8C 06 - 8:Kraken
8C 0A - 9:Mermaid
8C 0B - 10:BitKnit
8C 0A - 11:Selkie
8C 0A - 12:Hydra
8C 0C - 13:Leviathan }
var var
Codec: TPrecompressor; Codec: TPrecompressor;
@ -40,13 +25,13 @@ const
LEVIATHAN_CODEC = 5; LEVIATHAN_CODEC = 5;
const const
O_COUNT = 0; O_LENGTH = 32;
O_TRADEOFF = 256; O_TRADEOFF = 256;
O_MAXSIZE = 16 * 1024 * 1024; O_MAXSIZE = 16 * 1024 * 1024;
var var
SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList; SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList;
OCount: Integer = O_COUNT; OLength: Integer = O_LENGTH;
OTradeOff: Integer = O_TRADEOFF; OTradeOff: Integer = O_TRADEOFF;
CodecAvailable, CodecEnabled: TArray<Boolean>; CodecAvailable, CodecEnabled: TArray<Boolean>;
@ -247,135 +232,36 @@ begin
Result := A; Result := A;
end; end;
function CustomLZ_Decompress0(src, dst: PByte; srcSize, dstCapacity: Integer; function CustomLZ_Decompress(src, dst: PByte; srcSize, dstCapacity: Integer;
var Res: Integer): Boolean; var Res: Integer): Boolean;
type
T3Res = array [0 .. 2] of Integer;
procedure AddRes(const I: Integer; var Res: T3Res);
begin
Res[0] := Res[1];
Res[1] := Res[2];
Res[2] := I;
end;
const const
MinSize = 64;
BlkSize = 262144; BlkSize = 262144;
Range = 262144;
function ValidSize(Res: T3Res): Boolean;
const
ThresSize = 32;
begin
Result := (Res[0] > 0) and (Res[0] < Res[1]) and
InRange(Res[0], Res[0], Res[2] + 32);
end;
var var
LBuffer: array [0 .. BlkSize - 1] of Byte; W, X, Y, Z: Integer;
I, J, W, X, Y, Z: Integer;
LR1, LR2: T3Res;
begin begin
Result := False; Result := False;
Y := Max(LocalLZ_Decompress(src, dst, srcSize, dstCapacity, 0, Z), Y := 0;
LocalLZ_Decompress(src, dst, srcSize, dstCapacity, 1, Z)); X := dstCapacity;
if Y > MinSize then X := Min(Max(LocalLZ_Decompress(src, dst, srcSize, X, 0, Y),
LocalLZ_Decompress(src, dst, srcSize, X, 1, Z)), Pred(X));
W := X;
while (Y = 0) and (X > dstCapacity - BlkSize) and (W - X < OLength) do
begin begin
W := IfThen(Y mod BlkSize = 0, Pred(Y div BlkSize), Y div BlkSize) X := Min(Max(LocalLZ_Decompress(src, dst, srcSize, X, 0, Y),
* BlkSize; LocalLZ_Decompress(src, dst, srcSize, X, 1, Y)), Pred(X));
Move((dst + W)^, LBuffer[0], Y - W);
end; end;
if (Y = Z) and (Y = dstCapacity) then X := Min(Succ(W), dstCapacity);
while (Z = 0) and (X < Min(W + OLength, dstCapacity)) do
begin
LocalLZ_Decompress(src, dst, srcSize, X, 0, Z);
Inc(X);
end;
Y := Max(Y, Z);
if (Y > 0) then
begin begin
Res := Y; Res := Y;
I := Max(LocalLZ_Decompress(src, dst, srcSize, dstCapacity - 1, 0, Z),
LocalLZ_Decompress(src, dst, srcSize, dstCapacity - 1, 1, Z));
if (Res <> I) and (Res <> Pred(I)) then
begin
Move(LBuffer[0], (dst + W)^, Res - W);
Result := True; Result := True;
exit;
end; end;
end;
FillChar(LR1, SizeOf(T3Res), 0);
FillChar(LR2, SizeOf(T3Res), 0);
I := Y;
J := Min(dstCapacity, Y + Range);
while I < J do
begin
Y := Max(LocalLZ_Decompress(src, dst, srcSize, I, 0, Z),
LocalLZ_Decompress(src, dst, srcSize, I, 1, Z));
AddRes(Y, LR1);
AddRes(Z, LR2);
if (LR1[1] = LR2[1]) and ValidSize(LR1) then
begin
Res := LR1[1];
Move(LBuffer[0], (dst + W)^, Res - W);
Result := True;
break;
end;
if Y > MinSize then
begin
W := IfThen(Y mod BlkSize = 0, Pred(Y div BlkSize), Y div BlkSize)
* BlkSize;
Move((dst + W)^, LBuffer[0], Y - W);
end;
Inc(I);
end;
end;
function CustomLZ_DecompressN(src, dst: PByte; srcSize, dstCapacity: Integer;
var Res: TIntegerDynArray): Boolean;
const
BlkSize = 262144;
UpLen = 128;
DownLen = 16;
var
I, J, X, Y, Z: Integer;
Sizes: array [0 .. UpLen + DownLen - 1] of Integer;
begin
SetLength(Res, 0);
Y := Max(LocalLZ_Decompress(src, dst, srcSize, dstCapacity, 0, Z),
LocalLZ_Decompress(src, dst, srcSize, dstCapacity, 1, Z));
for I := Low(Sizes) to High(Sizes) do
Sizes[I] := -1;
J := Min(dstCapacity, Y + UpLen);
I := Max(IfThen(dstCapacity mod BlkSize = 0, Pred(dstCapacity div BlkSize),
dstCapacity div BlkSize) * BlkSize, Y - DownLen);
X := J - I;
while (J > I) do
begin
Y := Max(LocalLZ_Decompress(src, dst, srcSize, J, 0, Z),
LocalLZ_Decompress(src, dst, srcSize, J, 1, Z));
Sizes[Length(Sizes) - (J - I)] := Z;
Dec(J);
end;
for I := Low(Sizes) to High(Sizes) do
begin
X := Sizes[I];
for J := Low(Sizes) to High(Sizes) do
begin
Y := Sizes[J];
if I <> J then
if X = Y then
begin
Sizes[I] := -1;
Sizes[J] := -1;
end;
end;
end;
for I := Low(Sizes) to High(Sizes) do
if Sizes[I] > srcSize then
if OodleLZ_Decompress(src, srcSize, dst, Sizes[I]) = Sizes[I] then
begin
Insert(Sizes[I], Res, Length(Res));
if Length(Res) >= OCount then
break;
end;
Result := Length(Res) > 0;
end; end;
function GetOodleUS(Instance: Integer; Input: PByte; Pos: NativeInt; function GetOodleUS(Instance: Integer; Input: PByte; Pos: NativeInt;
@ -386,25 +272,29 @@ const
var var
Buffer: PByte; Buffer: PByte;
B: Boolean; B: Boolean;
I: Integer;
ResultN: TIntegerDynArray;
SI: _StrInfo1; SI: _StrInfo1;
begin begin
Result := 0; Result := 0;
{ if StreamInfo^.Codec = 3 then case StreamInfo^.Codec of
exit; } 1:
// StreamInfo^.DSize:=$8001; if (CodecEnabled[KRAKEN_CODEC] = False) and
Buffer := Funcs^.Allocator(Instance, StreamInfo^.DSize); (CodecEnabled[HYDRA_CODEC] = False) then
if OCount <= 0 then exit;
B := CustomLZ_Decompress0(Input + Pos, Buffer, StreamInfo^.CSize, 2:
StreamInfo^.DSize, Result) if (CodecEnabled[MERMAID_CODEC] = False) and
(CodecEnabled[SELKIE_CODEC] = False) and
(CodecEnabled[HYDRA_CODEC] = False) then
exit;
3:
if (CodecEnabled[LEVIATHAN_CODEC] = False) and
(CodecEnabled[HYDRA_CODEC] = False) then
exit;
else else
begin exit;
B := CustomLZ_DecompressN(Input + Pos, Buffer, StreamInfo^.CSize,
StreamInfo^.DSize, ResultN);
if B then
Result := ResultN[0];
end; end;
Buffer := Funcs^.Allocator(Instance, StreamInfo^.DSize);
B := CustomLZ_Decompress(Input + Pos, Buffer, StreamInfo^.CSize,
StreamInfo^.DSize, Result);
If B then If B then
if (Result > MinSize) and (Result > StreamInfo^.CSize) then if (Result > MinSize) and (Result > StreamInfo^.CSize) then
begin begin
@ -415,37 +305,25 @@ begin
SetBits(SI.Option, OTradeOff, 13, 11); SetBits(SI.Option, OTradeOff, 13, 11);
case StreamInfo^.Codec of case StreamInfo^.Codec of
1: 1:
if CodecEnabled[KRAKEN_CODEC] then
SetBits(SI.Option, KRAKEN_CODEC, 0, 5); SetBits(SI.Option, KRAKEN_CODEC, 0, 5);
2: 2:
if CodecEnabled[MERMAID_CODEC] then if CodecEnabled[MERMAID_CODEC] then
SetBits(SI.Option, MERMAID_CODEC, 0, 5) SetBits(SI.Option, MERMAID_CODEC, 0, 5)
else else if CodecEnabled[SELKIE_CODEC] then
SetBits(SI.Option, SELKIE_CODEC, 0, 5); SetBits(SI.Option, SELKIE_CODEC, 0, 5);
3: 3:
if CodecEnabled[LEVIATHAN_CODEC] then
SetBits(SI.Option, LEVIATHAN_CODEC, 0, 5); SetBits(SI.Option, LEVIATHAN_CODEC, 0, 5);
end; end;
if CodecEnabled[HYDRA_CODEC] then if CodecEnabled[HYDRA_CODEC] then
SetBits(SI.Option, HYDRA_CODEC, 0, 5); SetBits(SI.Option, HYDRA_CODEC, 0, 5);
SetBits(SI.Option, Integer(StreamInfo^.HasCRC), 12, 1); SetBits(SI.Option, Integer(StreamInfo^.HasCRC), 12, 1);
SI.Status := TStreamStatus.None; SI.Status := TStreamStatus.None;
if OCount <= 0 then
begin
SI.NewSize := Result; SI.NewSize := Result;
Funcs^.LogScan1(OodleCodecs[GetBits(SI.Option, 0, 5)], SI.Position, Funcs^.LogScan1(OodleCodecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize); SI.OldSize, SI.NewSize);
Add(Instance, @SI, nil, nil); Add(Instance, @SI, nil, nil);
end
else
begin
if Length(ResultN) > 0 then
for I := Low(ResultN) to High(ResultN) do
begin
SI.NewSize := ResultN[I];
Funcs^.LogScan1(OodleCodecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize);
Add(Instance, @SI, nil, nil);
end;
end;
end; end;
end; end;
@ -502,7 +380,7 @@ begin
SOList[I][Y].Update SOList[I][Y].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
if Funcs^.GetParam(Command, X, 'n') <> '' then if Funcs^.GetParam(Command, X, 'n') <> '' then
OCount := StrToInt(Funcs^.GetParam(Command, X, 'n')); OLength := StrToInt(Funcs^.GetParam(Command, X, 'n'));
if Funcs^.GetParam(Command, X, 't') <> '' then if Funcs^.GetParam(Command, X, 't') <> '' then
OTradeOff := StrToInt(Funcs^.GetParam(Command, X, 't')); OTradeOff := StrToInt(Funcs^.GetParam(Command, X, 't'));
end; end;
@ -573,7 +451,11 @@ begin
if DS <> '' then if DS <> '' then
begin begin
X := IndexTextW(@DS[0], OodleCodecs); X := IndexTextW(@DS[0], OodleCodecs);
if (X < 0) or (DI1.OldSize <> SizeEx) then if X < 0 then
exit;
if DI1.OldSize = 0 then
DI1.OldSize := SizeEx;
if not CodecAvailable[X] then
exit; exit;
if not CodecAvailable[X] then if not CodecAvailable[X] then
exit; exit;
@ -589,7 +471,7 @@ begin
begin begin
if DI1.NewSize <= 0 then if DI1.NewSize <= 0 then
begin begin
if not CustomLZ_Decompress0(Input, Buffer, DI1.OldSize, Res, Res) if not CustomLZ_Decompress(Input, Buffer, DI1.OldSize, Res, Res)
then then
Res := 0; Res := 0;
end end
@ -678,7 +560,7 @@ begin
then then
begin begin
Buffer := Funcs^.Allocator(Instance, OodleSI.DSize); Buffer := Funcs^.Allocator(Instance, OodleSI.DSize);
if CustomLZ_Decompress0(Input, Buffer, StreamInfo^.OldSize, if CustomLZ_Decompress(Input, Buffer, StreamInfo^.OldSize,
OodleSI.DSize, Res) then OodleSI.DSize, Res) then
begin begin
Output(Instance, Buffer, Res); Output(Instance, Buffer, Res);
@ -716,7 +598,7 @@ begin
if GetBits(StreamInfo^.Option, 5, 7) <> I then if GetBits(StreamInfo^.Option, 5, 7) <> I then
continue; continue;
if (StreamInfo^.Status = TStreamStatus.Database) and if (StreamInfo^.Status = TStreamStatus.Database) and
(GetBits(StreamInfo^.Option, 1, 31) = 0) then (GetBits(StreamInfo^.Option, 31, 1) = 0) then
begin begin
Res1 := StreamInfo^.OldSize; Res1 := StreamInfo^.OldSize;
Result := True; Result := True;
@ -726,6 +608,7 @@ begin
SizeOf(TOodleLZ_CompressOptions)); SizeOf(TOodleLZ_CompressOptions));
COptions.sendQuantumCRCs := GetBits(StreamInfo^.Option, 12, 1) = 1; COptions.sendQuantumCRCs := GetBits(StreamInfo^.Option, 12, 1) = 1;
COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo^.Option, 13, 11); COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo^.Option, 13, 11);
// COptions.dictionarySize := 262144;
Params := 'l' + I.ToString + ':' + 'c' + GetBits(StreamInfo^.Option, 12, 1) Params := 'l' + I.ToString + ':' + 'c' + GetBits(StreamInfo^.Option, 12, 1)
.ToString + ':' + 't' + GetBits(StreamInfo^.Option, 13, 11).ToString; .ToString + ':' + 't' + GetBits(StreamInfo^.Option, 13, 11).ToString;
if not Result then if not Result then
@ -739,7 +622,7 @@ begin
if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then
break; break;
end; end;
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or { if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or
(SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then (SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
begin begin
Buffer := Funcs^.Allocator(Instance, Res1 + Max(StreamInfo^.OldSize, Res1)); Buffer := Funcs^.Allocator(Instance, Res1 + Max(StreamInfo^.OldSize, Res1));
@ -754,7 +637,7 @@ begin
SOList[Instance][X].Add(I); SOList[Instance][X].Add(I);
Result := True; Result := True;
end; end;
end; end; }
if Result then if Result then
begin begin
SetBits(StreamInfo^.Option, I, 5, 7); SetBits(StreamInfo^.Option, I, 5, 7);

View File

@ -16,7 +16,7 @@ resourcestring
SPrecompSep2 = ':'; SPrecompSep2 = ':';
SPrecompSep3 = ','; SPrecompSep3 = ',';
SPrecompSep4 = '/'; SPrecompSep4 = '/';
SPrecompSep5 = '/'; SPrecompSep5 = '\';
const const
SuccessStatus = 4; SuccessStatus = 4;
@ -276,7 +276,7 @@ type
procedure SetSize(const NewSize: Int64); override; procedure SetSize(const NewSize: Int64); override;
procedure SetSize(NewSize: Longint); override; procedure SetSize(NewSize: Longint); override;
private private
FInitialised: Boolean; FInitialised, FDone: Boolean;
FStream: TStream; FStream: TStream;
FFilename: String; FFilename: String;
procedure Initialise; procedure Initialise;
@ -286,6 +286,8 @@ type
function Read(var Buffer; Count: Longint): Longint; override; function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override; function Write(const Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
procedure Done;
property FileName: String read FFilename;
end; end;
PResData = ^TResData; PResData = ^TResData;
@ -449,12 +451,14 @@ constructor TPrecompVMStream.Create;
begin begin
inherited Create; inherited Create;
FInitialised := False; FInitialised := False;
FDone := False;
end; end;
destructor TPrecompVMStream.Destroy; destructor TPrecompVMStream.Destroy;
begin begin
if FInitialised then if FInitialised then
begin begin
if not FDone then
FStream.Free; FStream.Free;
DeleteFile(FFilename); DeleteFile(FFilename);
end; end;
@ -521,6 +525,12 @@ begin
Result := 0; Result := 0;
end; end;
procedure TPrecompVMStream.Done;
begin
FStream.Free;
FDone := True;
end;
function PrecompGetCodec(Cmd: PChar; Index: Integer; WithParams: Boolean) function PrecompGetCodec(Cmd: PChar; Index: Integer; WithParams: Boolean)
: TPrecompStr; : TPrecompStr;
var var
@ -566,15 +576,17 @@ begin
begin begin
List2 := DecodeStr(List1[Index], SPrecompSep2); List2 := DecodeStr(List1[Index], SPrecompSep2);
if Param = '' then if Param = '' then
begin
if Length(List1) > 1 then
begin begin
S := ''; S := '';
if not ResourceExists(List2[I]) then for I := Succ(Low(List2)) to High(List2) do
S := S + List2[I] + SPrecompSep2; if ResourceExists(List2[I]) = False then
if Length(S) > 0 then begin
S := S.Remove(Pred(Length(S))); if S <> '' then
S := S + SPrecompSep2;
S := S + List2[I];
end; end;
if S = '' then
S := ' ';
end end
else else
begin begin
@ -705,8 +717,9 @@ var
S: String; S: String;
begin begin
Result := 0; Result := 0;
case IndexText(Codec, ['zlib', 'lz4', 'lz4hc', 'lzo1c', 'lzo1x', 'lzo2a', case IndexText(Codec, ['zlib', 'lz4', 'lz4hc', 'lz4f', 'lzo1c', 'lzo1x',
'zstd', 'lzna', 'kraken', 'mermaid', 'selkie', 'hydra', 'leviathan']) of 'lzo2a', 'zstd', 'lzna', 'kraken', 'mermaid', 'selkie', 'hydra',
'leviathan']) of
0: 0:
if ZLibDLL.DLLLoaded then if ZLibDLL.DLLLoaded then
begin begin
@ -729,10 +742,13 @@ begin
1, 2: 1, 2:
if LZ4DLL.DLLLoaded then if LZ4DLL.DLLLoaded then
Result := LZ4_decompress_safe(InBuff, OutBuff, InSize, OutSize); Result := LZ4_decompress_safe(InBuff, OutBuff, InSize, OutSize);
6: 3:
if LZ4DLL.DLLLoaded then
Result := LZ4F_decompress_safe(InBuff, OutBuff, InSize, OutSize);
7:
if ZSTDDLL.DLLLoaded then if ZSTDDLL.DLLLoaded then
Result := ZSTD_decompress(OutBuff, OutSize, InBuff, InSize); Result := ZSTD_decompress(OutBuff, OutSize, InBuff, InSize);
7 .. 12: 8 .. 13:
if OodleDLL.DLLLoaded then if OodleDLL.DLLLoaded then
Result := OodleLZ_Decompress(InBuff, InSize, OutBuff, OutSize); Result := OodleLZ_Decompress(InBuff, InSize, OutBuff, OutSize);
end; end;
@ -855,6 +871,8 @@ var
Res: NativeUInt; Res: NativeUInt;
begin begin
Result := 0; Result := 0;
if not XDeltaDLL.DLLLoaded then
exit;
if xd3_encode(OldBuff, OldSize, NewBuff, NewSize, PatchBuff, @Res, PatchSize, if xd3_encode(OldBuff, OldSize, NewBuff, NewSize, PatchBuff, @Res, PatchSize,
Integer(XD3_NOCOMPRESS)) = 0 then Integer(XD3_NOCOMPRESS)) = 0 then
Result := Res; Result := Res;
@ -868,6 +886,8 @@ var
Res: NativeUInt; Res: NativeUInt;
begin begin
Result := 0; Result := 0;
if not XDeltaDLL.DLLLoaded then
exit;
if xd3_decode(PatchBuff, PatchSize, OldBuff, OldSize, NewBuff, @Res, NewSize, if xd3_decode(PatchBuff, PatchSize, OldBuff, OldSize, NewBuff, @Res, NewSize,
Integer(XD3_NOCOMPRESS)) = 0 then Integer(XD3_NOCOMPRESS)) = 0 then
Result := Res; Result := Res;
@ -1234,5 +1254,7 @@ EncodeSICmp := TEncodeSIComparer.Create;
FutureSICmp := TFutureSIComparer.Create; FutureSICmp := TFutureSIComparer.Create;
StockMethods := TStringList.Create; StockMethods := TStringList.Create;
ExternalMethods := TStringList.Create; ExternalMethods := TStringList.Create;
if not XDeltaDLL.DLLLoaded then
DIFF_TOLERANCE := 0;
end. end.

View File

@ -530,7 +530,7 @@ begin
Res := inflate(ZStream^, Z_BLOCK); Res := inflate(ZStream^, Z_BLOCK);
if not(Res in [Z_OK, Z_STREAM_END]) then if not(Res in [Z_OK, Z_STREAM_END]) then
begin begin
if (LastIn >= Z_MINSIZE) then if (Res <> Z_DATA_ERROR) and (LastIn >= Z_MINSIZE) then
Res := Z_STREAM_END; Res := Z_STREAM_END;
break; break;
end; end;

View File

@ -3,7 +3,7 @@ unit PrecompZSTD;
interface interface
uses uses
ZSTDDLL, XDeltaDLL, ZSTDDLL,
Utils, Utils,
PrecompUtils, PrecompUtils,
System.SysUtils, System.Classes, System.Math; System.SysUtils, System.Classes, System.Math;
@ -267,7 +267,7 @@ begin
if GetBits(StreamInfo^.Option, 5, 7) <> I then if GetBits(StreamInfo^.Option, 5, 7) <> I then
continue; continue;
if (StreamInfo^.Status = TStreamStatus.Database) and if (StreamInfo^.Status = TStreamStatus.Database) and
(GetBits(StreamInfo^.Option, 1, 31) = 0) then (GetBits(StreamInfo^.Option, 31, 1) = 0) then
begin begin
Res1 := StreamInfo^.OldSize; Res1 := StreamInfo^.OldSize;
Result := True; Result := True;
@ -317,7 +317,7 @@ begin
StreamInfo^.OldSize); StreamInfo^.OldSize);
Funcs^.LogProcess(ZSTDCodecs[GetBits(StreamInfo^.Option, 0, 5)], Funcs^.LogProcess(ZSTDCodecs[GetBits(StreamInfo^.Option, 0, 5)],
PChar(Params), StreamInfo^.OldSize, StreamInfo^.NewSize, Res1, Result); PChar(Params), StreamInfo^.OldSize, StreamInfo^.NewSize, Res1, Result);
if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then if Result or (StreamInfo^.Status >= TStreamStatus.Predicted) then
break; break;
end; end;
if Res1 < 0 then if Res1 < 0 then

View File

@ -24,11 +24,8 @@ program xtool;
{$APPTYPE CONSOLE} {$APPTYPE CONSOLE}
{$R *.res} {$R *.res}
{$SETPEOSVERSION 6.0}
{$SETPESUBSYSVERSION 6.0}
{$WEAKLINKRTTI ON} {$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$R *.dres}
uses uses
WinAPI.Windows, WinAPI.Windows,
@ -38,6 +35,7 @@ uses
System.Types, System.Types,
System.Math, System.Math,
System.IOUtils, System.IOUtils,
LibImport in 'common\LibImport.pas',
Threading in 'common\Threading.pas', Threading in 'common\Threading.pas',
Utils in 'common\Utils.pas', Utils in 'common\Utils.pas',
FuncHook in 'contrib\Delphi_MemoryModule\FuncHook.pas', FuncHook in 'contrib\Delphi_MemoryModule\FuncHook.pas',
@ -47,8 +45,6 @@ uses
SynCrypto in 'contrib\mORMot\SynCrypto.pas', SynCrypto in 'contrib\mORMot\SynCrypto.pas',
SynLZ in 'contrib\mORMot\SynLZ.pas', SynLZ in 'contrib\mORMot\SynLZ.pas',
SynTable in 'contrib\mORMot\SynTable.pas', SynTable in 'contrib\mORMot\SynTable.pas',
DelphiCL in 'contrib\opencl\DelphiCL.pas',
OpenCL in 'contrib\opencl\OpenCL.pas',
oObjects in 'contrib\ParseExpression\oObjects.pas', oObjects in 'contrib\ParseExpression\oObjects.pas',
ParseClass in 'contrib\ParseExpression\ParseClass.pas', ParseClass in 'contrib\ParseExpression\ParseClass.pas',
ParseExpr in 'contrib\ParseExpression\ParseExpr.pas', ParseExpr in 'contrib\ParseExpression\ParseExpr.pas',
@ -102,6 +98,7 @@ const
CommandPatch = 'patch'; CommandPatch = 'patch';
CommandArchive = 'archive'; CommandArchive = 'archive';
CommandExecute = 'execute'; CommandExecute = 'execute';
CommandInject = 'inject';
CommandDecode = 'decode'; CommandDecode = 'decode';
procedure ProgramInfo; procedure ProgramInfo;
@ -121,6 +118,7 @@ begin
WriteLine(' ' + CommandExtract); WriteLine(' ' + CommandExtract);
WriteLine(' ' + CommandFind); WriteLine(' ' + CommandFind);
WriteLine(' ' + CommandGenerate); WriteLine(' ' + CommandGenerate);
WriteLine(' ' + CommandInject);
WriteLine(' ' + CommandPatch); WriteLine(' ' + CommandPatch);
WriteLine(' ' + CommandPrecomp); WriteLine(' ' + CommandPrecomp);
WriteLine(' ' + CommandReplace); WriteLine(' ' + CommandReplace);
@ -141,6 +139,15 @@ begin
WriteLine(''); WriteLine('');
end; end;
procedure InjectPrintHelp;
begin
WriteLine('inject - embed libraries as part of xtool');
WriteLine('');
WriteLine('Usage:');
WriteLine(' xtool inject dll');
WriteLine('');
end;
function GetInStream(Input: string): TStream; function GetInStream(Input: string): TStream;
begin begin
if (Input = '-') or (Input = '') then if (Input = '-') or (Input = '') then
@ -153,7 +160,7 @@ begin
Result := TDirInputStream.Create(Input); Result := TDirInputStream.Create(Input);
end; end;
function GetOutStream(Output: string; MultiInput: Boolean = False): TStream; function GetOutStream(Output: string): TStream;
begin begin
if (Output = '') then if (Output = '') then
Result := TNullStream.Create Result := TNullStream.Create
@ -170,6 +177,7 @@ const
var var
I, J: Integer; I, J: Integer;
S: String;
ParamArg: array [0 .. 1] of TArray<String>; ParamArg: array [0 .. 1] of TArray<String>;
StrArray: TArray<String>; StrArray: TArray<String>;
IsParam: Boolean; IsParam: Boolean;
@ -345,6 +353,18 @@ begin
Output.Free; Output.Free;
end; end;
end; end;
if ParamStr(1).StartsWith(CommandInject, True) then
if (Length(ParamArg[0]) = 0) and (Length(ParamArg[1]) = 0) then
InjectPrintHelp
else
begin
S := ChangeFileExt(GetModuleName,
'_inj' + ExtractFileExt(GetModuleName));
if not FileExists(S) then
TFile.Copy(GetModuleName, S);
InjectLib(ParamArg[1, 0], S);
WriteLine('Successfully injected ' + ExtractFileName(ParamArg[1, 0]));
end;
if ParamStr(1).StartsWith(CommandDecode, True) then if ParamStr(1).StartsWith(CommandDecode, True) then
if (Length(ParamArg[0]) = 0) and (Length(ParamArg[1]) = 0) then if (Length(ParamArg[0]) = 0) and (Length(ParamArg[1]) = 0) then
DecodePrintHelp DecodePrintHelp

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{E490A6E6-3D5F-49E7-860E-CB57A73FBF77}</ProjectGuid> <ProjectGuid>{E490A6E6-3D5F-49E7-860E-CB57A73FBF77}</ProjectGuid>
<ProjectVersion>19.4</ProjectVersion> <ProjectVersion>19.5</ProjectVersion>
<FrameworkType>None</FrameworkType> <FrameworkType>None</FrameworkType>
<MainSource>xtool.dpr</MainSource> <MainSource>xtool.dpr</MainSource>
<Base>True</Base> <Base>True</Base>
@ -13,6 +13,26 @@
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''"> <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base> <Base>true</Base>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Android' and '$(Base)'=='true') or '$(Base_Android)'!=''">
<Base_Android>true</Base_Android>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Android64' and '$(Base)'=='true') or '$(Base_Android64)'!=''">
<Base_Android64>true</Base_Android64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='iOSDevice64' and '$(Base)'=='true') or '$(Base_iOSDevice64)'!=''">
<Base_iOSDevice64>true</Base_iOSDevice64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='iOSSimARM64' and '$(Base)'=='true') or '$(Base_iOSSimARM64)'!=''">
<Base_iOSSimARM64>true</Base_iOSSimARM64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''"> <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32> <Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent> <CfgParent>Base</CfgParent>
@ -51,6 +71,28 @@
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace> <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
<SanitizedProjectName>xtool</SanitizedProjectName> <SanitizedProjectName>xtool</SanitizedProjectName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Base_Android)'!=''">
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey=</VerInfo_Keys>
<BT_BuildType>Debug</BT_BuildType>
<EnabledSysJars>annotation-1.2.0.dex.jar;asynclayoutinflater-1.0.0.dex.jar;billing-4.0.0.dex.jar;browser-1.0.0.dex.jar;cloud-messaging.dex.jar;collection-1.0.0.dex.jar;coordinatorlayout-1.0.0.dex.jar;core-1.5.0-rc02.dex.jar;core-common-2.0.1.dex.jar;core-runtime-2.0.1.dex.jar;cursoradapter-1.0.0.dex.jar;customview-1.0.0.dex.jar;documentfile-1.0.0.dex.jar;drawerlayout-1.0.0.dex.jar;firebase-annotations-16.0.0.dex.jar;firebase-common-20.0.0.dex.jar;firebase-components-17.0.0.dex.jar;firebase-datatransport-18.0.0.dex.jar;firebase-encoders-17.0.0.dex.jar;firebase-encoders-json-18.0.0.dex.jar;firebase-iid-interop-17.1.0.dex.jar;firebase-installations-17.0.0.dex.jar;firebase-installations-interop-17.0.0.dex.jar;firebase-measurement-connector-19.0.0.dex.jar;firebase-messaging-22.0.0.dex.jar;fmx.dex.jar;fragment-1.0.0.dex.jar;google-play-licensing.dex.jar;interpolator-1.0.0.dex.jar;javax.inject-1.dex.jar;legacy-support-core-ui-1.0.0.dex.jar;legacy-support-core-utils-1.0.0.dex.jar;lifecycle-common-2.0.0.dex.jar;lifecycle-livedata-2.0.0.dex.jar;lifecycle-livedata-core-2.0.0.dex.jar;lifecycle-runtime-2.0.0.dex.jar;lifecycle-service-2.0.0.dex.jar;lifecycle-viewmodel-2.0.0.dex.jar;listenablefuture-1.0.dex.jar;loader-1.0.0.dex.jar;localbroadcastmanager-1.0.0.dex.jar;play-services-ads-20.1.0.dex.jar;play-services-ads-base-20.1.0.dex.jar;play-services-ads-identifier-17.0.0.dex.jar;play-services-ads-lite-20.1.0.dex.jar;play-services-base-17.5.0.dex.jar;play-services-basement-17.6.0.dex.jar;play-services-cloud-messaging-16.0.0.dex.jar;play-services-drive-17.0.0.dex.jar;play-services-games-21.0.0.dex.jar;play-services-location-18.0.0.dex.jar;play-services-maps-17.0.1.dex.jar;play-services-measurement-base-18.0.0.dex.jar;play-services-measurement-sdk-api-18.0.0.dex.jar;play-services-places-placereport-17.0.0.dex.jar;play-services-stats-17.0.0.dex.jar;play-services-tasks-17.2.0.dex.jar;print-1.0.0.dex.jar;room-common-2.1.0.dex.jar;room-runtime-2.1.0.dex.jar;slidingpanelayout-1.0.0.dex.jar;sqlite-2.0.1.dex.jar;sqlite-framework-2.0.1.dex.jar;swiperefreshlayout-1.0.0.dex.jar;transport-api-3.0.0.dex.jar;transport-backend-cct-3.0.0.dex.jar;transport-runtime-3.0.0.dex.jar;user-messaging-platform-1.0.0.dex.jar;versionedparcelable-1.1.1.dex.jar;viewpager-1.0.0.dex.jar;work-runtime-2.1.0.dex.jar</EnabledSysJars>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Android64)'!=''">
<VerInfo_Keys>package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey=</VerInfo_Keys>
<BT_BuildType>Debug</BT_BuildType>
<EnabledSysJars>annotation-1.2.0.dex.jar;asynclayoutinflater-1.0.0.dex.jar;billing-4.0.0.dex.jar;browser-1.0.0.dex.jar;cloud-messaging.dex.jar;collection-1.0.0.dex.jar;coordinatorlayout-1.0.0.dex.jar;core-1.5.0-rc02.dex.jar;core-common-2.0.1.dex.jar;core-runtime-2.0.1.dex.jar;cursoradapter-1.0.0.dex.jar;customview-1.0.0.dex.jar;documentfile-1.0.0.dex.jar;drawerlayout-1.0.0.dex.jar;firebase-annotations-16.0.0.dex.jar;firebase-common-20.0.0.dex.jar;firebase-components-17.0.0.dex.jar;firebase-datatransport-18.0.0.dex.jar;firebase-encoders-17.0.0.dex.jar;firebase-encoders-json-18.0.0.dex.jar;firebase-iid-interop-17.1.0.dex.jar;firebase-installations-17.0.0.dex.jar;firebase-installations-interop-17.0.0.dex.jar;firebase-measurement-connector-19.0.0.dex.jar;firebase-messaging-22.0.0.dex.jar;fmx.dex.jar;fragment-1.0.0.dex.jar;google-play-licensing.dex.jar;interpolator-1.0.0.dex.jar;javax.inject-1.dex.jar;legacy-support-core-ui-1.0.0.dex.jar;legacy-support-core-utils-1.0.0.dex.jar;lifecycle-common-2.0.0.dex.jar;lifecycle-livedata-2.0.0.dex.jar;lifecycle-livedata-core-2.0.0.dex.jar;lifecycle-runtime-2.0.0.dex.jar;lifecycle-service-2.0.0.dex.jar;lifecycle-viewmodel-2.0.0.dex.jar;listenablefuture-1.0.dex.jar;loader-1.0.0.dex.jar;localbroadcastmanager-1.0.0.dex.jar;play-services-ads-20.1.0.dex.jar;play-services-ads-base-20.1.0.dex.jar;play-services-ads-identifier-17.0.0.dex.jar;play-services-ads-lite-20.1.0.dex.jar;play-services-base-17.5.0.dex.jar;play-services-basement-17.6.0.dex.jar;play-services-cloud-messaging-16.0.0.dex.jar;play-services-drive-17.0.0.dex.jar;play-services-games-21.0.0.dex.jar;play-services-location-18.0.0.dex.jar;play-services-maps-17.0.1.dex.jar;play-services-measurement-base-18.0.0.dex.jar;play-services-measurement-sdk-api-18.0.0.dex.jar;play-services-places-placereport-17.0.0.dex.jar;play-services-stats-17.0.0.dex.jar;play-services-tasks-17.2.0.dex.jar;print-1.0.0.dex.jar;room-common-2.1.0.dex.jar;room-runtime-2.1.0.dex.jar;slidingpanelayout-1.0.0.dex.jar;sqlite-2.0.1.dex.jar;sqlite-framework-2.0.1.dex.jar;swiperefreshlayout-1.0.0.dex.jar;transport-api-3.0.0.dex.jar;transport-backend-cct-3.0.0.dex.jar;transport-runtime-3.0.0.dex.jar;user-messaging-platform-1.0.0.dex.jar;versionedparcelable-1.1.1.dex.jar;viewpager-1.0.0.dex.jar;work-runtime-2.1.0.dex.jar</EnabledSysJars>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone &amp; iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple&apos;s speech recognition servers</VerInfo_Keys>
<VerInfo_UIDeviceFamily>iPhoneAndiPad</VerInfo_UIDeviceFamily>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_BundleId>$(MSBuildProjectName)</VerInfo_BundleId>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSSimARM64)'!=''">
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone &amp; iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple&apos;s speech recognition servers</VerInfo_Keys>
<VerInfo_UIDeviceFamily>iPhoneAndiPad</VerInfo_UIDeviceFamily>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''"> <PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_UsePackage>DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;DataSnapFireDAC;svnui;tethering;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;FireDACIBDriver;fmx;fmxdae;vclib;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;CloudService;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;IndyIPCommon;vcl;DBXSybaseASEDriver;IndyIPServer;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;ibxbindings;rtl;emsserverresource;DbxClientDriver;FireDACDSDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;inetdbxpress;FireDACMongoDBDriver;IndyProtocols;fmxase;$(DCC_UsePackage)</DCC_UsePackage> <DCC_UsePackage>DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;DataSnapFireDAC;svnui;tethering;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;FireDACIBDriver;fmx;fmxdae;vclib;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;CloudService;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;IndyIPCommon;vcl;DBXSybaseASEDriver;IndyIPServer;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;vclwinx;ibxbindings;rtl;emsserverresource;DbxClientDriver;FireDACDSDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;inetdbxpress;FireDACMongoDBDriver;IndyProtocols;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace> <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
@ -97,6 +139,7 @@
<DelphiCompile Include="$(MainSource)"> <DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource> <MainSource>MainSource</MainSource>
</DelphiCompile> </DelphiCompile>
<DCCReference Include="common\LibImport.pas"/>
<DCCReference Include="common\Threading.pas"/> <DCCReference Include="common\Threading.pas"/>
<DCCReference Include="common\Utils.pas"/> <DCCReference Include="common\Utils.pas"/>
<DCCReference Include="contrib\Delphi_MemoryModule\FuncHook.pas"/> <DCCReference Include="contrib\Delphi_MemoryModule\FuncHook.pas"/>
@ -106,8 +149,6 @@
<DCCReference Include="contrib\mORMot\SynCrypto.pas"/> <DCCReference Include="contrib\mORMot\SynCrypto.pas"/>
<DCCReference Include="contrib\mORMot\SynLZ.pas"/> <DCCReference Include="contrib\mORMot\SynLZ.pas"/>
<DCCReference Include="contrib\mORMot\SynTable.pas"/> <DCCReference Include="contrib\mORMot\SynTable.pas"/>
<DCCReference Include="contrib\opencl\DelphiCL.pas"/>
<DCCReference Include="contrib\opencl\OpenCL.pas"/>
<DCCReference Include="contrib\ParseExpression\oObjects.pas"/> <DCCReference Include="contrib\ParseExpression\oObjects.pas"/>
<DCCReference Include="contrib\ParseExpression\ParseClass.pas"/> <DCCReference Include="contrib\ParseExpression\ParseClass.pas"/>
<DCCReference Include="contrib\ParseExpression\ParseExpr.pas"/> <DCCReference Include="contrib\ParseExpression\ParseExpr.pas"/>
@ -148,17 +189,7 @@
<DCCReference Include="io\IOExecute.pas"/> <DCCReference Include="io\IOExecute.pas"/>
<DCCReference Include="io\IODecode.pas"/> <DCCReference Include="io\IODecode.pas"/>
<DCCReference Include="io\IOUtils.pas"/> <DCCReference Include="io\IOUtils.pas"/>
<RcItem Include="resources\Win64\xdelta3_dll.dll">
<ContainerId>ResourceItem</ContainerId>
<ResourceType>RCDATA</ResourceType>
<ResourceId>xdelta3_dll</ResourceId>
</RcItem>
<None Include="changes.txt"/> <None Include="changes.txt"/>
<RcItem Include="resources\Win64\fast-lzma2.dll">
<ContainerId>ResourceItem</ContainerId>
<ResourceType>RCDATA</ResourceType>
<ResourceId>fast_lzma2</ResourceId>
</RcItem>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
<Key>Base</Key> <Key>Base</Key>
</BuildConfiguration> </BuildConfiguration>
@ -180,7 +211,7 @@
<Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages> </Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Deployment Version="3"> <Deployment Version="4">
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule"> <DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator"> <Platform Name="iOSSimulator">
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
@ -196,42 +227,15 @@
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile LocalName="changes.txt" Configuration="Release" Class="ProjectFile"/>
<DeployFile LocalName="changes.txt" Configuration="Release" Class="ProjectFile"> <DeployFile LocalName="changes.txt" Configuration="Release" Class="ProjectFile">
<Platform Name="Win64"> <Platform Name="Win64">
<RemoteDir>.\</RemoteDir> <RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite> <Overwrite>true</Overwrite>
</Platform> </Platform>
</DeployFile> </DeployFile>
<DeployFile LocalName="resources\Win32\xdelta3_dll.dll" Configuration="Release" Class="ProjectFile"> <DeployFile LocalName="Win32\Release\xtool.exe" Configuration="Release" Class="ProjectOutput"/>
<Platform Name="Win32"> <DeployFile LocalName="Win64\Release\xtool.exe" Configuration="Release" Class="ProjectOutput"/>
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="resources\Win64\fast-lzma2.dll" Configuration="Release" Class="ProjectFile">
<Platform Name="Win64">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="resources\Win64\xdelta3_dll.dll" Configuration="Release" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="resources\Win64\xdelta3_dll.dll" Configuration="Release" Class="ProjectFile">
<Platform Name="Win64">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win32\Release\xtool.exe" Configuration="Release" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>xtool.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win64\Release\xtool.exe" Configuration="Release" Class="ProjectOutput"> <DeployFile LocalName="Win64\Release\xtool.exe" Configuration="Release" Class="ProjectOutput">
<Platform Name="Win64"> <Platform Name="Win64">
<RemoteName>xtool.exe</RemoteName> <RemoteName>xtool.exe</RemoteName>
@ -260,16 +264,6 @@
<Operation>64</Operation> <Operation>64</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="AndroidClassesDexFile">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider"> <DeployClass Name="AndroidFileProvider">
<Platform Name="Android"> <Platform Name="Android">
<RemoteDir>res\xml</RemoteDir> <RemoteDir>res\xml</RemoteDir>
@ -579,7 +573,7 @@
<Operation>1</Operation> <Operation>1</Operation>
<Extensions>.dylib</Extensions> <Extensions>.dylib</Extensions>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<Operation>1</Operation> <Operation>1</Operation>
<Extensions>.dylib</Extensions> <Extensions>.dylib</Extensions>
</Platform> </Platform>
@ -612,7 +606,7 @@
<Operation>1</Operation> <Operation>1</Operation>
<Extensions>.dylib</Extensions> <Extensions>.dylib</Extensions>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<Operation>1</Operation> <Operation>1</Operation>
<Extensions>.dylib</Extensions> <Extensions>.dylib</Extensions>
</Platform> </Platform>
@ -649,7 +643,7 @@
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<Operation>0</Operation> <Operation>0</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<Operation>0</Operation> <Operation>0</Operation>
</Platform> </Platform>
<Platform Name="OSX32"> <Platform Name="OSX32">
@ -673,13 +667,17 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iPad_AppIcon152"> <DeployClass Name="iPad_AppIcon152">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -689,137 +687,27 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iPad_Launch1024x768">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1536x2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1668">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch1668x2388">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048x1536">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2048x2732">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2224">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2388x1668">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2732x2048">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2x"> <DeployClass Name="iPad_Launch2x">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iPad_Launch768x1024">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_LaunchDark2x"> <DeployClass Name="iPad_LaunchDark2x">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -829,7 +717,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -839,7 +727,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -849,7 +737,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -859,7 +747,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -869,191 +757,37 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iPhone_Launch1125">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1136x640">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1242">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1242x2688">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1334">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch1792">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2208">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2436">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2688x1242">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2x"> <DeployClass Name="iPhone_Launch2x">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iPhone_Launch320">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch3x"> <DeployClass Name="iPhone_Launch3x">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iPhone_Launch640">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch640x1136">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch750">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch828">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_LaunchDark2x"> <DeployClass Name="iPhone_LaunchDark2x">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1063,7 +797,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1073,7 +807,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1083,7 +817,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1093,7 +827,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1103,7 +837,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1113,7 +847,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1123,7 +857,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
@ -1145,12 +879,8 @@
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir> <RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> <Platform Name="iOSSimARM64">
<DeployClass Name="ProjectiOSDeviceResourceRules"> <RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
@ -1163,6 +893,10 @@
<RemoteDir>..\</RemoteDir> <RemoteDir>..\</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass> </DeployClass>
<DeployClass Name="ProjectiOSInfoPList"> <DeployClass Name="ProjectiOSInfoPList">
<Platform Name="iOSDevice32"> <Platform Name="iOSDevice32">
@ -1171,7 +905,7 @@
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
@ -1180,7 +914,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir>
<Operation>64</Operation> <Operation>64</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir> <RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir>
<Operation>64</Operation> <Operation>64</Operation>
</Platform> </Platform>
@ -1192,7 +926,7 @@
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
</DeployClass> </DeployClass>
@ -1263,7 +997,7 @@
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="iOSSimulator"> <Platform Name="iOSSimARM64">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="Linux64"> <Platform Name="Linux64">
@ -1323,6 +1057,7 @@
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/> <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/> <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/> <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/> <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/> <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/> <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
@ -1332,6 +1067,11 @@
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/> <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment> </Deployment>
<Platforms> <Platforms>
<Platform value="Android">False</Platform>
<Platform value="Android64">False</Platform>
<Platform value="iOSDevice64">False</Platform>
<Platform value="iOSSimARM64">False</Platform>
<Platform value="Linux64">False</Platform>
<Platform value="Win32">True</Platform> <Platform value="Win32">True</Platform>
<Platform value="Win64">True</Platform> <Platform value="Win64">True</Platform>
</Platforms> </Platforms>

Binary file not shown.

View File

@ -1,2 +1 @@
xdelta3_dll RCDATA "resources\\Win64\\xdelta3_dll.dll" XTOOL RCDATA "cpp\\xtool\\x64\\Release\\xtool.dll"
fast_lzma2 RCDATA "resources\\Win64\\fast-lzma2.dll"