twall/jna — Issue #41: Wrong definition of DWORD in WIN32 Platform
Author: martin-a
Created: 2011-12-08 01:53:30+00:00
State: open

According to Microsoft documentation DWORD is a 32-bit unsigned integer:
http://msdn.microsoft.com/en-us/library/cc230318%28PROT.10%29.aspx

In com/sun/jna/platform/win32/WinDef.java#54 DWORD is defined as a 4 byte IntegerType

The problem is that com/sun/jna/IntegerType.java.setValue#55 casts the value as a Java Integer, thus making the value a 32-bit unsigned integer

Here is a simple example:

System.out.println(new DWORD(4294967295L).longValue());

This prints out "-1" where "4294967295" is expected

This bugs makes RecordNumber for event logs to be false in some cases as com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD.RecordNumber is defined as a DWORD