The question arises after I read an article on the MSDN blog, Why can't you treat FILETIME as __int64? . The article said casting a FILETIME to __int64 could lead to an invalid pointer.
FILETIME , LUID and LUID_AND_ATTRIBUTES structs are declared in the Windows header as follows:
typedef struct FILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; } typedef struct LUID { ULONG LowPart; LONG HighPart; } typedef struct LUID_AND_ATTRIBUTES { LUID Luid; DWORD Attributes; }
Since the FILETIME and LUID have a similar layout, handling LUID like __int64 can also lead to an invalid pointer. However, Windows.pas (Delphi XE3 here) practices this, for example:
{$ALIGN 4} LUID_AND_ATTRIBUTES = record Luid : Int64; // Here, LUID is treated as Int64 Attributes: DWORD; end; {$ALIGN ON}
another example:
function LookupPrivilegeValue(lpSystemName, lpName: LPCWSTR; var lpLuid: Int64): BOOL; stdcall;
How to safely treat structures like FILETIME or LUID directly as UInt64 / Int64 ? What is the key?
source share