diff --git a/projects/mozilla/vlcplugin.cpp b/projects/mozilla/vlcplugin.cpp
index bc3fd3b..c391f8b 100644
--- a/projects/mozilla/vlcplugin.cpp
+++ b/projects/mozilla/vlcplugin.cpp
@@ -80,6 +80,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 +103,64 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
 
     /* locate VLC module path */
 #ifdef XP_MACOSX
-    ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules";
+    Dl_info info;
+    char plugin_path[MAX_PATH + 1] = {0};
+    ppsz_argv[ppsz_argc++] = "--plugin-path";
+    if( dladdr((void *)&boolValue, &info) ) {
+        char *path = dirname( info.dli_fname );
+        strncpy( plugin_path, path, MAX_PATH );
+        strncpy( plugin_path + strlen(path), "/modules",
+                 MAX_PATH - strlen(path) );
+        ppsz_argv[ppsz_argc++] = plugin_path;
+    } else
+        ppsz_argv[ppsz_argc++] = "/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 )
-             {
-                 strcat( p_data, "\\plugins" );
-                 ppsz_argv[ppsz_argc++] = "--plugin-path";
-                 ppsz_argv[ppsz_argc++] = p_data;
-             }
-         }
+                 strncpy( p_data + strlen(p_data), "\\plugins",
+                          MAX_PATH - strlen(p_data) );
          RegCloseKey( h_key );
     }
+
+    if( p_data[0] )
+    {
+        ppsz_argv[ppsz_argc++] = "--plugin-path";
+        ppsz_argv[ppsz_argc++] = p_data;
+    }
+
     ppsz_argv[ppsz_argc++] = "--no-one-instance";
 
 #endif /* XP_MACOSX */
