Loading a DLL and HEAP problem
-
hi iam using the code below in my project! but when i Exit the program the Debuger goes to dbgheap.h and says Access Violation error, and if i remove this line of code : GetString(username, password, string); this error will not occure and the program will exit succesfully! i have also Free the Library by calling FreeLibrary(hLib); Any Suggestion how to get rid of this ? Thanx in advance
typedef bool (WINAPI * cfunc)(const char * username,const char * Password, char * result_6); HINSTANCE hLib=LoadLibrary("crypt_string.dll"); cfunc GetString; GetString=(cfunc)GetProcAddress(hLib, "Get_String"); CString username = "Myuser" , password= "Mypass" , string = ""; GetString(username, password, string); bool lo=FreeLibrary(hLib);
-
hi iam using the code below in my project! but when i Exit the program the Debuger goes to dbgheap.h and says Access Violation error, and if i remove this line of code : GetString(username, password, string); this error will not occure and the program will exit succesfully! i have also Free the Library by calling FreeLibrary(hLib); Any Suggestion how to get rid of this ? Thanx in advance
typedef bool (WINAPI * cfunc)(const char * username,const char * Password, char * result_6); HINSTANCE hLib=LoadLibrary("crypt_string.dll"); cfunc GetString; GetString=(cfunc)GetProcAddress(hLib, "Get_String"); CString username = "Myuser" , password= "Mypass" , string = ""; GetString(username, password, string); bool lo=FreeLibrary(hLib);
Seems like the problem is in GetYahooString(). Where's the source for that? Bikram Singh
-
Seems like the problem is in GetYahooString(). Where's the source for that? Bikram Singh
Sorry there is no GetYahooString , it is GetString !
-
hi iam using the code below in my project! but when i Exit the program the Debuger goes to dbgheap.h and says Access Violation error, and if i remove this line of code : GetString(username, password, string); this error will not occure and the program will exit succesfully! i have also Free the Library by calling FreeLibrary(hLib); Any Suggestion how to get rid of this ? Thanx in advance
typedef bool (WINAPI * cfunc)(const char * username,const char * Password, char * result_6); HINSTANCE hLib=LoadLibrary("crypt_string.dll"); cfunc GetString; GetString=(cfunc)GetProcAddress(hLib, "Get_String"); CString username = "Myuser" , password= "Mypass" , string = ""; GetString(username, password, string); bool lo=FreeLibrary(hLib);
Ehsan-de-Burge wrote: Any Suggestion how to get rid of this ? Yes, don't pass a CString to a function expecting char*. The GetString() prototype suggests that it expects a char* for the result, i am assuming it expects the buffer to exist and does not alloc one itself. You have initialized 'string' to "" which is at least 1 byte in size. When you pass 'string' to GetString() it downcasts to the buffer CString is using and passes that to GetString(). If GetString() expects the buffer to exist then you haven't made it big enough, if it alloc's one ... well then what you are doing is wrong in more ways than one. ...cmk Save the whales - collect the whole set