Hi,
I've a DLLA which exports certain functions. I am creating another dll DLLB that calls functions of DLLA. DLLB is eventually called from a Java application using JNI. The C++ code for DLLB compiles and Links without any errors but when I try to run the Java application it raises Exception_Access_Violation exception.
I use
extern "C" __declspec(dllimport)
statement to load functions in DLLB from DLLA.
Following is code for DLLB:
Connect(), DisConnect(), InitControl() and GetPropPicCount() functions are imported from DLLA
#include "resource.h"
#include <jni.h>
#include "StdAfx.h"
#include "ryecommon.h"
#include "proj.h"
#include "ProjTest.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
return TRUE;
}
JNIEXPORT jlong JNICALL Java_ProjTest_getPicCount (JNIEnv *env, jclass clas, jlong camID)
{
long picCount;
InitControl();
Connect((long)camID);
picCount = GetPropPicCount((long)camID);
DisConnect((long)camID);
return picCount;
}
I get the following message when the exception is raised:
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x77F83598
Function=RtlInitAnsiString+0x1B
Library=C:\WINNT\system32\ntdll.dll
Current Java thread:
at ProjTest.getPicCount(Native Method)
at ProjTest.main(ProjTest.java:25)
Dynamic libraries:
0x00400000 - 0x00406000 C:\WINNT\system32\java.exe
0x77F80000 - 0x77FFD000 C:\WINNT\system32\ntdll.dll
0x7C2D0000 - 0x7C332000 C:\WINNT\system32\ADVAPI32.dll
0x7C570000 - 0x7C628000 C:\WINNT\system32\KERNEL32.DLL
0x77D30000 - 0x77DA1000 C:\WINNT\system32\RPCRT4.DLL
0x78000000 - 0x78045000 C:\WINNT\system32\MSVCRT.dll
0x08000000 - 0x08138000 C:\Program Files\Java\j2re1.4.2_04\bin\client\jvm.dll
0x77E10000 - 0x77E75000 C:\WINNT\system32\USER32.dll
0x77F40000 - 0x77F7E000 C:\WINNT\system32\GDI32.DLL
0x77570000 - 0x775A0000 C:\WINNT\system32\WINMM.dll
0x75E60000 - 0x75E7A000 C:\WINNT\system32\IMM32.DLL
0x10000000 - 0x10007000 C:\Program Files\Java\j2re1.4.2_04\bin\hpi.dll
0x007C0000 - 0x007CE000 C:\Program Files\Java\j2re1.4.2_04\bin\verify.dll
0x007D0000 - 0x007E9000 C:\Program Files\Java\j2re1.4.2_04\bin\java.dll
0x007F0000 - 0x007FD000 C:\Program Files\Java\j2re1.4.2_04\bin\zip.dll
0x18270000 - 0x182A2000 C:\patel\ProjTest\proj.dll
0x182B0000 - 0x182C0000 C:\patel\ProjTest\RyeDLL.dll
0x77920000 - 0x77943000 C:\WINNT\system32\imagehlp.dll
0x72A00000 - 0x72A2D000 C:\WINNT\system32\DBGHELP.dll
0x690A0000 - 0x690AB000 C:\WINNT\system32\PSAPI.DLL
Heap at VM Abort:
Heap
def new generation total 576K, used 115K [0x10010000, 0x100b0000, 0x104f0000)
eden space 512K, 22% used [0x10010000, 0x1002cfc0, 0x10090000)
from space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000)
to space 64K, 0% used [0x100a0000, 0x100a0000, 0x100b0000)
tenured generation total 1408K, used 0K [0x104f0000, 0x10650000, 0x14010000)
the space 1408K, 0% used [0x104f0000, 0x104f0000, 0x104f0200, 0x10650000)
compacting perm gen total 4096K, used 938K [0x14010000, 0x14410000, 0x18010000)
the space 4096K, 22% used [0x14010000, 0x140faae8, 0x140fac00, 0x14410000)
Local Time = Mon Sep 13 13:58:06 2004
Elapsed Time = 1
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_04-b05 mixed mode)
#
Please help me out of this problem as I've been trying to solve it since past 4 days and all my progress has stalled.