mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
Bug 455381 - WinCE XPCOM Explicit Unicode API Calls, Wide Char CheckVersion Function r=bsmedberg
This commit is contained in:
parent
91e13e4046
commit
418f5366f7
@ -66,6 +66,11 @@
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include <tchar.h>
|
||||
#include "nsString.h"
|
||||
#endif
|
||||
|
||||
static void
|
||||
Abort(const char *aMsg);
|
||||
|
||||
@ -97,7 +102,7 @@ PRBool InDebugger()
|
||||
#ifndef WINCE
|
||||
PRBool fReturn = PR_FALSE;
|
||||
LPFNISDEBUGGERPRESENT lpfnIsDebuggerPresent = NULL;
|
||||
HINSTANCE hKernel = LoadLibrary("Kernel32.dll");
|
||||
HINSTANCE hKernel = LoadLibraryW(L"Kernel32.dll");
|
||||
|
||||
if(hKernel)
|
||||
{
|
||||
@ -402,9 +407,9 @@ Break(const char *aMsg)
|
||||
* See http://bugzilla.mozilla.org/show_bug.cgi?id=54792
|
||||
*/
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si;
|
||||
char executable[MAX_PATH];
|
||||
char* pName;
|
||||
STARTUPINFOW si;
|
||||
PRUnichar executable[MAX_PATH];
|
||||
PRUnichar* pName;
|
||||
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
|
||||
@ -413,13 +418,15 @@ Break(const char *aMsg)
|
||||
si.wShowWindow = SW_SHOW;
|
||||
|
||||
// 2nd arg of CreateProcess is in/out
|
||||
char *msgCopy = (char*) _alloca(strlen(aMsg) + 1);
|
||||
strcpy(msgCopy, aMsg);
|
||||
PRUnichar *msgCopy = (PRUnichar*) _alloca((strlen(aMsg) + 1)*sizeof(PRUnichar));
|
||||
wcscpy(msgCopy , (PRUnichar*)NS_ConvertUTF8toUTF16(aMsg).get());
|
||||
|
||||
if(GetModuleFileName(GetModuleHandle("xpcom.dll"), executable, MAX_PATH) &&
|
||||
NULL != (pName = strrchr(executable, '\\')) &&
|
||||
NULL != strcpy(pName+1, "windbgdlg.exe") &&
|
||||
CreateProcess(executable, msgCopy, NULL, NULL, PR_FALSE,
|
||||
if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), (LPWCH)executable, MAX_PATH) &&
|
||||
NULL != (pName = wcsrchr(executable, '\\')) &&
|
||||
NULL !=
|
||||
wcscpy((WCHAR*)
|
||||
pName+1, L"windbgdlg.exe") &&
|
||||
CreateProcessW((LPCWSTR)executable, (LPWSTR)msgCopy, NULL, NULL, PR_FALSE,
|
||||
DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
|
||||
NULL, NULL, &si, &pi)) {
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
|
@ -328,9 +328,9 @@ EnsureImageHlpInitialized()
|
||||
|
||||
::InitializeCriticalSection(&gDbgHelpCS);
|
||||
|
||||
HMODULE module = ::LoadLibrary("DBGHELP.DLL");
|
||||
HMODULE module = ::LoadLibraryW(L"DBGHELP.DLL");
|
||||
if (!module) {
|
||||
module = ::LoadLibrary("IMAGEHLP.DLL");
|
||||
module = ::LoadLibraryW(L"IMAGEHLP.DLL");
|
||||
if (!module) return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -217,9 +217,11 @@ NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
||||
|
||||
#define XPCOM_SEARCH_KEY "PATH"
|
||||
#define GRE_CONF_NAME "gre.config"
|
||||
#define GRE_WIN_REG_LOC "Software\\mozilla.org\\GRE"
|
||||
#define GRE_WIN_REG_LOC L"Software\\mozilla.org\\GRE"
|
||||
#define XPCOM_DLL "xpcom.dll"
|
||||
#define LXPCOM_DLL L"xpcom.dll"
|
||||
#define XUL_DLL "xul.dll"
|
||||
#define LXUL_DLL L"xul.dll"
|
||||
|
||||
#elif defined(XP_BEOS)
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef XP_WIN32
|
||||
# include <windows.h>
|
||||
@ -101,11 +102,18 @@ static PRBool safe_strncat(char *dest, const char *append, PRUint32 count)
|
||||
return *append == '\0';
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
static PRBool
|
||||
CheckVersion(const PRUnichar* toCheck,
|
||||
const GREVersionRange *versions,
|
||||
PRUint32 versionsLength);
|
||||
#endif
|
||||
static PRBool
|
||||
CheckVersion(const char* toCheck,
|
||||
const GREVersionRange *versions,
|
||||
PRUint32 versionsLength);
|
||||
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
|
||||
static PRBool
|
||||
@ -142,7 +150,7 @@ GRE_GetPathFromRegKey(HKEY aRegKey,
|
||||
PRUint32 versionsLength,
|
||||
const GREProperty *properties,
|
||||
PRUint32 propertiesLength,
|
||||
char* buffer, PRUint32 buflen);
|
||||
PRUnichar* buffer, PRUint32 buflen);
|
||||
|
||||
#endif
|
||||
|
||||
@ -421,28 +429,28 @@ GRE_GetGREPathWithProperties(const GREVersionRange *versions,
|
||||
// Please see http://www.mozilla.org/projects/embedding/GRE.html for
|
||||
// more info.
|
||||
//
|
||||
if (::RegOpenKeyEx(HKEY_CURRENT_USER, GRE_WIN_REG_LOC, 0,
|
||||
KEY_READ, &hRegKey) == ERROR_SUCCESS) {
|
||||
PRBool ok = GRE_GetPathFromRegKey(hRegKey,
|
||||
versions, versionsLength,
|
||||
allProperties, allPropertiesLength,
|
||||
aBuffer, aBufLen);
|
||||
::RegCloseKey(hRegKey);
|
||||
if (::RegOpenKeyExW(HKEY_CURRENT_USER, GRE_WIN_REG_LOC, 0,
|
||||
KEY_READ, &hRegKey) == ERROR_SUCCESS) {
|
||||
PRBool ok = GRE_GetPathFromRegKey(hRegKey,
|
||||
versions, versionsLength,
|
||||
allProperties, allPropertiesLength,
|
||||
(WCHAR*) NS_ConvertUTF8toUTF16(aBuffer).get(), aBufLen);
|
||||
::RegCloseKey(hRegKey);
|
||||
|
||||
if (ok)
|
||||
return NS_OK;
|
||||
if (ok)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, GRE_WIN_REG_LOC, 0,
|
||||
KEY_ENUMERATE_SUB_KEYS, &hRegKey) == ERROR_SUCCESS) {
|
||||
PRBool ok = GRE_GetPathFromRegKey(hRegKey,
|
||||
versions, versionsLength,
|
||||
allProperties, allPropertiesLength,
|
||||
aBuffer, aBufLen);
|
||||
::RegCloseKey(hRegKey);
|
||||
if (::RegOpenKeyExW(HKEY_LOCAL_MACHINE, GRE_WIN_REG_LOC, 0,
|
||||
KEY_ENUMERATE_SUB_KEYS, &hRegKey) == ERROR_SUCCESS) {
|
||||
PRBool ok = GRE_GetPathFromRegKey(hRegKey,
|
||||
versions, versionsLength,
|
||||
allProperties, allPropertiesLength,
|
||||
(WCHAR*) NS_ConvertUTF8toUTF16(aBuffer).get(), aBufLen);
|
||||
::RegCloseKey(hRegKey);
|
||||
|
||||
if (ok)
|
||||
return NS_OK;
|
||||
if (ok)
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -478,6 +486,38 @@ CheckVersion(const char* toCheck,
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
static PRBool
|
||||
CheckVersion(const PRUnichar* toCheck,
|
||||
const GREVersionRange *versions,
|
||||
PRUint32 versionsLength)
|
||||
{
|
||||
|
||||
for (const GREVersionRange *versionsEnd = versions + versionsLength;
|
||||
versions < versionsEnd;
|
||||
++versions) {
|
||||
PRInt32 c = NS_CompareVersions(toCheck, NS_ConvertUTF8toUTF16(versions->lower).get());
|
||||
if (c < 0)
|
||||
continue;
|
||||
|
||||
if (!c && !versions->lowerInclusive)
|
||||
continue;
|
||||
|
||||
c = NS_CompareVersions(toCheck, NS_ConvertUTF8toUTF16(versions->upper).get());
|
||||
if (c > 0)
|
||||
continue;
|
||||
|
||||
if (!c && !versions->upperInclusive)
|
||||
continue;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
PRBool
|
||||
GRE_FindGREFramework(const char* rootPath,
|
||||
@ -641,19 +681,19 @@ GRE_GetPathFromConfigFile(const char* filename,
|
||||
#elif defined(XP_WIN)
|
||||
|
||||
static PRBool
|
||||
CopyWithEnvExpansion(char* aDest, const char* aSource, PRUint32 aBufLen,
|
||||
CopyWithEnvExpansion(PRUnichar* aDest, const PRUnichar* aSource, PRUint32 aBufLen,
|
||||
DWORD aType)
|
||||
{
|
||||
switch (aType) {
|
||||
case REG_SZ:
|
||||
if (strlen(aSource) >= aBufLen)
|
||||
if (wcslen(aSource) >= aBufLen)
|
||||
return PR_FALSE;
|
||||
|
||||
strcpy(aDest, aSource);
|
||||
wcscpy(aDest, aSource);
|
||||
return PR_TRUE;
|
||||
|
||||
case REG_EXPAND_SZ:
|
||||
if (ExpandEnvironmentStrings(aSource, aDest, aBufLen) > aBufLen)
|
||||
if (ExpandEnvironmentStringsW(aSource, aDest, aBufLen) > aBufLen)
|
||||
return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
@ -670,7 +710,7 @@ GRE_GetPathFromRegKey(HKEY aRegKey,
|
||||
PRUint32 versionsLength,
|
||||
const GREProperty *properties,
|
||||
PRUint32 propertiesLength,
|
||||
char* aBuffer, PRUint32 aBufLen)
|
||||
PRUnichar* aBuffer, PRUint32 aBufLen)
|
||||
{
|
||||
// Formerly, GREs were registered at the registry key
|
||||
// HKLM/Software/mozilla.org/GRE/<version> valuepair GreHome=Path.
|
||||
@ -694,30 +734,30 @@ GRE_GetPathFromRegKey(HKEY aRegKey,
|
||||
DWORD i = 0;
|
||||
|
||||
while (PR_TRUE) {
|
||||
char name[MAXPATHLEN + 1];
|
||||
PRUnichar name[MAXPATHLEN + 1];
|
||||
DWORD nameLen = MAXPATHLEN;
|
||||
if (::RegEnumKeyEx(aRegKey, i, name, &nameLen, NULL, NULL, NULL, NULL) !=
|
||||
ERROR_SUCCESS) {
|
||||
break;
|
||||
if (::RegEnumKeyExW(aRegKey, i, name, &nameLen, NULL, NULL, NULL, NULL) !=
|
||||
ERROR_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
HKEY subKey = NULL;
|
||||
if (::RegOpenKeyEx(aRegKey, name, 0, KEY_QUERY_VALUE, &subKey) !=
|
||||
ERROR_SUCCESS) {
|
||||
continue;
|
||||
if (::RegOpenKeyExW(aRegKey, name, 0, KEY_QUERY_VALUE, &subKey) !=
|
||||
ERROR_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char version[40];
|
||||
PRUnichar version[40];
|
||||
DWORD versionlen = 40;
|
||||
char pathbuf[MAXPATHLEN];
|
||||
PRUnichar pathbuf[MAXPATHLEN];
|
||||
DWORD pathlen;
|
||||
DWORD pathtype;
|
||||
|
||||
PRBool ok = PR_FALSE;
|
||||
|
||||
if (::RegQueryValueEx(subKey, "Version", NULL, NULL,
|
||||
(BYTE*) version, &versionlen) == ERROR_SUCCESS &&
|
||||
CheckVersion(version, versions, versionsLength)) {
|
||||
if (::RegQueryValueExW(subKey, L"Version", NULL, NULL,
|
||||
(BYTE*) version, &versionlen) == ERROR_SUCCESS &&
|
||||
CheckVersion(version, versions, versionsLength)) {
|
||||
|
||||
ok = PR_TRUE;
|
||||
const GREProperty *props = properties;
|
||||
@ -725,22 +765,23 @@ GRE_GetPathFromRegKey(HKEY aRegKey,
|
||||
for (; ok && props < propsEnd; ++props) {
|
||||
pathlen = sizeof(pathbuf);
|
||||
|
||||
if (::RegQueryValueEx(subKey, props->property, NULL, &pathtype,
|
||||
(BYTE*) pathbuf, &pathlen) != ERROR_SUCCESS ||
|
||||
strcmp(pathbuf, props->value))
|
||||
ok = PR_FALSE;
|
||||
if (::RegQueryValueExW(subKey, NS_ConvertUTF8toUTF16(props->property).get(), NULL, &pathtype,
|
||||
(BYTE*) pathbuf, &pathlen) != ERROR_SUCCESS ||
|
||||
wcscmp(pathbuf, NS_ConvertUTF8toUTF16(props->value).get()))
|
||||
ok = PR_FALSE;
|
||||
}
|
||||
|
||||
pathlen = sizeof(pathbuf);
|
||||
if (ok &&
|
||||
(!::RegQueryValueEx(subKey, "GreHome", NULL, &pathtype,
|
||||
(!::RegQueryValueExW(subKey, L"GreHome", NULL, &pathtype,
|
||||
(BYTE*) pathbuf, &pathlen) == ERROR_SUCCESS ||
|
||||
!*pathbuf ||
|
||||
!CopyWithEnvExpansion(aBuffer, pathbuf, aBufLen, pathtype))) {
|
||||
ok = PR_FALSE;
|
||||
}
|
||||
else if (!safe_strncat(aBuffer, "\\" XPCOM_DLL, aBufLen) ||
|
||||
access(aBuffer, R_OK)) {
|
||||
else if (!wcsncat(aBuffer, L"\\" LXPCOM_DLL, aBufLen) ||
|
||||
_waccess(
|
||||
aBuffer, R_OK)) {
|
||||
ok = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef XP_WIN
|
||||
#include <wchar.h>
|
||||
#include "nsStringGlue.h"
|
||||
#endif
|
||||
|
||||
struct VersionPart {
|
||||
PRInt32 numA;
|
||||
@ -51,6 +55,20 @@ struct VersionPart {
|
||||
char *extraD; // null-terminated
|
||||
};
|
||||
|
||||
#ifdef XP_WIN
|
||||
struct VersionPartW {
|
||||
PRInt32 numA;
|
||||
|
||||
const PRUnichar *strB; // NOT null-terminated, can be a null pointer
|
||||
PRUint32 strBlen;
|
||||
|
||||
PRInt32 numC;
|
||||
|
||||
PRUnichar *extraD; // null-terminated
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Parse a version part into a number and "extra text".
|
||||
*
|
||||
@ -119,6 +137,78 @@ ParseVP(char *part, VersionPart &result)
|
||||
return dot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse a version part into a number and "extra text".
|
||||
*
|
||||
* @returns A pointer to the next versionpart, or null if none.
|
||||
*/
|
||||
#ifdef XP_WIN
|
||||
static PRUnichar*
|
||||
ParseVP(PRUnichar *part, VersionPartW &result)
|
||||
{
|
||||
|
||||
PRUnichar *dot;
|
||||
|
||||
result.numA = 0;
|
||||
result.strB = nsnull;
|
||||
result.strBlen = 0;
|
||||
result.numC = 0;
|
||||
result.extraD = nsnull;
|
||||
|
||||
if (!part)
|
||||
return part;
|
||||
|
||||
dot = wcschr(part, '.');
|
||||
if (dot)
|
||||
*dot = '\0';
|
||||
|
||||
if (part[0] == '*' && part[1] == '\0') {
|
||||
result.numA = PR_INT32_MAX;
|
||||
result.strB = L"";
|
||||
}
|
||||
else {
|
||||
result.numA = wcstol(part, const_cast<PRUnichar**>(&result.strB), 10);
|
||||
}
|
||||
|
||||
if (!*result.strB) {
|
||||
result.strB = nsnull;
|
||||
result.strBlen = 0;
|
||||
}
|
||||
else {
|
||||
if (result.strB[0] == '+') {
|
||||
static const PRUnichar kPre[] = L"pre";
|
||||
|
||||
++result.numA;
|
||||
result.strB = kPre;
|
||||
result.strBlen = sizeof(kPre) - 1;
|
||||
}
|
||||
else {
|
||||
const PRUnichar *numstart = wcspbrk(result.strB, L"0123456789+-");
|
||||
if (!numstart) {
|
||||
result.strBlen = wcslen(result.strB);
|
||||
}
|
||||
else {
|
||||
result.strBlen = numstart - result.strB;
|
||||
|
||||
result.numC = wcstol(numstart, &result.extraD, 10);
|
||||
if (!*result.extraD)
|
||||
result.extraD = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dot) {
|
||||
++dot;
|
||||
|
||||
if (!*dot)
|
||||
dot = nsnull;
|
||||
}
|
||||
|
||||
return dot;
|
||||
}
|
||||
#endif
|
||||
|
||||
// compare two null-terminated strings, which may be null pointers
|
||||
static PRInt32
|
||||
ns_strcmp(const char *str1, const char *str2)
|
||||
@ -189,6 +279,64 @@ CompareVP(VersionPart &v1, VersionPart &v2)
|
||||
return ns_strcmp(v1.extraD, v2.extraD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two VersionParts
|
||||
*/
|
||||
#ifdef XP_WIN
|
||||
static PRInt32
|
||||
CompareVP(VersionPartW &v1, VersionPartW &v2)
|
||||
{
|
||||
PRInt32 r = ns_cmp(v1.numA, v2.numA);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = wcsncmp(v1.strB, v2.strB, PR_MIN(v1.strBlen,v2.strBlen));
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
r = ns_cmp(v1.numC, v2.numC);
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
return wcscmp(v1.extraD, v2.extraD);
|
||||
}
|
||||
|
||||
|
||||
PRInt32
|
||||
NS_CompareVersions(const PRUnichar *A, const PRUnichar *B)
|
||||
{
|
||||
PRUnichar *A2 = wcsdup(A);
|
||||
if (!A2)
|
||||
return 1;
|
||||
|
||||
PRUnichar *B2 = wcsdup(B);
|
||||
if (!B2) {
|
||||
free(A2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRInt32 result;
|
||||
PRUnichar *a = A2, *b = B2;
|
||||
|
||||
do {
|
||||
VersionPartW va, vb;
|
||||
|
||||
a = ParseVP(a, va);
|
||||
b = ParseVP(b, vb);
|
||||
|
||||
result = CompareVP(va, vb);
|
||||
if (result)
|
||||
break;
|
||||
|
||||
} while (a || b);
|
||||
|
||||
free(A2);
|
||||
free(B2);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32
|
||||
NS_CompareVersions(const char *A, const char *B)
|
||||
{
|
||||
|
@ -40,6 +40,14 @@
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
/**
|
||||
* Compare two version strings.
|
||||
*
|
||||
* @see nsIVersionComparator
|
||||
*/
|
||||
PRInt32 NS_COM_GLUE
|
||||
NS_CompareVersions(const PRUnichar *A, const PRUnichar *B);
|
||||
|
||||
/**
|
||||
* Compare two version strings.
|
||||
*
|
||||
|
@ -39,9 +39,11 @@
|
||||
#include "nsGlueLinking.h"
|
||||
#include "nsXPCOMGlue.h"
|
||||
|
||||
#include "nsStringAPI.h"
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
struct DependentLib
|
||||
{
|
||||
@ -68,8 +70,9 @@ AppendDependentLib(HINSTANCE libHandle)
|
||||
static void
|
||||
ReadDependentCB(const char *aDependentLib)
|
||||
{
|
||||
|
||||
HINSTANCE h =
|
||||
LoadLibraryEx(aDependentLib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
LoadLibraryExW(NS_ConvertUTF8toUTF16(aDependentLib).get(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (!h)
|
||||
return;
|
||||
|
||||
@ -93,35 +96,116 @@ ns_strrpbrk(char *string, const char *strCharSet)
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
GetFrozenFunctionsFunc
|
||||
XPCOMGlueLoad(const char *xpcomFile)
|
||||
// like strpbrk but finds the *last* char, not the first
|
||||
static wchar_t*
|
||||
ns_wcspbrk(wchar_t *string, const wchar_t *strCharSet)
|
||||
{
|
||||
if (xpcomFile[0] == '.' && xpcomFile[1] == '\0') {
|
||||
xpcomFile = XPCOM_DLL;
|
||||
}
|
||||
else {
|
||||
char xpcomDir[MAXPATHLEN];
|
||||
|
||||
_fullpath(xpcomDir, xpcomFile, sizeof(xpcomDir));
|
||||
char *lastSlash = ns_strrpbrk(xpcomDir, "/\\");
|
||||
if (lastSlash) {
|
||||
*lastSlash = '\0';
|
||||
|
||||
XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB);
|
||||
|
||||
_snprintf(lastSlash, MAXPATHLEN - strlen(xpcomDir), "\\" XUL_DLL);
|
||||
|
||||
sXULLibrary =
|
||||
LoadLibraryEx(xpcomDir, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
wchar_t *found = NULL;
|
||||
for (; *string; ++string) {
|
||||
for (const wchar_t *search = strCharSet; *search; ++search) {
|
||||
if (*search == *string) {
|
||||
found = string;
|
||||
// Since we're looking for the last char, we save "found"
|
||||
// until we're at the end of the string.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HINSTANCE h =
|
||||
LoadLibraryEx(xpcomFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
return found;
|
||||
}
|
||||
|
||||
if (!h)
|
||||
bool ns_isRelPath(wchar_t* path)
|
||||
{
|
||||
#ifdef WINCE
|
||||
if (path[0] == '\\')
|
||||
return false;
|
||||
#else
|
||||
if (path[1] == ':')
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
GetFrozenFunctionsFunc
|
||||
XPCOMGlueLoad(const char *aXpcomFile)
|
||||
{
|
||||
wchar_t xpcomFile[MAXPATHLEN];
|
||||
MultiByteToWideChar(CP_ACP, 0, aXpcomFile,-1,
|
||||
xpcomFile, MAXPATHLEN);
|
||||
|
||||
|
||||
if (xpcomFile[0] == '.' && xpcomFile[1] == '\0') {
|
||||
wcscpy(xpcomFile, LXPCOM_DLL);
|
||||
}
|
||||
else {
|
||||
wchar_t xpcomDir[MAXPATHLEN];
|
||||
|
||||
if (ns_isRelPath(xpcomFile))
|
||||
{
|
||||
_wfullpath
|
||||
(xpcomDir, xpcomFile, sizeof(xpcomDir));
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(xpcomDir, xpcomFile);
|
||||
}
|
||||
wchar_t *lastSlash = ns_wcspbrk(xpcomDir, L"/\\");
|
||||
if (lastSlash) {
|
||||
*lastSlash = '\0';
|
||||
char xpcomDir_narrow[MAXPATHLEN];
|
||||
WideCharToMultiByte(CP_ACP, 0, xpcomDir,-1,
|
||||
xpcomDir_narrow, MAX_PATH, NULL, NULL);
|
||||
|
||||
XPCOMGlueLoadDependentLibs(xpcomDir_narrow, ReadDependentCB);
|
||||
|
||||
_snwprintf(lastSlash, MAXPATHLEN - wcslen(xpcomDir), L"\\" LXUL_DLL);
|
||||
sXULLibrary =
|
||||
LoadLibraryExW(xpcomDir, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!sXULLibrary)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
wprintf(L"Error loading xul.dll: %s\n", lpMsgBuf);
|
||||
}
|
||||
#endif //DEBUG
|
||||
}
|
||||
}
|
||||
HINSTANCE h =
|
||||
LoadLibraryExW(xpcomFile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
|
||||
|
||||
if (!h)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
wprintf(L"Error loading xpcom.dll: %s\n", lpMsgBuf);
|
||||
#endif
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
AppendDependentLib(h);
|
||||
|
||||
|
@ -66,6 +66,7 @@ nsresult XPCOMGlueStartup(const char* xpcomFile)
|
||||
|
||||
if (!xpcomFile)
|
||||
xpcomFile = XPCOM_DLL;
|
||||
|
||||
|
||||
func = XPCOMGlueLoad(xpcomFile);
|
||||
|
||||
|
@ -127,7 +127,7 @@ NS_COM void StartupSpecialSystemDirectory()
|
||||
#if defined (XP_WIN)
|
||||
// SHGetKnownFolderPath is only available on Windows Vista
|
||||
// so that we need to use GetProcAddress to get the pointer.
|
||||
gShell32DLLInst = LoadLibrary("Shell32.dll");
|
||||
gShell32DLLInst = LoadLibraryW(L"shell32.dll");
|
||||
if(gShell32DLLInst)
|
||||
{
|
||||
gGetKnownFolderPath = (nsGetKnownFolderPath)
|
||||
|
@ -62,7 +62,10 @@
|
||||
|
||||
#include <direct.h>
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef WINCE
|
||||
#include <aclapi.h>
|
||||
#endif
|
||||
|
||||
#include "shellapi.h"
|
||||
#include "shlguid.h"
|
||||
@ -110,8 +113,8 @@ private:
|
||||
* HasMoreElements reads mLetter.
|
||||
* GetNext advances mLetter.
|
||||
*/
|
||||
nsCString mDrives;
|
||||
const char *mLetter;
|
||||
nsString mDrives;
|
||||
const PRUnichar *mLetter;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -2990,7 +2993,7 @@ nsresult nsDriveEnumerator::Init()
|
||||
/* The string is null terminated */
|
||||
if (!EnsureStringLength(mDrives, length+1))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (!GetLogicalDriveStrings(length, mDrives.BeginWriting()))
|
||||
if (!GetLogicalDriveStringsW(length, mDrives.BeginWriting()))
|
||||
return NS_ERROR_FAILURE;
|
||||
mLetter = mDrives.get();
|
||||
return NS_OK;
|
||||
@ -3010,7 +3013,7 @@ NS_IMETHODIMP nsDriveEnumerator::GetNext(nsISupports **aNext)
|
||||
*aNext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ConvertASCIItoUTF16 drive(mLetter);
|
||||
nsString drive(mDrives);
|
||||
mLetter += drive.Length() + 1;
|
||||
nsILocalFile *file;
|
||||
nsresult rv = NS_NewLocalFile(drive, PR_FALSE, &file);
|
||||
|
@ -46,5 +46,7 @@ SIMPLE_PROGRAMS = windbgdlg$(BIN_SUFFIX)
|
||||
|
||||
CPPSRCS = windbgdlg.cpp
|
||||
|
||||
OS_LIBS += $(call EXPAND_LIBNAME, shell32)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
@ -59,15 +60,16 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
DWORD regValue = -1;
|
||||
DWORD regLength = sizeof regValue;
|
||||
HKEY hkeyCU, hkeyLM;
|
||||
RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU);
|
||||
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM);
|
||||
const char * const * argv = __argv;
|
||||
for (int i = __argc - 1; regValue == (DWORD)-1 && i; --i) {
|
||||
RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyCU);
|
||||
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\mozilla.org\\windbgdlg", 0, KEY_READ, &hkeyLM);
|
||||
int argc =0;
|
||||
LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
for (int i = argc - 1; regValue == (DWORD)-1 && i; --i) {
|
||||
bool ok = false;
|
||||
if (hkeyCU)
|
||||
ok = RegQueryValueEx(hkeyCU, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
|
||||
ok = RegQueryValueExW(hkeyCU, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
|
||||
if (!ok && hkeyLM)
|
||||
ok = RegQueryValueEx(hkeyLM, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
|
||||
ok = RegQueryValueExW(hkeyLM, argv[i], 0, ®Type, (LPBYTE)®Value, ®Length) == ERROR_SUCCESS;
|
||||
if (!ok)
|
||||
regValue = -1;
|
||||
}
|
||||
@ -77,15 +79,15 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
RegCloseKey(hkeyLM);
|
||||
if (regValue != (DWORD)-1 && regValue != (DWORD)-2)
|
||||
return regValue;
|
||||
static char msg[4048];
|
||||
static WCHAR msg[4048];
|
||||
|
||||
wsprintf(msg,
|
||||
"%s\n\nClick Abort to exit the Application.\n"
|
||||
"Click Retry to Debug the Application..\n"
|
||||
"Click Ignore to continue running the Application.",
|
||||
wsprintfW(msg,
|
||||
L"%s\n\nClick Abort to exit the Application.\n"
|
||||
L"Click Retry to Debug the Application..\n"
|
||||
L"Click Ignore to continue running the Application.",
|
||||
lpszCmdLine);
|
||||
|
||||
return MessageBox(NULL, msg, "NSGlue_Assertion",
|
||||
return MessageBoxW(NULL, msg, L"NSGlue_Assertion",
|
||||
MB_ICONSTOP | MB_SYSTEMMODAL|
|
||||
MB_ABORTRETRYIGNORE | MB_DEFBUTTON3);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user