I'm having problem calling a dll that I created having an entry point like this:
void _stdcall Entry_Point_Function(unsigned char *input, int count, unsigned char *Output)
{
Function1(Input, count);
Function2(Output);
}
Some of the internal functions in the dll are declare as static.
In the host application, the main function calls the dll like this:
typedef void (*FUNCPROC)(unsigned char *, int, unsigned char *);
int main()
{
HINSTANCE hinstLib;
FUNCPROC func_proc;
unsigned char *Input = "data";
int count = 4
unsigned char *Output;
Output = malloc(count * sizeof(unsigned char));
hinstLib = LoadLibrary("mydll"
if (hinstLib != NULL) {
func_proc = (FUNCPROC) GetProcAddress(hinstLib, "Entry_Point_Function"
if (func_proc != NULL){
(func_proc)((unsigned char *)Input, (int) count, (unsigned char *)Output);
}
else {
printf("Failed to get the function.\n"
return 1;
}
}
/* Free the DLL module.!!! */
FreeLibrary(hinstLib);
}
else {
printf("Can't load the library.\n"
return 2;
}
return 0;
}
But when I run the host executable I had this error message:
Degug Error!
Program ........\testdll.exe
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Even with that, if a press Ignore, I got the right output. But then, a fatal exception error window is displayed. I debuged the dll using the host application and the dll return the right answer. Just when I try to move to the next instruction in the host application. the error appears.
I run my code not as a dll but a normal project with the same calling function that I use as the Entry Point of the dll and everything runs find.
Any suggestion...???
void _stdcall Entry_Point_Function(unsigned char *input, int count, unsigned char *Output)
{
Function1(Input, count);
Function2(Output);
}
Some of the internal functions in the dll are declare as static.
In the host application, the main function calls the dll like this:
typedef void (*FUNCPROC)(unsigned char *, int, unsigned char *);
int main()
{
HINSTANCE hinstLib;
FUNCPROC func_proc;
unsigned char *Input = "data";
int count = 4
unsigned char *Output;
Output = malloc(count * sizeof(unsigned char));
hinstLib = LoadLibrary("mydll"
if (hinstLib != NULL) {
func_proc = (FUNCPROC) GetProcAddress(hinstLib, "Entry_Point_Function"
if (func_proc != NULL){
(func_proc)((unsigned char *)Input, (int) count, (unsigned char *)Output);
}
else {
printf("Failed to get the function.\n"
return 1;
}
}
/* Free the DLL module.!!! */
FreeLibrary(hinstLib);
}
else {
printf("Can't load the library.\n"
return 2;
}
return 0;
}
But when I run the host executable I had this error message:
Degug Error!
Program ........\testdll.exe
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Even with that, if a press Ignore, I got the right output. But then, a fatal exception error window is displayed. I debuged the dll using the host application and the dll return the right answer. Just when I try to move to the next instruction in the host application. the error appears.
I run my code not as a dll but a normal project with the same calling function that I use as the Entry Point of the dll and everything runs find.
Any suggestion...???