ISCmplr.dpr 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. library ISCmplr;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2024 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. Shared.ResUpdateFunc in 'Src\Shared.ResUpdateFunc.pas',
  27. Compiler.ExeUpdateFunc in 'Src\Compiler.ExeUpdateFunc.pas',
  28. Compression.Base in 'Src\Compression.Base.pas',
  29. Compression.Zlib in 'Src\Compression.Zlib.pas',
  30. Compression.bzlib in 'Src\Compression.bzlib.pas',
  31. Compression.LZMACompressor in 'Src\Compression.LZMACompressor.pas',
  32. Shared.FileClass in 'Src\Shared.FileClass.pas',
  33. ChaCha20 in '..\Components\ChaCha20.pas',
  34. Shared.VerInfoFunc in 'Src\Shared.VerInfoFunc.pas',
  35. PathFunc in '..\Components\PathFunc.pas',
  36. TrustFunc in '..\Components\TrustFunc.pas',
  37. Shared.CommonFunc in 'Src\Shared.CommonFunc.pas',
  38. Shared.Int64Em in 'Src\Shared.Int64Em.pas',
  39. SHA256 in '..\Components\SHA256.pas',
  40. Shared.DebugStruct in 'Src\Shared.DebugStruct.pas',
  41. Shared.LangOptionsSectionDirectives in 'Src\Shared.LangOptionsSectionDirectives.pas',
  42. Shared.SetupMessageIDs in 'Src\Shared.SetupMessageIDs.pas',
  43. Shared.SetupEntFunc in 'Src\Shared.SetupEntFunc.pas',
  44. Shared.SetupSectionDirectives in 'Src\Shared.SetupSectionDirectives.pas',
  45. Shared.SetupTypes in 'Src\Shared.SetupTypes.pas',
  46. Shared.SetupSteps in 'Src\Shared.SetupSteps.pas',
  47. SimpleExpression in '..\Components\SimpleExpression.pas',
  48. Shared.DotNetVersion in 'Src\Shared.DotNetVersion.pas',
  49. PBKDF2 in '..\Components\PBKDF2.pas',
  50. ECDSA in '..\Components\ECDSA.pas',
  51. ISSigFunc in '..\Components\ISSigFunc.pas',
  52. StringScanner in '..\Components\StringScanner.pas';
  53. {$IMAGEBASE $00800000}
  54. {$SETPEOSVERSION 6.1}
  55. {$SETPESUBSYSVERSION 6.1}
  56. {$WEAKLINKRTTI ON}
  57. {$R Res\ISCmplr.images.res}
  58. {$R Res\ISCmplr.version.res}
  59. function ISDllCompileScript(const Params: TCompileScriptParamsEx): Integer;
  60. stdcall;
  61. begin
  62. Result := ISCompileScript(Params, False);
  63. end;
  64. type
  65. PWrapperData = ^TWrapperData;
  66. TWrapperData = record
  67. CallerParams: PCompileScriptParamsEx;
  68. LastLineRead: String;
  69. end;
  70. { Does not support iscbNotifyPreproc }
  71. function WrapperCallbackProc(Code: Integer; var Data: TCompilerCallbackData;
  72. AppData: Longint): Integer;
  73. stdcall;
  74. var
  75. WrapperData: PWrapperData;
  76. CallerParams: PCompileScriptParamsEx;
  77. AnsiStatusMsg, AnsiOutputExeFilename, AnsiErrorMsg, AnsiErrorFilename: AnsiString;
  78. begin
  79. WrapperData := PWrapperData(AppData);
  80. CallerParams := WrapperData.CallerParams;
  81. case Code of
  82. iscbReadScript:
  83. begin
  84. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  85. if Assigned(Data.LineRead) then begin
  86. WrapperData.LastLineRead := String(PAnsiChar(Data.LineRead));
  87. Data.LineRead := PWideChar(WrapperData.LastLineRead);
  88. end;
  89. end;
  90. iscbNotifyStatus:
  91. begin
  92. if Assigned(Data.StatusMsg) then begin
  93. AnsiStatusMsg := AnsiString(Data.StatusMsg);
  94. Data.StatusMsg := PWideChar(PAnsiChar(AnsiStatusMsg));
  95. end;
  96. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  97. end;
  98. iscbNotifySuccess:
  99. begin
  100. if Assigned(Data.OutputExeFilename) then begin
  101. AnsiOutputExeFilename := AnsiString(Data.OutputExeFilename);
  102. Data.OutputExeFilename := PWideChar(PAnsiChar(AnsiOutputExeFilename));
  103. end;
  104. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  105. end;
  106. iscbNotifyError:
  107. begin
  108. if Assigned(Data.ErrorMsg) then begin
  109. AnsiErrorMsg := AnsiString(Data.ErrorMsg);
  110. Data.ErrorMsg := PWideChar(PAnsiChar(AnsiErrorMsg));
  111. end;
  112. if Assigned(Data.ErrorFilename) then begin
  113. AnsiErrorFilename := AnsiString(Data.ErrorFilename);
  114. Data.ErrorFilename := PWideChar(PAnsiChar(AnsiErrorFilename));
  115. end;
  116. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  117. end;
  118. else
  119. Result := CallerParams.CallbackProc(Code, Data, CallerParams.AppData);
  120. end;
  121. end;
  122. function ISDllCompileScriptA(const Params: TCompileScriptParamsEx): Integer;
  123. stdcall;
  124. var
  125. WrapperData: TWrapperData;
  126. WrapperParams: PCompileScriptParamsEx;
  127. P: PAnsiChar;
  128. Options: String;
  129. begin
  130. if ((Params.Size <> SizeOf(Params)) and
  131. (Params.Size <> SizeOf(TCompileScriptParams))) or
  132. not Assigned(Params.CallbackProc) then begin
  133. Result := isceInvalidParam;
  134. Exit;
  135. end;
  136. WrapperData.CallerParams := @Params;
  137. GetMem(WrapperParams, Params.Size);
  138. try
  139. Move(Params, WrapperParams^, Params.Size);
  140. WrapperParams.CallbackProc := WrapperCallbackProc;
  141. WrapperParams.AppData := Integer(@WrapperData);
  142. if Assigned(Params.CompilerPath) then
  143. WrapperParams.CompilerPath := PWideChar(String(PAnsiChar(Params.CompilerPath)));
  144. if Assigned(Params.SourcePath) then
  145. WrapperParams.SourcePath := PWideChar(String(PAnsiChar(Params.SourcePath)));
  146. if (Params.Size <> SizeOf(TCompileScriptParams)) and Assigned(Params.Options) then begin
  147. P := PAnsiChar(Params.Options);
  148. while P^ <> #0 do begin
  149. Options := Options + String(P) + #0;
  150. Inc(P, StrLen(P) + 1);
  151. end;
  152. WrapperParams.Options := PWideChar(Options);
  153. end;
  154. Result := ISCompileScript(WrapperParams^, False);
  155. finally
  156. FreeMem(WrapperParams);
  157. end;
  158. end;
  159. function ISDllGetVersion: PCompilerVersionInfo; stdcall;
  160. begin
  161. Result := ISGetVersion;
  162. end;
  163. exports
  164. ISDllCompileScript name 'ISDllCompileScriptW',
  165. ISDllCompileScriptA name 'ISDllCompileScript',
  166. ISDllGetVersion;
  167. begin
  168. { The user might call ISDllCompileScript from multiple threads
  169. simultaneously, so set our instance of the Delphi memory manager to
  170. thread-safe mode }
  171. IsMultiThread := True;
  172. end.