Hi All,
I am getting an access violation when executing a function that was dynamically loaded from a dll. A pointer to std::map is passed as a parameter to the function, and when calling the map::find() method in the dll, there is a crash. I use visual studio 6.
This is the code that loads the dll and execute the function:

###################################
typedef BOOL (__cdecl *DllFunction)(LPVOID);
typedef map<CL_STRING, CL_STRING> MAP_PARAMETER_VALUE;

HMODULE hModule = LoadLibrary("GA.dll");
if (hModule)
{
DllFunction pExecuteFunc = NULL;
pExecuteFunc = (DllFunction)GetProcAddress(hModule, "GAFunc");
if (pExecuteFunc)
{
MAP_PARAMETER_VALUE mapContextParams
BOOL bRes = pExecuteFunc( &mapContextParams );
}
}
###################################

In the dll project, I declared a .def file that looks like this:

LIBRARY "GA"

EXPORTS
GAFunc
###################################

The function in the dll is declared:

#define DllExport __declspec( dllexport )

DllExport BOOL __cdecl GAFunc(IN LPVOID contextParams)
{
MAP_PARAMETER_VALUE* pMapParams = (MAP_PARAMETER_VALUE*)contextParams;
CL_STRING strParamName("SomeKey");

// The following line causes the access violation!!!
MAP_PARAMETER_VALUE::iterator paramFound = pMapParams->find(strParamName);
return TRUE;
}

####################################

Class CL_STRING is declared and overrides operator <,>,<=,>=,==,=,!=. It also overrides copy constructor.

If the GAFunc gets a parameter which is a pointer to char (LPSTR) it works fine.

I look at the memory of contextParams before passing it to the dll, and after, and it points to the same memory address, but in the dll I see that _Nil filed is NULL, and that what eventually causes the crash.

What am I missing here? Why is the _Nil field changing?
Thanks,

Adi