13 messages in net.java.dev.jna.usersRe: [jna-users] Cannot pass any data ...
FromSent OnAttachments
Daniel HorowitzJun 14, 2007 11:27 am 
Timothy WallJun 14, 2007 11:29 am 
Daniel HorowitzJun 14, 2007 11:31 am 
Daniel HorowitzJun 14, 2007 11:39 am 
Timothy WallJun 14, 2007 11:42 am 
Daniel HorowitzJun 14, 2007 11:52 am 
Timothy WallJun 14, 2007 11:53 am 
Timothy WallJun 14, 2007 12:03 pm 
Daniel HorowitzJun 14, 2007 12:13 pm 
Daniel HorowitzJun 14, 2007 12:22 pm 
Timothy WallJun 14, 2007 12:30 pm 
Daniel HorowitzJun 14, 2007 2:11 pm 
Timothy WallJun 14, 2007 2:23 pm 
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] Cannot pass any data to native dllActions...
From:Daniel Horowitz (dani@gmail.com)
Date:Jun 14, 2007 11:39:36 am
List:net.java.dev.jna.users

Some more info that might clear things up - I am compiling my dll with VS2005 and my project settings are

Calling convention - __cdecl Compile as - C++

Through reading the forms i tried __stdcall but then jna cant find any of my functions. Then I tried compile as C, and the compiler complained about my extern definitions being strings (very strange).

Timothy,

I am. Here is my java interface.

import com.sun.jna.*; import com.sun.jna.win32.*;

public interface GTAPI32 extends StdCallLibrary { interface WNDENUMPROC extends StdCallCallback { boolean callback(Pointer hWnd, Pointer arg); }

public static class HGTBSESSION extends Structure { public Pointer unused; }

GTAPI32 INSTANCE = (GTAPI32) Native.loadLibrary("TestAPIB", GTAPI32.class);

int init(); int login(); int subscribe(int foo); int destroy(); int logout(); }

On 6/14/07, Timothy Wall <twal@dev.java.net> wrote:

On Jun 14, 2007, at 2:28 PM, Daniel Horowitz wrote:

Hey,

I am able to invoke functions in my dll that do not take any arguments. But if the function takes arguments of any type, and I call the function, java crashes with the following message -

# # An unexpected error has been detected by Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x009dfa9c, pid=3616, tid=3192 # # Java VM: Java HotSpot(TM) Client VM ( 1.6.0_01-b06 mixed mode) # Problematic frame: # C 0x009dfa9c

Here are my dll function definitions. all the functions work except subscribe.

#ifndef _TESTAPIB_H_ #define _TESTAPIB_H_

extern "C" __declspec(dllexport)int init(); extern "C" __declspec(dllexport)int destroy(); extern "C" __declspec(dllexport)int login(); extern "C" __declspec(dllexport)int logout(); extern "C" __declspec(dllexport)int subscribe(int foo);

#endif

Probably you need to derive from StdCallLibrary rather than Library, so that w32 stdcall calling convention is used.