|
-
March 7th, 2007, 05:57 AM
#1
dynamic loading of dll
Hi,
I am having problems calling a function within a DLL. The code is as below, actually there is no problem in loading the DLL but when the call is made to the "JNI_GetDefaultJavaVMInitArgs" function message box appears saying:
"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."
Any help in this regard is highly appreciatred.
Thanks.
_declspec(dllexport) int CALLCONV JINVOKER(jbyte *input, unsigned short inputLen,
jbyte *output, unsigned short maxOutputLen,
unsigned short *outputLen) {
........................
HINSTANCE handle;
jint res=0;
typedef jint (JNICALL *pfunc1)(void*);
typedef jint (JNICALL *pfunc2)(JavaVM **, void**, void*);
pfunc1 Func1;
pfunc2 Func2;
JavaVMOption options[1];
options[0].optionString =
"-Djava.class.path=" USER_CLASSPATH;
vm_args.version = 0x00010004;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
handle = LoadLibrary("C:\\Program Files\\IBM\\WebSphere Studio\\Application Developer\\v5.1\\runtimes\\base_v5\\java\\jre\\bin\\classic\\jvm.dll");
if(handle!=NULL)
{
Func1=(pfunc1)GetProcAddress(handle,"JNI_GetDefaultJavaVMInitArgs");
Func2=(pfunc2)GetProcAddress(handle,"JNI_CreateJavaVM");
if((Func1!=NULL)&&(Func2!=NULL))
{
.
.
.
.
if (!env) {
vm_args.version = 0x00010004;
//JNI_GetDefaultJavaVMInitArgs(&vm_args);
res=(*Func1)(&vm_args); // ERROR SHOWING IN THIS LINE
.
.
.
res=(*Func2)(&jvm,(void *)&env,&vm_args);
.
.
.
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|