[fpc-devel] Some more THandle problems

Sven Barth pascaldragon at googlemail.com
Sat Nov 20 13:26:19 CET 2010


Hello together!

While getting SysUtils and Classes to compile for Native NT I've 
stumbled upon some more spots where Handle=LongInt/LongWord is assumed.

1. In objpas/sysutils/filutilh.inc and its implementation 
objpas/sysutils/fina.inc the GetFileHandle functions are defined with 
return type LongInt, but TFileRec.Handle and TFileRec.Handle are defined 
as THandle (which is - as we know - QWord on Win64).

2. THandleStream has a field FHandle which is defined as Integer. Now 
this handle is filled either by the constructor which takes an Integer 
as well or by e.g. TFileStream which gets its handle from 
FileOpen/FileCreate. Those return a THandle and you might guess what 
happens if a value >= 2^32 is returned. ^^

3. The handle types for resource streams are defined as PtrUInt while 
the handle for Native NT is defined as Pointer.
For me locally I've fixed this my casting the handles to the FPResource* 
types, but I might have reached the point where I should change my 
handle type from Pointer to PtrUInt, because the pros (no more Ordinal 
<-> Pointer conflicts) outweigh the cons (no more strict following of 
the ReactOS headers).

I can provide patches for 1 and 2 in bug reports if you want, but I 
won't touch the resource related parts mentioned in 3 cause those issues 
will be fixed when I provide my patch for the Native NT RTL (by changing 
THandle from Pointer to PtrUInt).

But I've discovered some nice THandle problems while THandle was defined 
as Pointer. :D

Regards,
Sven



More information about the fpc-devel mailing list