Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL ERROR??? What is this?

Status
Not open for further replies.

shakera

Programmer
Dec 11, 2003
1
0
0
US
I am trying to use the following .c and .h files to create a dll. After the dll is created and I try to reference it, I get the following error:

"The instruction at "0x003e776" reference memory at "0x004e776". The memory could not be "written".

AM I MISSING SOMETHING HERE????

Here is the MainDll.c file:
___________________________________
/* MainDll.h contains the foreward declarations
for the three functions we define in this source
file */

#include "MainDll.h"

/******************************************************************************/
/* */
/* Function: */
/* Name: Login */
/* type: int */
/* parameters: PCSTR key, PSTR buffer, SIZE_T buffLen */
/* return values: 0 - successful */
/* prototype:int CALLBACK Login(PCSTR key, PSTR buffer, SIZE_T buffLen)*/
/* description: This function is called whenever a user attempts to log*/
/* in. Key is login name and is copied into buffer, */
/* bufflen is always 11 */
/* */
/******************************************************************************/

int Login(char const *key, char *buffer, int buffLen)
{
strcpy(buffer,key);

return (0); // Successful
}

void Logout(char const *key)
{

}

int VerifyUser(char const *uid, char const *pwd)
{

return (0); // Successful
}

Here is the header file:
____________________________________

#ifndef _MAINDLL_H
#define _MAINDLL_H

#include <string.h>

int Login(char const *, char *, int);
void Logout(char const *);
int VerifyUser(char const *, char const *);

#endif

 
The error you get suggest you are trying to write to an address not belonging to your process.

Could be because your dll calls strcpy(buffer, key)

What exactly does buffer point to ?

Show the code calling the Login function.

/JOlesen
 
Well I think you need to export the APIs in the .lib file which seems to be missing. Actually you need to tell which APIs in a dll can be called by other process.

Use format like
__declspec(dllexport) void __cdecl Function1(void);

where __declspec(dllexport) specifies that this function/API needs to be exported. Otherwise you will not be able to see the definition of the API in other process.

Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top