Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Sven Barth via fpc-pascal
Bo Berglund via fpc-pascal  schrieb am
Mi., 22. März 2023, 11:18:

>
> >The object file won't be a problem for FPC on i386-win32 because it will
> be
> >a COFF file which is the default.
>
> When you say "on i386-win32" does that mean a 32 bit version of Windows as
> the
> host system for building the programs?
>

I mean a variant of FPC that targets the i386 platform together with the
compiled units for i386-win32.


> If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64 bit
> target
> exe which will be the output, right?
>
> If that is the case will the obj file work when building the exe?
>

No.


> Is it possible to check if the obj file is of the "COFF" type?
> Note that the timestamp of the obj file is 2003-05-29...
>

You could use the objdump utility provided with FPC (call it as "objdump -x
"). If it doesn't print any errors then it's a COFF 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...
> >>
> >
> >Aside from asking the company for a 64-bit variant or reverse engineering
> >the object file, no. How large is that object file?
>
> Size = 39330 bytes
>

That mean there's quite a bit of code in there, so it isn't trivially to
reverse engineer...

>
> >> 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?
> >>
> >
> >Are you really sure there's a driver involved? When you install it is
> there
> >a driver binary for both 32- and 64-bit? Cause 64-bit Windows *can not*
> >load 32-bit drivers.
>
> THALES has supplied a dedicated driver for Windows, which we use on all s/w
> installations. It is a rather big (2945376 bytes) installer file named
> "Sentinel
> System Driver Installer 7.6.0.exe"
> So, yes I am sure it is needed, whithout it the s/w cannot read the
> protection
> key.
> The driver has changed over the years as Windows progressed and we now use
> version 7.6.0
>

Then you should ask them for a suitable 64-bit object file (I assume that
they'll provide the one for C which they probably also did for you back
then and then you might need to adjust the import unit a bit to be usable
with x86_64-win64; as long as they also provide a C header that should be
doable).

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Sven Barth via fpc-pascal
Bo Berglund via fpc-pascal  schrieb am
Mi., 22. März 2023, 13:57:

> On Wed, 22 Mar 2023 12:33:16 +0100, Giuliano Colla via fpc-pascal
>  wrote:
>
> >Il 22/03/2023 11:18, Bo Berglund via fpc-pascal ha scritto:
> >
> >> If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64
> bit target
> >> exe which will be the output, right?
> >If in Project Options -> Config and Target ->Target OS you specify
> >Win32, you'll get a 32 bit exe (which is what Delphi does, I presume, if
> >it links a 32 bit object).
>
> I changed target to Win32 then when I closed the dialog an error message
> popped
> up:
>
> The current FPC has no config file. It will probably miss
> some units. Check your installation of fpc.
> [OK]  [Ignore]
>
> My installation was done using a full Lazarus/FPC installer from
> SourceForge:
> lazarus-2.2.4-fpc-3.2.2-win64.exe
>
> So both Lazarus and Fpc come from the same installer and it installs an
> isolated
> environment so one can have several versions installed at the same time.
>
> What to do now?
> And what is the problem?
>

You need to download the Win32 addon for Lazarus from the same location,
install that and then set operating system to Win32 and platform to i386.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Mar 2023 12:33:16 +0100, Giuliano Colla via fpc-pascal
 wrote:

>Il 22/03/2023 11:18, Bo Berglund via fpc-pascal ha scritto:
>
>> If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64 bit 
>> target
>> exe which will be the output, right?
>If in Project Options -> Config and Target ->Target OS you specify 
>Win32, you'll get a 32 bit exe (which is what Delphi does, I presume, if 
>it links a 32 bit object).

I changed target to Win32 then when I closed the dialog an error message popped
up:

-
The current FPC has no config file. It will probably miss
some units. Check your installation of fpc.
[OK]  [Ignore]
-

When I hit [OK] I got this pop-up:

---
The project uses target OS=win32 and CPU=x86_64.
The system.ppu for this target was not found in the FPC
binary directories.
Make sure fpc is installed correctly for this target and the
fpc.cfg contains the right directories.
   [OK]


My installation was done using a full Lazarus/FPC installer from SourceForge:
lazarus-2.2.4-fpc-3.2.2-win64.exe

So both Lazarus and Fpc come from the same installer and it installs an isolated
environment so one can have several versions installed at the same time.

What to do now?
And what is the problem?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Mar 2023 12:33:16 +0100, Giuliano Colla via fpc-pascal
 wrote:

>Il 22/03/2023 11:18, Bo Berglund via fpc-pascal ha scritto:
>
>> If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64 bit 
>> target
>> exe which will be the output, right?
>If in Project Options -> Config and Target ->Target OS you specify 
>Win32, you'll get a 32 bit exe (which is what Delphi does, I presume, if 
>it links a 32 bit object).

I changed target to Win32 then when I closed the dialog an error message popped
up:

The current FPC has no config file. It will probably miss
some units. Check your installation of fpc.
[OK]  [Ignore]

My installation was done using a full Lazarus/FPC installer from SourceForge:
lazarus-2.2.4-fpc-3.2.2-win64.exe

So both Lazarus and Fpc come from the same installer and it installs an isolated
environment so one can have several versions installed at the same time.

What to do now?
And what is the problem?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Giuliano Colla via fpc-pascal

Il 22/03/2023 11:18, Bo Berglund via fpc-pascal ha scritto:


If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64 bit target
exe which will be the output, right?
If in Project Options -> Config and Target ->Target OS you specify 
Win32, you'll get a 32 bit exe (which is what Delphi does, I presume, if 
it links a 32 bit object).


Giuliano

--
Do not do to others as you would have them do to you.They might have different 
tastes.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Mar 2023 11:18:10 +0100, Bo Berglund via fpc-pascal
 wrote:

>
>I guess I have to just create a simple program which reads the key data and 
>does
>nothing else to check if the handling will actually work...
>Or convert a small tool we already have from Delphi7 to Lazarus/FPC and see 
>what
>happens..

Now I created a new program and set it to mode Delphi.
The syntac check Run/Quick_Compile works OK but then when I use the Run/Compile
function this is what I get:

Compile Project, Target: DongleTest.exe: Exit code 1, Errors: 1
DongleTest.lpr(24,1) Error: Illegal COFF Magic while reading
D:\Engineering\Projects\Subversion\PC\DongleTest\SPROMEPS.OBJ

Sigh...
I guess it is a problem regarding 32 vs 64 bit application code here...

Is there a settinmg in FPC which will make it produce a 32bit Windows exe?

Or do I have to install a complete set of 32 bit Lazarus/FPC on my 64 bit
Windows 10?
Or even worse: do I have to create a virtual Windows 10 32 bit computer to do
the build on? It might not work there too.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Mar 2023 08:01:57 +0100, Sven Barth via fpc-pascal
 wrote:

>Bo Berglund via fpc-pascal  schrieb am
>Di., 21. März 2023, 23:54:
>
>> 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 }
>>
>
>These won't be a problem. Both Delphi and FPC (for non-i8086) will skip the
>$F directive as it's not necessary on 32- or 64-bit systems.

OK, so I don't have to modify this part then.

>The object file won't be a problem for FPC on i386-win32 because it will be
>a COFF file which is the default.

When you say "on i386-win32" does that mean a 32 bit version of Windows as the
host system for building the programs?

If I have fpc 3.2.2 inbstalled on Windows 10 x64 I assume it is a 64 bit target
exe which will be the output, right?

If that is the case will the obj file work when building the exe?

Is it possible to check if the obj file is of the "COFF" type?
Note that the timestamp of the obj file is 2003-05-29...

>> 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...
>>
>
>Aside from asking the company for a 64-bit variant or reverse engineering
>the object file, no. How large is that object file?

Size = 39330 bytes

>Maybe it's only a relatively simple interface to the driver..

The accompanying pas file I quoted from declares 12 different API calls into the
driver, which we have used to create our own interface functions for the key
handling. This was done about 20 or so years ago...

>
>> 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?
>>
>
>Are you really sure there's a driver involved? When you install it is there
>a driver binary for both 32- and 64-bit? Cause 64-bit Windows *can not*
>load 32-bit drivers.

THALES has supplied a dedicated driver for Windows, which we use on all s/w
installations. It is a rather big (2945376 bytes) installer file named "Sentinel
System Driver Installer 7.6.0.exe"
So, yes I am sure it is needed, whithout it the s/w cannot read the protection
key.
The driver has changed over the years as Windows progressed and we now use
version 7.6.0


I guess I have to just create a simple program which reads the key data and does
nothing else to check if the handling will actually work...
Or convert a small tool we already have from Delphi7 to Lazarus/FPC and see what
happens..


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Bo Berglund via fpc-pascal
On Wed, 22 Mar 2023 00:19:58 +0100 (CET), Michael Van Canneyt via fpc-pascal
 wrote:

>Maybe the THALES company has a 64-bit version of the .OBJ file.

OK, I will try and get some answers from them.
Problem is that they seem to have concentrated on Microsoft dev tools so lat
time I looked there was not much for Delphi and none for FreePascal.

There really should be some generic interface to use independent of dev
environment nowadays when there are so many systems in use (C-sharp, C++, Python
etc etc).

I will have to open a support ticket.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting Delphi7 code to FreePascal with interfacing to protection key?

2023-03-22 Thread Sven Barth via fpc-pascal
Bo Berglund via fpc-pascal  schrieb am
Di., 21. März 2023, 23:54:

> 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 }
>

These won't be a problem. Both Delphi and FPC (for non-i8086) will skip the
$F directive as it's not necessary on 32- or 64-bit systems.

The object file won't be a problem for FPC on i386-win32 because it will be
a COFF file which is the default.


> 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...
>

Aside from asking the company for a 64-bit variant or reverse engineering
the object file, no. How large is that object file? Maybe it's only a
relatively simple interface to the driver...


> 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?
>

Are you really sure there's a driver involved? When you install it is there
a driver binary for both 32- and 64-bit? Cause 64-bit Windows *can not*
load 32-bit drivers.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal