mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1334665: Eliminate runtime dynamic linking for pre-win7 functions in ipc/mscom; r=jimm
MozReview-Commit-ID: 7ySl728hdka --HG-- extra : rebase_source : fd5914c70fb89176a71ffbc636c0f39662cf9d38
This commit is contained in:
parent
f254b7dc1a
commit
08f3a463ec
@ -4,7 +4,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DynamicallyLinkedFunctionPtr.h"
|
||||
#include "mozilla/mscom/EnsureMTA.h"
|
||||
#include "mozilla/mscom/ProxyStream.h"
|
||||
#include "mozilla/mscom/Utils.h"
|
||||
@ -74,13 +73,7 @@ ProxyStream::ProxyStream(const BYTE* aInitBuf, const int aInitBufSize)
|
||||
already_AddRefed<IStream>
|
||||
ProxyStream::InitStream(const BYTE* aInitBuf, const UINT aInitBufSize)
|
||||
{
|
||||
// Need to link to this as ordinal 12 for Windows XP
|
||||
static DynamicallyLinkedFunctionPtr<decltype(&::SHCreateMemStream)>
|
||||
pSHCreateMemStream(L"shlwapi.dll", reinterpret_cast<const char*>(12));
|
||||
if (!pSHCreateMemStream) {
|
||||
return nullptr;
|
||||
}
|
||||
return already_AddRefed<IStream>(pSHCreateMemStream(aInitBuf, aInitBufSize));
|
||||
return already_AddRefed<IStream>(::SHCreateMemStream(aInitBuf, aInitBufSize));
|
||||
}
|
||||
|
||||
ProxyStream::ProxyStream(ProxyStream&& aOther)
|
||||
|
@ -4,67 +4,21 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// We need Windows 7 headers
|
||||
#ifdef NTDDI_VERSION
|
||||
#undef NTDDI_VERSION
|
||||
#endif
|
||||
#define NTDDI_VERSION 0x06010000
|
||||
#ifdef _WIN32_WINNT
|
||||
#undef _WIN32_WINNT
|
||||
#endif
|
||||
#define _WIN32_WINNT 0x0601
|
||||
|
||||
#include "DynamicallyLinkedFunctionPtr.h"
|
||||
#include "mozilla/mscom/Utils.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
#include <objbase.h>
|
||||
#include <objidl.h>
|
||||
|
||||
static bool
|
||||
IsCurrentThreadMTALegacy()
|
||||
{
|
||||
// We don't use RefPtr for token because CoGetContextToken does *not*
|
||||
// increment its refcount!
|
||||
IUnknown* token = nullptr;
|
||||
HRESULT hr =
|
||||
CoGetContextToken(reinterpret_cast<ULONG_PTR*>(&token));
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<IComThreadingInfo> threadingInfo;
|
||||
hr = token->QueryInterface(IID_IComThreadingInfo,
|
||||
getter_AddRefs(threadingInfo));
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
APTTYPE aptType;
|
||||
hr = threadingInfo->GetCurrentApartmentType(&aptType);
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return aptType == APTTYPE_MTA;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace mscom {
|
||||
|
||||
bool
|
||||
IsCurrentThreadMTA()
|
||||
{
|
||||
static DynamicallyLinkedFunctionPtr<decltype(&::CoGetApartmentType)>
|
||||
pCoGetApartmentType(L"ole32.dll", "CoGetApartmentType");
|
||||
|
||||
if (!pCoGetApartmentType) {
|
||||
// XP and Vista do not expose the newer API.
|
||||
return IsCurrentThreadMTALegacy();
|
||||
}
|
||||
|
||||
APTTYPE aptType;
|
||||
APTTYPEQUALIFIER aptTypeQualifier;
|
||||
HRESULT hr = pCoGetApartmentType(&aptType, &aptTypeQualifier);
|
||||
HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -14,14 +14,11 @@ EXPORTS.mozilla.mscom += [
|
||||
'Utils.h',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'Utils.cpp',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'EnsureMTA.cpp',
|
||||
'MainThreadRuntime.cpp',
|
||||
'ProxyStream.cpp',
|
||||
'Utils.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['ACCESSIBILITY']:
|
||||
|
Loading…
x
Reference in New Issue
Block a user