This repository was archived by the owner on Oct 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcls_xtool.dpr
More file actions
136 lines (129 loc) · 4.21 KB
/
cls_xtool.dpr
File metadata and controls
136 lines (129 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
library cls_xtool;
{$R *.res}
{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$DEFINE UseFastMM}
uses
{$IFDEF UseFastMM}
FastMM4 in 'contrib\FastMM4-AVX\FastMM4.pas',
FastMM4Messages in 'contrib\FastMM4-AVX\FastMM4Messages.pas',
{$ENDIF }
WinAPI.Windows,
System.SysUtils,
System.StrUtils,
System.Classes,
System.Types,
System.Math,
System.IOUtils,
System.SyncObjs,
CLS in 'common\CLS.pas',
DStorage in 'common\DStorage.pas',
LibImport in 'common\LibImport.pas',
Threading in 'common\Threading.pas',
Utils in 'common\Utils.pas',
libc in 'contrib\LIBC\libc.pas',
lz4lib in 'contrib\LZ4Delphi\lz4lib.pas',
FuncHook in 'contrib\Delphi_MemoryModule\FuncHook.pas',
MemoryModule in 'contrib\Delphi_MemoryModule\MemoryModule.pas',
MemoryModuleHook in 'contrib\Delphi_MemoryModule\MemoryModuleHook.pas',
SynCommons in 'contrib\mORMot\SynCommons.pas',
SynCrypto in 'contrib\mORMot\SynCrypto.pas',
SynLZ in 'contrib\mORMot\SynLZ.pas',
SynTable in 'contrib\mORMot\SynTable.pas',
oObjects in 'contrib\ParseExpression\oObjects.pas',
ParseClass in 'contrib\ParseExpression\ParseClass.pas',
ParseExpr in 'contrib\ParseExpression\ParseExpr.pas',
XXHASHLIB in 'contrib\XXHASH4Delphi\XXHASHLIB.pas',
ZSTDLib in 'contrib\ZSTD4Delphi\ZSTDLib.pas',
InitCode in 'InitCode.pas',
BrunsliDLL in 'imports\BrunsliDLL.pas',
FLACDLL in 'imports\FLACDLL.pas',
FLZMA2DLL in 'imports\FLZMA2DLL.pas',
JoJpegDLL in 'imports\JoJpegDLL.pas',
LZ4DLL in 'imports\LZ4DLL.pas',
LZODLL in 'imports\LZODLL.pas',
OodleDLL in 'imports\OodleDLL.pas',
PackJPGDLL in 'imports\PackJPGDLL.pas',
PreflateDLL in 'imports\PreflateDLL.pas',
ReflateDLL in 'imports\ReflateDLL.pas',
ZLibDLL in 'imports\ZLibDLL.pas',
ZSTDDLL in 'imports\ZSTDDLL.pas',
lz4 in 'sources\lz4.pas',
PrecompMain in 'precompressor\PrecompMain.pas',
PrecompUtils in 'precompressor\PrecompUtils.pas',
PrecompCrypto in 'precompressor\PrecompCrypto.pas',
PrecompZLib in 'precompressor\PrecompZLib.pas',
PrecompLZ4 in 'precompressor\PrecompLZ4.pas',
PrecompLZO in 'precompressor\PrecompLZO.pas',
PrecompZSTD in 'precompressor\PrecompZSTD.pas',
PrecompMedia in 'precompressor\PrecompMedia.pas',
PrecompOodle in 'precompressor\PrecompOodle.pas',
PrecompINI in 'precompressor\PrecompINI.pas',
PrecompINIEx in 'precompressor\PrecompINIEx.pas',
PrecompSearch in 'precompressor\PrecompSearch.pas',
PrecompDLL in 'precompressor\PrecompDLL.pas',
PrecompEXE in 'precompressor\PrecompEXE.pas',
PrecompDStorage in 'precompressor\PrecompDStorage.pas';
{$SETPEFLAGS IMAGE_FILE_LARGE_ADDRESS_AWARE}
function ClsMain(operation: Integer; Callback: CLS_CALLBACK; Instance: Pointer)
: Integer cdecl;
const
BufferSize = 1048576;
var
CLS: TCLSStream;
PrecompEnc: PrecompMain.TEncodeOptions;
PrecompDec: PrecompMain.TDecodeOptions;
I: Integer;
Str: array [0 .. 255] of AnsiChar;
StrArray: TArray<String>;
begin
Result := CLS_ERROR_GENERAL;
case (operation) of
CLS_COMPRESS:
begin
CLS := TCLSStream.Create(Callback, Instance);
try
FillChar(Str, Length(Str), 0);
Callback(Instance, CLS_GET_PARAMSTR, @Str[0], Length(Str));
StrArray := DecodeStr(String(Str), ':');
for I := Low(StrArray) to High(StrArray) do
StrArray[I] := '-' + StrArray[I];
PrecompMain.Parse(StrArray, PrecompEnc);
try
PrecompMain.Encode(CLS, CLS, PrecompEnc);
Result := CLS_OK;
except
Result := CLS_ERROR_GENERAL;
end;
finally
CLS.Free;
end;
end;
CLS_DECOMPRESS:
begin
CLS := TCLSStream.Create(Callback, Instance);
try
CLS.ReadBuffer(I, I.Size);
case I of
XTOOL_PRECOMP:
begin
PrecompMain.Parse(['-t100p'], PrecompDec);
try
PrecompMain.Decode(CLS, CLS, PrecompDec);
Result := CLS_OK;
except
Result := CLS_ERROR_GENERAL;
end;
end;
end;
finally
CLS.Free;
end;
end;
else
Result := CLS_ERROR_NOT_IMPLEMENTED;
end;
end;
exports ClsMain;
begin
end.