Update for Delphi 10.2 Tokyo
To use this library with Delphi 10.2 and later, three procedures in SBUtils.pas need to be modified. I've chosen to overload them for not touching the original code.
// Addition for DX 10.2
// "Given that dynamic arrays are managed types, involving reference counting
// and associated helper function generation, casting array elements using
// the @ operator is disallowed as it leads to memory corruption. Performing a
// similar operation is still allowed using an explicit cast operation, under the
// developer responsibility."
// http://docwiki.embarcadero.com/RADStudio/Tokyo/en/What%27s_New
procedure PointerToLInt(var B : PLInt; const P : Pointer; Size : integer);
begin
PointerToLInt(B, ByteArray(P), Size);
end;
procedure LIntToPointer(B: PLInt; P: Pointer; var Size: LongInt);
begin
LIntToPointer(B, ByteArray(P), Size);
end;
procedure SBMove(Src: ByteArray; SrcOffset: Integer; Dst: Pointer; DstOffset: Integer; Size: Integer);
begin
SBMove(Src, SrcOffset, ByteArray(Dst), DstOffset, Size);
end;
And of course:
procedure PointerToLInt(var B : PLInt; const P : Pointer; Size : integer); overload;
procedure LIntToPointer(B: PLInt; P: Pointer; var Size: LongInt); overload;
procedure SBMove(Src: ByteArray; SrcOffset: Integer; Dst: Pointer; DstOffset: Integer; Size: Integer); overload;
For not having to modify the project compiler settings in every project where you use this library, I would recommend to add these three lines at the top of SecBbox.inc:
{$define SB_UNICODE_VCL}
{$define SB_NO_BYTEARRAY_CONST_ARRAYS}
{$define SB_PASCAL_STRINGS}
Hi, That was very useful information. You mentioned the PointerToLint procedure twice. Did you mean the LIntToPointer requires a similar change, eg, procedure LIntToPointer(B: PLInt; P: Pointer; var Size: Integer); Overload;
procedure LIntToPointer(B: PLInt; P: Pointer; var Size: Integer); begin LInttoPointer(B, ByteArray(P), Size); end; I know this post is 6 months old, but I hope you can reply back so I know I did the right thing.
Also in the defines for SecBBox.inc, you have {$define SB_NO_BYTEARRAY_CONST_ARRAYS} twice. Was that a typo or am I missing another Define I should put in? Thanks AL
Thank you. I had to copy it from different locations and apparently copied it incorrectly. Sorry for my carelessness. It should be correct now.
Hi IgitBuh, Thank you very much for the quick response. My code now compiles correctly. I can't believe I found your post after endless searching, but am glad I did.
AL.
Thanks for the information. I posted back at the github site. Thanks againAL.
On Tuesday, 12 February 2019, 1:59:20 am AEST, IgitBuh <[email protected]> wrote:
Thank you. I had to copy it from different locations and apparently copied it incorrectly. Sorry for my carelessness. It should be correct now.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.