I have a DLL function that looks like this:
Its job is to take a <string,string> map, populate it, and give it back to the function that called it.Code:bool GetSupportedHeaders(map <string, string> &Me) { map <string, string> HeaderMap; HeaderMap["Host:"] = "Hello"; Me = HeaderMap; return true; }
Now, in my main code I load and call the DLL like this:
Which loads the library and is supposed to print what the DLL put into the map.Code:typedef bool (*GETSUPPORTEDHEADERS) (map<string, string> &Me); GETSUPPORTEDHEADERS GetSupportedHeaders; HINSTANCE gSWEBS_headermapDLL; int main() { map <string, string> SupportedHeaders; gSWEBS_headermapDLL = LoadLibrary(".\\SWEBS_headermap.dll"); // Load the library if (gSWEBS_headermapDLL == NULL) { cout << "Could not load DLL"; return true; } cout << "Library loaded succesfully" << endl; GetSupportedHeaders = (GETSUPPORTEDHEADERS) GetProcAddress(gSWEBS_headermapDLL, "GetSupportedHeaders"); if (GetSupportedHeaders == NULL) { cout << "Could not find GetSupportedHeaders() :(" << endl; return true; } cout << "Set GetSupportHeaders()" << endl; GetSupportedHeaders( SupportedHeaders ); cout << "GetSupportHeaders() has returned." << endl; cout << SupportedHeaders["Host:"]; GetSupportedHeaders = NULL; return false; }
When it runs I get this:
Library loaded successfully
Set GetSupportedHeaders()
GetSupportedHeaders() has returned
And then there are 2 access violationsI am not too sure why, because my understanding of pointers isn't very good. Can somone please tell me whats going on and how I must fix it? Thanks
![]()



LinkBack URL
About LinkBacks
I am not too sure why, because my understanding of pointers isn't very good. Can somone please tell me whats going on and how I must fix it? Thanks



