Prechádzať zdrojové kódy

Change TSetupLdrOffsetTable TotalSize and Offset* fields to Int64.

Jordan Russell 1 mesiac pred
rodič
commit
bc85563b07

+ 1 - 0
Projects/Res/SetupLdr.offsettable.rc

@@ -0,0 +1 @@
+11111 RCDATA SetupLdr.offsettable.txt

BIN
Projects/Res/SetupLdr.offsettable.res


+ 1 - 0
Projects/Res/SetupLdr.offsettable.txt

@@ -0,0 +1 @@
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

+ 1 - 1
Projects/SetupLdr.dpr

@@ -495,7 +495,7 @@ begin
 
 
         { Now execute Setup. Use the exit code it returns as our exit code. }
         { Now execute Setup. Use the exit code it returns as our exit code. }
         ExecAndWait(TempFile, Format('/SL5="$%x,%d,%d,',
         ExecAndWait(TempFile, Format('/SL5="$%x,%d,%d,',
-          [SetupLdrWnd, OffsetTable.Offset0, OffsetTable.Offset1]) +
+          [UInt32(SetupLdrWnd), OffsetTable.Offset0, OffsetTable.Offset1]) +
           SelfFilename + '" ' + GetCmdTail, SetupLdrExitCode);
           SelfFilename + '" ' + GetCmdTail, SetupLdrExitCode);
 
 
         { Synchronize our active language with Setup's, in case we need to
         { Synchronize our active language with Setup's, in case we need to

+ 6 - 7
Projects/Src/Compiler.SetupCompiler.pas

@@ -6867,10 +6867,9 @@ var
   WizardImages, WizardSmallImages: TObjectList<TCustomMemoryStream>;
   WizardImages, WizardSmallImages: TObjectList<TCustomMemoryStream>;
   DecompressorDLL, SevenZipDLL: TMemoryStream;
   DecompressorDLL, SevenZipDLL: TMemoryStream;
 
 
-  SetupLdrOffsetTable: TSetupLdrOffsetTable;
-  SizeOfExe, SizeOfHeaders: Longint;
+  SizeOfExe, SizeOfHeaders: Int64;
 
 
-  function WriteSetup0(const F: TFile): Longint;
+  function WriteSetup0(const F: TFile): Int64;
 
 
     procedure WriteStream(Stream: TCustomMemoryStream; W: TCompressedBlockWriter);
     procedure WriteStream(Stream: TCustomMemoryStream; W: TCompressedBlockWriter);
     var
     var
@@ -7000,7 +6999,7 @@ var
     Result := F.Position - StartPosition;
     Result := F.Position - StartPosition;
   end;
   end;
 
 
-  function CreateSetup0File: Longint;
+  function CreateSetup0File: Int64;
   var
   var
     F: TFile;
     F: TFile;
   begin
   begin
@@ -7013,7 +7012,7 @@ var
     end;
     end;
   end;
   end;
 
 
-  function RoundToNearestClusterSize(const L: Longint): Longint;
+  function RoundToNearestClusterSize(const L: Int64): Int64;
   begin
   begin
     Result := (L div DiskClusterSize) * DiskClusterSize;
     Result := (L div DiskClusterSize) * DiskClusterSize;
     if L mod DiskClusterSize <> 0 then
     if L mod DiskClusterSize <> 0 then
@@ -7021,7 +7020,7 @@ var
   end;
   end;
 
 
   procedure CompressFiles(const FirstDestFile: String;
   procedure CompressFiles(const FirstDestFile: String;
-    const BytesToReserveOnFirstDisk: Longint);
+    const BytesToReserveOnFirstDisk: Int64);
   var
   var
     CurrentTime: TSystemTime;
     CurrentTime: TSystemTime;
 
 
@@ -8316,7 +8315,7 @@ begin
 
 
             { Move the data from Setup.e?? into the Setup.exe, and write
             { Move the data from Setup.e?? into the Setup.exe, and write
               header data }
               header data }
-            FillChar(SetupLdrOffsetTable, SizeOf(SetupLdrOffsetTable), 0);
+            var SetupLdrOffsetTable := Default(TSetupLdrOffsetTable);
             SetupLdrOffsetTable.ID := SetupLdrOffsetTableID;
             SetupLdrOffsetTable.ID := SetupLdrOffsetTableID;
             SetupLdrOffsetTable.Version := SetupLdrOffsetTableVersion;
             SetupLdrOffsetTable.Version := SetupLdrOffsetTableVersion;
             SetupLdrOffsetTable.Offset0 := ExeFile.Position;
             SetupLdrOffsetTable.Offset0 := ExeFile.Position;

+ 10 - 10
Projects/Src/Setup.MainFunc.pas

@@ -68,7 +68,7 @@ var
   { Variables for command line parameters }
   { Variables for command line parameters }
   SetupLdrMode: Boolean;
   SetupLdrMode: Boolean;
   SetupLdrOriginalFilename: String;
   SetupLdrOriginalFilename: String;
-  SetupLdrOffset0, SetupLdrOffset1: Longint;
+  SetupLdrOffset0, SetupLdrOffset1: Int64;
   SetupNotifyWndPresent: Boolean;
   SetupNotifyWndPresent: Boolean;
   SetupNotifyWnd: HWND;
   SetupNotifyWnd: HWND;
   InitLang: String;
   InitLang: String;
@@ -2592,14 +2592,14 @@ procedure InitializeSetup;
 var
 var
   DecompressorDLL, SevenZipDLL: TMemoryStream;
   DecompressorDLL, SevenZipDLL: TMemoryStream;
 
 
-  function ExtractLongWord(var S: String): LongWord;
-  var
-    P: Integer;
+  function ExtractInt64(var S: String): Int64;
   begin
   begin
-    P := PathPos(',', S);
+    const P = Pos(',', S);
     if P = 0 then
     if P = 0 then
-      raise Exception.Create('ExtractLongWord: Missing comma');
-    Result := LongWord(StrToInt(Copy(S, 1, P-1)));
+      raise Exception.Create('Error parsing command line: Missing comma');
+    Result := StrToInt64Def(Copy(S, 1, P-1), -1);
+    if Result < 0 then
+      raise Exception.Create('Error parsing command line: Invalid value');
     Delete(S, 1, P);
     Delete(S, 1, P);
   end;
   end;
 
 
@@ -2981,10 +2981,10 @@ begin
   if CompareText(ParamName, '/SL5=') = 0 then begin
   if CompareText(ParamName, '/SL5=') = 0 then begin
     StartParam := 2;
     StartParam := 2;
     SetupLdrMode := True;
     SetupLdrMode := True;
-    SetupNotifyWnd := ExtractLongWord(ParamValue);
+    SetupNotifyWnd := UInt32(ExtractInt64(ParamValue));
     SetupNotifyWndPresent := True;
     SetupNotifyWndPresent := True;
-    SetupLdrOffset0 := ExtractLongWord(ParamValue);
-    SetupLdrOffset1 := ExtractLongWord(ParamValue);
+    SetupLdrOffset0 := ExtractInt64(ParamValue);
+    SetupLdrOffset1 := ExtractInt64(ParamValue);
     SetupLdrOriginalFilename := ParamValue;
     SetupLdrOriginalFilename := ParamValue;
   end
   end
   else begin
   else begin

+ 11 - 10
Projects/Src/Shared.Struct.pas

@@ -387,17 +387,18 @@ type
   { TSetupLdrOffsetTable is stored inside SetupLdr's SetupLdrOffsetTableResID
   { TSetupLdrOffsetTable is stored inside SetupLdr's SetupLdrOffsetTableResID
     RCDATA resource }
     RCDATA resource }
   PSetupLdrOffsetTable = ^TSetupLdrOffsetTable;
   PSetupLdrOffsetTable = ^TSetupLdrOffsetTable;
-  TSetupLdrOffsetTable = packed record
+  TSetupLdrOffsetTable = record
     ID: array[1..12] of AnsiChar;   { = SetupLdrOffsetTableID }
     ID: array[1..12] of AnsiChar;   { = SetupLdrOffsetTableID }
-    Version: LongWord;              { = SetupLdrOffsetTableVersion }
-    TotalSize: LongWord;            { Minimum expected size of setup.exe }
-    OffsetEXE: LongWord;            { Offset of compressed setup.e32 }
-    UncompressedSizeEXE: LongWord;  { Size of setup.e32 before compression }
-    CRCEXE: Longint;                { CRC of setup.e32 before compression }
-    Offset0: LongWord;              { Offset of embedded setup-0.bin data }
-    Offset1: LongWord;              { Offset of embedded setup-1.bin data,
+    Version: UInt32;                { = SetupLdrOffsetTableVersion }
+    TotalSize: Int64;               { Minimum expected size of setup.exe }
+    OffsetEXE: Int64;               { Offset of compressed setup.e32 }
+    UncompressedSizeEXE: UInt32;    { Size of setup.e32 before compression }
+    CRCEXE: Int32;                  { CRC of setup.e32 before compression }
+    Offset0: Int64;                 { Offset of embedded setup-0.bin data }
+    Offset1: Int64;                 { Offset of embedded setup-1.bin data,
                                       or 0 when DiskSpanning=yes }
                                       or 0 when DiskSpanning=yes }
-    TableCRC: Longint;              { CRC of all prior fields in this record }
+    ReservedPadding: UInt32;        { Not set (just provides padding) }
+    TableCRC: Int32;                { CRC of all prior fields in this record }
   end;
   end;
 
 
   { TMessagesLangOptions is a simplified version of TSetupLanguageEntry that
   { TMessagesLangOptions is a simplified version of TSetupLanguageEntry that
@@ -416,7 +417,7 @@ type
 const
 const
   SetupLdrOffsetTableResID = 11111;
   SetupLdrOffsetTableResID = 11111;
   SetupLdrOffsetTableID = 'rDlPtS'#$CD#$E6#$D7#$7B#$0B#$2A;
   SetupLdrOffsetTableID = 'rDlPtS'#$CD#$E6#$D7#$7B#$0B#$2A;
-  SetupLdrOffsetTableVersion = 1;
+  SetupLdrOffsetTableVersion = 2;
   SetupExeModeOffset = $30;
   SetupExeModeOffset = $30;
   SetupExeModeUninstaller = $6E556E49;
   SetupExeModeUninstaller = $6E556E49;
   SetupExeModeRegSvr = $53526E49;
   SetupExeModeRegSvr = $53526E49;