Backed out 3 changesets (bug 1366256) for failing in toolkit/components/url-classifier/tests/browser/browser_flashblock_off_with_always_activate.js | Plugin should have the correct 'plugin running' state on a CLOSED TREE

Backed out changeset fb9e8967c454 (bug 1366256)
Backed out changeset 5bee2ab0b174 (bug 1366256)
Backed out changeset c08e6bfa67d0 (bug 1366256)
This commit is contained in:
shindli 2018-03-20 15:20:29 +02:00
parent ec64c538e5
commit a569e1df9e
7 changed files with 389 additions and 521 deletions

View File

@ -1036,9 +1036,8 @@ pref("dom.ipc.shims.enabledWarnings", false);
// everything, but will probably cause some functionality restrictions
pref("dom.ipc.plugins.sandbox-level.default", 0);
#if defined(_AMD64_)
// The base sandbox level in nsPluginTag::InitSandboxLevel must be
// updated to keep in sync with this value.
pref("dom.ipc.plugins.sandbox-level.flash", 3);
// The lines in PluginModuleParent.cpp should be changed in line with this.
pref("dom.ipc.plugins.sandbox-level.flash", 2);
#else
pref("dom.ipc.plugins.sandbox-level.flash", 0);
#endif

View File

@ -419,9 +419,9 @@ nsPluginTag::InitSandboxLevel()
}
#if defined(_AMD64_)
// Level 3 is now the default NPAPI sandbox level for 64-bit flash.
// We permit the user to drop the sandbox level by at most 1. This should
// be kept up to date with the default value in the firefox.js pref file.
// As level 2 is now the default NPAPI sandbox level for 64-bit flash, we
// don't want to allow a lower setting. This should be changed if the
// firefox.js pref file is changed.
if (mIsFlashPlugin && mSandboxLevel < 2) {
mSandboxLevel = 2;
}

View File

@ -11,7 +11,6 @@
#if defined(XP_WIN)
#include <commdlg.h>
#include <schannel.h>
#include <sddl.h>
#endif // defined(XP_WIN)
using namespace mozilla;
@ -31,199 +30,10 @@ void FreeDestructor(void* aObj) { free(aObj); }
#if defined(XP_WIN)
// Specialization of EndpointHandlers for Flash file dialog brokering.
struct FileDlgEHContainer
{
template<Endpoint e> struct EndpointHandler;
};
template<>
struct FileDlgEHContainer::EndpointHandler<CLIENT> :
public BaseEndpointHandler<CLIENT, FileDlgEHContainer::EndpointHandler<CLIENT>>
{
using BaseEndpointHandler<CLIENT, EndpointHandler<CLIENT>>::Copy;
inline static void Copy(OpenFileNameIPC& aDest, const LPOPENFILENAMEW& aSrc)
{
aDest.CopyFromOfn(aSrc);
}
inline static void Copy(LPOPENFILENAMEW& aDest, const OpenFileNameRetIPC& aSrc)
{
aSrc.AddToOfn(aDest);
}
};
template<>
struct FileDlgEHContainer::EndpointHandler<SERVER> :
public BaseEndpointHandler<SERVER, FileDlgEHContainer::EndpointHandler<SERVER>>
{
using BaseEndpointHandler<SERVER, EndpointHandler<SERVER>>::Copy;
inline static void Copy(OpenFileNameRetIPC& aDest, const LPOPENFILENAMEW& aSrc)
{
aDest.CopyFromOfn(aSrc);
}
inline static void Copy(ServerCallData* aScd, LPOPENFILENAMEW& aDest, const OpenFileNameIPC& aSrc)
{
MOZ_ASSERT(!aDest);
ServerCallData::DestructorType* destructor =
[](void* aObj) {
OpenFileNameIPC::FreeOfnStrings(static_cast<LPOPENFILENAMEW>(aObj));
DeleteDestructor<OPENFILENAMEW>(aObj);
};
aDest = aScd->Allocate<OPENFILENAMEW>(destructor);
aSrc.AllocateOfnStrings(aDest);
aSrc.AddToOfn(aDest);
}
};
// FunctionBroker type that uses FileDlgEHContainer
template <FunctionHookId functionId, typename FunctionType>
using FileDlgFunctionBroker = FunctionBroker<functionId, FunctionType, FileDlgEHContainer>;
// Specialization of EndpointHandlers for Flash SSL brokering.
struct SslEHContainer {
template<Endpoint e> struct EndpointHandler;
};
template<>
struct SslEHContainer::EndpointHandler<CLIENT> :
public BaseEndpointHandler<CLIENT, SslEHContainer::EndpointHandler<CLIENT>>
{
using BaseEndpointHandler<CLIENT, EndpointHandler<CLIENT>>::Copy;
inline static void Copy(uint64_t& aDest, const PSecHandle& aSrc)
{
MOZ_ASSERT((aSrc->dwLower == aSrc->dwUpper) && IsOdd(aSrc->dwLower));
aDest = static_cast<uint64_t>(aSrc->dwLower);
}
inline static void Copy(PSecHandle& aDest, const uint64_t& aSrc)
{
MOZ_ASSERT(IsOdd(aSrc));
aDest->dwLower = static_cast<ULONG_PTR>(aSrc);
aDest->dwUpper = static_cast<ULONG_PTR>(aSrc);
}
inline static void Copy(IPCSchannelCred& aDest, const PSCHANNEL_CRED& aSrc)
{
if (aSrc) {
aDest.CopyFrom(aSrc);
}
}
inline static void Copy(IPCInternetBuffers& aDest, const LPINTERNET_BUFFERSA& aSrc)
{
aDest.CopyFrom(aSrc);
}
};
template<>
struct SslEHContainer::EndpointHandler<SERVER> :
public BaseEndpointHandler<SERVER, SslEHContainer::EndpointHandler<SERVER>>
{
using BaseEndpointHandler<SERVER, EndpointHandler<SERVER>>::Copy;
// PSecHandle is the same thing as PCtxtHandle and PCredHandle.
inline static void Copy(uint64_t& aDest, const PSecHandle& aSrc)
{
// If the SecHandle was an error then don't store it.
if (!aSrc) {
aDest = 0;
return;
}
static uint64_t sNextVal = 1;
UlongPair key(aSrc->dwLower, aSrc->dwUpper);
// Fetch val by reference to update the value in the map
uint64_t& val = sPairToIdMap[key];
if (val == 0) {
MOZ_ASSERT(IsOdd(sNextVal));
val = sNextVal;
sIdToPairMap[val] = key;
sNextVal += 2;
}
aDest = val;
}
// HANDLEs and HINTERNETs marshal with obfuscation (for return values)
inline static void Copy(uint64_t& aDest, void* const & aSrc)
{
// If the HANDLE/HINTERNET was an error then don't store it.
if (!aSrc) {
aDest = 0;
return;
}
static uint64_t sNextVal = 1;
// Fetch val by reference to update the value in the map
uint64_t& val = sPtrToIdMap[aSrc];
if (val == 0) {
MOZ_ASSERT(IsOdd(sNextVal));
val = sNextVal;
sIdToPtrMap[val] = aSrc;
sNextVal += 2;
}
aDest = val;
}
// HANDLEs and HINTERNETs unmarshal with obfuscation
inline static void Copy(void*& aDest, const uint64_t& aSrc)
{
aDest = nullptr;
MOZ_RELEASE_ASSERT(IsOdd(aSrc));
// If the src is not found in the map then we get aDest == 0
void* ptr = sIdToPtrMap[aSrc];
aDest = reinterpret_cast<void*>(ptr);
MOZ_RELEASE_ASSERT(aDest);
}
inline static void Copy(PSCHANNEL_CRED& aDest, const IPCSchannelCred& aSrc)
{
if (aDest) {
aSrc.CopyTo(aDest);
}
}
inline static void Copy(ServerCallData* aScd, PSecHandle& aDest, const uint64_t& aSrc)
{
MOZ_ASSERT(!aDest);
MOZ_RELEASE_ASSERT(IsOdd(aSrc));
// If the src is not found in the map then we get the pair { 0, 0 }
aDest = aScd->Allocate<SecHandle>();
const UlongPair& pair = sIdToPairMap[aSrc];
MOZ_RELEASE_ASSERT(pair.first || pair.second);
aDest->dwLower = pair.first;
aDest->dwUpper = pair.second;
}
inline static void Copy(ServerCallData* aScd, PSCHANNEL_CRED& aDest, const IPCSchannelCred& aSrc)
{
MOZ_ASSERT(!aDest);
aDest = aScd->Allocate<SCHANNEL_CRED>();
Copy(aDest, aSrc);
}
inline static void Copy(ServerCallData* aScd, LPINTERNET_BUFFERSA& aDest, const IPCInternetBuffers& aSrc)
{
MOZ_ASSERT(!aDest);
aSrc.CopyTo(aDest);
ServerCallData::DestructorType* destructor =
[](void* aObj) {
LPINTERNET_BUFFERSA inetBuf = static_cast<LPINTERNET_BUFFERSA>(aObj);
IPCInternetBuffers::FreeBuffers(inetBuf);
FreeDestructor(inetBuf);
};
aScd->PostDestructor(aDest, destructor);
}
};
// FunctionBroker type that uses SslEHContainer
template <FunctionHookId functionId, typename FunctionType>
using SslFunctionBroker = FunctionBroker<functionId, FunctionType, SslEHContainer>;
/* GetKeyState */
typedef FunctionBroker<ID_GetKeyState, decltype(GetKeyState)> GetKeyStateFB;
typedef FunctionBroker<ID_GetKeyState,
decltype(GetKeyState)> GetKeyStateFB;
template<>
ShouldHookFunc* const
@ -236,8 +46,8 @@ typedef FunctionBroker<ID_SetCursorPos,
/* GetSaveFileNameW */
typedef FileDlgFunctionBroker<ID_GetSaveFileNameW,
decltype(GetSaveFileNameW)> GetSaveFileNameWFB;
typedef FunctionBroker<ID_GetSaveFileNameW,
decltype(GetSaveFileNameW)> GetSaveFileNameWFB;
// Remember files granted access in the chrome process
static void GrantFileAccess(base::ProcessId aClientId, LPOPENFILENAME& aLpofn,
@ -300,8 +110,8 @@ struct GetSaveFileNameWFB::Response::Info::ShouldMarshal<0> { static const bool
/* GetOpenFileNameW */
typedef FileDlgFunctionBroker<ID_GetOpenFileNameW,
decltype(GetOpenFileNameW)> GetOpenFileNameWFB;
typedef FunctionBroker<ID_GetOpenFileNameW,
decltype(GetOpenFileNameW)> GetOpenFileNameWFB;
template<> template<>
BOOL GetOpenFileNameWFB::RunFunction(GetOpenFileNameWFB::FunctionType* aOrigFunction,
@ -321,8 +131,8 @@ struct GetOpenFileNameWFB::Response::Info::ShouldMarshal<0> { static const bool
/* InternetOpenA */
typedef SslFunctionBroker<ID_InternetOpenA,
decltype(InternetOpenA)> InternetOpenAFB;
typedef FunctionBroker<ID_InternetOpenA,
decltype(InternetOpenA)> InternetOpenAFB;
template<>
ShouldHookFunc* const
@ -330,8 +140,8 @@ InternetOpenAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
/* InternetConnectA */
typedef SslFunctionBroker<ID_InternetConnectA,
decltype(InternetConnectA)> InternetConnectAFB;
typedef FunctionBroker<ID_InternetConnectA,
decltype(InternetConnectA)> InternetConnectAFB;
template<>
ShouldHookFunc* const
@ -351,8 +161,8 @@ bool ICAReqHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h,
/* InternetCloseHandle */
typedef SslFunctionBroker<ID_InternetCloseHandle,
decltype(InternetCloseHandle)> InternetCloseHandleFB;
typedef FunctionBroker<ID_InternetCloseHandle,
decltype(InternetCloseHandle)> InternetCloseHandleFB;
template<>
ShouldHookFunc* const
@ -371,15 +181,17 @@ bool ICHReqHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h)
/* InternetQueryDataAvailable */
typedef SslFunctionBroker<ID_InternetQueryDataAvailable,
decltype(InternetQueryDataAvailable)> InternetQueryDataAvailableFB;
typedef FunctionBroker<ID_InternetQueryDataAvailable,
decltype(InternetQueryDataAvailable)> InternetQueryDataAvailableFB;
template<>
ShouldHookFunc* const
InternetQueryDataAvailableFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef InternetQueryDataAvailableFB::Request IQDAReq;
typedef InternetQueryDataAvailableFB::RequestDelegate<BOOL HOOK_CALL (HINTERNET)> IQDADelegateReq;
typedef struct RequestHandler<ID_InternetQueryDataAvailable,
BOOL HOOK_CALL (HINTERNET)> IQDADelegateReq;
template<>
void IQDAReq::Marshal(IpdlTuple& aTuple, const HINTERNET& file,
@ -421,15 +233,16 @@ struct InternetQueryDataAvailableFB::Response::Info::ShouldMarshal<1> { static c
/* InternetReadFile */
typedef SslFunctionBroker<ID_InternetReadFile,
decltype(InternetReadFile)> InternetReadFileFB;
typedef FunctionBroker<ID_InternetReadFile,
decltype(InternetReadFile)> InternetReadFileFB;
template<>
ShouldHookFunc* const
InternetReadFileFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef InternetReadFileFB::Request IRFRequestHandler;
typedef InternetReadFileFB::RequestDelegate<BOOL HOOK_CALL (HINTERNET, DWORD)> IRFDelegateReq;
typedef struct RequestHandler<ID_InternetReadFile,
BOOL HOOK_CALL (HINTERNET, DWORD)> IRFDelegateReq;
template<>
void IRFRequestHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& h,
@ -467,12 +280,13 @@ bool IRFRequestHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h,
return (endpoint == SERVER) || IsOdd(reinterpret_cast<uint64_t>(h));
}
typedef InternetReadFileFB::Response IRFResponseHandler;
typedef InternetReadFileFB::ResponseDelegate<BOOL HOOK_CALL (nsDependentCSubstring)> IRFDelegateResponseHandler;
// Marshal the output parameter that we sent to the response delegate.
template<> template<>
struct IRFResponseHandler::Info::ShouldMarshal<0> { static const bool value = true; };
struct InternetReadFileFB::Response::Info::ShouldMarshal<0> { static const bool value = true; };
typedef ResponseHandler<ID_InternetReadFile, decltype(InternetReadFile)> IRFResponseHandler;
typedef ResponseHandler<ID_InternetReadFile,
BOOL HOOK_CALL (nsDependentCSubstring)> IRFDelegateResponseHandler;
template<>
void IRFResponseHandler::Marshal(IpdlTuple& aTuple, const BOOL& ret, const HINTERNET& h,
@ -507,15 +321,16 @@ bool IRFResponseHandler::Unmarshal(const IpdlTuple& aTuple, BOOL& ret, HINTERNET
/* InternetWriteFile */
typedef SslFunctionBroker<ID_InternetWriteFile,
decltype(InternetWriteFile)> InternetWriteFileFB;
typedef FunctionBroker<ID_InternetWriteFile,
decltype(InternetWriteFile)> InternetWriteFileFB;
template<>
ShouldHookFunc* const
InternetWriteFileFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef InternetWriteFileFB::Request IWFReqHandler;
typedef InternetWriteFileFB::RequestDelegate<int HOOK_CALL (HINTERNET, nsDependentCSubstring)> IWFDelegateReqHandler;
typedef RequestHandler<ID_InternetWriteFile,
int HOOK_CALL (HINTERNET, nsDependentCSubstring)> IWFDelegateReqHandler;
template<>
void IWFReqHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& file, const LPCVOID& buf,
@ -557,15 +372,16 @@ struct InternetWriteFileFB::Response::Info::ShouldMarshal<3> { static const bool
/* InternetSetOptionA */
typedef SslFunctionBroker<ID_InternetSetOptionA,
decltype(InternetSetOptionA)> InternetSetOptionAFB;
typedef FunctionBroker<ID_InternetSetOptionA,
decltype(InternetSetOptionA)> InternetSetOptionAFB;
template<>
ShouldHookFunc* const
InternetSetOptionAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef InternetSetOptionAFB::Request ISOAReqHandler;
typedef InternetSetOptionAFB::RequestDelegate<BOOL HOOK_CALL (HINTERNET, DWORD, nsDependentCSubstring)> ISOADelegateReqHandler;
typedef RequestHandler<ID_InternetSetOptionA,
BOOL HOOK_CALL (HINTERNET, DWORD, nsDependentCSubstring)> ISOADelegateReqHandler;
template<>
void ISOAReqHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& h, const DWORD& opt,
@ -601,8 +417,8 @@ bool ISOAReqHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h, const D
/* HttpAddRequestHeadersA */
typedef SslFunctionBroker<ID_HttpAddRequestHeadersA,
decltype(HttpAddRequestHeadersA)> HttpAddRequestHeadersAFB;
typedef FunctionBroker<ID_HttpAddRequestHeadersA,
decltype(HttpAddRequestHeadersA)> HttpAddRequestHeadersAFB;
template<>
ShouldHookFunc* const
@ -623,15 +439,17 @@ bool HARHAReqHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h,
/* HttpOpenRequestA */
typedef SslFunctionBroker<ID_HttpOpenRequestA,
decltype(HttpOpenRequestA)> HttpOpenRequestAFB;
typedef FunctionBroker<ID_HttpOpenRequestA,
decltype(HttpOpenRequestA)> HttpOpenRequestAFB;
template<>
ShouldHookFunc* const
HttpOpenRequestAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef HttpOpenRequestAFB::Request HORAReqHandler;
typedef HttpOpenRequestAFB::RequestDelegate<HINTERNET HOOK_CALL (HINTERNET, LPCSTR, LPCSTR, LPCSTR, LPCSTR, nsTArray<nsCString>, DWORD, DWORD_PTR)> HORADelegateReqHandler;
typedef RequestHandler<ID_HttpOpenRequestA,
HINTERNET HOOK_CALL (HINTERNET, LPCSTR, LPCSTR, LPCSTR, LPCSTR,
nsTArray<nsCString>, DWORD, DWORD_PTR)> HORADelegateReqHandler;
template<>
void HORAReqHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& h,
@ -689,15 +507,17 @@ bool HORAReqHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h,
/* HttpQueryInfoA */
typedef SslFunctionBroker<ID_HttpQueryInfoA,
decltype(HttpQueryInfoA)> HttpQueryInfoAFB;
typedef FunctionBroker<ID_HttpQueryInfoA,
decltype(HttpQueryInfoA)> HttpQueryInfoAFB;
template<>
ShouldHookFunc* const
HttpQueryInfoAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef HttpQueryInfoAFB::Request HQIARequestHandler;
typedef HttpQueryInfoAFB::RequestDelegate<BOOL HOOK_CALL (HINTERNET, DWORD, BOOL, DWORD, BOOL, DWORD)> HQIADelegateRequestHandler;
typedef RequestHandler<ID_HttpQueryInfoA,
BOOL HOOK_CALL (HINTERNET, DWORD, BOOL, DWORD, BOOL,
DWORD)> HQIADelegateRequestHandler;
template<>
void HQIARequestHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& h,
@ -752,7 +572,9 @@ template<> template<>
struct HttpQueryInfoAFB::Response::Info::ShouldMarshal<2> { static const bool value = true; };
typedef HttpQueryInfoAFB::Response HQIAResponseHandler;
typedef HttpQueryInfoAFB::ResponseDelegate<BOOL HOOK_CALL (nsDependentCSubstring, DWORD, DWORD)> HQIADelegateResponseHandler;
typedef ResponseHandler<ID_HttpQueryInfoA,
BOOL HOOK_CALL (nsDependentCSubstring,
DWORD, DWORD)> HQIADelegateResponseHandler;
template<>
void HQIAResponseHandler::Marshal(IpdlTuple& aTuple, const BOOL& ret, const HINTERNET& h,
@ -809,15 +631,17 @@ bool HQIAResponseHandler::Unmarshal(const IpdlTuple& aTuple, BOOL& ret, HINTERNE
/* HttpSendRequestA */
typedef SslFunctionBroker<ID_HttpSendRequestA,
decltype(HttpSendRequestA)> HttpSendRequestAFB;
typedef FunctionBroker<ID_HttpSendRequestA,
decltype(HttpSendRequestA)> HttpSendRequestAFB;
template<>
ShouldHookFunc* const
HttpSendRequestAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef HttpSendRequestAFB::Request HSRARequestHandler;
typedef HttpSendRequestAFB::RequestDelegate<BOOL HOOK_CALL (HINTERNET, nsDependentCSubstring, nsDependentCSubstring)> HSRADelegateRequestHandler;
typedef RequestHandler<ID_HttpSendRequestA,
BOOL HOOK_CALL (HINTERNET, nsDependentCSubstring,
nsDependentCSubstring)> HSRADelegateRequestHandler;
template<>
void HSRARequestHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& h,
@ -885,8 +709,8 @@ bool HSRARequestHandler::ShouldBroker(Endpoint endpoint, const HINTERNET& h,
/* HttpSendRequestExA */
typedef SslFunctionBroker<ID_HttpSendRequestExA,
decltype(HttpSendRequestExA)> HttpSendRequestExAFB;
typedef FunctionBroker<ID_HttpSendRequestExA,
decltype(HttpSendRequestExA)> HttpSendRequestExAFB;
template<>
ShouldHookFunc* const
@ -909,15 +733,16 @@ const DWORD_PTR HSRExAReqInfo::FixedValue<4>::value = 0;
/* InternetQueryOptionA */
typedef SslFunctionBroker<ID_InternetQueryOptionA,
decltype(InternetQueryOptionA)> InternetQueryOptionAFB;
typedef FunctionBroker<ID_InternetQueryOptionA,
decltype(InternetQueryOptionA)> InternetQueryOptionAFB;
template<>
ShouldHookFunc* const
InternetQueryOptionAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_SSL>;
typedef InternetQueryOptionAFB::Request IQOARequestHandler;
typedef InternetQueryOptionAFB::RequestDelegate<BOOL HOOK_CALL (HINTERNET, DWORD, DWORD)> IQOADelegateRequestHandler;
typedef RequestHandler<ID_InternetQueryOptionA,
BOOL HOOK_CALL (HINTERNET, DWORD, DWORD)> IQOADelegateRequestHandler;
template<>
void IQOARequestHandler::Marshal(IpdlTuple& aTuple, const HINTERNET& h,
@ -960,7 +785,8 @@ template<> template<>
struct InternetQueryOptionAFB::Response::Info::ShouldMarshal<1> { static const bool value = true; };
typedef InternetQueryOptionAFB::Response IQOAResponseHandler;
typedef InternetQueryOptionAFB::ResponseDelegate<BOOL HOOK_CALL (nsDependentCSubstring, DWORD)> IQOADelegateResponseHandler;
typedef ResponseHandler<ID_InternetQueryOptionA,
BOOL HOOK_CALL (nsDependentCSubstring, DWORD)> IQOADelegateResponseHandler;
template<>
void IQOAResponseHandler::Marshal(IpdlTuple& aTuple, const BOOL& ret, const HINTERNET& h,
@ -994,8 +820,8 @@ bool IQOAResponseHandler::Unmarshal(const IpdlTuple& aTuple, BOOL& ret, HINTERNE
/* InternetErrorDlg */
typedef SslFunctionBroker<ID_InternetErrorDlg,
decltype(InternetErrorDlg)> InternetErrorDlgFB;
typedef FunctionBroker<ID_InternetErrorDlg,
decltype(InternetErrorDlg)> InternetErrorDlgFB;
template<>
ShouldHookFunc* const
@ -1027,8 +853,8 @@ bool IEDReqHandler::ShouldBroker(Endpoint endpoint, const HWND& hwnd,
/* AcquireCredentialsHandleA */
typedef SslFunctionBroker<ID_AcquireCredentialsHandleA,
decltype(AcquireCredentialsHandleA)> AcquireCredentialsHandleAFB;
typedef FunctionBroker<ID_AcquireCredentialsHandleA,
decltype(AcquireCredentialsHandleA)> AcquireCredentialsHandleAFB;
template<>
ShouldHookFunc* const
@ -1061,7 +887,10 @@ struct ACHAReqInfo::FixedValue<6> { static void* const value; };
void* const ACHAReqInfo::FixedValue<6>::value = nullptr;
typedef AcquireCredentialsHandleAFB::Request ACHARequestHandler;
typedef AcquireCredentialsHandleAFB::RequestDelegate<SECURITY_STATUS HOOK_CALL (LPSTR, LPSTR, unsigned long, void*, PSCHANNEL_CRED, SEC_GET_KEY_FN, void*)> ACHADelegateRequestHandler;
typedef RequestHandler<ID_AcquireCredentialsHandleA,
SECURITY_STATUS HOOK_CALL (LPSTR, LPSTR, unsigned long,
void*, PSCHANNEL_CRED, SEC_GET_KEY_FN,
void*)> ACHADelegateRequestHandler;
template<>
void ACHARequestHandler::Marshal(IpdlTuple& aTuple, const LPSTR& principal,
@ -1103,8 +932,8 @@ struct ACHARspInfo::ShouldMarshal<8> { static const bool value = true; };
/* QueryCredentialsAttributesA */
typedef SslFunctionBroker<ID_QueryCredentialsAttributesA,
decltype(QueryCredentialsAttributesA)> QueryCredentialsAttributesAFB;
typedef FunctionBroker<ID_QueryCredentialsAttributesA,
decltype(QueryCredentialsAttributesA)> QueryCredentialsAttributesAFB;
template<>
ShouldHookFunc* const
@ -1112,8 +941,8 @@ QueryCredentialsAttributesAFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_
/* FreeCredentialsHandle */
typedef SslFunctionBroker<ID_FreeCredentialsHandle,
decltype(FreeCredentialsHandle)> FreeCredentialsHandleFB;
typedef FunctionBroker<ID_FreeCredentialsHandle,
decltype(FreeCredentialsHandle)> FreeCredentialsHandleFB;
template<>
ShouldHookFunc* const
@ -1131,128 +960,6 @@ bool FCHReq::ShouldBroker(Endpoint endpoint, const PCredHandle& h)
((h->dwLower == h->dwUpper) && IsOdd(static_cast<uint64_t>(h->dwLower)));
}
/* CreateMutexW */
// Get the user's SID as a string. Returns an empty string on failure.
static std::wstring GetUserSid()
{
std::wstring ret;
// Get user SID from process token information
HANDLE token;
BOOL success = ::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token);
if (!success) {
return ret;
}
DWORD bufLen;
success = ::GetTokenInformation(token, TokenUser, nullptr, 0, &bufLen);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return ret;
}
void* buf = malloc(bufLen);
success = ::GetTokenInformation(token, TokenUser, buf, bufLen, &bufLen);
MOZ_ASSERT(success);
if (success) {
TOKEN_USER* tokenUser = static_cast<TOKEN_USER*>(buf);
PSID sid = tokenUser->User.Sid;
LPWSTR sidStr;
success = ::ConvertSidToStringSid(sid, &sidStr);
if (success) {
ret = sidStr;
::LocalFree(sidStr);
}
}
free(buf);
::CloseHandle(token);
return ret;
}
// Get the name Windows uses for the camera mutex. Returns an empty string
// on failure.
// The camera mutex is identified in Windows code using a hard-coded GUID string,
// "eed3bd3a-a1ad-4e99-987b-d7cb3fcfa7f0", and the user's SID. The GUID
// value was determined by investigating Windows code. It is referenced in
// CCreateSwEnum::CCreateSwEnum(void) in devenum.dll.
static std::wstring GetCameraMutexName()
{
std::wstring userSid = GetUserSid();
if (userSid.empty()) {
return userSid;
}
return std::wstring(L"eed3bd3a-a1ad-4e99-987b-d7cb3fcfa7f0 - ") + userSid;
}
typedef FunctionBroker<ID_CreateMutexW, decltype(CreateMutexW)> CreateMutexWFB;
template<>
ShouldHookFunc* const
CreateMutexWFB::BaseType::mShouldHook = &CheckQuirks<QUIRK_FLASH_HOOK_CREATEMUTEXW>;
typedef CreateMutexWFB::Request CMWReqHandler;
typedef CMWReqHandler::Info CMWReqInfo;
typedef CreateMutexWFB::Response CMWRspHandler;
template<>
bool CMWReqHandler::ShouldBroker(Endpoint endpoint,
const LPSECURITY_ATTRIBUTES& aAttribs,
const BOOL& aOwner,
const LPCWSTR& aName)
{
// Statically hold the camera mutex name so that we dont recompute it for
// every CreateMutexW call in the client process.
static std::wstring camMutexName = GetCameraMutexName();
// Only broker if we are requesting the camera mutex. Note that we only
// need to check that the client is actually requesting the camera. The
// command is always valid on the server as long as we can construct the
// mutex name.
if (endpoint == SERVER) {
return !camMutexName.empty();
}
return (!aOwner) && aName && (!camMutexName.empty()) && (camMutexName == aName);
}
// We dont need to marshal any parameters. We construct all of them server-side.
template<> template<>
struct CMWReqInfo::ShouldMarshal<0> { static const bool value = false; };
template<> template<>
struct CMWReqInfo::ShouldMarshal<1> { static const bool value = false; };
template<> template<>
struct CMWReqInfo::ShouldMarshal<2> { static const bool value = false; };
template<> template<>
HANDLE CreateMutexWFB::RunFunction(CreateMutexWFB::FunctionType* aOrigFunction,
base::ProcessId aClientId,
LPSECURITY_ATTRIBUTES& aAttribs,
BOOL& aOwner,
LPCWSTR& aName) const
{
// Use CreateMutexW to get the camera mutex and DuplicateHandle to open it
// for use in the child process.
// Recall that aAttribs, aOwner and aName are all unmarshaled so they are
// unassigned garbage.
SECURITY_ATTRIBUTES mutexAttrib =
{ sizeof(SECURITY_ATTRIBUTES), nullptr /* ignored */, TRUE };
std::wstring camMutexName = GetCameraMutexName();
if (camMutexName.empty()) {
return 0;
}
HANDLE serverMutex = ::CreateMutexW(&mutexAttrib, FALSE, camMutexName.c_str());
if (serverMutex == 0) {
return 0;
}
ScopedProcessHandle clientProcHandle;
if (!base::OpenProcessHandle(aClientId, &clientProcHandle.rwget())) {
return 0;
}
HANDLE ret;
if (!::DuplicateHandle(::GetCurrentProcess(), serverMutex, clientProcHandle,
&ret, SYNCHRONIZE, FALSE, DUPLICATE_CLOSE_SOURCE)) {
return 0;
}
return ret;
}
#endif // defined(XP_WIN)
/*****************************************************************************/
@ -1328,8 +1035,6 @@ AddBrokeredFunctionHooks(FunctionHookArray& aHooks)
FUN_HOOK(new FreeCredentialsHandleFB("sspicli.dll",
"FreeCredentialsHandle",
&FreeCredentialsHandle));
aHooks[ID_CreateMutexW] =
FUN_HOOK(new CreateMutexWFB("kernel32.dll", "CreateMutexW", &CreateMutexW));
#endif // defined(XP_WIN)
}

View File

@ -94,10 +94,7 @@
* for client -> server and for server -> client. Note that the
* types must be able to Copy() from one another -- the default Copy()
* implementation uses the type's assignment operator.
* The EndpointHandler itself is a template parameter of the FunctionBroker.
* The default EndpointHandler recognizes basic types.
* See e.g. FileDlgEndpointHandler<CLIENT>::IPCTypeMap<LPOPENFILENAMEW>
* for an example of specialization.
* See e.g. EndpointHandler<CLIENT>::IPCTypeMap<LPOPENFILENAMEW>.
*
* * Anything more complex involving parameter transmission:
*
@ -458,16 +455,15 @@ inline void Copy(PTimeStamp& aDest, const uint64_t& aSrc)
#endif // defined(XP_WIN)
template<Endpoint e, typename SelfType> struct BaseEndpointHandler;
template<typename SelfType>
struct BaseEndpointHandler<CLIENT,SelfType> {
template<Endpoint e> struct EndpointHandler;
template<> struct EndpointHandler<CLIENT> {
static const Endpoint OtherSide = SERVER;
template<typename DestType, typename SrcType>
inline static void Copy(ServerCallData* aScd, DestType& aDest, const SrcType& aSrc)
{
MOZ_ASSERT(!aScd); // never used in the CLIENT
SelfType::Copy(aDest, aSrc);
Copy(aDest, aSrc);
}
template<typename DestType, typename SrcType>
@ -475,54 +471,109 @@ struct BaseEndpointHandler<CLIENT,SelfType> {
{
mozilla::plugins::Copy(aDest, aSrc);
}
// const char* should be null terminated but this is not always the case.
// In those cases, we must override this default behavior.
inline static void Copy(nsDependentCSubstring& aDest, const char* const& aSrc)
{
// In the client, we just bind to the caller's string
if (aSrc) {
aDest.Rebind(aSrc, strlen(aSrc));
} else {
aDest.SetIsVoid(true);
}
}
inline static void Copy(const char*& aDest, const nsDependentCSubstring& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Cannot return const parameters.");
}
inline static void Copy(nsDependentCSubstring& aDest, char* const& aSrc)
{
// In the client, we just bind to the caller's string
if (aSrc) {
aDest.Rebind(aSrc, strlen(aSrc));
} else {
aDest.SetIsVoid(true);
}
}
inline static void Copy(char*& aDest, const nsDependentCSubstring& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Returning char* parameters is not yet suported.");
}
#if defined(XP_WIN)
inline static void Copy(uint32_t& aDest, const LPDWORD& aSrc)
{
aDest = *aSrc;
}
inline static void Copy(LPDWORD& aDest, const uint32_t& aSrc)
{
*aDest = aSrc;
}
#endif // #if defined(XP_WIN)
};
template<typename SelfType>
struct BaseEndpointHandler<SERVER, SelfType> {
#if defined(XP_WIN)
template<>
inline void EndpointHandler<CLIENT>::Copy(uint64_t& aDest, const PSecHandle& aSrc)
{
MOZ_ASSERT((aSrc->dwLower == aSrc->dwUpper) && IsOdd(aSrc->dwLower));
aDest = static_cast<uint64_t>(aSrc->dwLower);
}
template<>
inline void EndpointHandler<CLIENT>::Copy(PSecHandle& aDest, const uint64_t& aSrc)
{
MOZ_ASSERT(IsOdd(aSrc));
aDest->dwLower = static_cast<ULONG_PTR>(aSrc);
aDest->dwUpper = static_cast<ULONG_PTR>(aSrc);
}
template<>
inline void EndpointHandler<CLIENT>::Copy(OpenFileNameIPC& aDest, const LPOPENFILENAMEW& aSrc)
{
aDest.CopyFromOfn(aSrc);
}
template<>
inline void EndpointHandler<CLIENT>::Copy(LPOPENFILENAMEW& aDest, const OpenFileNameRetIPC& aSrc)
{
aSrc.AddToOfn(aDest);
}
#endif // defined(XP_WIN)
// const char* should be null terminated but this is not always the case.
// In those cases, we must override this default behavior.
template<>
inline void EndpointHandler<CLIENT>::Copy(nsDependentCSubstring& aDest, const char* const& aSrc)
{
// In the client, we just bind to the caller's string
if (aSrc) {
aDest.Rebind(aSrc, strlen(aSrc));
} else {
aDest.SetIsVoid(true);
}
}
template<>
inline void EndpointHandler<CLIENT>::Copy(const char*& aDest, const nsDependentCSubstring& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Cannot return const parameters.");
}
template<>
inline void EndpointHandler<CLIENT>::Copy(nsDependentCSubstring& aDest, char* const& aSrc)
{
// In the client, we just bind to the caller's string
if (aSrc) {
aDest.Rebind(aSrc, strlen(aSrc));
} else {
aDest.SetIsVoid(true);
}
}
template<>
inline void EndpointHandler<CLIENT>::Copy(char*& aDest,
const nsDependentCSubstring& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Returning char* parameters is not yet suported.");
}
#if defined(XP_WIN)
template<>
inline void EndpointHandler<CLIENT>::Copy(IPCSchannelCred& aDest,
const PSCHANNEL_CRED& aSrc)
{
if (aSrc) {
aDest.CopyFrom(aSrc);
}
}
template<>
inline void EndpointHandler<CLIENT>::Copy(IPCInternetBuffers& aDest,
const LPINTERNET_BUFFERSA& aSrc)
{
aDest.CopyFrom(aSrc);
}
template<>
inline void EndpointHandler<CLIENT>::Copy(uint32_t& aDest, const LPDWORD& aSrc)
{
aDest = *aSrc;
}
template<>
inline void EndpointHandler<CLIENT>::Copy(LPDWORD& aDest, const uint32_t& aSrc)
{
*aDest = aSrc;
}
#endif // #if defined(XP_WIN)
template<> struct EndpointHandler<SERVER> {
static const Endpoint OtherSide = CLIENT;
// Specializations of this method may allocate memory for types that need it
@ -533,7 +584,7 @@ struct BaseEndpointHandler<SERVER, SelfType> {
template<typename DestType, typename SrcType>
inline static void Copy(ServerCallData* aScd, DestType& aDest, const SrcType& aSrc)
{
SelfType::Copy(aDest, aSrc);
Copy(aDest, aSrc);
}
template<typename DestType, typename SrcType>
@ -541,65 +592,195 @@ struct BaseEndpointHandler<SERVER, SelfType> {
{
mozilla::plugins::Copy(aDest, aSrc);
}
};
inline static void Copy(nsDependentCSubstring& aDest, const nsDependentCSubstring& aSrc)
{
aDest.Rebind(aSrc.Data(), aSrc.Length());
aDest.SetIsVoid(aSrc.IsVoid());
}
template<>
inline void EndpointHandler<SERVER>::Copy(nsDependentCSubstring& aDest, const nsDependentCSubstring& aSrc)
{
aDest.Rebind(aSrc.Data(), aSrc.Length());
aDest.SetIsVoid(aSrc.IsVoid());
}
// const char* should be null terminated but this is not always the case.
// In those cases, we override this default behavior.
inline static void Copy(nsDependentCSubstring& aDest, const char* const& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Const parameter cannot be returned by brokering process.");
}
// const char* should be null terminated but this is not always the case.
// In those cases, we override this default behavior.
template<>
inline void EndpointHandler<SERVER>::Copy(nsDependentCSubstring& aDest, const char* const& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Const parameter cannot be returned by brokering process.");
}
inline static void Copy(nsDependentCSubstring& aDest, char* const& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Returning char* parameters is not yet suported.");
}
inline static void Copy(ServerCallData* aScd, char*& aDest, const nsDependentCSubstring& aSrc)
{
// In the parent, we must allocate the string.
MOZ_ASSERT(aScd);
if (aSrc.IsVoid()) {
aDest = nullptr;
return;
}
aScd->AllocateMemory(aSrc.Length() + 1, aDest);
memcpy(aDest, aSrc.Data(), aSrc.Length());
aDest[aSrc.Length()] = '\0';
}
inline static void Copy(ServerCallData* aScd, const char*& aDest, const nsDependentCSubstring& aSrc)
{
char* nonConstDest;
Copy(aScd, nonConstDest, aSrc);
aDest = nonConstDest;
}
template<>
inline void EndpointHandler<SERVER>::Copy(nsDependentCSubstring& aDest, char* const& aSrc)
{
MOZ_ASSERT_UNREACHABLE("Returning char* parameters is not yet suported.");
}
#if defined(XP_WIN)
inline static void Copy(uint32_t& aDest, const LPDWORD& aSrc)
{
aDest = *aSrc;
// PSecHandle is the same thing as PCtxtHandle and PCredHandle
template<>
inline void EndpointHandler<SERVER>::Copy(uint64_t& aDest, const PSecHandle& aSrc)
{
static uint64_t sNextVal = 1;
UlongPair key(aSrc->dwLower, aSrc->dwUpper);
// Fetch val by reference to update the value in the map
uint64_t& val = sPairToIdMap[key];
if (val == 0) {
MOZ_ASSERT(IsOdd(sNextVal));
val = sNextVal;
sIdToPairMap[val] = key;
sNextVal += 2;
}
aDest = val;
}
// HANDLEs and HINTERNETs marshal (for return values)
template<>
inline void EndpointHandler<SERVER>::Copy(uint64_t& aDest, void* const & aSrc)
{
// If the HANDLE/HINSTANCE was an error then don't store it.
if (!aSrc) {
aDest = 0;
return;
}
inline static void Copy(LPDWORD& aDest, const uint32_t& aSrc)
{
MOZ_RELEASE_ASSERT(aDest);
*aDest = aSrc;
static uint64_t sNextVal = 1;
// Fetch val by reference to update the value in the map
uint64_t& val = sPtrToIdMap[aSrc];
if (val == 0) {
MOZ_ASSERT(IsOdd(sNextVal));
val = sNextVal;
sIdToPtrMap[val] = aSrc;
sNextVal += 2;
}
aDest = val;
}
inline static void Copy(ServerCallData* aScd, PTimeStamp& aDest, const uint64_t& aSrc)
{
MOZ_ASSERT(!aDest);
aDest = aScd->Allocate<::TimeStamp>();
Copy(aDest, aSrc);
// HANDLEs and HINTERNETs unmarshal
template<>
inline void EndpointHandler<SERVER>::Copy(void*& aDest, const uint64_t& aSrc)
{
aDest = nullptr;
MOZ_RELEASE_ASSERT(IsOdd(aSrc));
// If the src is not found in the map then we get aDest == 0
void* ptr = sIdToPtrMap[aSrc];
aDest = reinterpret_cast<void*>(ptr);
MOZ_RELEASE_ASSERT(aDest);
}
template<>
inline void EndpointHandler<SERVER>::Copy(OpenFileNameRetIPC& aDest, const LPOPENFILENAMEW& aSrc)
{
aDest.CopyFromOfn(aSrc);
}
template<>
inline void EndpointHandler<SERVER>::Copy(PSCHANNEL_CRED& aDest, const IPCSchannelCred& aSrc)
{
if (aDest) {
aSrc.CopyTo(aDest);
}
}
template<>
inline void EndpointHandler<SERVER>::Copy(uint32_t& aDest, const LPDWORD& aSrc)
{
aDest = *aSrc;
}
template<>
inline void EndpointHandler<SERVER>::Copy(LPDWORD& aDest, const uint32_t& aSrc)
{
MOZ_RELEASE_ASSERT(aDest);
*aDest = aSrc;
}
#endif // defined(XP_WIN)
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, char*& aDest, const nsDependentCSubstring& aSrc)
{
// In the parent, we must allocate the string.
MOZ_ASSERT(aScd);
if (aSrc.IsVoid()) {
aDest = nullptr;
return;
}
aScd->AllocateMemory(aSrc.Length() + 1, aDest);
memcpy(aDest, aSrc.Data(), aSrc.Length());
aDest[aSrc.Length()] = '\0';
}
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, const char*& aDest, const nsDependentCSubstring& aSrc)
{
char* nonConstDest;
Copy(aScd, nonConstDest, aSrc);
aDest = nonConstDest;
}
#if defined(XP_WIN)
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, PSecHandle& aDest, const uint64_t& aSrc)
{
MOZ_ASSERT(!aDest);
MOZ_RELEASE_ASSERT(IsOdd(aSrc));
// If the src is not found in the map then we get the pair { 0, 0 }
aDest = aScd->Allocate<SecHandle>();
const UlongPair& pair = sIdToPairMap[aSrc];
MOZ_RELEASE_ASSERT(pair.first || pair.second);
aDest->dwLower = pair.first;
aDest->dwUpper = pair.second;
}
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, PTimeStamp& aDest, const uint64_t& aSrc)
{
MOZ_ASSERT(!aDest);
aDest = aScd->Allocate<::TimeStamp>();
Copy(aDest, aSrc);
}
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, LPOPENFILENAMEW& aDest, const OpenFileNameIPC& aSrc)
{
MOZ_ASSERT(!aDest);
ServerCallData::DestructorType* destructor =
[](void* aObj) {
OpenFileNameIPC::FreeOfnStrings(static_cast<LPOPENFILENAMEW>(aObj));
DeleteDestructor<OPENFILENAMEW>(aObj);
};
aDest = aScd->Allocate<OPENFILENAMEW>(destructor);
aSrc.AllocateOfnStrings(aDest);
aSrc.AddToOfn(aDest);
}
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, PSCHANNEL_CRED& aDest, const IPCSchannelCred& aSrc)
{
MOZ_ASSERT(!aDest);
aDest = aScd->Allocate<SCHANNEL_CRED>();
Copy(aDest, aSrc);
}
template<>
inline void EndpointHandler<SERVER>::Copy(ServerCallData* aScd, LPINTERNET_BUFFERSA& aDest, const IPCInternetBuffers& aSrc)
{
MOZ_ASSERT(!aDest);
aSrc.CopyTo(aDest);
ServerCallData::DestructorType* destructor =
[](void* aObj) {
LPINTERNET_BUFFERSA inetBuf = static_cast<LPINTERNET_BUFFERSA>(aObj);
IPCInternetBuffers::FreeBuffers(inetBuf);
FreeDestructor(inetBuf);
};
aScd->PostDestructor(aDest, destructor);
}
#endif // defined(XP_WIN)
};
// PhaseHandler is a RequestHandler or a ResponseHandler.
template<Endpoint endpoint, typename PhaseHandler>
@ -636,8 +817,7 @@ struct Marshaler
HOOK_LOG(LogLevel::Verbose,
("%s marshaling parameter %d.", EndpointMsg(endpoint), paramIndex));
IPCType ipcObject;
// EndpointHandler must be able to Copy() from OrigType to IPCType
PhaseHandler::EHContainer::template EndpointHandler<endpoint>::Copy(ipcObject, aParam);
EndpointHandler<endpoint>::Copy(ipcObject, aParam); // Must be able to Copy() from OrigType to IPCType
LogParameterValue(paramIndex, ipcObject);
aMarshaledTuple.AddElement(ipcObject);
}
@ -700,7 +880,7 @@ struct Marshaler
HOOK_LOG(LogLevel::Verbose,
("%s unmarshaled parameter %d.", EndpointMsg(endpoint), tupleIndex));
LogParameterValue(tupleIndex, *ipcObject);
PhaseHandler::EHContainer::template EndpointHandler<endpoint>::Copy(aUnmarshaledTuple.GetServerCallData(), aParam, *ipcObject);
EndpointHandler<endpoint>::Copy(aUnmarshaledTuple.GetServerCallData(), aParam, *ipcObject);
++aNextTupleIdx;
return true;
}
@ -742,7 +922,7 @@ struct Marshaler
{
nsDependentCSubstring tempStr;
bool ret = MaybeUnmarshalParameter<tupleIndex, nsDependentCSubstring, true, false>::UnmarshalParameter(aUnmarshaledTuple, aNextTupleIdx, tempStr);
PhaseHandler::EHContainer::template EndpointHandler<endpoint>::Copy(aUnmarshaledTuple.GetServerCallData(), aParam, tempStr);
EndpointHandler<endpoint>::Copy(aUnmarshaledTuple.GetServerCallData(), aParam, tempStr);
return ret;
}
};
@ -841,7 +1021,7 @@ template<FunctionHookId functionId> struct RequestInfo
* This base stores the RequestHandler's IPCTypeMap. It really only
* exists to circumvent the arbitrary C++ rule (enforced by mingw) forbidding
* full class specialization of a class (IPCTypeMap<T>) inside of an
* unspecialized template class (RequestHandler<T>).
* unspecialized template class (RequestHandler<T>).p
*/
struct RequestHandlerBase
{
@ -861,20 +1041,15 @@ struct RequestHandlerBase::IPCTypeMap<LPOPENFILENAMEW> { typedef OpenFileNameIPC
#endif // defined(XP_WIN)
struct BaseEHContainer {
template <Endpoint e> struct EndpointHandler : public BaseEndpointHandler<e,EndpointHandler<e>> {};
};
template<FunctionHookId functionId, typename FunctionType> struct RequestHandler;
template<FunctionHookId functionId, typename FunctionType, typename EHContainer> struct RequestHandler;
template<FunctionHookId functionId, typename EHContainerType, typename ResultType, typename ... ParamTypes>
struct RequestHandler<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainerType> :
template<FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
struct RequestHandler<functionId, ResultType HOOK_CALL (ParamTypes...)> :
public RequestHandlerBase
{
typedef ResultType(HOOK_CALL FunctionType)(ParamTypes...);
typedef RequestHandler<functionId, FunctionType, EHContainerType> SelfType;
typedef RequestHandler<functionId, FunctionType> SelfType;
typedef RequestInfo<functionId> Info;
typedef EHContainerType EHContainer;
static void Marshal(IpdlTuple& aTuple, const ParamTypes&... aParams)
{
@ -988,16 +1163,15 @@ struct ResponseHandlerBase::IPCTypeMap<LPOPENFILENAMEW> { typedef OpenFileNameRe
#endif
template<FunctionHookId functionId, typename FunctionType, typename EHContainer> struct ResponseHandler;
template<FunctionHookId functionId, typename FunctionType> struct ResponseHandler;
template<FunctionHookId functionId, typename EHContainerType, typename ResultType, typename ... ParamTypes>
struct ResponseHandler<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainerType> :
template<FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
struct ResponseHandler<functionId, ResultType HOOK_CALL (ParamTypes...)> :
public ResponseHandlerBase
{
typedef ResultType(HOOK_CALL FunctionType)(ParamTypes...);
typedef ResponseHandler<functionId, FunctionType, EHContainerType> SelfType;
typedef ResponseHandler<functionId, FunctionType> SelfType;
typedef ResponseInfo<functionId> Info;
typedef EHContainerType EHContainer;
static void Marshal(IpdlTuple& aTuple, const ResultType& aResult, const ParamTypes&... aParams)
{
@ -1024,12 +1198,11 @@ struct ResponseHandler<functionId, ResultType HOOK_CALL (ParamTypes...), EHConta
* Data for hooking a function that we automatically broker in a remote
* process.
*/
template <FunctionHookId functionId, typename FunctionType,
typename EHContainer = BaseEHContainer>
template <FunctionHookId functionId, typename FunctionType>
class FunctionBroker;
template <FunctionHookId functionId, typename EHContainer, typename ResultType, typename ... ParamTypes>
class FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer> :
template <FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
class FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...)> :
public BasicFunctionHook<functionId, ResultType HOOK_CALL (ParamTypes...)>
{
public:
@ -1040,17 +1213,12 @@ public:
static const size_t numParams = sizeof...(ParamTypes);
typedef ResultType (HOOK_CALL FunctionType)(ParamTypes...);
typedef FunctionBroker<functionId, FunctionType, EHContainer> SelfType;
typedef FunctionBroker<functionId, FunctionType> SelfType;
typedef BasicFunctionHook<functionId, FunctionType> FunctionHookInfoType;
typedef FunctionHookInfoType BaseType;
typedef RequestHandler<functionId, FunctionType, EHContainer> Request;
typedef ResponseHandler<functionId, FunctionType, EHContainer> Response;
template <typename DelegateFcnType>
using RequestDelegate = RequestHandler<functionId, DelegateFcnType, EHContainer>;
template <typename DelegateFcnType>
using ResponseDelegate = ResponseHandler<functionId, DelegateFcnType, EHContainer>;
typedef RequestHandler<functionId, FunctionType> Request;
typedef ResponseHandler<functionId, FunctionType> Response;
FunctionBroker(const char* aModuleName, const char* aMethodName,
FunctionType* aOriginalFunction) :
@ -1143,9 +1311,9 @@ protected:
}
};
template <FunctionHookId functionId, typename EHContainer, typename ResultType, typename ... ParamTypes>
template <FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
ResultType
FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer>::MaybeBrokerCallClient(ParamTypes&... aParameters) const
FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...)>::MaybeBrokerCallClient(ParamTypes&... aParameters) const
{
MOZ_ASSERT(FunctionBrokerChild::GetInstance());
@ -1180,9 +1348,9 @@ FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer>::M
return FunctionHookInfoType::mOldFunction(aParameters...);
}
template <FunctionHookId functionId, typename EHContainer, typename ResultType, typename ... ParamTypes>
template <FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
bool
FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer>::BrokerCallClient(uint32_t& aWinError,
FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...)>::BrokerCallClient(uint32_t& aWinError,
ResultType& aResult,
ParamTypes&... aParameters) const
{
@ -1227,9 +1395,9 @@ FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer>::B
return false;
}
template <FunctionHookId functionId, typename EHContainer, typename ResultType, typename ... ParamTypes>
template <FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
bool
FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer>::BrokerCallServer(base::ProcessId aClientId, const IpdlTuple &aInTuple,
FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...)>::BrokerCallServer(base::ProcessId aClientId, const IpdlTuple &aInTuple,
IpdlTuple *aOutTuple, ParamTypes&... aParams) const
{
HOOK_LOG(LogLevel::Info, ("[%s] Server brokering function.", FunctionHookInfoType::mFunctionName.Data()));
@ -1275,9 +1443,9 @@ FunctionBroker<functionId, ResultType HOOK_CALL (ParamTypes...), EHContainer>::B
return true;
}
template <FunctionHookId functionId, typename EHContainer, typename ResultType, typename ... ParamTypes>
template <FunctionHookId functionId, typename ResultType, typename ... ParamTypes>
bool
FunctionBroker<functionId,ResultType HOOK_CALL (ParamTypes...), EHContainer>::
FunctionBroker<functionId,ResultType HOOK_CALL (ParamTypes...)>::
PostToDispatchThread(uint32_t& aWinError, ResultType& aRet,
ParamTypes&... aParameters) const
{

View File

@ -46,7 +46,6 @@ enum FunctionHookId
, ID_QueryCredentialsAttributesA
, ID_FreeCredentialsHandle
, ID_PrintDlgW
, ID_CreateMutexW
, ID_FunctionHookCount
#else // defined(XP_WIN)
ID_FunctionHookCount

View File

@ -31,7 +31,6 @@ int GetQuirksFromMimeTypeAndFilename(const nsCString& aMimeType,
quirks |= QUIRK_FLASH_HOOK_GETKEYSTATE;
quirks |= QUIRK_FLASH_HOOK_PRINTDLGW;
quirks |= QUIRK_FLASH_HOOK_SSL;
quirks |= QUIRK_FLASH_HOOK_CREATEMUTEXW;
#endif
#endif
}

View File

@ -51,8 +51,6 @@ enum PluginQuirks {
QUIRK_FLASH_HOOK_PRINTDLGW = 1 << 14,
// Win: Broker Win32 SSL operations
QUIRK_FLASH_HOOK_SSL = 1 << 15,
// Win: Hook CreateMutexW for brokering when using the camera
QUIRK_FLASH_HOOK_CREATEMUTEXW = 1 << 16,
};
int GetQuirksFromMimeTypeAndFilename(const nsCString& aMimeType,