From 4e60c971ec906a95a4c10347a98d34c5b698fc4e Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Wed, 27 Oct 2004 08:10:40 +0000 Subject: [PATCH] Applying fix for smoketest blocker, bug 266214 "Browser will not start after install (xpcom_core.dll not found)" git-svn-id: svn://10.0.0.236/trunk@164499 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp b/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp index 44a139ec3c0..7af2ed2f69c 100644 --- a/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp +++ b/mozilla/xpcom/glue/standalone/nsXPCOMGlue.cpp @@ -49,6 +49,7 @@ #if XP_WIN32 #include +#include #endif void GRE_AddGREToEnvironment(); @@ -109,8 +110,28 @@ nsresult XPCOMGlueStartup(const char* xpcomFile) libSpec.type = PR_LibSpec_Pathname; if (!xpcomFile) libSpec.value.pathname = XPCOM_DLL; - else + else { libSpec.value.pathname = xpcomFile; +#ifdef XP_WIN32 + // Add directory containing xpcomFile to the DLL search path. This + // is done so that the OS knows where to find xpcom_core.dll and + // any other dependent libs. + const char *lastSlash = + (const char *) _mbsrchr((const unsigned char *) xpcomFile, '\\'); + if (lastSlash) { + char path[32767]; + DWORD pathLen = GetEnvironmentVariable("PATH", path, sizeof(path)); + if (pathLen != 0) + path[pathLen++] = ';'; + DWORD dirLen = lastSlash - xpcomFile; + if (sizeof(path) - pathLen > dirLen) { + memcpy(&path[pathLen], xpcomFile, dirLen); + path[pathLen + dirLen] = '\0'; + SetEnvironmentVariable("PATH", path); + } + } +#endif + } xpcomLib = PR_LoadLibraryWithFlags(libSpec, PR_LD_LAZY|PR_LD_GLOBAL); if (!xpcomLib)