浏览代码

Restore comment removed by previous + one more cleanup, doh.

Martijn Laan 1 月之前
父节点
当前提交
1fcb39a48b
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 11 4
      Projects/Src/Setup.MainFunc.pas
  2. 1 0
      Projects/Src/SetupLdrAndSetup.Messages.pas

+ 11 - 4
Projects/Src/Setup.MainFunc.pas

@@ -2588,12 +2588,18 @@ var
     Delete(S, 1, P);
   end;
 
-  procedure AbortInit(const Msg: TSetupMessageID);
+  procedure AbortInit(const Msg: TSetupMessageID); overload;
   begin
     LoggedMsgBox(SetupMessages[Msg], '', mbCriticalError, MB_OK, True, IDOK);
     Abort;
   end;
 
+  procedure AbortInit(const Msg: String); overload;
+  begin
+    LoggedMsgBox(Msg, '', mbCriticalError, MB_OK, True, IDOK);
+    Abort;
+  end;
+
   procedure AbortInitFmt1(const Msg: TSetupMessageID; const Arg1: String);
   begin
     LoggedMsgBox(FmtSetupMessage(Msg, [Arg1]), '', mbCriticalError, MB_OK, True, IDOK);
@@ -3073,7 +3079,6 @@ begin
   SetupMessages[msgSetupFileMissing] := SSetupFileMissing;
   SetupMessages[msgSetupFileCorrupt] := SSetupFileCorrupt;
   SetupMessages[msgSetupFileCorruptOrWrongVer] := SSetupFileCorruptOrWrongVer;
-  SetupMessages[msgIncorrectPassword] := SIncorrectPassword;
 
   { Read setup-0.bin, or from EXE }
   if not SetupLdrMode then begin
@@ -3100,10 +3105,12 @@ begin
     var CryptKey: TSetupEncryptionKey;
     if SetupEncryptionHeader.EncryptionUse = euFull then begin
       if InitPassword = '' then
-        raise Exception.Create(SMissingPassword);
+        AbortInit(SMissingPassword);
       GenerateEncryptionKey(InitPassword, SetupEncryptionHeader.KDFSalt, SetupEncryptionHeader.KDFIterations, CryptKey);
       if not TestPassword(CryptKey, SetupEncryptionHeader.BaseNonce, SetupEncryptionHeader.PasswordTest) then
-        AbortInit(msgIncorrectPassword);
+        AbortInit(SIncorrectPassword);
+      { FileExtractor (a function!) requires SetupHeader.CompressMethod to be set, so delaying setting
+        FileExtractor.CryptKey until SetupHeader is read below }
     end;
 
     try

+ 1 - 0
Projects/Src/SetupLdrAndSetup.Messages.pas

@@ -47,6 +47,7 @@ const
     'obtain a new copy of the program.';
   SMsgsFileMissing = 'Messages file "%s" is missing. Please correct ' +
     'the problem or obtain a new copy of the program.';
+  { These currently always occur before the messages file is loaded }
   SMissingPassword = 'Please specify the password using the /PASSWORD= command line parameter.';
   SIncorrectPassword = 'The password you specified is not correct. Please try again.';