I am writting a DLL, with a function where I receive a function address of the calling process in order to call that remote function when I need in my code. The function has a string pointer as argument.
In the DLL I have this global variable, where I define the pointer to the remote function:
Code:
int (__stdcall *f_status) (char *);
One of the exported function in the DLL is:
Code:
INT __declspec(dllexport) __stdcall _MYDLL_RegisterStatusFunc (int (__stdcall *statusfunc) (char*)) {
f_status=statusfunc;
return OK;
}
This function is called by the remote program, which I don't have the source code.
In my DLL code, the calling program call this function. Then, if I call f_status function the call is OK. But I have code where I create a thread with beginthread.
I make two call to f_status, One before thread begin: the call is OK. The second one is after thread creation, the first instruction in the thread, and the programs crash. it is like if thread creation destroy same kind of remote calls. If I don't call this remote function, the rest of the thread run OK.
I have tried to write in a log file the content in bytes of the f_status, and the pointer itself; I see that before and after thread creation is the same.... so the remote address does not change..... only the execution of the call is what crash.
Of course, I check before calling f_status that it is not NULL.
I am using lcc32 compiler, free for non-comercial use.
Do you know what's the problem?. If I make calls outside threads it works perfect.
Any tip? Am I doing samething wrong?
Thanks in advance.
Kem