예제 #1
0
	void Common::SaveModules() {
		wxFileConfig config;
		for (std::uint32_t i = 0, max_i = System::GetLoadedPunkModulesCount(); i < max_i; ++i) {
			auto module = System::GetLoadedPunkModule(i);
			config.Write((wchar_t*)module->GetName().Data(), (const wchar_t*)module->GetFullpath().Data());
		}
		wxFileOutputStream stream("modules.ini");
		config.Save(stream);
	}
예제 #2
0
bool GenPlugin::Load()
{
	if( IsLoaded() ) return true;

	// (1) Load DLL
	hDLL = LoadLibrary( GetFullpath() );
	if( !hDLL ) return false;

	// (2) Find export
	WINAMP_GEN_GETTER winampGetGeneralPurposePlugin =
		( WINAMP_GEN_GETTER )GetProcAddress(	hDLL, "winampGetGeneralPurposePlugin" );
	if( winampGetGeneralPurposePlugin == NULL )
	{
		FreeLibrary( hDLL );
		hDLL = NULL;
		return false;
	}

	// (3) Get module
	plugin = winampGetGeneralPurposePlugin();
	if( !plugin )
	{
		FreeLibrary( hDLL );
		hDLL = NULL;
		return false;
	}

	// (4) Process module
	plugin->hDllInstance  = hDLL;
	plugin->hwndParent    = WindowMain;

	// Note:  Some plugins (mainly old ones) set description in init.
	//        Therefore we init first and copy the name after.


	// (5) Init
	if( plugin->init )
	{
		const WNDPROC WndprocBefore = ( WNDPROC )GetWindowLong( WindowMain, GWL_WNDPROC );
			plugin->init();
		const WNDPROC WndprocAfter = ( WNDPROC )GetWindowLong( WindowMain, GWL_WNDPROC );
		
		if( WndprocBefore != WndprocAfter )
		{
			WndprocBackup  = WndprocBefore;
			iHookerIndex   = iWndprocHookCounter++;
		}
	}


	if( !szName )
	{
		// Note:  The prefix is not removed to hide their
		//        origin at Nullsoft! It just reads easier.
		if( !strnicmp( plugin->description, "nullsoft ", 9 ) )
		{
			plugin->description += 9;
		}
		
		// Get rid of " (xxx.dll)" postfix
		char * walk = plugin->description + strlen( plugin->description ) - 5;
		while( true )
		{
			if( ( walk <= plugin->description ) || strnicmp( walk, ".dll)", 5 ) ) break;
			while( ( walk > plugin->description ) && ( *walk != '(' ) ) walk--;
			if( walk <= plugin->description ) break;
			walk--;
			if( ( walk <= plugin->description ) || ( *walk != ' ' ) ) break;
			*walk = '\0';
		}
		
		iNameLen = ( int )strlen( plugin->description );
		szName = new TCHAR[ iNameLen + 1 ];
		ToTchar( szName, plugin->description, iNameLen );
		szName[ iNameLen ] = TEXT( '\0' );
	}


	TCHAR szBuffer[ 5000 ];
	_stprintf( szBuffer, TEXT( "Loading <%s>, %s" ), GetFilename(), szName );
	Console::Append( szBuffer );
	Console::Append( TEXT( " " ) );


	// Note:  Plugins that use a wndproc hook need
	//        to be unloaded in the inverse loading order.
	//        This is due to the nature of wndproc hooking.
	if( iHookerIndex != -1 )
	{
		Console::Append( TEXT( "Wndproc hook added (by plugin)" ) );
	}

	return true;
}
예제 #3
0
bool OutputPlugin::Load()
{
	if( IsLoaded() ) return true;

	// (1) Load DLL
	hDLL = LoadLibrary( GetFullpath() );
	if( !hDLL ) return false;

	// (2) Find export
	WINAMP_OUTPUT_GETTER winampGetOutModule =
		( WINAMP_OUTPUT_GETTER )GetProcAddress(	hDLL, "winampGetOutModule" );
	if( winampGetOutModule == NULL )
	{
		FreeLibrary( hDLL );
		hDLL = NULL;
		return false;
	}

	// (3) Get module
	plugin = winampGetOutModule();
	if( !plugin )
	{
		FreeLibrary( hDLL );
		hDLL = NULL;
		return false;
	}

	// (4) Process module
	plugin->hDllInstance  = hDLL;
	plugin->hMainWindow   = WindowMain;

	if( !szName )
	{
		// Note:  The prefix is not removed to hide their
		//        origin at Nullsoft! It just reads easier.
		if( !strnicmp( plugin->description, "nullsoft ", 9 ) )
		{
			plugin->description += 9;
		}
		iNameLen = ( int )strlen( plugin->description );
		szName = new TCHAR[ iNameLen + 1 ];
		ToTchar( szName, plugin->description, iNameLen );
		szName[ iNameLen ] = TEXT( '\0' );
	}


	TCHAR szBuffer[ 5000 ];
	_stprintf( szBuffer, TEXT( "Loading <%s>, %s" ), GetFilename(), szName );
	Console::Append( szBuffer );
	Console::Append( TEXT( " " ) );
	
	if( plugin->Init )
	{
		// Init
		const WNDPROC WndprocBefore = ( WNDPROC )GetWindowLong( WindowMain, GWL_WNDPROC );
			plugin->Init();
		const WNDPROC WndprocAfter = ( WNDPROC )GetWindowLong( WindowMain, GWL_WNDPROC );
		
		if( WndprocBefore != WndprocAfter )
		{
			WndprocBackup  = WndprocBefore;
			iHookerIndex   = iWndprocHookCounter++;
		}


		// Note:  Plugins that use a wndproc hook need
		//        to be unloaded in the inverse loading order.
		//        This is due to the nature of wndproc hooking.
		if( iHookerIndex != -1 )
		{
			Console::Append( TEXT( "Wndproc hook added (by plugin)" ) );
		}
	}

	return true;
}