Hi Zoran,
And I don't know is there a reason why you cut Pointer to LongWord
Initially I wrote that function for delphi, where an explicit typecast needed, otherwise the function won't compile. The error message( both with D2007 and XE4): "E2015 Operator not applicable to this operand type".
Now I noticed that compiler issues hints on these two lines:
Because we casting a pointer to a fixed size variable. The compiler knows that the size of pointers can have different values on different platforms, while the size of the variable stays the same(or not, it depends on a lot of things), hence the warning, nothing to worry about in my opinion.
in a 64-bit application this might lose significant bits
You have a valid point here, Longword is enough for a 32 bit system, but NativeUInt(PtrUint) or QWord is more appropriate for 64 bit. Your pointer alternative is also good if you don't mind dropping the delphi compatibility support.
PS: I also find this:
https://0x2a.wtf/projects/pesp . Supports both Windows and Linux. It's pure pascal. You get a lot more info then bitness: Import/Export tables, Entry Point, etc...This is also an answer to @Thaddy's reply.