I have an a.dll (not modifiable as i do not have the source) with a function bool openPort(DWORD mem).
I wrote a c++ main, loaded this dll using LoadLibrary, and the function works well.
It returns true.
Now, I need to call this function from Java via JNI.
I wrote another b.dll with a function like so
JNIEXPORT void JNICALL Java_MyClass_openPortFunc
(JNIEnv *env, jobject obj, jint pMemPhy)
{
hInstLibrary = LoadLibrary("a.dll");
typedef bool (*openPort)(DWORD);
openPort _openPort;
_openPort = (openPort)GetProcAddress(hInstLibrary, "openPort");
DWORD memAddr = 0xda000;
if(_openPort(memAddr)){
cout << "ok" << endl;
}else{
cout << "failed " << endl;
}
}
This however, causes the openPort to return false despite using the same parameters.
I hope someone can advise me.
Thank you. :)