4 messages in net.java.dev.jna.usersRe: [jna-users] _HIDP_PREPARSED_DATA ...
FromSent OnAttachments
Alan VeaseyMar 31, 2008 10:41 am 
Timothy WallMar 31, 2008 11:22 am 
Alan VeaseyApr 3, 2008 8:24 am 
Timothy WallApr 3, 2008 8:33 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:Re: [jna-users] _HIDP_PREPARSED_DATA structure defintion not availableActions...
From:Timothy Wall (twal@dev.java.net)
Date:Apr 3, 2008 8:33:20 am
List:net.java.dev.jna.users

On Apr 3, 2008, at 11:24 AM, Alan Veasey wrote:

Thank you for the quick reply!!!

I understand what you are saying about it being a pointer to a structure.

The argument must be a pointer to a pointer to a structure, NOT a pointer to a structure. You are, in effect, providing some random integer (probably zero) as a pointer value, which guarantees an access violation.

I guess I don't care about the internals of the structure just so long as windows is ok with it. I still don't understand why I am getting an access violation calling HidD_GetPreparsedData, though. Just for testing I changed the first parameter to take an int and passed in the value 23. It didn't give an access violation error, but instead Native.getLastError was set to "Invalid handle". That leads me to believe that the HANDLE variable I am passing as the first parameter has a problem.

Sometimes you can get away with passing null as the HANDLE. Otherwise, you can use GetModule(null) to obtain a handle for the current context. That may or may not work depending on what GetPreparsedData wants for the handle value.

This, however, is not the problem. The problem is that you are not providing valid memory in which the function can write a pointer value to return to you. Pass in an instance of PointerByReference, use getValue() to retrieve the result after the call; that value is your magic pointer to structure for later use.

This HANDLE variable is returned from the Kernel32.CreateFile function and I am testing the value against INVALID_HANDLE_VALUE. Just for kicks I executed "System.out.println(HidDevice.getPointer().getInt(0));" and it gives an access violation. HidDevice is of type W32API.HANDLE.

Any thoughts? --- Timothy Wall <twal@dev.java.net> wrote:

On Mar 31, 2008, at 1:42 PM, Alan Veasey wrote:

Without taking too much time, I would like to say that this project is a God-send.

I need to call a Windows function called HidD_GetPreparsedData(). It's second argument is a structure called _HIDP_PREPARSED_DATA. The MSDN documentation for this structure says, "The internal structure of a _HIDP_PREPARSED_DATA structure is reserved for internal system use." I'm not sure where to go from here. I've tried making a new class by extended Structure and PointerType, but I keep getting an access violation. Any help with this would be greatly, greatly appreciated.

This is the API for HidD_GetPreparsedData(): BOOLEAN HidD_GetPreparsedData( IN HANDLE HidDeviceObject, OUT PHIDP_PREPARSED_DATA *PreparsedData );

This is the available struct def for PHIDP_PREPARSED_DATA: typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;

The function is asking for a pointer to pointer (PHIDP_PREPARSED_DATA *). You can use an instance of PointerByReference, or define your own XByReference type which holds a derived PointerType.

Thank you for this project and keep up the great work!

You're very welcome :)

T.

---------------------------------------------------------------------

To unsubscribe, e-mail: user@jna.dev.java.net For additional commands, e-mail: user@jna.dev.java.net