Pārlūkot izejas kodu

Use TrustedFile before loading isscint.dll. This also makes it give an error message instead of crashing when you start Compil32 with isscint.dll missing.

Martijn Laan 6 mēneši atpakaļ
vecāks
revīzija
f80c9ea357
2 mainītis faili ar 12 papildinājumiem un 3 dzēšanām
  1. 7 3
      Components/ScintInt.pas
  2. 5 0
      Projects/Compil32.dpr

+ 7 - 3
Components/ScintInt.pas

@@ -1346,15 +1346,19 @@ type
   SciFnDirectStatus = function(ptr: Pointer; iMessage: Cardinal;
     wParam: WPARAM; lParam: LPARAM; var Status: Integer): LRESULT; cdecl;
 
+const
+  IsscintDLL = 'isscint.dll';
+
 var
   IsscintLibary: HMODULE;
 
 implementation
 
 uses
-  PathFunc;
+  PathFunc, TrustFunc;
 
 initialization
-  IsscintLibary := LoadLibrary(PChar(AddBackslash(PathExtractPath(ParamStr(0))) + 'isscint.dll'));
-
+  var FileName := AddBackslash(PathExtractPath(ParamStr(0))) + IsscintDLL;
+  if TrustedFile(FileName) then
+    IsscintLibary := LoadLibrary(PChar(FileName));
 end.

+ 5 - 0
Projects/Compil32.dpr

@@ -209,6 +209,11 @@ begin
   end;
   {$ENDIF}
 
+  if IsscintLibary = 0 then begin
+    MessageBox(0, PChar(Format('Could not load %s.', [IsscintDLL])), nil, MB_OK or MB_ICONSTOP);
+    Halt(4);
+  end;
+
   {$IFDEF DEBUG}
   ReportMemoryLeaksOnShutdown := True;
   {$ENDIF}