|
|
|
|
#1 |
|
Junior Member
Join Date: Feb 2006
Posts: 5
|
Possible to unload a plugin from a plugin?
I would like to know if it's possible to tell Winamp to shut down a plugin from within another plugin's init function?
I have two version of a plugin, an ML one that should be used if the media library is installed, and a GEN one if the media library is installed. As I can't seem to influence the order Winamp loads up plugins in, I thought I'd let it go ahead and load the GEN one, and if I further down the line find myself in the init function of the ML one, and the GEN is already loaded, I'd like to unload the GEN one and let the ML version load instead. If we never get to the init of the ML one, that means the media library is not installed and we let the GEN plugin do the work. Is this possible? |
|
|
|
|
|
#2 |
|
-
Join Date: Sep 2003
Location: UK
Posts: 22,265
|
it depends on what/if you need to do much in the init call of the gen plugin though gen_ml and the ml_* plugins could be loaded before your gen_* is loaded.
when the ml one is loaded, do a GetModuleHandle(path_of_gen_dll) check and if that returns a handle then the gen plugin will have been loaded into the address space. as long as you're gen_* hasn't done any subclassing then i think you can just do a FreeLibrary(..) call on the handle which you obtained and it would unload the gen_* from winamp's process space. there of course is the other option of in the gen_*'s init(..), you test for gen_ml being present/being able to get a valid hwnd for the ml and if you get a success then use the ML_IPC_ADD_PLUGIN to load your plugin in as a ml plugin (not the comments in ml.h about this process though). UINT libhwndipc = (LONG)SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE); HWND ml_wnd = (HWND)SendMessage(wa,WM_WA_IPC,-1,(LPARAM)libhwndipc); (use to get the ml hwnd) -daz |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2006
Posts: 5
|
Thanks! I apologise in advance if some of these questions are very basic, but I'm new to Winamp plugin development and am taking over some code from a previous developer.
I don't think the FreeLibrary approach will work as the plugin is subclassing both the Winamp and the Playlist window procedures. And the pointers to the old versions will live inside the other plugin's memory space so I can't easily restore them. That code snippet you posted is actually present in the plugin to try and work out whether we can get an ML handle. However, when I stepped through this code inside the gen plugin running in a Winamp instance with ML installed, the value of ml_hwnd I got was 0x01, which doesn't look right. And what exactly is gen_ml? A general plugin? An ML plugin? |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Feb 2006
Posts: 5
|
OK, I've done a little bit of further testing. I've been testing the exact same code with a plugin named gen_* and one named ml_*.
In the init of the gen version, the code snippet above returns 65537 for libhwndipc and when used to request the ML window handle, the handle returned is an invalid 0x01. Putting the same code snippet in the init of the ml version, I get 65545 for libhwndipc and the ML window handle returned is valid. I also tried going back to the gen version and hardcoding 65545 for the last param of the call to get the ML hwnd but still get 0x01 back. This seems to imply that it's impossible to get the ML hwnd from a plugin named gen_*. Is this correct? |
|
|
|
|
|
#5 |
|
-
Join Date: Sep 2003
Location: UK
Posts: 22,265
|
no, that's not correct since i've got the ml hwnd fine in my gen plugins. i think there were some other calls for libhwndipc 0 or 1 along with -1 but i can't remember if one of them was meant to force load the ml if it was not already there. however depending on the plugin load order you may get the 1, i've found a postmessage on load can get around the loading issues but that doesn't seem to be viable for what you're trying to do.
i wouldn't hard code that value of libhwndipc since it's created at run time and there is no guarantee it would be the same on anyother install. oh, and gen_ml is the media library itself (since it's just implemented as another plugin) -daz |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Feb 2006
Posts: 5
|
Aha, the library is in fact a general plugin!
OK, I think I've found another way. Discovered a file in the Winamp directory called install.ini. It contains a line: Winamp Media Library=0 where the digit seems to be 1 if the ML is installed and 0 if it's not. So I'm going to look for this when installing my plugin and then name it gen_* or ml_* accordingly. Does anyone know if this is a reasonably reliable method? |
|
|
|
|
|
#7 |
|
-
Join Date: Sep 2003
Location: UK
Posts: 22,265
|
i'd just go with a installer check for gen_ml instead since the installer.ini cannot be guaranteed especially if someone installed on a pre 5.2 setup (when that option in the installer became public)
-daz |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|