[fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?
Bo Berglund
bo.berglund at gmail.com
Tue Mar 21 23:49:30 CET 2023
We have a number of old Delphi7 applications which are in need of porting over
to FreePascal. I have successfully done a number of these ports in the last few
years...
But now I am up against a bit of a problem regarding software we have protected
using an USB connected hardware key originally bought from Rainbow, a company
that has been bought up in several steps and is now named THALES.
Anyway, our software interfaces to the SuperPro protection keys is via a Windows
driver from THALES and they have provided a software integration kit way back
when we started using the keys.
It consist of a Delphi unit basically containing a list of definitions of
available API functions into the driver looking like this:
------
{ Force FAR calls }
{$F+}
INTERFACE
CONST
{ SuperPro API error codes }
SP_SUCCESS = 0;
<snip>
SPRO_MAX_QUERY_SIZE = 56;
TYPE
RB_SPRO_APIPACKET = ARRAY [1..1028] OF CHAR; { Spro API Packet }
RB_SPRO_APIPACKET_PTR = ^RB_SPRO_APIPACKET;
FUNCTION SproInitialize( ApiPacket : RB_SPRO_APIPACKET_PTR ) : WORD;
FUNCTION SproGetExtendedStatus( ApiPacket : RB_SPRO_APIPACKET_PTR ) : WORD;
<snip>
IMPLEMENTATION
USES
Windows;
{$L SPROMEPS.OBJ} { LINK WITH THE SUPERPRO OBJECT FILE }
{ External functions }
FUNCTION RNBOsproFormatPacket( ApiPacket : RB_SPRO_APIPACKET_PTR;
thePacketSize : WORD ) : WORD; STDCALL; EXTERNAL;
FUNCTION RNBOsproInitialize( ApiPacket : RB_SPRO_APIPACKET_PTR ) : WORD;
STDCALL; EXTERNAL;
<snip>
FUNCTION SproInitialize( ApiPacket : RB_SPRO_APIPACKET_PTR ) : WORD;
VAR
returnVal : WORD;
BEGIN
returnVal := RNBOsproFormatPacket (ApiPacket, RB_SPRO_APIPACKET_SIZE);
IF returnVal <> SP_SUCCESS THEN
SproInitialize := returnVal
ELSE
SproInitialize := RNBOsproInitialize (ApiPacket);
END; { SproInitialize }
<snip a lot of other API functions>
BEGIN
END.
------
Obviously being from the time when it was received the OBJ file SPROMEPS.OBJ to
be linked in is a 32 bit type, so the ported programs need to be compiled/linked
into a 32 bit exe file on Windows.
Questions:
----------
1) How should I go about translating the above to current FreePascal syntax?
This involves:
{ Force FAR calls }
{$F+}
{$L SPROMEPS.OBJ} { LINK WITH THE SUPERPRO OBJECT FILE }
2) Is there a way to translate/convert the 32 bit Windows SPROMEPS.OBJ file into
a 64 bit one such that it could be used for a 64 bit fpc compiler?
It is the interface to the protection key driver on the Windows system...
It does work for our 32 bit Delphi7 programs on Windows 10 x64, so there must be
some 32<->64 bit handling in Windows maybe?
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list