Răsfoiți Sursa

Don't treat a failed trust check on ISPP.dll the same as a missing ISPP.dll.

Martijn Laan 4 luni în urmă
părinte
comite
01fd96aa03
1 a modificat fișierele cu 13 adăugiri și 16 ștergeri
  1. 13 16
      Projects/Src/Compiler.SetupCompiler.pas

+ 13 - 16
Projects/Src/Compiler.SetupCompiler.pas

@@ -511,13 +511,16 @@ begin
     Exit;
 {$IFNDEF STATICPREPROC}
   var Filename := CompilerDir + 'ISPP.dll';
-  if TrustedFileExists(Filename) then begin
-    var M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
-    if M = 0 then
-      AbortCompileFmt('Failed to load ISPP.dll (%d)', [GetLastError]);
-    PreprocessScriptProc := GetProcAddress(M, 'ISPreprocessScriptW');
-    if not Assigned(PreprocessScriptProc) then
-      AbortCompile('Failed to get address of functions in ISPP.dll');
+  if NewFileExists(Filename) then begin
+    if TrustedFileExists(Filename) then begin
+      var M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
+      if M = 0 then
+        AbortCompileFmt('Failed to load ISPP.dll (%d)', [GetLastError]);
+      PreprocessScriptProc := GetProcAddress(M, 'ISPreprocessScriptW');
+      if not Assigned(PreprocessScriptProc) then
+        AbortCompile('Failed to get address of functions in ISPP.dll');
+    end else
+      AbortCompile('Failed to load ISPP.dll (not trusted)');
   end; { else ISPP unavailable; fall back to built-in preprocessor }
 {$ELSE}
   PreprocessScriptProc := ISPreprocessScript;
@@ -526,14 +529,12 @@ begin
 end;
 
 procedure TSetupCompiler.InitZipDLL;
-var
-  M: HMODULE;
 begin
   if ZipInitialized then
     Exit;
   var Filename := CompilerDir + 'iszlib.dll';
   if TrustedFileExists(Filename) then begin
-    M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
+    var M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
     if M = 0 then
       AbortCompileFmt('Failed to load iszlib.dll (%d)', [GetLastError]);
     if not ZlibInitCompressFunctions(M) then
@@ -544,14 +545,12 @@ begin
 end;
 
 procedure TSetupCompiler.InitBzipDLL;
-var
-  M: HMODULE;
 begin
   if BzipInitialized then
     Exit;
   var Filename := CompilerDir + 'isbzip.dll';
   if TrustedFileExists(Filename) then begin
-    M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
+    var M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
     if M = 0 then
       AbortCompileFmt('Failed to load isbzip.dll (%d)', [GetLastError]);
     if not BZInitCompressFunctions(M) then
@@ -562,14 +561,12 @@ begin
 end;
 
 procedure TSetupCompiler.InitLZMADLL;
-var
-  M: HMODULE;
 begin
   if LZMAInitialized then
     Exit;
   var Filename := CompilerDir + 'islzma.dll';
   if TrustedFileExists(Filename) then begin
-    M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
+    var M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
     if M = 0 then
       AbortCompileFmt('Failed to load islzma.dll (%d)', [GetLastError]);
     if not LZMAInitCompressFunctions(M) then