I had an access violation resulting from using DWORD(ptrVal) because I did not cast the ptrVal to DWORD using _CAST.
While the CLVO group I saw using the address of ptrVal like DWORD(@ptrVal) which also works. So, is it the same as DWORD(_CAST, ptrVal) ?
My quick test below shows the same result. Is one better than the other?
LOCAL y as ptr
y := 0x00000004
? "y: ", y
? "dword(@y)", dword(@y)
? "dword(_cast, y)", dword(_cast, y)
is using the ptrVal and tells the compiler that it is a pointer to a location where a dword is stored. That would be the same as
LOCAL pDword AS DWORD PTR
Of course this will crash when y has the value 0x00000004 , because that is usually an invalid memory location.
All the other examples will simply take the 32 bits from the PTR and will tell the compiler to use them as a DWORD.
I am not sure where you need this, but this kind of casting is considered "dangerous" and will only work in a 32 bit environment because the size of a PTR is the same as the size of a DWORD. In a 64 bits environment (if you would compile this in X# with AnyCPU) this will not be allowed.