@@ -564,7 +564,7 @@ procedure ProtectStream(Stream: TStream; SizeToProtect: Int64 = 0);
564
564
const
565
565
BufferSize = 512 ;
566
566
var
567
- Buffer: String ;
567
+ Buffer: string ;
568
568
Count, Bytes, Size: Integer;
569
569
Position: Integer;
570
570
begin
@@ -595,7 +595,11 @@ procedure ProtectStream(Stream: TStream; SizeToProtect: Int64 = 0);
595
595
Bytes := Size;
596
596
if Bytes > BufferSize then
597
597
Bytes := BufferSize;
598
+ { $IF CompilerVersion >= 17.0}
598
599
Stream.Write(Buffer[Low(Buffer)], Bytes);
600
+ { $ELSE}
601
+ Stream.Write(Buffer[1 ], Bytes);
602
+ { $ENDIF}
599
603
Dec(Size, Bytes);
600
604
end ;
601
605
end ;
@@ -615,7 +619,11 @@ procedure ProtectString(var Source: string);
615
619
if Length(Source) > 0 then
616
620
begin
617
621
System.UniqueString(Source);
622
+ { $IF CompilerVersion >= 17.0}
618
623
ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[Low(Source)]));
624
+ { $ELSE}
625
+ ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[1 ]));
626
+ { $ENDIF}
619
627
Source := ' ' ;
620
628
end ;
621
629
end ;
@@ -627,7 +635,11 @@ procedure ProtectString(var Source: RawByteString);
627
635
// UniqueString(Source); cannot be called with a RawByteString as there is
628
636
// no overload for it, so we need to call our own one.
629
637
DECUtilRawByteStringHelper.UniqueString(Source);
638
+ { $IF CompilerVersion >= 17.0}
630
639
ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[Low(Source)]));
640
+ { $ELSE}
641
+ ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[1 ]));
642
+ { $ENDIF}
631
643
Source := ' ' ;
632
644
end ;
633
645
end ;
@@ -638,7 +650,11 @@ procedure ProtectString(var Source: AnsiString); overload;
638
650
if Length(Source) > 0 then
639
651
begin
640
652
System.UniqueString(Source);
653
+ { $IF CompilerVersion >= 17.0}
641
654
ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[Low(Source)]));
655
+ { $ELSE}
656
+ ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[1 ]));
657
+ { $ENDIF}
642
658
Source := ' ' ;
643
659
end ;
644
660
end ;
@@ -648,7 +664,11 @@ procedure ProtectString(var Source: WideString); overload;
648
664
if Length(Source) > 0 then
649
665
begin
650
666
System.UniqueString(Source); // for OS <> Win, WideString is not RefCounted on Win
667
+ { $IF CompilerVersion >= 17.0}
651
668
ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[Low(Source)]));
669
+ { $ELSE}
670
+ ProtectBuffer(Pointer(Source)^, Length(Source) * SizeOf(Source[1 ]));
671
+ { $ENDIF}
652
672
Source := ' ' ;
653
673
end ;
654
674
end ;
@@ -660,7 +680,11 @@ function BytesToRawString(const Source: TBytes): RawByteString;
660
680
if Length(Source) > 0 then
661
681
begin
662
682
// determine lowest string index for handling of ZeroBasedStrings
683
+ { $IF CompilerVersion >= 17.0}
663
684
Move(Source[0 ], Result[Low(result)], Length(Source));
685
+ { $ELSE}
686
+ Move(Source[0 ], Result[1 ], Length(Source));
687
+ { $ENDIF}
664
688
end ;
665
689
end ;
666
690
0 commit comments