Martijn Laan 5 months ago
parent
commit
b96f44bd74
3 changed files with 14 additions and 15 deletions
  1. 7 1
      Projects/ISCC.dpr
  2. 3 11
      Projects/Src/Compiler.SetupCompiler.pas
  3. 4 3
      Projects/Src/IDE.HelperFunc.pas

+ 7 - 1
Projects/ISCC.dpr

@@ -649,6 +649,12 @@ begin
     Halt(ExitCode);
 end;
 
+function ISPPInstalled: Boolean;
+begin
+  var Filename := PathExtractPath(NewParamStr(0)) + 'ISPP.dll';
+  Result := NewFileExists(Filename) and TrustedFile(Filename);
+end;
+
 begin
   SignTools := TStringList.Create;
   try
@@ -659,7 +665,7 @@ begin
     StdErrHandleIsConsole := GetConsoleMode(StdErrHandle, Mode);
     SetConsoleCtrlHandler(@ConsoleCtrlHandler, True);
     try
-      IsppMode := FileExists(ExtractFilePath(NewParamStr(0)) + 'ispp.dll');
+      IsppMode := ISPPInstalled;
       ProcessCommandLine;
       Go;
     except

+ 3 - 11
Projects/Src/Compiler.SetupCompiler.pas

@@ -506,21 +506,13 @@ begin
 end;
 
 procedure TSetupCompiler.InitPreprocessor;
-{$IFNDEF STATICPREPROC}
-var
-  Filename: String;
-  Attr: DWORD;
-  M: HMODULE;
-{$ENDIF}
 begin
   if PreprocessorInitialized then
     Exit;
 {$IFNDEF STATICPREPROC}
-  Filename := CompilerDir + 'ISPP.dll';
-  Attr := GetFileAttributes(PChar(Filename));
-  if not ((Attr = $FFFFFFFF) and (GetLastError = ERROR_FILE_NOT_FOUND)) and
-     TrustedFile(Filename) then begin
-    M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
+  var Filename := CompilerDir + 'ISPP.dll';
+  if NewFileExists(Filename) and TrustedFile(Filename) then begin
+    var M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
     if M = 0 then
       AbortCompileFmt('Failed to load preprocessor DLL "%s" (%d)',
         [Filename, GetLastError]);

+ 4 - 3
Projects/Src/IDE.HelperFunc.pas

@@ -1,4 +1,4 @@
-unit IDE.HelperFunc;
+unit IDE.HelperFunc;
 
 {
   Inno Setup
@@ -85,7 +85,7 @@ implementation
 uses
   ActiveX, ShlObj, ShellApi, CommDlg, SysUtils, IOUtils, StrUtils,
   Messages, DwmApi, Consts,
-  Shared.CommonFunc, Shared.CommonFunc.Vcl, PathFunc, Shared.FileClass, NewUxTheme,
+  TrustFunc, Shared.CommonFunc, Shared.CommonFunc.Vcl, PathFunc, Shared.FileClass, NewUxTheme,
   IDE.MainForm, IDE.Messages, Shared.ConfigIniFile;
 
 procedure InitFormFont(Form: TForm);
@@ -233,7 +233,8 @@ end;
 
 function ISPPInstalled: Boolean;
 begin
-  Result := NewFileExists(PathExtractPath(NewParamStr(0)) + 'ISPP.dll');
+  var Filename := PathExtractPath(NewParamStr(0)) + 'ISPP.dll';
+  Result := NewFileExists(Filename) and TrustedFile(Filename);
 end;
 
 function IsISPPBuiltins(const Filename: String): Boolean;