Bug 603679 - Shockwave fails to load (10-9 nightly and newer); r=bsmedberg a=blocking-beta8+
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 14 Oct 2010 19:53:42 -0400
changeset 55874 fd54372f6b832a21d98db5346384f31d288c1efa
parent 55873 2ad78af5ae6b091cf7cb8d322f6df1cb384fbed7
child 55875 21c846fa8e89dbd4f889842ae9a0c4badb465086
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg, blocking-beta8
bugs603679
milestone2.0b8pre
Bug 603679 - Shockwave fails to load (10-9 nightly and newer); r=bsmedberg a=blocking-beta8+
modules/plugin/base/src/nsPluginsDirWin.cpp
--- a/modules/plugin/base/src/nsPluginsDirWin.cpp
+++ b/modules/plugin/base/src/nsPluginsDirWin.cpp
@@ -261,16 +261,25 @@ nsPluginFile::~nsPluginFile()
  */
 nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary)
 {
   nsCOMPtr<nsILocalFile> plugin = do_QueryInterface(mPlugin);
 
   if (!plugin)
     return NS_ERROR_NULL_POINTER;
 
+  typedef BOOL
+  (WINAPI *pfnSetDllDirectory) (LPCWSTR);
+  pfnSetDllDirectory setDllDirectory =
+    reinterpret_cast<pfnSetDllDirectory>
+    (GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDllDirectoryW"));
+  if (setDllDirectory) {
+    setDllDirectory(NULL);
+  }
+
 #ifndef WINCE
   nsAutoString pluginFolderPath;
   plugin->GetPath(pluginFolderPath);
 
   PRInt32 idx = pluginFolderPath.RFindChar('\\');
   if (kNotFound == idx)
     return NS_ERROR_FILE_INVALID_PATH;
 
@@ -282,40 +291,31 @@ nsresult nsPluginFile::LoadPlugin(PRLibr
   NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin");
 
   if (dwCheck <= MAX_PATH + 1) {
     restoreOrigDir = SetCurrentDirectoryW(pluginFolderPath.get());
     NS_ASSERTION(restoreOrigDir, "Error in Loading plugin");
   }
 #endif
 
-  typedef BOOL
-  (WINAPI *pfnSetDllDirectory) (LPCWSTR);
-  pfnSetDllDirectory setDllDirectory =
-    reinterpret_cast<pfnSetDllDirectory>
-    (GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "SetDllDirectoryW"));
-  if (setDllDirectory) {
-    setDllDirectory(NULL);
-  }
-
   nsresult rv = plugin->Load(outLibrary);
   if (NS_FAILED(rv))
       *outLibrary = NULL;
 
-  if (setDllDirectory) {
-    setDllDirectory(L"");
-  }
-
 #ifndef WINCE    
   if (restoreOrigDir) {
     BOOL bCheck = SetCurrentDirectoryW(aOrigDir);
     NS_ASSERTION(bCheck, "Error in Loading plugin");
   }
 #endif
 
+  if (setDllDirectory) {
+    setDllDirectory(L"");
+  }
+
   return rv;
 }
 
 /**
  * Obtains all of the information currently available for this plugin.
  */
 nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
 {