mIRC Home    About    Download    Register    News    Help

Print Thread
Problem calling DLL? #166624 13/12/06 03:10 AM
Joined: Aug 2003
Posts: 18
Z
z0r Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Aug 2003
Posts: 18
A 32-bit DLL I've written for mIRC basically wraps some winsock functions and does some simple processing. When I call any function from this DLL, mIRC 6.21 crashes. The code I've posted is enough to cause mIRC 6.21 to crash, by running the dll in such a way: $dll(thefile.dll, init, $null). It appears mIRC doesn't even get the opportunity to call the function, it just crashes. Is this a mIRC bug, or is there something I've done wrong?

Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include <winsock.h>
#pragma comment(lib, "ws2_32.lib")

#define FORMAT "%08p"

typedef struct {
   DWORD  mVersion;
   HWND   mHwnd;
   BOOL   mKeep;
} LOADINFO;

void __declspec(dllexport) LoadDll(LOADINFO *ldinfo);
int __declspec(dllexport) init(HWND mWnd, HWND aWnd, char *data, char *params, BOOL show, BOOL nopause);

void __declspec(dllexport) LoadDll(LOADINFO *ldinfo) {
	return;
}

int __declspec(dllexport) init(HWND mWnd, HWND aWnd, char *data, char *params, BOOL show, BOOL nopause) {
	WSADATA wsa;

	sprintf(data, FORMAT FORMAT, WSAStartup(0x10, &wsa), &wsa);
	return 3;
}

Last edited by z0r; 13/12/06 03:11 AM.
Re: Problem calling DLL? [Re: z0r] #166626 13/12/06 03:41 AM
Joined: Jan 2003
Posts: 249
C
ClickHeRe Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Jan 2003
Posts: 249
Aren't you missing the unloadDll function?


Re: Problem calling DLL? [Re: z0r] #166640 13/12/06 10:29 AM
Joined: Apr 2004
Posts: 865
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 865
You haven't declared your functions as __stdcall.


Saturn, QuakeNet staff