mIRC Homepage
Posted By: high6 Keep a plugin loaded problem. - 17/07/08 08:37 PM
Version: 6.21

I have come across a problem with keeping a plugin loaded.

The plugin stays loaded after the first call but then after about 10 minutes of not calling the dll, mirc crashes and I noticed when debugging the crash that the plugin isn't loaded when it crashes.

So I think what is happening is mirc still sees the dll as being loaded but for some reason the dll is unloaded so when tries to access it it has a memory access violation because the dll isn't there anymore.
Posted By: Jigsy Re: Keep a plugin loaded problem. - 17/07/08 09:16 PM
Try updating to 6.32 then see if the problem occurs.
Posted By: symphony Re: Keep a plugin loaded problem. - 17/07/08 11:35 PM
Which DLL was that? Please elaborate accurately explaining what did you do, which DLL, your operating system and version etc...

AND what Jigsy said too!
Posted By: high6 Re: Keep a plugin loaded problem. - 18/07/08 02:01 AM
Got 6.32, same thing.
Posted By: starbucks_mafia Re: Keep a plugin loaded problem. - 18/07/08 02:20 AM
If a DLL isn't used for ten minutes mIRC will attempt to unload it. A DLL can prevent itself from being unloaded by defining an UnloadDll() function and checking the parameter passed to it has a value of 1. Most likely the DLL is interacting with either mIRC or another DLL in such a way that unloading it is causing the crash. You should contact the DLL author to ensure they are accounting for mIRC's "timeout" behaviour.
Posted By: maroon Re: Keep a plugin loaded problem. - 18/07/08 02:33 AM
Or else the guy could set a 9 minute timer to call one of the dll's minor functions to keep it from timing out, assuming it's exactly 10 minutes and not an approximation.
Posted By: high6 Re: Keep a plugin loaded problem. - 18/07/08 08:28 AM
That fixed it, still kinda seems silly that after it unloads the dll it still thinks it has it and tries to access it without reloading it.

Also kinda stupid that it unloads it after a timeout. I think if you set Keep to true I think you maybe don't want it unloaded after 10 minutes...
Posted By: Collective Re: Keep a plugin loaded problem. - 18/07/08 10:18 AM
Originally Posted By: high6
That fixed it, still kinda seems silly that after it unloads the dll it still thinks it has it and tries to access it without reloading it.

That would be silly, which is why mIRC doesn't do it.

Your DLL is likely doing something that results in it being called upon by Windows or another external application (subclassing a window, for example). Your DLL should clean these things up when it's being unloaded.

You seem very eager to blame mIRC for what is very likely your own bad coding.
Posted By: argv0 Re: Keep a plugin loaded problem. - 18/07/08 06:45 PM
It can't "reload it" because "it" doesn't know what was loaded to begin with. It's gone. As Collective mentioned, the Dll developer is responsible for cleanup, mIRC has no way of knowing what was left behind.
Posted By: high6 Re: Keep a plugin loaded problem. - 19/07/08 03:38 PM
I am guessing that when you don't have UnloadDll defined it just unloads it but because of Keep in LoadDll it still thinks its loaded when it's not.
Posted By: argv0 Re: Keep a plugin loaded problem. - 19/07/08 03:56 PM
No.. mIRC doesn't think its loaded. Whatever process/subroutines the dll initiated will stick around though, because mIRC isn't responsible for cleaning them up.. those subroutines will assume the parent is still loaded, when it's not... that's what you meant to say. Of course, that's not mIRC's fault/problem, it's the dll author's

/help Dll Support and read Unloading a Dll. When a dll times out, mIRC unloads it and knows that it unloaded it. That's why this is not a bug. It's intentional.
© mIRC Discussion Forums