title: JNA wrong structure field values
body: <p>I'm dancing around JNA adapter to "twain.h" - almost did it, but still have some problems with getting scanner capabilities.
  There is an original enity:</p>
  
  <pre><code>typedef unsigned short TW_UINT16, FAR *pTW_UINT16;
  typedef unsigned long  TW_UINT32, FAR *pTW_UINT32;
  
  typedef struct {
     TW_UINT16  ItemType;
     TW_UINT32  MinValue;     /* Starting value in the range.           */
     TW_UINT32  MaxValue;     /* Final value in the range.              */
     TW_UINT32  StepSize;     /* Increment from MinValue to MaxValue.   */
     TW_UINT32  DefaultValue; /* Power-up value.                        */
     TW_UINT32  CurrentValue; /* The value that is currently in effect. */
  } TW_RANGE, FAR * pTW_RANGE;
  </code></pre>
  
  <p>This is my mapping (thnx JNAerator)</p>
  
  <pre><code>public static class TW_RANGE extends Structure {
          /** C type : TW_UINT16 */
          public short ItemType;
          /** C type : TW_UINT32 */
          public NativeLong MinValue;
          /** C type : TW_UINT32 */
          public NativeLong MaxValue;
          /** C type : TW_UINT32 */
          public NativeLong StepSize;
          /** C type : TW_UINT32 */
          public NativeLong DefaultValue;
          /** C type : TW_UINT32 */
          public NativeLong CurrentValue;
          public TW_RANGE() {
              super();
          }
          protected List&lt;? &gt; getFieldOrder() {
              return Arrays.asList("ItemType", "MinValue", "MaxValue", "StepSize", "DefaultValue", "CurrentValue");
          }
  }
  </code></pre>
  
  <p>When I'm asking scanner for this entity, scanner sends me back filled object, but when I create it through </p>
  
  <pre><code>new TW_RANGE(pointer)
  </code></pre>
  
  <p>it returns me some wired stuff</p>
  
  <pre><code>TwaindsmLibrary$TW_RANGE(native@0x157c000c) (22 bytes) {
    short ItemType@0=870
    NativeLong MinValue@2=1572916
    NativeLong MaxValue@6=5500
    NativeLong StepSize@a=2097152
    NativeLong DefaultValue@e=5500
    NativeLong CurrentValue@12=2621440
  }
  </code></pre>
  
  <ol>
  <li>How can I interpret this values? </li>
  <li>Can I dump native structure and analyze it with some tool? Have seen Pointer.dump, but it requires the size of dumped value, how can i get size of structure under pointer?</li>
  </ol>