Hello everyone! Developing a small autocompletion tool for mIRC I've encountered a problem. At dll loading (/dll plugin.dll Start) I subclass the current channel window with my own WndProc. When I later remove this subclass in UnloadDll, direct call "/dll -u plugin.dll" causes immediate termination of mIRC. However if I remove the subclass in some other function before unloading dll (/dll plugin.dll Stop; /dll -u plugin.dll), everything is fine.

It happens only if I subclass the chat window; subclassing main mIRC window works fine. Also, once I subclass anything else, WinApi's GetLastError() starts flooding with 6 "invalid handle" and 126 "module not found" errors.

For some reason there are also two possible stack traces:
First one in debug mode:
Code:
>	0fa45551()	Unknown
 	[Frames below may be incorrect and/or missing]	
 	comctl32.dll!_CallNextSubclassProc@20()	Unknown
 	comctl32.dll!_MasterSubclassProc@16()	Unknown
 	user32.dll!76466238()	Unknown
 	user32.dll!764668ea()	Unknown
 	user32.dll!764678b0()	Unknown
 	user32.dll!76467d31()	Unknown
 	user32.dll!76467dfa()	Unknown
 	mIRC.exe!014a7f9f()	Unknown
 	mIRC.exe!014ae0e9()	Unknown
 	mIRC.exe!0158ec7c()	Unknown
 	kernel32.dll!@BaseThreadInitThunk@12()	Unknown
 	ntdll.dll!___RtlUserThreadStart@8()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8()	Unknown


And the other in release mode:
Code:
	0f187cd5()	Unknown
 	[Frames below may be incorrect and/or missing]	
 	user32.dll!76466238()	Unknown
 	msctf.dll!ATL::CComPtr<struct IBackingStoreHolder>::CComPtr<struct IBackingStoreHolder>(struct IBackingStoreHolder *)	Unknown
 	msctf.dll!CicBridge::OnSysKeyboardProc(unsigned int,long)	Unknown