Thread: Passing a Pointer from an Application to DLL

  1. #1
    Registered User
    Join Date
    Jun 2003

    Passing a Pointer from an Application to DLL

    I am implementing a RAS Extension DLL.
    I want that whenever a user connects to the RAS server on Windows my application recieves a notification. For this purpose I call an exported member of the dll . The argument to this function is the pointer to the function which I want to be called whenever any user connects to the RAS server. This works fine but when the user connects to the RAS server the error is shown as that the memory could not be read.

    Can any body help??
    One can't let go and still win

  2. #2
    Bioport Productions
    Join Date
    Oct 2005
    Memory could not be read usually means you have a NULL object somewhere. Make sure you instantianted the class the member resides in and if you can't find the problem yourself I'm sure we could help you with some code examples.
    -"What we wish, we readily believe, and what we ourselves think, we imagine others think also."
    PHP Code:

  3. #3
    Registered User
    Join Date
    Jun 2003


    #pragma data_seg(".SH")
    static TDataReadNotify DataReadNotify=NULL;
    #pragma data_seg()
       IN RAS_CONNECTION_0 *   pRasConnection0,
       IN RAS_CONNECTION_1 *   pRasConnection1
        return( TRUE );
    Now DataReadNotify is a function in my application linked to dll
    int main()
    long lProcAddr;
    long  SetCallbackProcAddr(long lProcAddress)
      long Result = 0;
    // Set the Proc-Address for the notify-func of the caller app.
      DataReadNotify = (TDataReadNotify)lProcAddress; 
       if(DataReadNotify!=NULL)DataReadNotify(50);//just for check
      if (DataReadNotify != NULL) Result = 1;
      return Result;
    So when I call SetCallBackProcAddr from my application main
    the function pointer is successfully passed and I am able to call the DataReadNotify function

    but when a user dials to the RasServer and the function MprAdminacceptNewConnection is called by windows the pointer 's value is same as that passed from the application to the dll but it says
    Error cannot read Memory location 0x00401014.

    I have read that pointers should not be passed like this in shared data segments but I want to know other work arounds to this problem.

    Basically I want to call the function in my application from the dll function when dll is loaded by Windows.
    One can't let go and still win

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. Replies: 1
    Last Post: 09-18-2005, 09:06 PM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Passing a pointer to a struct
    By Natase in forum C Programming
    Replies: 2
    Last Post: 10-02-2001, 10:29 AM