[Lazarus] Newbie, porting class to FPC but get procedure assignment error

Bo Berglund bo.berglund at gmail.com
Mon Jun 22 08:11:43 CEST 2015

On Mon, 22 Jun 2015 01:00:58 +0200, Bo Berglund
<bo.berglund at gmail.com> wrote:

>When I stepped through the code I reached the first call to the driver
>via the obj file I get an exception when calling RNBOsproFormatPacket
>in this function, which is in the SPROMEPS.pas file supplied by
>FUNCTION SproInitialize( ApiPacket : RB_SPRO_APIPACKET_PTR ) : WORD;
>    returnVal : WORD;
>    returnVal := RNBOsproFormatPacket (ApiPacket,
>    IF returnVal <> SP_SUCCESS THEN
>       SproInitialize := returnVal
>    ELSE
>       SproInitialize := RNBOsproInitialize (ApiPacket);
>END; { SproInitialize }
>Exception text:
>"Project DongleTest raised exception class
>'External: SIGSEGV'."
To clarify:
The error happens when I call RNBOsproFormatPacket, which is the first
time any driver interface function is called.

I have googled SIGSEGV and understand that it is a memory access
So I followed the ApiPacket handling through the code.

In the class definition file I have this:
   RB_SPRO_APIPACKET_SIZE         = 1028;
  RB_SPRO_APIPACKET = ARRAY [1..1028] OF CHAR;{ Spro API Packet }

  { TSentinel }
  TSentinel = class
      FSentinelPacket : RB_SPRO_APIPACKET;

Then in the dongle initialization method I have this:

{Check if the key is initialized, then find first key on system}
  status := InitSuperProKey(FSentinelPacket);

InitSuperProKey() looks like this:

function TSentinel.InitSuperProKey(var thePacket: RB_SPRO_APIPACKET):
  error : WORD;
  Result := 0;
  error := SproInitialize(@thePacket);
  if error <> 0 then begin
    Result := error;
  error := SproFindFirstUnit(@thePacket, DeveloperID);
  if error <> 0 then
    Result := error;

And SproInitialize is shown in my previos post above as:

FUNCTION SproInitialize( ApiPacket : RB_SPRO_APIPACKET_PTR ) : WORD;
    returnVal : WORD;
  returnVal:=RNBOsproFormatPacket (ApiPacket,RB_SPRO_APIPACKET_SIZE);
    IF returnVal <> SP_SUCCESS THEN
       SproInitialize := returnVal
       SproInitialize := RNBOsproInitialize (ApiPacket);
END; { SproInitialize }

So to me it seems strange that there should be a memory access problem
since the "packet" is an array of fixed size which is a private member
of the object only used by the object itself via the pointer....

Bo Berglund
Developer in Sweden

More information about the Lazarus mailing list