ISCmplr.dpr 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. library ISCmplr;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2025 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Compiler DLL
  8. }
  9. uses
  10. SafeDLLPath in '..\Components\SafeDLLPath.pas',
  11. SysUtils,
  12. Shared.CompilerInt.Struct in 'Src\Shared.CompilerInt.Struct.pas',
  13. Shared.PreprocInt in 'Src\Shared.PreprocInt.pas',
  14. Compiler.Compile in 'Src\Compiler.Compile.pas',
  15. Compiler.SetupCompiler in 'Src\Compiler.SetupCompiler.pas',
  16. Compiler.Messages in 'Src\Compiler.Messages.pas',
  17. Compiler.StringLists in 'Src\Compiler.StringLists.pas',
  18. Compiler.CompressionHandler in 'Src\Compiler.CompressionHandler.pas',
  19. Compiler.HelperFunc in 'Src\Compiler.HelperFunc.pas',
  20. Compiler.BuiltinPreproc in 'Src\Compiler.BuiltinPreproc.pas',
  21. Shared.Struct in 'Src\Shared.Struct.pas',
  22. Shared.ScriptFunc in 'Src\Shared.ScriptFunc.pas',
  23. Compiler.ScriptFunc in 'Src\Compiler.ScriptFunc.pas',
  24. Compiler.ScriptCompiler in 'Src\Compiler.ScriptCompiler.pas',
  25. Compiler.ScriptClasses in 'Src\Compiler.ScriptClasses.pas',
  26. Compiler.ExeUpdateFunc in 'Src\Compiler.ExeUpdateFunc.pas',
  27. Compression.Base in 'Src\Compression.Base.pas',
  28. Compression.Zlib in 'Src\Compression.Zlib.pas',
  29. Compression.bzlib in 'Src\Compression.bzlib.pas',
  30. Compression.LZMACompressor in 'Src\Compression.LZMACompressor.pas',
  31. Shared.FileClass in 'Src\Shared.FileClass.pas',
  32. ChaCha20 in '..\Components\ChaCha20.pas',
  33. Shared.VerInfoFunc in 'Src\Shared.VerInfoFunc.pas',
  34. PathFunc in '..\Components\PathFunc.pas',
  35. TrustFunc in '..\Components\TrustFunc.pas',
  36. Shared.CommonFunc in 'Src\Shared.CommonFunc.pas',
  37. SHA256 in '..\Components\SHA256.pas',
  38. Shared.DebugStruct in 'Src\Shared.DebugStruct.pas',
  39. Shared.LangOptionsSectionDirectives in 'Src\Shared.LangOptionsSectionDirectives.pas',
  40. Shared.SetupMessageIDs in 'Src\Shared.SetupMessageIDs.pas',
  41. Shared.SetupEntFunc in 'Src\Shared.SetupEntFunc.pas',
  42. Shared.SetupSectionDirectives in 'Src\Shared.SetupSectionDirectives.pas',
  43. Shared.SetupTypes in 'Src\Shared.SetupTypes.pas',
  44. Shared.SetupSteps in 'Src\Shared.SetupSteps.pas',
  45. SimpleExpression in '..\Components\SimpleExpression.pas',
  46. Shared.DotNetVersion in 'Src\Shared.DotNetVersion.pas',
  47. PBKDF2 in '..\Components\PBKDF2.pas',
  48. ECDSA in '..\Components\ECDSA.pas',
  49. ISSigFunc in '..\Components\ISSigFunc.pas',
  50. StringScanner in '..\Components\StringScanner.pas',
  51. Shared.EncryptionFunc in 'Src\Shared.EncryptionFunc.pas',
  52. UnsignedFunc in '..\Components\UnsignedFunc.pas',
  53. uPSC_classes in '..\Components\UniPs\Source\uPSC_classes.pas',
  54. uPSC_comobj in '..\Components\UniPs\Source\uPSC_comobj.pas',
  55. uPSC_controls in '..\Components\UniPs\Source\uPSC_controls.pas',
  56. uPSC_dll in '..\Components\UniPs\Source\uPSC_dll.pas',
  57. uPSC_extctrls in '..\Components\UniPs\Source\uPSC_extctrls.pas',
  58. uPSC_forms in '..\Components\UniPs\Source\uPSC_forms.pas',
  59. uPSC_graphics in '..\Components\UniPs\Source\uPSC_graphics.pas',
  60. uPSC_std in '..\Components\UniPs\Source\uPSC_std.pas',
  61. uPSC_stdctrls in '..\Components\UniPs\Source\uPSC_stdctrls.pas',
  62. uPSCompiler in '..\Components\UniPs\Source\uPSCompiler.pas',
  63. uPSUtils in '..\Components\UniPs\Source\uPSUtils.pas';
  64. {$IMAGEBASE $00800000}
  65. {$SETPEOSVERSION 6.1}
  66. {$SETPESUBSYSVERSION 6.1}
  67. {$WEAKLINKRTTI ON}
  68. {$R Res\ISCmplr.images.res}
  69. {$R Res\ISCmplr.images.dark.res}
  70. {$R Res\ISCmplr.version.res}
  71. function ISDllCompileScript(const Params: TCompileScriptParamsEx): Integer;
  72. stdcall;
  73. begin
  74. Result := ISCompileScript(Params, False);
  75. end;
  76. type
  77. PWrapperData = ^TWrapperData;
  78. TWrapperData = record
  79. CallerParams: PCompileScriptParamsEx;
  80. LastLineRead: String;
  81. end;
  82. { Does not support iscbNotifyPreproc }
  83. function WrapperCallbackProc(Code: Integer; var Data: TCompilerCallbackData;
  84. AppData: NativeInt): Integer;
  85. stdcall;
  86. var
  87. WrapperData: PWrapperData;
  88. CallerParams: PCompileScriptParamsEx;
  89. AnsiStatusMsg, AnsiOutputExeFilename, AnsiErrorMsg, AnsiErrorFilename: AnsiString;
  90. begin
  91. WrapperData := PWrapperData(AppData);
  92. CallerParams := WrapperData.CallerParams;
  93. case Code of
  94. iscbReadScript:
  95. begin
  96. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  97. if Assigned(Data.LineRead) then begin
  98. WrapperData.LastLineRead := String(PAnsiChar(Data.LineRead));
  99. Data.LineRead := PWideChar(WrapperData.LastLineRead);
  100. end;
  101. end;
  102. iscbNotifyStatus:
  103. begin
  104. if Assigned(Data.StatusMsg) then begin
  105. AnsiStatusMsg := AnsiString(Data.StatusMsg);
  106. Data.StatusMsg := PWideChar(PAnsiChar(AnsiStatusMsg));
  107. end;
  108. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  109. end;
  110. iscbNotifySuccess:
  111. begin
  112. if Assigned(Data.OutputExeFilename) then begin
  113. AnsiOutputExeFilename := AnsiString(Data.OutputExeFilename);
  114. Data.OutputExeFilename := PWideChar(PAnsiChar(AnsiOutputExeFilename));
  115. end;
  116. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  117. end;
  118. iscbNotifyError:
  119. begin
  120. if Assigned(Data.ErrorMsg) then begin
  121. AnsiErrorMsg := AnsiString(Data.ErrorMsg);
  122. Data.ErrorMsg := PWideChar(PAnsiChar(AnsiErrorMsg));
  123. end;
  124. if Assigned(Data.ErrorFilename) then begin
  125. AnsiErrorFilename := AnsiString(Data.ErrorFilename);
  126. Data.ErrorFilename := PWideChar(PAnsiChar(AnsiErrorFilename));
  127. end;
  128. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  129. end;
  130. else
  131. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  132. end;
  133. end;
  134. function ISDllCompileScriptA(const Params: TCompileScriptParamsEx): Integer;
  135. stdcall;
  136. var
  137. WrapperData: TWrapperData;
  138. WrapperParams: PCompileScriptParamsEx;
  139. P: PAnsiChar;
  140. Options: String;
  141. begin
  142. if ((Params.Size <> SizeOf(Params)) and
  143. (Params.Size <> SizeOf(TCompileScriptParams))) or
  144. not Assigned(Params.CallbackProc) then begin
  145. Result := isceInvalidParam;
  146. Exit;
  147. end;
  148. WrapperData.CallerParams := @Params;
  149. GetMem(WrapperParams, Params.Size);
  150. try
  151. UMove(Params, WrapperParams^, Params.Size);
  152. WrapperParams.CallbackProc := WrapperCallbackProc;
  153. WrapperParams.AppData := NativeInt(@WrapperData);
  154. if Assigned(Params.CompilerPath) then
  155. WrapperParams.CompilerPath := PWideChar(String(PAnsiChar(Params.CompilerPath)));
  156. if Assigned(Params.SourcePath) then
  157. WrapperParams.SourcePath := PWideChar(String(PAnsiChar(Params.SourcePath)));
  158. if (Params.Size <> SizeOf(TCompileScriptParams)) and Assigned(Params.Options) then begin
  159. P := PAnsiChar(Params.Options);
  160. while P^ <> #0 do begin
  161. Options := Options + String(P) + #0;
  162. Inc(P, StrLen(P) + 1);
  163. end;
  164. WrapperParams.Options := PWideChar(Options);
  165. end;
  166. Result := ISCompileScript(WrapperParams^, False);
  167. finally
  168. FreeMem(WrapperParams);
  169. end;
  170. end;
  171. function ISDllGetVersion: PCompilerVersionInfo; stdcall;
  172. begin
  173. Result := ISGetVersion;
  174. end;
  175. exports
  176. ISDllCompileScript name 'ISDllCompileScriptW',
  177. ISDllCompileScriptA name 'ISDllCompileScript',
  178. ISDllGetVersion;
  179. begin
  180. { The user might call ISDllCompileScript from multiple threads
  181. simultaneously, so set our instance of the Delphi memory manager to
  182. thread-safe mode }
  183. IsMultiThread := True;
  184. end.