diff --git a/Makefile.am b/Makefile.am
index e85fd4a..5715ded 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -681,6 +681,7 @@ VLC.app: vlc $(top_builddir)/src/.libs/libvlccore.dylib $(top_builddir)/src/.lib
 ## Win                                                                    ##
 ############################################################################
 win32_destdir=$(top_builddir)/vlc-$(VERSION)
+win32_xpi_destdir=$(win32_destdir)/vlc-plugin
 win32_debugdir=$(top_builddir)/symbols-$(VERSION)
 npvlc=vlc-$(VERSION)/mozilla/npvlc$(LIBEXT)
 axvlc=vlc-$(VERSION)/activex/axvlc$(LIBEXT)
@@ -749,6 +750,28 @@ endif
 		find $(win32_destdir) -type f -name '*.dll' -print | rebase -b 0x70000000 -T -; \
 	fi
 
+package-win32-xpi:
+	mkdir -p "$(win32_xpi_destdir)/plugins"
+	cp $(top_builddir)/projects/mozilla/install.rdf "$(win32_xpi_destdir)"
+	cp $(top_builddir)/projects/mozilla/.libs/npvlc$(LIBEXT) \
+		"$(win32_xpi_destdir)/plugins"
+	cp $(top_srcdir)/projects/mozilla/npvlc.dll.manifest \
+		"$(win32_xpi_destdir)/plugins"
+	cp "$(top_srcdir)/extras/package/win32/libvlc.dll.manifest" \
+		"$(win32_xpi_destdir)/plugins"
+	cp "$(top_builddir)/src/.libs/libvlccore$(LIBEXT)" \
+		"$(win32_xpi_destdir)/plugins"
+	cp "$(top_builddir)/src/.libs/libvlc$(LIBEXT)" \
+		"$(win32_xpi_destdir)/plugins"
+
+	mkdir -p "$(win32_xpi_destdir)/plugins/plugins"
+	find "$(top_builddir)/modules/" -name '*_plugin$(LIBEXT)' | \
+	  while read i; do \
+	    if test -n "$$i" ; then \
+	      $(INSTALL) "$$i" "$(win32_xpi_destdir)/plugins/plugins/" ; \
+	    fi ; done
+	cd $(win32_xpi_destdir) && zip -r vlc-$(VERSION).xpi install.rdf plugins
+
 package-win32-base-debug: package-win-common
 # Copy relevant files
 # Script installer
@@ -1162,6 +1185,16 @@ if BUILD_MOZILLA
 	rm -rf "$(top_builddir)/vlc-plugin-$(VERSION)"
 endif
 
+package-macosx-xpi:
+if BUILD_MOZILLA
+	mkdir -p "$(top_builddir)/macosx-xpi/plugins"
+	cp $(top_builddir)/projects/mozilla/install.rdf \
+		"$(top_builddir)/macosx-xpi/"
+	cp -R "$(top_builddir)/projects/mozilla/VLC Plugin.plugin" \
+		"$(top_builddir)/macosx-xpi/plugins"
+	cd "$(top_builddir)/macosx-xpi" && zip -r vlc-$(VERSION).xpi install.rdf plugins
+endif
+
 package-translations:
 	@if test -e "$(srcdir)/vlc-translations-$(VERSION)"; then \
 	  echo "Error: please remove $(srcdir)/vlc-translations-$(VERSION), it is in the way"; \
diff --git a/configure.ac b/configure.ac
index 23f55d2..55c670b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5113,6 +5113,7 @@ AC_CONFIG_FILES([
   projects/mozilla/npvlc_rc.rc
   projects/mozilla/vlc.r
   projects/mozilla/install.js
+  projects/mozilla/install.rdf
   share/Makefile
   share/vlc_win32_rc.rc
   share/libvlc_win32_rc.rc
diff --git a/projects/mozilla/install.rdf.in b/projects/mozilla/install.rdf.in
new file mode 100644
index 0000000..4c95bcf
--- /dev/null
+++ b/projects/mozilla/install.rdf.in
@@ -0,0 +1,15 @@
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>vlc-plugin@videolan.org</em:id>
+    <em:name>VideoLAN</em:name>
+    <em:version>@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_REVISION@@VERSION_EXTRA@</em:version>
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+        <em:minVersion>1.5</em:minVersion>
+        <em:maxVersion>3.5.*</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+  </Description>
+</RDF>
+
diff --git a/projects/mozilla/vlcplugin.cpp b/projects/mozilla/vlcplugin.cpp
index bc3fd3b..1e1a754 100644
--- a/projects/mozilla/vlcplugin.cpp
+++ b/projects/mozilla/vlcplugin.cpp
@@ -37,6 +37,11 @@
 
 #include <ctype.h>
 
+#ifdef XP_MACOSX
+# include <dlfcn.h>
+# include <libgen.h>
+#endif
+
 /*****************************************************************************
  * VlcPlugin constructor and destructor
  *****************************************************************************/
@@ -80,6 +85,11 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
 #endif
 }
 
+/*
+ * this function symbol is also used by dladdr and VirtualQuery to discover
+ * the plugin path
+ */
+
 static bool boolValue(const char *value) {
     return ( !strcmp(value, "1") ||
              !strcasecmp(value, "true") ||
@@ -98,27 +108,64 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
 
     /* locate VLC module path */
 #ifdef XP_MACOSX
+    Dl_info info;
+    char plugin_path[PATH_MAX + 1] = {0};
+    if( dladdr((void *)&boolValue, &info) ) {
+        char *path = dirname( (char*)info.dli_fname );
+        strlcpy( plugin_path, "--plugin-path=", sizeof(plugin_path) );
+        strlcat( plugin_path, path, sizeof(plugin_path) );
+        strlcat( plugin_path, "/modules", sizeof(plugin_path) );
+        ppsz_argv[ppsz_argc++] = plugin_path;
+        fprintf(stderr, "String %s\n", plugin_path);
+    } else
     ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
     ppsz_argv[ppsz_argc++] = "--vout=minimal_macosx";
 #elif defined(XP_WIN)
     HKEY h_key;
     DWORD i_type, i_data = MAX_PATH + 1;
-    char p_data[MAX_PATH + 1];
+    MEMORY_BASIC_INFORMATION mbi;
+    char path_buffer[_MAX_PATH];
+    char drive[_MAX_DRIVE];
+    char dir[_MAX_DIR];
+    char fname[_MAX_FNAME];
+    char ext[_MAX_EXT];
+    char p_data[MAX_PATH + 1] = {0};
+    fprintf(stderr, "Pointer %p\n",(const void *)&boolValue);
+    if( VirtualQuery( (const void *)&boolValue, &mbi, sizeof(mbi) ) )
+    {
+        HMODULE hMod = (HMODULE) mbi.AllocationBase;
+        fprintf(stderr, "Module %p\n",(const void *)hMod);
+
+        char moduleName[MAX_PATH];
+        if( GetModuleFileName( hMod, moduleName, sizeof(moduleName) ) )
+        {
+            fprintf(stderr, "Module Name %s\n", moduleName);
+            _splitpath( moduleName, drive, dir, fname, ext );
+            _makepath( path_buffer, drive, dir, NULL, NULL );
+            strncpy( p_data, path_buffer, MAX_PATH );
+            strncpy( p_data + strlen(path_buffer), "\\plugins",
+                     MAX_PATH - strlen(path_buffer));
+            fprintf(stderr, "Module Path %s\n", p_data);
+        }
+    } else
+
     if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
                       0, KEY_READ, &h_key ) == ERROR_SUCCESS )
     {
          if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
                               (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
-         {
              if( i_type == REG_SZ )
+                 strncpy( p_data + strlen(p_data), "\\plugins",
+                          MAX_PATH - strlen(p_data) );
+         RegCloseKey( h_key );
+    }
+
+    if( p_data[0] )
              {
-                 strcat( p_data, "\\plugins" );
                  ppsz_argv[ppsz_argc++] = "--plugin-path";
                  ppsz_argv[ppsz_argc++] = p_data;
              }
-         }
-         RegCloseKey( h_key );
-    }
+
     ppsz_argv[ppsz_argc++] = "--no-one-instance";
 
 #endif /* XP_MACOSX */
