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)
- added feature to inject libraries to main executable
ES_R36 (0.6.1)
- added fast lzma2 compression for portable mode
- fixed issues with wav stream detection
- fixed minor issue with stream deduplication feature
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
I: Integer;
begin
Result := -1;
while True do
begin
for I := Low(Tasks) to High(Tasks) do

View File

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

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ unit FLZMA2DLL;
interface
uses
MemoryModule,
LibImport,
WinAPI.Windows,
System.SysUtils, System.Classes, System.Types;
@ -24,6 +24,82 @@ type
pos: size_t;
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
FL2_compress: function(dst: Pointer; dstCapacity: size_t; const src: Pointer;
srcSize: size_t; compressionLevel: Integer): size_t cdecl;
@ -63,13 +139,20 @@ var
input: PFL2_inBuffer): size_t cdecl;
FL2_endStream: function(fcs: Pointer; output: PFL2_outBuffer): size_t 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;
type
TLZMACRec = record
Threads: Integer;
Level: Integer;
HighCompress: boolean;
procedure Parse(S: String);
end;
@ -86,8 +169,9 @@ type
FProp: TLZMACRec;
FOutput: TStream;
FBuffer: array [0 .. FBufferSize - 1] of Byte;
FInitialized: boolean;
public
constructor Create(AOutput: TStream; AConfig: String = 't50p');
constructor Create(AOutput: TStream; AConfig: String);
destructor Destroy; override;
function Write(const Buffer; Count: LongInt): LongInt; override;
end;
@ -113,8 +197,7 @@ uses
Utils;
var
DLLStream: TResourceStream;
DLLHandle: TMemoryModule;
Lib: TLibImport;
procedure TLZMACRec.Parse(S: string);
var
@ -122,7 +205,8 @@ var
I, J: Integer;
begin
Threads := 1;
Level := 5;
Level := 6;
HighCompress := False;
List := DecodeStr(S, ':');
for I := Low(List) to High(List) do
begin
@ -130,6 +214,8 @@ begin
Threads := ConvertToThreads(List[I].Substring(1));
if List[I].StartsWith('l', True) then
Level := List[I].Substring(1).ToInteger;
if List[I].StartsWith('hi', True) then
HighCompress := List[I].Substring(2).ToBoolean;
end;
end;
@ -148,15 +234,22 @@ begin
end;
constructor TLZMACompressStream.Create(AOutput: TStream; AConfig: String);
var
LConfig: String;
begin
inherited Create;
FProp.Parse(AConfig);
LConfig := AConfig;
if LConfig = '' then
LConfig := 't50p';
FProp.Parse(LConfig);
FOutput := AOutput;
if FProp.Threads > 1 then
FCtx := FL2_createCStreamMt(FProp.Threads, 0)
else
FCtx := FL2_createCStream;
FL2_initCStream(FCtx, FProp.Level);
FL2_CStream_setParameter(FCtx, FL2_cParameter.FL2_p_highCompression,
Integer(FProp.HighCompress));
FInitialized := False;
end;
destructor TLZMACompressStream.Destroy;
@ -164,14 +257,17 @@ var
Oup: FL2_outBuffer;
Res: size_t;
begin
Oup.dst := @FBuffer[0];
Oup.size := FBufferSize;
Oup.pos := 0;
repeat
Res := FL2_endStream(FCtx, @Oup);
FOutput.WriteBuffer(FBuffer[0], Oup.pos);
if FInitialized then
begin
Oup.dst := @FBuffer[0];
Oup.size := FBufferSize;
Oup.pos := 0;
until Res = 0;
repeat
Res := FL2_endStream(FCtx, @Oup);
FOutput.WriteBuffer(FBuffer[0], Oup.pos);
Oup.pos := 0;
until Res = 0;
end;
FL2_freeCCtx(FCtx);
inherited Destroy;
end;
@ -182,6 +278,11 @@ var
Oup: FL2_outBuffer;
begin
Result := 0;
if not FInitialized then
begin
FL2_initCStream(FCtx, FProp.Level);
FInitialized := True;
end;
Inp.src := PByte(@Buffer);
Inp.size := Count;
Inp.pos := 0;
@ -200,12 +301,23 @@ begin
end;
constructor TLZMADecompressStream.Create(AInput: TStream; AConfig: String);
var
LConfig: String;
LSize: Int64;
begin
inherited Create;
FProp.Parse(AConfig);
LConfig := AConfig;
if LConfig = '' then
LConfig := 't50p';
FProp.Parse(LConfig);
FInput := AInput;
LSize := 0;
LSize := LSize.MaxValue;
if FProp.Threads > 1 then
FCtx := FL2_createDStreamMt(FProp.Threads)
begin
FCtx := FL2_createDStreamMt(FProp.Threads);
FL2_setDStreamMemoryLimitMt(FCtx, LSize);
end
else
FCtx := FL2_createDStream;
FL2_initDStream(FCtx);
@ -255,50 +367,44 @@ end;
procedure Init;
begin
DLLStream := TResourceStream.Create(HInstance, 'fast_lzma2', RT_RCDATA);
DLLHandle := MemoryLoadLibary(DLLStream.Memory);
if Assigned(DLLHandle) then
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'fast-lzma2.dll');
if Lib.Loaded then
begin
@FL2_compress := MemoryGetProcAddress(DLLHandle, 'FL2_compress');
@FL2_compressMt := MemoryGetProcAddress(DLLHandle, 'FL2_compressMt');
@FL2_decompress := MemoryGetProcAddress(DLLHandle, 'FL2_decompress');
@FL2_decompressMt := MemoryGetProcAddress(DLLHandle, 'FL2_decompressMt');
@FL2_createCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_createCCtx');
@FL2_createCCtxMt := MemoryGetProcAddress(DLLHandle, 'FL2_createCCtxMt');
@FL2_freeCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_freeCCtx');
@FL2_compressCCtx := MemoryGetProcAddress(DLLHandle, 'FL2_compressCCtx');
@FL2_createDCtx := MemoryGetProcAddress(DLLHandle, 'FL2_createDCtx');
@FL2_createDCtxMt := MemoryGetProcAddress(DLLHandle, 'FL2_createDCtxMt');
@FL2_freeDCtx := MemoryGetProcAddress(DLLHandle, 'FL2_freeDCtx');
@FL2_decompressDCtx := MemoryGetProcAddress(DLLHandle,
'FL2_decompressDCtx');
@FL2_createCStream := MemoryGetProcAddress(DLLHandle, 'FL2_createCStream');
@FL2_createCStreamMt := MemoryGetProcAddress(DLLHandle,
'FL2_createCStreamMt');
@FL2_freeCStream := MemoryGetProcAddress(DLLHandle, 'FL2_freeCStream');
@FL2_initCStream := MemoryGetProcAddress(DLLHandle, 'FL2_initCStream');
@FL2_compressStream := MemoryGetProcAddress(DLLHandle,
'FL2_compressStream');
@FL2_createDStream := MemoryGetProcAddress(DLLHandle, 'FL2_createDStream');
@FL2_createDStreamMt := MemoryGetProcAddress(DLLHandle,
'FL2_createDStreamMt');
@FL2_freeDStream := MemoryGetProcAddress(DLLHandle, 'FL2_freeDStream');
@FL2_initDStream := MemoryGetProcAddress(DLLHandle, 'FL2_initDStream');
@FL2_decompressStream := MemoryGetProcAddress(DLLHandle,
'FL2_decompressStream');
@FL2_endStream := MemoryGetProcAddress(DLLHandle, 'FL2_endStream');
@FL2_isError := MemoryGetProcAddress(DLLHandle, 'FL2_isError');
@FL2_compress := Lib.GetProcAddr('FL2_compress');
@FL2_compressMt := Lib.GetProcAddr('FL2_compressMt');
@FL2_decompress := Lib.GetProcAddr('FL2_decompress');
@FL2_decompressMt := Lib.GetProcAddr('FL2_decompressMt');
@FL2_createCCtx := Lib.GetProcAddr('FL2_createCCtx');
@FL2_createCCtxMt := Lib.GetProcAddr('FL2_createCCtxMt');
@FL2_freeCCtx := Lib.GetProcAddr('FL2_freeCCtx');
@FL2_compressCCtx := Lib.GetProcAddr('FL2_compressCCtx');
@FL2_createDCtx := Lib.GetProcAddr('FL2_createDCtx');
@FL2_createDCtxMt := Lib.GetProcAddr('FL2_createDCtxMt');
@FL2_freeDCtx := Lib.GetProcAddr('FL2_freeDCtx');
@FL2_decompressDCtx := Lib.GetProcAddr('FL2_decompressDCtx');
@FL2_createCStream := Lib.GetProcAddr('FL2_createCStream');
@FL2_createCStreamMt := Lib.GetProcAddr('FL2_createCStreamMt');
@FL2_freeCStream := Lib.GetProcAddr('FL2_freeCStream');
@FL2_initCStream := Lib.GetProcAddr('FL2_initCStream');
@FL2_compressStream := Lib.GetProcAddr('FL2_compressStream');
@FL2_createDStream := Lib.GetProcAddr('FL2_createDStream');
@FL2_createDStreamMt := Lib.GetProcAddr('FL2_createDStreamMt');
@FL2_freeDStream := Lib.GetProcAddr('FL2_freeDStream');
@FL2_initDStream := Lib.GetProcAddr('FL2_initDStream');
@FL2_decompressStream := Lib.GetProcAddr('FL2_decompressStream');
@FL2_endStream := Lib.GetProcAddr('FL2_endStream');
@FL2_isError := Lib.GetProcAddr('FL2_isError');
@FL2_CStream_setParameter := Lib.GetProcAddr('FL2_CStream_setParameter');
@FL2_CStream_getParameter := Lib.GetProcAddr('FL2_CStream_getParameter');
@FL2_setDStreamMemoryLimitMt :=
Lib.GetProcAddr('FL2_setDStreamMemoryLimitMt');
DLLLoaded := Assigned(FL2_compress) and Assigned(FL2_decompress);
end
else
DLLLoaded := False;
end;
end;
procedure Deinit;
begin
if not DLLLoaded then
exit;
MemoryFreeLibrary(DLLHandle);
Lib.Free;
end;
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
uses
LibImport,
WinAPI.Windows,
System.SysUtils, System.Classes;
@ -32,30 +33,25 @@ var
implementation
var
DLLHandle: THandle;
Lib: TLibImport;
procedure Init;
begin
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) +
'jojpeg_dll.dll'));
if DLLHandle >= 32 then
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'jojpeg_dll.dll');
if Lib.Loaded then
begin
@jojpeg_Init := GetProcAddress(DLLHandle, 'jojpeg_Init');
@jojpeg_Quit := GetProcAddress(DLLHandle, 'jojpeg_Quit');
@jojpeg_Loop := GetProcAddress(DLLHandle, 'jojpeg_Loop');
@jojpeg_Getvalue := GetProcAddress(DLLHandle, 'jojpeg_Getvalue');
@jojpeg_Addbuf := GetProcAddress(DLLHandle, 'jojpeg_Addbuf');
@jojpeg_Init := Lib.GetProcAddr('jojpeg_Init');
@jojpeg_Quit := Lib.GetProcAddr('jojpeg_Quit');
@jojpeg_Loop := Lib.GetProcAddr('jojpeg_Loop');
@jojpeg_Getvalue := Lib.GetProcAddr('jojpeg_Getvalue');
@jojpeg_Addbuf := Lib.GetProcAddr('jojpeg_Addbuf');
DLLLoaded := Assigned(jojpeg_Init);
end
else
DLLLoaded := False;
end;
end;
procedure Deinit;
begin
if not DLLLoaded then
exit;
FreeLibrary(DLLHandle);
Lib.Free;
end;
initialization

View File

@ -3,13 +3,23 @@ unit LZ4DLL;
interface
uses
LibImport,
WinAPI.Windows,
System.SysUtils;
System.SysUtils, System.Math;
const
LZ4F_VERSION = 100;
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_blockSizeID_t = (LZ4F_default = 0, LZ4F_max64KB = 4, LZ4F_max256KB = 5,
@ -83,67 +93,65 @@ var
LZ4F_getFrameInfo: function(dctx: LZ4F_dctx;
out frameInfoPtr: LZ4F_frameInfo_t; srcBuffer: Pointer;
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;
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
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;
compressedSize: Integer; maxDecompressedSize: Integer): Integer;
sourceSize: Integer; destSize: Integer; compressedSize: PInteger;
blockSize: PInteger): Integer;
var
ctx: LZ4F_dctx;
srcSizePtr, dstSizePtr: size_t;
fi: LZ4F_frameInfo_t;
srcSizePtr, dstSizePtr, srcSizePtr2: size_t;
begin
Result := 0;
if Assigned(compressedSize) then
compressedSize^ := 0;
if Assigned(blockSize) then
blockSize^ := 4;
if NativeUInt(LZ4F_createDecompressionContext(ctx)) = 0 then
try
srcSizePtr := compressedSize;
dstSizePtr := maxDecompressedSize;
srcSizePtr := sourceSize;
dstSizePtr := destSize;
try
FillChar(fi, SizeOf(LZ4F_frameInfo_t), 0);
srcSizePtr2 := sourceSize;
if LZ4F_decompress(ctx, dest, dstSizePtr, source, srcSizePtr, nil) = 0
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;
end;
finally
LZ4F_freeDecompressionContext(ctx);
end;
@ -151,6 +159,157 @@ begin
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
DLLParam = '--lz4=';

View File

@ -3,6 +3,7 @@ unit LZODLL;
interface
uses
LibImport,
WinAPI.Windows,
System.SysUtils;
@ -60,83 +61,36 @@ var
dst: Pointer; dst_len: PNativeUInt; wrkmem: Pointer): integer; cdecl;
lzo2a_decompress_safe: function(const src: Pointer; src_len: NativeUInt;
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;
function lzo1x_99_compress(const src: Pointer; src_len: NativeUInt;
dst: Pointer; dst_len: PNativeUInt; compression_level: integer): integer;
implementation
var
DLLHandle: THandle;
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;
Lib: TLibImport;
procedure Init(Filename: String);
begin
if DLLLoaded then
Exit;
DLLHandle := LoadLibrary(PChar(ExtractFilePath(ParamStr(0)) + Filename));
if DLLHandle >= 32 then
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
if Lib.Loaded then
begin
@lzo1x_1_compress := GetProcAddress(DLLHandle, 'lzo1x_1_compress');
@lzo1x_1_11_compress := GetProcAddress(DLLHandle, 'lzo1x_1_11_compress');
@lzo1x_1_12_compress := GetProcAddress(DLLHandle, 'lzo1x_1_12_compress');
@lzo1x_1_15_compress := GetProcAddress(DLLHandle, 'lzo1x_1_15_compress');
@lzo1x_999_compress := GetProcAddress(DLLHandle, 'lzo1x_999_compress');
@lzo1x_999_compress_level := GetProcAddress(DLLHandle,
'lzo1x_999_compress_level');
@lzo1x_decompress_safe := GetProcAddress(DLLHandle,
'lzo1x_decompress_safe');
@lzo1c_999_compress := GetProcAddress(DLLHandle, 'lzo1c_999_compress');
@lzo1c_decompress_safe := GetProcAddress(DLLHandle,
'lzo1c_decompress_safe');
@lzo2a_999_compress := GetProcAddress(DLLHandle, 'lzo2a_999_compress');
@lzo2a_decompress_safe := GetProcAddress(DLLHandle,
'lzo2a_decompress_safe');
@lzo1x_1_compress := Lib.GetProcAddr('lzo1x_1_compress');
@lzo1x_1_11_compress := Lib.GetProcAddr('lzo1x_1_11_compress');
@lzo1x_1_12_compress := Lib.GetProcAddr('lzo1x_1_12_compress');
@lzo1x_1_15_compress := Lib.GetProcAddr('lzo1x_1_15_compress');
@lzo1x_999_compress := Lib.GetProcAddr('lzo1x_999_compress');
@lzo1x_999_compress_level := Lib.GetProcAddr('lzo1x_999_compress_level');
@lzo1x_decompress_safe := Lib.GetProcAddr('lzo1x_decompress_safe');
@lzo1c_999_compress := Lib.GetProcAddr('lzo1c_999_compress');
@lzo1c_decompress_safe := Lib.GetProcAddr('lzo1c_decompress_safe');
@lzo2a_999_compress := Lib.GetProcAddr('lzo2a_999_compress');
@lzo2a_decompress_safe := Lib.GetProcAddr('lzo2a_decompress_safe');
DLLLoaded := Assigned(lzo1x_decompress_safe);
end
else
DLLLoaded := False;
end;
end;
procedure Deinit;
begin
if not DLLLoaded then
Exit;
FreeLibrary(DLLHandle);
Lib.Free;
end;
const

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ unit ZLibDLL;
interface
uses
LibImport,
WinAPI.Windows,
System.SysUtils, System.Types, System.IOUtils, System.ZLib;
@ -86,55 +87,8 @@ function inflateReset(var strm: z_stream): integer;
implementation
var
DLLHandle: THandle;
Lib: TLibImport;
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,
strategy: integer): integer;
@ -192,11 +146,49 @@ begin
Result := System.ZLib.inflateReset(strm);
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;
begin
if not DLLLoaded then
Exit;
FreeLibrary(DLLHandle);
Lib.Free;
end;
const

View File

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

View File

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

View File

@ -3,9 +3,11 @@ unit PrecompLZ4;
interface
uses
LZ4DLL, XDeltaDLL,
LZ4DLL,
lz4,
Utils,
PrecompUtils,
WinAPI.Windows,
System.SysUtils, System.StrUtils, System.Classes, System.Math;
var
@ -163,7 +165,8 @@ procedure LZ4Scan1(Instance, Depth: Integer; Input: PByte;
Funcs: PPrecompFuncs);
var
Buffer: PByte;
X, Y: Integer;
Pos: NativeInt;
X, Y, Z: Integer;
SI: _StrInfo1;
DI1, DI2: TDepthInfo;
DS: TPrecompStr;
@ -173,8 +176,10 @@ begin
if DS <> '' then
begin
X := IndexTextW(@DS[0], LZ4Codecs);
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;
Y := Max(DI1.NewSize, L_MAXSIZE);
@ -212,6 +217,71 @@ begin
end;
if BoolArray(CodecEnabled, False) then
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;
function LZ4Scan2(Instance, Depth: Integer; Input: Pointer; Size: NativeInt;
@ -271,7 +341,7 @@ begin
if GetBits(StreamInfo^.Option, 5, 7) <> I then
continue;
if (StreamInfo^.Status = TStreamStatus.Database) and
(GetBits(StreamInfo^.Option, 1, 31) = 0) then
(GetBits(StreamInfo^.Option, 31, 1) = 0) then
begin
Res1 := StreamInfo^.OldSize;
Result := True;
@ -283,6 +353,8 @@ begin
begin
Params := 'a' + GetBits(StreamInfo^.Option, 15, 7).ToString;
if not Result then
{ Res1 := LZ4_compress_block(NewInput, Buffer,
StreamInfo^.NewSize, Y); }
Res1 := LZ4_compress_fast(NewInput, Buffer, StreamInfo^.NewSize, Y,
GetBits(StreamInfo^.Option, 15, 7));
end;
@ -314,7 +386,7 @@ begin
StreamInfo^.OldSize);
Funcs^.LogProcess(LZ4Codecs[GetBits(StreamInfo^.Option, 0, 5)],
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;
end;
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or

View File

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

View File

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

View File

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

View File

@ -3,26 +3,11 @@ unit PrecompOodle;
interface
uses
OodleDLL, XDeltaDLL,
OodleDLL,
Utils,
PrecompUtils,
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
Codec: TPrecompressor;
@ -40,13 +25,13 @@ const
LEVIATHAN_CODEC = 5;
const
O_COUNT = 0;
O_LENGTH = 32;
O_TRADEOFF = 256;
O_MAXSIZE = 16 * 1024 * 1024;
var
SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList;
OCount: Integer = O_COUNT;
OLength: Integer = O_LENGTH;
OTradeOff: Integer = O_TRADEOFF;
CodecAvailable, CodecEnabled: TArray<Boolean>;
@ -247,135 +232,36 @@ begin
Result := A;
end;
function CustomLZ_Decompress0(src, dst: PByte; srcSize, dstCapacity: Integer;
function CustomLZ_Decompress(src, dst: PByte; srcSize, dstCapacity: Integer;
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
MinSize = 64;
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
LBuffer: array [0 .. BlkSize - 1] of Byte;
I, J, W, X, Y, Z: Integer;
LR1, LR2: T3Res;
W, X, Y, Z: Integer;
begin
Result := False;
Y := Max(LocalLZ_Decompress(src, dst, srcSize, dstCapacity, 0, Z),
LocalLZ_Decompress(src, dst, srcSize, dstCapacity, 1, Z));
if Y > MinSize then
Y := 0;
X := dstCapacity;
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
W := IfThen(Y mod BlkSize = 0, Pred(Y div BlkSize), Y div BlkSize)
* BlkSize;
Move((dst + W)^, LBuffer[0], Y - W);
X := Min(Max(LocalLZ_Decompress(src, dst, srcSize, X, 0, Y),
LocalLZ_Decompress(src, dst, srcSize, X, 1, Y)), Pred(X));
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
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;
exit;
end;
Result := True;
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;
function GetOodleUS(Instance: Integer; Input: PByte; Pos: NativeInt;
@ -386,25 +272,29 @@ const
var
Buffer: PByte;
B: Boolean;
I: Integer;
ResultN: TIntegerDynArray;
SI: _StrInfo1;
begin
Result := 0;
{ if StreamInfo^.Codec = 3 then
exit; }
// StreamInfo^.DSize:=$8001;
Buffer := Funcs^.Allocator(Instance, StreamInfo^.DSize);
if OCount <= 0 then
B := CustomLZ_Decompress0(Input + Pos, Buffer, StreamInfo^.CSize,
StreamInfo^.DSize, Result)
case StreamInfo^.Codec of
1:
if (CodecEnabled[KRAKEN_CODEC] = False) and
(CodecEnabled[HYDRA_CODEC] = False) then
exit;
2:
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
begin
B := CustomLZ_DecompressN(Input + Pos, Buffer, StreamInfo^.CSize,
StreamInfo^.DSize, ResultN);
if B then
Result := ResultN[0];
exit;
end;
Buffer := Funcs^.Allocator(Instance, StreamInfo^.DSize);
B := CustomLZ_Decompress(Input + Pos, Buffer, StreamInfo^.CSize,
StreamInfo^.DSize, Result);
If B then
if (Result > MinSize) and (Result > StreamInfo^.CSize) then
begin
@ -415,37 +305,25 @@ begin
SetBits(SI.Option, OTradeOff, 13, 11);
case StreamInfo^.Codec of
1:
SetBits(SI.Option, KRAKEN_CODEC, 0, 5);
if CodecEnabled[KRAKEN_CODEC] then
SetBits(SI.Option, KRAKEN_CODEC, 0, 5);
2:
if CodecEnabled[MERMAID_CODEC] then
SetBits(SI.Option, MERMAID_CODEC, 0, 5)
else
else if CodecEnabled[SELKIE_CODEC] then
SetBits(SI.Option, SELKIE_CODEC, 0, 5);
3:
SetBits(SI.Option, LEVIATHAN_CODEC, 0, 5);
if CodecEnabled[LEVIATHAN_CODEC] then
SetBits(SI.Option, LEVIATHAN_CODEC, 0, 5);
end;
if CodecEnabled[HYDRA_CODEC] then
SetBits(SI.Option, HYDRA_CODEC, 0, 5);
SetBits(SI.Option, Integer(StreamInfo^.HasCRC), 12, 1);
SI.Status := TStreamStatus.None;
if OCount <= 0 then
begin
SI.NewSize := Result;
Funcs^.LogScan1(OodleCodecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize);
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;
SI.NewSize := Result;
Funcs^.LogScan1(OodleCodecs[GetBits(SI.Option, 0, 5)], SI.Position,
SI.OldSize, SI.NewSize);
Add(Instance, @SI, nil, nil);
end;
end;
@ -502,7 +380,7 @@ begin
SOList[I][Y].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
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
OTradeOff := StrToInt(Funcs^.GetParam(Command, X, 't'));
end;
@ -573,7 +451,11 @@ begin
if DS <> '' then
begin
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;
if not CodecAvailable[X] then
exit;
@ -589,7 +471,7 @@ begin
begin
if DI1.NewSize <= 0 then
begin
if not CustomLZ_Decompress0(Input, Buffer, DI1.OldSize, Res, Res)
if not CustomLZ_Decompress(Input, Buffer, DI1.OldSize, Res, Res)
then
Res := 0;
end
@ -678,7 +560,7 @@ begin
then
begin
Buffer := Funcs^.Allocator(Instance, OodleSI.DSize);
if CustomLZ_Decompress0(Input, Buffer, StreamInfo^.OldSize,
if CustomLZ_Decompress(Input, Buffer, StreamInfo^.OldSize,
OodleSI.DSize, Res) then
begin
Output(Instance, Buffer, Res);
@ -716,7 +598,7 @@ begin
if GetBits(StreamInfo^.Option, 5, 7) <> I then
continue;
if (StreamInfo^.Status = TStreamStatus.Database) and
(GetBits(StreamInfo^.Option, 1, 31) = 0) then
(GetBits(StreamInfo^.Option, 31, 1) = 0) then
begin
Res1 := StreamInfo^.OldSize;
Result := True;
@ -726,6 +608,7 @@ begin
SizeOf(TOodleLZ_CompressOptions));
COptions.sendQuantumCRCs := GetBits(StreamInfo^.Option, 12, 1) = 1;
COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo^.Option, 13, 11);
// COptions.dictionarySize := 262144;
Params := 'l' + I.ToString + ':' + 'c' + GetBits(StreamInfo^.Option, 12, 1)
.ToString + ':' + 't' + GetBits(StreamInfo^.Option, 13, 11).ToString;
if not Result then
@ -739,22 +622,22 @@ begin
if Result or (StreamInfo^.Status = TStreamStatus.Predicted) then
break;
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
begin
begin
Buffer := Funcs^.Allocator(Instance, Res1 + Max(StreamInfo^.OldSize, Res1));
Res2 := PrecompEncodePatch(OldInput, StreamInfo^.OldSize, Buffer, Res1,
Buffer + Res1, Max(StreamInfo^.OldSize, Res1));
Buffer + Res1, Max(StreamInfo^.OldSize, Res1));
Funcs^.LogPatch1(StreamInfo^.OldSize, Res1, Res2,
Funcs^.AcceptPatch(StreamInfo^.OldSize, Res1, Res2));
Funcs^.AcceptPatch(StreamInfo^.OldSize, Res1, Res2));
if Funcs^.AcceptPatch(StreamInfo^.OldSize, Res1, Res2) then
begin
Output(Instance, Buffer + Res1, Res2);
SetBits(StreamInfo^.Option, 1, 31, 1);
SOList[Instance][X].Add(I);
Result := True;
Output(Instance, Buffer + Res1, Res2);
SetBits(StreamInfo^.Option, 1, 31, 1);
SOList[Instance][X].Add(I);
Result := True;
end;
end;
end; }
if Result then
begin
SetBits(StreamInfo^.Option, I, 5, 7);

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{E490A6E6-3D5F-49E7-860E-CB57A73FBF77}</ProjectGuid>
<ProjectVersion>19.4</ProjectVersion>
<ProjectVersion>19.5</ProjectVersion>
<FrameworkType>None</FrameworkType>
<MainSource>xtool.dpr</MainSource>
<Base>True</Base>
@ -13,6 +13,26 @@
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</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)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
@ -51,6 +71,28 @@
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
<SanitizedProjectName>xtool</SanitizedProjectName>
</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)'!=''">
<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>
@ -97,6 +139,7 @@
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="common\LibImport.pas"/>
<DCCReference Include="common\Threading.pas"/>
<DCCReference Include="common\Utils.pas"/>
<DCCReference Include="contrib\Delphi_MemoryModule\FuncHook.pas"/>
@ -106,8 +149,6 @@
<DCCReference Include="contrib\mORMot\SynCrypto.pas"/>
<DCCReference Include="contrib\mORMot\SynLZ.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\ParseClass.pas"/>
<DCCReference Include="contrib\ParseExpression\ParseExpr.pas"/>
@ -148,17 +189,7 @@
<DCCReference Include="io\IOExecute.pas"/>
<DCCReference Include="io\IODecode.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"/>
<RcItem Include="resources\Win64\fast-lzma2.dll">
<ContainerId>ResourceItem</ContainerId>
<ResourceType>RCDATA</ResourceType>
<ResourceId>fast_lzma2</ResourceId>
</RcItem>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
@ -180,7 +211,7 @@
<Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<Deployment Version="4">
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
@ -196,42 +227,15 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="changes.txt" Configuration="Release" Class="ProjectFile"/>
<DeployFile LocalName="changes.txt" Configuration="Release" Class="ProjectFile">
<Platform Name="Win64">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="resources\Win32\xdelta3_dll.dll" Configuration="Release" Class="ProjectFile">
<Platform Name="Win32">
<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="Win32\Release\xtool.exe" Configuration="Release" Class="ProjectOutput"/>
<DeployFile LocalName="Win64\Release\xtool.exe" Configuration="Release" Class="ProjectOutput"/>
<DeployFile LocalName="Win64\Release\xtool.exe" Configuration="Release" Class="ProjectOutput">
<Platform Name="Win64">
<RemoteName>xtool.exe</RemoteName>
@ -260,16 +264,6 @@
<Operation>64</Operation>
</Platform>
</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">
<Platform Name="Android">
<RemoteDir>res\xml</RemoteDir>
@ -579,7 +573,7 @@
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
@ -612,7 +606,7 @@
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
@ -649,7 +643,7 @@
<Platform Name="iOSDevice64">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<Operation>0</Operation>
</Platform>
<Platform Name="OSX32">
@ -673,13 +667,17 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_AppIcon152">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -689,137 +687,27 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</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">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</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">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -829,7 +717,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -839,7 +727,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -849,7 +737,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -859,7 +747,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -869,191 +757,37 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</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">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</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">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</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">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1063,7 +797,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1073,7 +807,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1083,7 +817,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1093,7 +827,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1103,7 +837,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1113,7 +847,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1123,7 +857,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
@ -1145,12 +879,8 @@
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceResourceRules">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
@ -1163,6 +893,10 @@
<RemoteDir>..\</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSInfoPList">
<Platform Name="iOSDevice32">
@ -1171,7 +905,7 @@
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
</Platform>
</DeployClass>
@ -1180,7 +914,7 @@
<RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir>
<Operation>64</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen</RemoteDir>
<Operation>64</Operation>
</Platform>
@ -1192,7 +926,7 @@
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
</Platform>
</DeployClass>
@ -1263,7 +997,7 @@
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimulator">
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
</Platform>
<Platform Name="Linux64">
@ -1323,6 +1057,7 @@
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
@ -1332,6 +1067,11 @@
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<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="Win64">True</Platform>
</Platforms>

Binary file not shown.

View File

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