From e647dbc5472d59be0321c944fbcaddfe1645c154 Mon Sep 17 00:00:00 2001 From: Brian Crowder Date: Wed, 27 Aug 2008 14:44:54 -0700 Subject: [PATCH] Bug 422772 - reduce narrow Windows API calls in embedding, original patch by Brad Lassey , r=bsmedberg --- .../activex/src/plugin/LegacyPlugin.cpp | 3 +- .../activex/src/plugin/XPCDocument.cpp | 2 +- .../browser/activex/src/plugin/XPConnect.cpp | 2 +- extensions/auth/nsAuthSSPI.cpp | 40 +++++++++---------- 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp index 8ab3fe738dc5..f0044c2217c4 100644 --- a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp +++ b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp @@ -303,8 +303,7 @@ ShowError(MozAxPluginErrors errorCode, const CLSID &clsid) LPOLESTR szClsid; StringFromCLSID(clsid, &szClsid); _sntprintf(szBuffer, kBufSize - 1, - _T("Could not create the control %s. Check that it has been installed on your computer " - "and that this page correctly references it."), OLE2T(szClsid)); + _T("Could not create the control %s. Check that it has been installed on your computer and that this page correctly references it."), OLE2T(szClsid)); CoTaskMemFree(szClsid); szMsg = szBuffer; } diff --git a/embedding/browser/activex/src/plugin/XPCDocument.cpp b/embedding/browser/activex/src/plugin/XPCDocument.cpp index 1c6a9235ae02..60f9c86a6b61 100644 --- a/embedding/browser/activex/src/plugin/XPCDocument.cpp +++ b/embedding/browser/activex/src/plugin/XPCDocument.cpp @@ -1915,7 +1915,7 @@ END_COM_MAP() NS_SUCCEEDED(baseURI->GetSpec(spec))) { USES_CONVERSION; - if (FAILED(CreateURLMoniker(NULL, T2CW(spec.get()), &baseURLMoniker))) + if (FAILED(CreateURLMoniker(NULL, A2CW(spec.get()), &baseURLMoniker))) return E_UNEXPECTED; } } diff --git a/embedding/browser/activex/src/plugin/XPConnect.cpp b/embedding/browser/activex/src/plugin/XPConnect.cpp index c5dc232d4672..0620194ed363 100644 --- a/embedding/browser/activex/src/plugin/XPConnect.cpp +++ b/embedding/browser/activex/src/plugin/XPConnect.cpp @@ -372,7 +372,7 @@ nsScriptablePeer::ConvertVariants(VARIANT *aIn, nsIVariant **aOut) { // do_CreateInstance macro is broken so load the component manager by // hand and get it to create the component. - HMODULE hlib = ::LoadLibrary("xpcom.dll"); + HMODULE hlib = ::LoadLibraryW(L"xpcom.dll"); if (hlib) { nsIComponentManager *pManager = nsnull; // A frozen interface, even in 1.0.x diff --git a/extensions/auth/nsAuthSSPI.cpp b/extensions/auth/nsAuthSSPI.cpp index ca70729e7c5d..fd3884a95896 100644 --- a/extensions/auth/nsAuthSSPI.cpp +++ b/extensions/auth/nsAuthSSPI.cpp @@ -52,6 +52,8 @@ #include "nsNetCID.h" #include "nsCOMPtr.h" +#include + #define SEC_SUCCESS(Status) ((Status) >= 0) #ifndef KERB_WRAP_NO_ENCRYPT @@ -103,34 +105,34 @@ static const char *MapErrorCode(int rc) //----------------------------------------------------------------------------- static HINSTANCE sspi_lib; -static PSecurityFunctionTable sspi; +static PSecurityFunctionTableW sspi; static nsresult InitSSPI() { - PSecurityFunctionTable (*initFun)(void); + PSecurityFunctionTableW (*initFun)(void); LOG((" InitSSPI\n")); - sspi_lib = LoadLibrary("secur32.dll"); + sspi_lib = LoadLibraryW(L"secur32.dll"); if (!sspi_lib) { - sspi_lib = LoadLibrary("security.dll"); + sspi_lib = LoadLibraryW(L"security.dll"); if (!sspi_lib) { LOG(("SSPI library not found")); return NS_ERROR_UNEXPECTED; } } - initFun = (PSecurityFunctionTable (*)(void)) - GetProcAddress(sspi_lib, "InitSecurityInterfaceA"); + initFun = (PSecurityFunctionTableW (*)(void)) + GetProcAddress(sspi_lib, "InitSecurityInterfaceW"); if (!initFun) { - LOG(("InitSecurityInterfaceA not found")); + LOG(("InitSecurityInterfaceW not found")); return NS_ERROR_UNEXPECTED; } sspi = initFun(); if (!sspi) { - LOG(("InitSecurityInterfaceA failed")); + LOG(("InitSecurityInterfaceW failed")); return NS_ERROR_UNEXPECTED; } @@ -242,11 +244,9 @@ nsAuthSSPI::Init(const char *serviceName, if (NS_FAILED(rv)) return rv; } + SEC_WCHAR *package; - SEC_CHAR *package; - - package = (SEC_CHAR *) pTypeName[(int)mPackage]; - + package = (SEC_WCHAR *) pTypeName[(int)mPackage]; if (mPackage != PACKAGE_TYPE_NTLM) { rv = MakeSN(serviceName, mServiceName); @@ -257,8 +257,8 @@ nsAuthSSPI::Init(const char *serviceName, SECURITY_STATUS rc; - PSecPkgInfo pinfo; - rc = (sspi->QuerySecurityPackageInfo)(package, &pinfo); + PSecPkgInfoW pinfo; + rc = (sspi->QuerySecurityPackageInfoW)(package, &pinfo); if (rc != SEC_E_OK) { LOG(("%s package not found\n", package)); return NS_ERROR_UNEXPECTED; @@ -268,7 +268,7 @@ nsAuthSSPI::Init(const char *serviceName, TimeStamp useBefore; - rc = (sspi->AcquireCredentialsHandle)(NULL, + rc = (sspi->AcquireCredentialsHandleW)(NULL, package, SECPKG_CRED_OUTBOUND, NULL, @@ -336,15 +336,13 @@ nsAuthSSPI::GetNextToken(const void *inToken, if (!ob.pvBuffer) return NS_ERROR_OUT_OF_MEMORY; memset(ob.pvBuffer, 0, ob.cbBuffer); - - SEC_CHAR *sn; - + SEC_WCHAR *sn; if (mPackage == PACKAGE_TYPE_NTLM) sn = NULL; else - sn = (SEC_CHAR *) mServiceName.get(); + sn = (SEC_WCHAR *) mServiceName.get(); - rc = (sspi->InitializeSecurityContext)(&mCred, + rc = (sspi->InitializeSecurityContextW)(&mCred, ctxIn, sn, ctxReq, @@ -461,7 +459,7 @@ nsAuthSSPI::Wrap(const void *inToken, secBuffers bufs; SecPkgContext_Sizes sizes; - rc = (sspi->QueryContextAttributes)( + rc = (sspi->QueryContextAttributesW)( &mCtxt, SECPKG_ATTR_SIZES, &sizes);