4 messages in net.java.dev.jna.users[jna-users] VM crash - bad parameters?
FromSent OnAttachments
Paul GiffordSep 10, 2008 4:31 am 
Timothy WallSep 10, 2008 5:08 am 
Paul GiffordSep 10, 2008 5:38 am 
Timothy WallSep 10, 2008 6:05 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[jna-users] VM crash - bad parameters?Actions...
From:Paul Gifford (paul@yahoo.com)
Date:Sep 10, 2008 4:31:09 am
List:net.java.dev.jna.users

Hi,

  I'm trying to call a method with this signature:   DWORD __stdcall EnumeratePIE(long VID, long *data, long &count)   The API has this note:  "The count parameter MUST be long, not int, even though
Borland defines these as having the same meaning. The value returned in this
parameter is the number of devices, not the number of data values. The long
*data parameter should be an array of at least 100 long values."   My interface looks like this:   public interface PieLibrary extends StdCallLibrary {     PieLibrary INSTANCE = (PieLibrary) Native.loadLibrary("PIEHid",
PieLibrary.class);

    public int EnumeratePIE(long vid, long[] data, NativeLongByReference count); }     And I call it like so:   // ****************************************     PieLibrary lib = PieLibrary.INSTANCE;     long vidLong = 0x05F3;     long[] data = new long[100];     NativeLongByReference count = new NativeLongByReference();     int result = lib.EnumeratePIE(vidLong, data, count); //*****************************************   As soon as I run the above code I get a vm crash:   # An unexpected error has been detected by Java Runtime Environment: # #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x03071818, pid=516, tid=3880 # # Java VM: Java HotSpot(TM) Client VM (10.0-b23 mixed mode, sharing windows-x86) # Problematic frame: # C  [PIEHid.dll+0x1818]

The library is not mine; it's from an SDK to a 3rd party commercial product. 
I've got sample code for C++ Builder, VB6 (ActiveX and not), VC6 (MFC and not),
VC7 (MFC and not) but I'm not getting the parameters right.  I know the product
works, as does the sample code.   Any help greatly appreciated!   Paul