Re: Problems calling a function in a DLL
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Mon, 30 Apr 2007 14:19:38 -0400
shanzer <shanzer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
typedef DWORD (WINAPI *tfn) (unsigned char *, unsigned int, unsigned
int *);
The typedef defines a poitner to function using __stdcall calling
convention (that's what WINAPI expands to).
extern "C" {
__declspec(dllexport) DWORD GetData(unsigned char *data,
unsigned int dataSize,
unsigned int *dataLen)
The actual function is declared with no explicit calling convention, and
most likely defaults to __cdecl. When the caller and the callee don't
agree on the calling convention, the result is corrupted stack.
Specify WINAPI in both places.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- References:
- Problems calling a function in a DLL
- From: shanzer
- Problems calling a function in a DLL
- Prev by Date: Re: Problems calling a function in a DLL
- Next by Date: Re: Check to see if an exe is blocked
- Previous by thread: Re: Problems calling a function in a DLL
- Next by thread: disappearing toolbar
- Index(es):
Relevant Pages
|