Want to support development? Maybe get a nice server to do your own development on? Check out BuyVM or Vultr using our affiliate links! New users get $50 of free credit with Vultr, and BuyVM offers affordable servers with affordable, true DDoS filtering. You can also support us on Patreon.
Submitted on February 15, 2017 at 09:28 AM

dllmain.cpp (C++)

#include <Windows.h>
#include <CommCtrl.h>

#pragma comment(lib, "Comctl32.lib")

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


HWND hChanWnd = 0;

UINT_PTR ChannelWndProcId = 1;


enum MIRC_EXIT_CODE {
	MIRC_HALT = 0, // 0 means that mIRC should /halt processing
	MIRC_CONTINUE, // 1 means that mIRC should continue processing
	MIRC_EXEC_CMD, // 2 means that it has filled the data variable with a command which it wants mIRC to perform, and has filled parms with the parameters to use, if any, when performing the command.
	MIRC_RET_ID3 // means that the DLL has filled the data variable with the result that $dll() as an identifier should return.
};


LRESULT CALLBACK HookProc(HWND hWnd, UINT uMsg, WPARAM wParam,
	LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
	return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}


void __stdcall LoadDll(LOADINFO *info) {
}


int __stdcall UnloadDll(int mTimeout) {
	RemoveWindowSubclass(hChanWnd, HookProc, ChannelWndProcId);
	return 0;
}


BOOL APIENTRY DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved) {
	return TRUE;
}


int __stdcall Start(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause) {
	hChanWnd = aWnd;
	SetWindowSubclass(hChanWnd, HookProc, ChannelWndProcId, 0);
	return MIRC_CONTINUE;
}