Hi,
I have a DLL created in Borland C++, which I am trying to call at runtime using DLL LoadLibrary() from one of my Visual studio C++ project which is a DLL again. And both these are used in a .Net application.
Following is the way I am trying to export and call.
Borland C++ DLL exposing the function,
__declspec(dlle xport) const char * __stdcall Function(char *paramStr1, char *paramStr2, int paramStr3)
{
// function body
// allocates memory - global variables and static variables
}
---------------
Visualt Studio C++ DLL calling the function,
HINSTANCE mHInstance;
typedef char* (__stdcall *BorlandDll) (const char*, const char*, int);
BorlandDll _BorlandDll;
_BorlandDll= (BorlandDll)::G etProcAddress(m HInstance, "Function" );
std::string returnvalue= _BorlandDll(par amStr1, paramStr2, paramStr3);
The borland Dll decodes an encoded message sent to it from VS C++ Dll by allocating memory(globaly and statically) and it makes call to another project which also allocates memory by using malloc.
When the Dll called for the first time and if the encoded message is small things are working fine, but if I try to call the Dll function over the same encoded message multiple times(max 5 times) the Dll crashes... Also if the encoded message is huge(upto 150 bytes) the Dll again crashes...
I get this following error
"Unhandled exception at 0x32554c54 in TestPerDLL.exe: 0xC0000005: Access violation reading location 0x00000012."
Remeber the borland C++ dll also calls some code which allocated huge memory.
Can somebody help me out from this. Or point me to a place where in I can refer to this kind of issues dealt before.
I also wanted to know where these memory allocation happens. In such case what is the right way of calling the DLL.
I have a DLL created in Borland C++, which I am trying to call at runtime using DLL LoadLibrary() from one of my Visual studio C++ project which is a DLL again. And both these are used in a .Net application.
Following is the way I am trying to export and call.
Borland C++ DLL exposing the function,
__declspec(dlle xport) const char * __stdcall Function(char *paramStr1, char *paramStr2, int paramStr3)
{
// function body
// allocates memory - global variables and static variables
}
---------------
Visualt Studio C++ DLL calling the function,
HINSTANCE mHInstance;
typedef char* (__stdcall *BorlandDll) (const char*, const char*, int);
BorlandDll _BorlandDll;
_BorlandDll= (BorlandDll)::G etProcAddress(m HInstance, "Function" );
std::string returnvalue= _BorlandDll(par amStr1, paramStr2, paramStr3);
The borland Dll decodes an encoded message sent to it from VS C++ Dll by allocating memory(globaly and statically) and it makes call to another project which also allocates memory by using malloc.
When the Dll called for the first time and if the encoded message is small things are working fine, but if I try to call the Dll function over the same encoded message multiple times(max 5 times) the Dll crashes... Also if the encoded message is huge(upto 150 bytes) the Dll again crashes...
I get this following error
"Unhandled exception at 0x32554c54 in TestPerDLL.exe: 0xC0000005: Access violation reading location 0x00000012."
Remeber the borland C++ dll also calls some code which allocated huge memory.
Can somebody help me out from this. Or point me to a place where in I can refer to this kind of issues dealt before.
I also wanted to know where these memory allocation happens. In such case what is the right way of calling the DLL.
Comment