Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Loading a DLL and HEAP problem

Loading a DLL and HEAP problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex H 1983
    wrote on last edited by
    #1

    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);
    
    B C 2 Replies Last reply
    0
    • A Alex H 1983

      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);
      
      B Offline
      B Offline
      bikram singh
      wrote on last edited by
      #2

      Seems like the problem is in GetYahooString(). Where's the source for that? Bikram Singh

      A 1 Reply Last reply
      0
      • B bikram singh

        Seems like the problem is in GetYahooString(). Where's the source for that? Bikram Singh

        A Offline
        A Offline
        Alex H 1983
        wrote on last edited by
        #3

        Sorry there is no GetYahooString , it is GetString !

        1 Reply Last reply
        0
        • A Alex H 1983

          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);
          
          C Offline
          C Offline
          cmk
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups