Thread overview
Winamp plugin
Jul 05, 2012
dnewbie
Jul 05, 2012
Denis Shelomovskij
Jul 05, 2012
dnewbie
Jul 05, 2012
Denis Shelomovskij
Jul 06, 2012
dnewbie
Jul 12, 2012
dnewbie
July 05, 2012
I'm writing a Winamp plugin in D. Winamp loads my plugin and everything is fine until I close Winamp. At this point, Winamp calls the Quit() function of my plugin and *after* that, Winamp crashes.

Here is the code.

D source
http://dpaste.dzfl.pl/e2b2f886


myplugin.def - .DEF file
-------------------------------
LIBRARY "ml_myplugind.dll"
EXETYPE NT
SUBSYSTEM WINDOWS
EXPORTS
	winampGetMediaLibraryPlugin
-------------------------------

Compile:
dmd myplugin.d myplugin.def -ofml_myplugind.dll -L/IMPLIB

Copy ml_myplugind.dll to 'C:\Program Files (x86)\Winamp\Plugins'

Restart Winamp and go to Options -> Preferences -> Plugins -> Media Library.
You'll see 'My Cool Plugin D' [ml_myplugind.dll]' that means the plugin was loaded.

Close Winamp. You'll see a message box 'Quit() from D', from the plugin and
MS-Windows displays a error dialog. Click more information and it says APPCRASH module ml_myplugind.dll.

I have tried the following C code which does the same thing, and I've got no APPCRASHES

http://pastebin.com/7t8jkfn8

I can't see what is wrong. Any help is appreciated.

More information about Winamp plugin:
http://wiki.winamp.com/wiki/Media_Library_Plugin

July 05, 2012
05.07.2012 8:37, dnewbie пишет:
> I'm writing a Winamp plugin in D. Winamp loads my plugin and everything
> is fine until I close Winamp. At this point, Winamp calls the Quit()
> function of my plugin and *after* that, Winamp crashes.
>
> Here is the code.
>
> D source
> http://dpaste.dzfl.pl/e2b2f886
>
>
> myplugin.def - .DEF file
> -------------------------------
> LIBRARY "ml_myplugind.dll"
> EXETYPE NT
> SUBSYSTEM WINDOWS
> EXPORTS
>      winampGetMediaLibraryPlugin
> -------------------------------
>
> Compile:
> dmd myplugin.d myplugin.def -ofml_myplugind.dll -L/IMPLIB
>
> Copy ml_myplugind.dll to 'C:\Program Files (x86)\Winamp\Plugins'
>
> Restart Winamp and go to Options -> Preferences -> Plugins -> Media
> Library.
> You'll see 'My Cool Plugin D' [ml_myplugind.dll]' that means the plugin
> was loaded.
>
> Close Winamp. You'll see a message box 'Quit() from D', from the plugin and
> MS-Windows displays a error dialog. Click more information and it says
> APPCRASH module ml_myplugind.dll.
>
> I have tried the following C code which does the same thing, and I've
> got no APPCRASHES
>
> http://pastebin.com/7t8jkfn8
>
> I can't see what is wrong. Any help is appreciated.
>
> More information about Winamp plugin:
> http://wiki.winamp.com/wiki/Media_Library_Plugin
>

What's your OS? If Windows XP, than D DLL can't be unloaded because of non-perfect TLS fixing technique (I created a "perfect" one but I never managed to prepare such projects for release so nobody knows about them).

And on any Windows Digital Mars C runtime behaves very nasty when it's dynamically loaded. IIRC, it do bad things when loaded in non-main with TLS index != 0 thread and when unloaded (IIRC, again, at least it closes handles).

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


July 05, 2012
On Thursday, 5 July 2012 at 08:55:33 UTC, Denis Shelomovskij wrote:
>
> What's your OS? If Windows XP, than D DLL can't be unloaded because of non-perfect TLS fixing technique (I created a "perfect" one but I never managed to prepare such projects for release so nobody knows about them).
>
> And on any Windows Digital Mars C runtime behaves very nasty when it's dynamically loaded. IIRC, it do bad things when loaded in non-main with TLS index != 0 thread and when unloaded (IIRC, again, at least it closes handles).

Hi. OS is Windows7-64bit.
When I run Winamp in windbg, windbg crashes. The last information I can see is
'Module Unload: C:\WINDOWS\WINSXS\X86_....\MSVCR90.DLL'
Thanks.

July 05, 2012
05.07.2012 18:13, dnewbie пишет:
> On Thursday, 5 July 2012 at 08:55:33 UTC, Denis Shelomovskij wrote:
>>
>> What's your OS? If Windows XP, than D DLL can't be unloaded because of
>> non-perfect TLS fixing technique (I created a "perfect" one but I
>> never managed to prepare such projects for release so nobody knows
>> about them).
>>
>> And on any Windows Digital Mars C runtime behaves very nasty when it's
>> dynamically loaded. IIRC, it do bad things when loaded in non-main
>> with TLS index != 0 thread and when unloaded (IIRC, again, at least it
>> closes handles).
>
> Hi. OS is Windows7-64bit.
> When I run Winamp in windbg, windbg crashes. The last information I can
> see is
> 'Module Unload: C:\WINDOWS\WINSXS\X86_....\MSVCR90.DLL'
> Thanks.

I don't think I can add anything to my previous post. Sorry.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij


July 06, 2012
It works without error when compiled by GDC.
Thanks.

July 12, 2012
On Friday, 6 July 2012 at 00:38:28 UTC, dnewbie wrote:
> It works without error when compiled by GDC.
> Thanks.

Here it is
http://my.opera.com/run3/blog/2012/07/12/copyto-winamp-plugin

It adds an item in Winamp 'Send to' menu