forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathISCmplr.dpr
161 lines (148 loc) · 4.94 KB
/
ISCmplr.dpr
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
library ISCmplr;
{
Inno Setup
Copyright (C) 1997-2020 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Compiler DLL
}
{$IMAGEBASE $00800000}
{$SETPEOSVERSION 6.0}
{$SETPESUBSYSVERSION 6.0}
{$WEAKLINKRTTI ON}
uses
SafeDLLPath in 'SafeDLLPath.pas',
SysUtils,
CompInt in 'CompInt.pas',
CompPreprocInt in 'CompPreprocInt.pas',
Compile in 'Compile.pas',
CompMsgs in 'CompMsgs.pas',
Struct in 'Struct.pas',
ScriptFunc in 'ScriptFunc.pas',
ScriptFunc_C in 'ScriptFunc_C.pas',
ScriptCompiler in 'ScriptCompiler.pas',
ScriptClasses_C in 'ScriptClasses_C.pas',
ResUpdate in 'ResUpdate.pas',
CompExeUpdate in 'CompExeUpdate.pas',
Compress in 'Compress.pas',
CompressZlib in 'CompressZlib.pas',
bzlib in 'bzlib.pas',
LZMA in 'LZMA.pas',
FileClass in 'FileClass.pas',
ArcFour in 'ArcFour.pas',
VerInfo in 'VerInfo.pas';
{$R *.RES}
function ISDllCompileScript(const Params: TCompileScriptParamsEx): Integer;
stdcall;
begin
Result := ISCompileScript(Params, False);
end;
type
PWrapperData = ^TWrapperData;
TWrapperData = record
CallerParams: PCompileScriptParamsEx;
LastLineRead: String;
end;
{ Does not support iscbNotifyPreproc }
function WrapperCallbackProc(Code: Integer; var Data: TCompilerCallbackData;
AppData: Longint): Integer;
stdcall;
var
WrapperData: PWrapperData;
CallerParams: PCompileScriptParamsEx;
AnsiStatusMsg, AnsiOutputExeFilename, AnsiErrorMsg, AnsiErrorFilename: AnsiString;
begin
WrapperData := PWrapperData(AppData);
CallerParams := WrapperData.CallerParams;
case Code of
iscbReadScript:
begin
Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
if Assigned(Data.LineRead) then begin
WrapperData.LastLineRead := String(PAnsiChar(Data.LineRead));
Data.LineRead := PWideChar(WrapperData.LastLineRead);
end;
end;
iscbNotifyStatus:
begin
if Assigned(Data.StatusMsg) then begin
AnsiStatusMsg := AnsiString(Data.StatusMsg);
Data.StatusMsg := PWideChar(PAnsiChar(AnsiStatusMsg));
end;
Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
end;
iscbNotifySuccess:
begin
if Assigned(Data.OutputExeFilename) then begin
AnsiOutputExeFilename := AnsiString(Data.OutputExeFilename);
Data.OutputExeFilename := PWideChar(PAnsiChar(AnsiOutputExeFilename));
end;
Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
end;
iscbNotifyError:
begin
if Assigned(Data.ErrorMsg) then begin
AnsiErrorMsg := AnsiString(Data.ErrorMsg);
Data.ErrorMsg := PWideChar(PAnsiChar(AnsiErrorMsg));
end;
if Assigned(Data.ErrorFilename) then begin
AnsiErrorFilename := AnsiString(Data.ErrorFilename);
Data.ErrorFilename := PWideChar(PAnsiChar(AnsiErrorFilename));
end;
Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
end;
else
Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
end;
end;
function ISDllCompileScriptA(const Params: TCompileScriptParamsEx): Integer;
stdcall;
var
WrapperData: TWrapperData;
WrapperParams: PCompileScriptParamsEx;
P: PAnsiChar;
Options: String;
begin
if ((Params.Size <> SizeOf(Params)) and
(Params.Size <> SizeOf(TCompileScriptParams))) or
not Assigned(Params.CallbackProc) then begin
Result := isceInvalidParam;
Exit;
end;
WrapperData.CallerParams := @Params;
GetMem(WrapperParams, Params.Size);
try
Move(Params, WrapperParams^, Params.Size);
WrapperParams.CallbackProc := WrapperCallbackProc;
WrapperParams.AppData := Integer(@WrapperData);
if Assigned(Params.CompilerPath) then
WrapperParams.CompilerPath := PWideChar(String(PAnsiChar(Params.CompilerPath)));
if Assigned(Params.SourcePath) then
WrapperParams.SourcePath := PWideChar(String(PAnsiChar(Params.SourcePath)));
if (Params.Size <> SizeOf(TCompileScriptParams)) and Assigned(Params.Options) then begin
P := PAnsiChar(Params.Options);
while P^ <> #0 do begin
Options := Options + String(P) + #0;
Inc(P, StrLen(P) + 1);
end;
WrapperParams.Options := PWideChar(Options);
end;
Result := ISCompileScript(WrapperParams^, False);
finally
FreeMem(WrapperParams);
end;
end;
function ISDllGetVersion: PCompilerVersionInfo; stdcall;
begin
Result := ISGetVersion;
end;
exports
ISDllCompileScript name 'ISDllCompileScriptW',
ISDllCompileScriptA name 'ISDllCompileScript',
ISDllGetVersion;
begin
{ The user might call ISDllCompileScript from multiple threads
simultaneously, so set our instance of the Delphi memory manager to
thread-safe mode }
IsMultiThread := True;
end.