bug 459629 - Avoid code path with LoadLibraryEx called with LOAD_WITH_ALTERED_SEARCH_PATH in nsGlueLinkingWin for windows ce

This commit is contained in:
Brad Lassey 2009-01-22 22:55:01 -05:00
Родитель 07779f2b8e
Коммит f414bb8854
2 изменённых файлов: 38 добавлений и 5 удалений

Просмотреть файл

@ -349,7 +349,9 @@ MOZCE_SHUNT_API unsigned short *_wfullpath( unsigned short *absPath, const unsig
}
if(len+wcslen(relPath) < maxLength){
#if (_WIN32_WCE > 300)
if ( 0 < CeGetCanonicalPathName(wcscat(cwd,relPath), absPath, maxLength, 0) )
if ( 0 < CeGetCanonicalPathName(relPath[0] == L'\\'? relPath :
wcscat(cwd,relPath),
absPath, maxLength, 0))
return absPath;
#else
#error Need CeGetCanonicalPathName to build.

Просмотреть файл

@ -261,9 +261,10 @@ main(int argc, char **argv)
iniPath);
#ifdef WINCE
DWORD fileAttrs = GetFileAttributesW(NS_ConvertUTF8toUTF16(greDir).get());
greFound = fileAttrs != INVALID_FILE_ATTRIBUTES &&
fileAttrs | FILE_ATTRIBUTE_DIRECTORY;
wchar_t wideGreDir[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, greDir, -1, wideGreDir, MAX_PATH);
DWORD fileAttrs = GetFileAttributesW(wideGreDir);
greFound = fileAttrs != INVALID_FILE_ATTRIBUTES;
#else
greFound = (access(greDir, R_OK) == 0);
#endif
@ -330,6 +331,7 @@ main(int argc, char **argv)
DosSetExtLIBPATH(tmpPath, BEGIN_LIBPATH);
#endif
#ifndef WINCE
rv = XPCOMGlueStartup(greDir);
if (NS_FAILED(rv)) {
Output(PR_TRUE, "Couldn't load XPCOM.\n");
@ -386,6 +388,35 @@ main(int argc, char **argv)
NS_LogTerm();
XPCOMGlueShutdown();
#else
// LoadLibraryExW doesn't take the LOAD_WITH_ALTERED_SEARCH_PATH flag, caling
// xulrunner.exe from the gre dir sets the library search path correctly.
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(si));
si.cb = sizeof(si);
wchar_t xrPath[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, greDir, -1, xrPath, MAX_PATH);
wchar_t* wLastSlash = wcsrchr(xrPath, PATH_SEPARATOR_CHAR);
if (wLastSlash) {
*wLastSlash = L'\0';
}
wcscat(xrPath, L"\\xulrunner.exe");
wchar_t wideIniPath[MAX_PATH+2];
swprintf(wideIniPath, L"\"%S\"", iniPath);
CreateProcessW(xrPath, wideIniPath, NULL, NULL, FALSE, 0, NULL, NULL,
&si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD retval = 0;
if (!GetExitCodeProcess(pi.hProcess, &retval))
printf("failed to get exit code, error = %d\n", retval = GetLastError());
// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
#endif
return retval;
}