2017-06-07 02:35:51 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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 "mozilla/mscom/Objref.h"
|
|
|
|
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/mscom/Utils.h"
|
2017-08-22 19:48:12 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2017-09-24 23:32:36 +03:00
|
|
|
#include "mozilla/ScopeExit.h"
|
2017-06-07 02:35:51 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
|
|
|
|
|
|
|
#include <guiddef.h>
|
|
|
|
#include <objidl.h>
|
2017-08-22 19:48:12 +03:00
|
|
|
#include <winnt.h>
|
2017-06-07 02:35:51 +03:00
|
|
|
|
Bug 1581441: mscom::GetObjRefSize: Correctly handle proxies marshaled by the aggregated standard marshaler. r=aklotz
For Fission, the parent process needs to take an Accessible sent up from one content process and send it down to another content process, where it will eventually be returned to the client.
If sandboxing is enabled, we must use a PassthruProxy, and if the handler is enabled, the handler will marshal the interface.
Even though we strip out the handler, the handler still marshals using the aggregated standard marshaler, which uses a different clsid (CLSID_AggStdMarshal).
When unmarshaling to return to the client, we call GetObjRefSize.
This previously didn't know about the aggregated standard marshaler, so it failed, causing E_INVALIDARG to be returned to the client.
Now, we just handle these clsids in the same way.
Differential Revision: https://phabricator.services.mozilla.com/D51246
--HG--
extra : moz-landing-system : lando
2019-11-01 00:45:17 +03:00
|
|
|
// {00000027-0000-0008-C000-000000000046}
|
|
|
|
static const GUID CLSID_AggStdMarshal = {
|
|
|
|
0x27, 0x0, 0x8, {0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46}};
|
|
|
|
|
2017-06-07 02:35:51 +03:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
typedef uint64_t OID;
|
|
|
|
typedef uint64_t OXID;
|
|
|
|
typedef GUID IPID;
|
|
|
|
|
|
|
|
struct STDOBJREF {
|
|
|
|
uint32_t mFlags;
|
|
|
|
uint32_t mPublicRefs;
|
|
|
|
OXID mOxid;
|
|
|
|
OID mOid;
|
|
|
|
IPID mIpid;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum STDOBJREF_FLAGS { SORF_PING = 0, SORF_NOPING = 0x1000 };
|
|
|
|
|
|
|
|
struct DUALSTRINGARRAY {
|
|
|
|
static size_t SizeFromNumEntries(const uint16_t aNumEntries) {
|
|
|
|
return sizeof(mNumEntries) + sizeof(mSecurityOffset) +
|
|
|
|
aNumEntries * sizeof(uint16_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SizeOf() const { return SizeFromNumEntries(mNumEntries); }
|
|
|
|
|
|
|
|
uint16_t mNumEntries;
|
|
|
|
uint16_t mSecurityOffset;
|
|
|
|
uint16_t mStringArray[1]; // Length is mNumEntries
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OBJREF_STANDARD {
|
2017-08-22 19:48:12 +03:00
|
|
|
static size_t SizeOfFixedLenHeader() { return sizeof(mStd); }
|
|
|
|
|
|
|
|
size_t SizeOf() const { return SizeOfFixedLenHeader() + mResAddr.SizeOf(); }
|
2017-06-07 02:35:51 +03:00
|
|
|
|
|
|
|
STDOBJREF mStd;
|
|
|
|
DUALSTRINGARRAY mResAddr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OBJREF_HANDLER {
|
2017-08-22 19:48:12 +03:00
|
|
|
static size_t SizeOfFixedLenHeader() { return sizeof(mStd) + sizeof(mClsid); }
|
|
|
|
|
|
|
|
size_t SizeOf() const { return SizeOfFixedLenHeader() + mResAddr.SizeOf(); }
|
2017-06-07 02:35:51 +03:00
|
|
|
|
|
|
|
STDOBJREF mStd;
|
|
|
|
CLSID mClsid;
|
|
|
|
DUALSTRINGARRAY mResAddr;
|
|
|
|
};
|
|
|
|
|
2017-08-22 19:48:12 +03:00
|
|
|
struct OBJREF_CUSTOM {
|
|
|
|
static size_t SizeOfFixedLenHeader() {
|
|
|
|
return sizeof(mClsid) + sizeof(mCbExtension) + sizeof(mReserved);
|
|
|
|
}
|
|
|
|
|
|
|
|
CLSID mClsid;
|
|
|
|
uint32_t mCbExtension;
|
|
|
|
uint32_t mReserved;
|
|
|
|
uint8_t mPayload[1];
|
|
|
|
};
|
|
|
|
|
2017-06-07 02:35:51 +03:00
|
|
|
enum OBJREF_FLAGS {
|
|
|
|
OBJREF_TYPE_STANDARD = 0x00000001UL,
|
|
|
|
OBJREF_TYPE_HANDLER = 0x00000002UL,
|
|
|
|
OBJREF_TYPE_CUSTOM = 0x00000004UL,
|
|
|
|
OBJREF_TYPE_EXTENDED = 0x00000008UL,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OBJREF {
|
2017-09-24 23:32:36 +03:00
|
|
|
static size_t SizeOfFixedLenHeader(OBJREF_FLAGS aFlags) {
|
|
|
|
size_t size = sizeof(mSignature) + sizeof(mFlags) + sizeof(mIid);
|
|
|
|
|
|
|
|
switch (aFlags) {
|
|
|
|
case OBJREF_TYPE_STANDARD:
|
|
|
|
size += OBJREF_STANDARD::SizeOfFixedLenHeader();
|
|
|
|
break;
|
|
|
|
case OBJREF_TYPE_HANDLER:
|
|
|
|
size += OBJREF_HANDLER::SizeOfFixedLenHeader();
|
|
|
|
break;
|
|
|
|
case OBJREF_TYPE_CUSTOM:
|
|
|
|
size += OBJREF_CUSTOM::SizeOfFixedLenHeader();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unsupported OBJREF type");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2017-06-07 02:35:51 +03:00
|
|
|
size_t SizeOf() const {
|
|
|
|
size_t size = sizeof(mSignature) + sizeof(mFlags) + sizeof(mIid);
|
|
|
|
|
|
|
|
switch (mFlags) {
|
|
|
|
case OBJREF_TYPE_STANDARD:
|
|
|
|
size += mObjRefStd.SizeOf();
|
|
|
|
break;
|
|
|
|
case OBJREF_TYPE_HANDLER:
|
|
|
|
size += mObjRefHandler.SizeOf();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unsupported OBJREF type");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t mSignature;
|
|
|
|
uint32_t mFlags;
|
|
|
|
IID mIid;
|
|
|
|
union {
|
|
|
|
OBJREF_STANDARD mObjRefStd;
|
|
|
|
OBJREF_HANDLER mObjRefHandler;
|
2017-08-22 19:48:12 +03:00
|
|
|
OBJREF_CUSTOM mObjRefCustom;
|
2017-06-07 02:35:51 +03:00
|
|
|
// There are others but we're not supporting them here
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
enum OBJREF_SIGNATURES { OBJREF_SIGNATURE = 0x574F454DUL };
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
struct ByteArrayDeleter {
|
|
|
|
void operator()(void* aPtr) { delete[] reinterpret_cast<uint8_t*>(aPtr); }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
using VarStructUniquePtr = mozilla::UniquePtr<T, ByteArrayDeleter>;
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace mscom {
|
|
|
|
|
2017-08-02 00:43:26 +03:00
|
|
|
bool StripHandlerFromOBJREF(NotNull<IStream*> aStream, const uint64_t aStartPos,
|
|
|
|
const uint64_t aEndPos) {
|
|
|
|
// Ensure that the current stream position is set to the beginning
|
2017-06-07 02:35:51 +03:00
|
|
|
LARGE_INTEGER seekTo;
|
2017-08-02 00:43:26 +03:00
|
|
|
seekTo.QuadPart = aStartPos;
|
2017-06-07 02:35:51 +03:00
|
|
|
|
2017-08-02 00:43:26 +03:00
|
|
|
HRESULT hr = aStream->Seek(seekTo, STREAM_SEEK_SET, nullptr);
|
2017-06-07 02:35:51 +03:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG bytesRead;
|
|
|
|
|
|
|
|
uint32_t signature;
|
|
|
|
hr = aStream->Read(&signature, sizeof(signature), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(signature) ||
|
|
|
|
signature != OBJREF_SIGNATURE) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t type;
|
|
|
|
hr = aStream->Read(&type, sizeof(type), &bytesRead);
|
2017-08-02 00:43:26 +03:00
|
|
|
if (FAILED(hr) || bytesRead != sizeof(type)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (type != OBJREF_TYPE_HANDLER) {
|
|
|
|
// If we're not a handler then just seek to the end of the OBJREF and return
|
|
|
|
// success; there is nothing left to do.
|
|
|
|
seekTo.QuadPart = aEndPos;
|
|
|
|
return SUCCEEDED(aStream->Seek(seekTo, STREAM_SEEK_SET, nullptr));
|
2017-06-07 02:35:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
IID iid;
|
|
|
|
hr = aStream->Read(&iid, sizeof(iid), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(iid) || !IsValidGUID(iid)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Seek past fixed-size STDOBJREF and CLSID
|
|
|
|
seekTo.QuadPart = sizeof(STDOBJREF) + sizeof(CLSID);
|
|
|
|
hr = aStream->Seek(seekTo, STREAM_SEEK_CUR, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
2017-08-22 19:48:12 +03:00
|
|
|
return false;
|
2017-06-07 02:35:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t numEntries;
|
|
|
|
hr = aStream->Read(&numEntries, sizeof(numEntries), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(numEntries)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We'll try to use a stack buffer if resAddrSize <= kMinDualStringArraySize
|
|
|
|
const uint32_t kMinDualStringArraySize = 12;
|
|
|
|
uint16_t staticResAddrBuf[kMinDualStringArraySize / sizeof(uint16_t)];
|
|
|
|
|
|
|
|
size_t resAddrSize = DUALSTRINGARRAY::SizeFromNumEntries(numEntries);
|
|
|
|
|
|
|
|
DUALSTRINGARRAY* resAddr;
|
|
|
|
VarStructUniquePtr<DUALSTRINGARRAY> dynamicResAddrBuf;
|
|
|
|
|
|
|
|
if (resAddrSize <= kMinDualStringArraySize) {
|
|
|
|
resAddr = reinterpret_cast<DUALSTRINGARRAY*>(staticResAddrBuf);
|
|
|
|
} else {
|
|
|
|
dynamicResAddrBuf.reset(
|
|
|
|
reinterpret_cast<DUALSTRINGARRAY*>(new uint8_t[resAddrSize]));
|
|
|
|
resAddr = dynamicResAddrBuf.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
resAddr->mNumEntries = numEntries;
|
|
|
|
|
|
|
|
// Because we've already read numEntries
|
|
|
|
ULONG bytesToRead = resAddrSize - sizeof(numEntries);
|
|
|
|
|
|
|
|
hr = aStream->Read(&resAddr->mSecurityOffset, bytesToRead, &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != bytesToRead) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signature doesn't change so we'll seek past that
|
2017-08-02 00:43:26 +03:00
|
|
|
seekTo.QuadPart = aStartPos + sizeof(signature);
|
2017-06-07 02:35:51 +03:00
|
|
|
hr = aStream->Seek(seekTo, STREAM_SEEK_SET, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG bytesWritten;
|
|
|
|
|
|
|
|
uint32_t newType = OBJREF_TYPE_STANDARD;
|
|
|
|
hr = aStream->Write(&newType, sizeof(newType), &bytesWritten);
|
|
|
|
if (FAILED(hr) || bytesWritten != sizeof(newType)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Skip past IID and STDOBJREF since those don't change
|
|
|
|
seekTo.QuadPart = sizeof(IID) + sizeof(STDOBJREF);
|
|
|
|
hr = aStream->Seek(seekTo, STREAM_SEEK_CUR, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = aStream->Write(resAddr, resAddrSize, &bytesWritten);
|
|
|
|
if (FAILED(hr) || bytesWritten != resAddrSize) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-22 01:16:16 +03:00
|
|
|
// The difference between a OBJREF_STANDARD and an OBJREF_HANDLER is
|
|
|
|
// sizeof(CLSID), so we'll zero out the remaining bytes.
|
|
|
|
CLSID zeroClsid = {0};
|
|
|
|
hr = aStream->Write(&zeroClsid, sizeof(CLSID), &bytesWritten);
|
|
|
|
if (FAILED(hr) || bytesWritten != sizeof(CLSID)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-23 08:37:24 +03:00
|
|
|
// Back up to the end of the tweaked OBJREF.
|
|
|
|
// There are now sizeof(CLSID) less bytes.
|
|
|
|
// Bug 1403180: Using -sizeof(CLSID) with a relative seek sometimes
|
|
|
|
// doesn't work on Windows 7.
|
|
|
|
// It succeeds, but doesn't seek the stream for some unknown reason.
|
|
|
|
// Use an absolute seek instead.
|
|
|
|
seekTo.QuadPart = aEndPos - sizeof(CLSID);
|
|
|
|
return SUCCEEDED(aStream->Seek(seekTo, STREAM_SEEK_SET, nullptr));
|
2017-06-07 02:35:51 +03:00
|
|
|
}
|
|
|
|
|
2017-08-22 19:48:12 +03:00
|
|
|
uint32_t GetOBJREFSize(NotNull<IStream*> aStream) {
|
|
|
|
// Make a clone so that we don't manipulate aStream's seek pointer
|
|
|
|
RefPtr<IStream> cloned;
|
|
|
|
HRESULT hr = aStream->Clone(getter_AddRefs(cloned));
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t accumulatedSize = 0;
|
|
|
|
|
|
|
|
ULONG bytesRead;
|
|
|
|
|
|
|
|
uint32_t signature;
|
|
|
|
hr = cloned->Read(&signature, sizeof(signature), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(signature) ||
|
|
|
|
signature != OBJREF_SIGNATURE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += bytesRead;
|
|
|
|
|
|
|
|
uint32_t type;
|
|
|
|
hr = cloned->Read(&type, sizeof(type), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(type)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += bytesRead;
|
|
|
|
|
|
|
|
IID iid;
|
|
|
|
hr = cloned->Read(&iid, sizeof(iid), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(iid) || !IsValidGUID(iid)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += bytesRead;
|
|
|
|
|
|
|
|
LARGE_INTEGER seekTo;
|
|
|
|
|
|
|
|
if (type == OBJREF_TYPE_CUSTOM) {
|
|
|
|
CLSID clsid;
|
|
|
|
hr = cloned->Read(&clsid, sizeof(CLSID), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(CLSID)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Bug 1581441: mscom::GetObjRefSize: Correctly handle proxies marshaled by the aggregated standard marshaler. r=aklotz
For Fission, the parent process needs to take an Accessible sent up from one content process and send it down to another content process, where it will eventually be returned to the client.
If sandboxing is enabled, we must use a PassthruProxy, and if the handler is enabled, the handler will marshal the interface.
Even though we strip out the handler, the handler still marshals using the aggregated standard marshaler, which uses a different clsid (CLSID_AggStdMarshal).
When unmarshaling to return to the client, we call GetObjRefSize.
This previously didn't know about the aggregated standard marshaler, so it failed, causing E_INVALIDARG to be returned to the client.
Now, we just handle these clsids in the same way.
Differential Revision: https://phabricator.services.mozilla.com/D51246
--HG--
extra : moz-landing-system : lando
2019-11-01 00:45:17 +03:00
|
|
|
if (clsid != CLSID_StdMarshal && clsid != CLSID_AggStdMarshal) {
|
2017-08-22 19:48:12 +03:00
|
|
|
// We can only calulate the size if the payload is a standard OBJREF as
|
Bug 1581441: mscom::GetObjRefSize: Correctly handle proxies marshaled by the aggregated standard marshaler. r=aklotz
For Fission, the parent process needs to take an Accessible sent up from one content process and send it down to another content process, where it will eventually be returned to the client.
If sandboxing is enabled, we must use a PassthruProxy, and if the handler is enabled, the handler will marshal the interface.
Even though we strip out the handler, the handler still marshals using the aggregated standard marshaler, which uses a different clsid (CLSID_AggStdMarshal).
When unmarshaling to return to the client, we call GetObjRefSize.
This previously didn't know about the aggregated standard marshaler, so it failed, causing E_INVALIDARG to be returned to the client.
Now, we just handle these clsids in the same way.
Differential Revision: https://phabricator.services.mozilla.com/D51246
--HG--
extra : moz-landing-system : lando
2019-11-01 00:45:17 +03:00
|
|
|
// identified by clsid being CLSID_StdMarshal or CLSID_AggStdMarshal.
|
|
|
|
// (CLSID_AggStdMarshal, the aggregated standard marshaler, is used when
|
|
|
|
// the handler marshals an interface.)
|
2017-08-22 19:48:12 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += bytesRead;
|
|
|
|
|
|
|
|
seekTo.QuadPart =
|
|
|
|
sizeof(OBJREF_CUSTOM::mCbExtension) + sizeof(OBJREF_CUSTOM::mReserved);
|
|
|
|
hr = cloned->Seek(seekTo, STREAM_SEEK_CUR, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += seekTo.LowPart;
|
|
|
|
|
|
|
|
uint32_t payloadLen = GetOBJREFSize(WrapNotNull(cloned.get()));
|
|
|
|
if (!payloadLen) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += payloadLen;
|
|
|
|
return accumulatedSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case OBJREF_TYPE_STANDARD:
|
|
|
|
seekTo.QuadPart = OBJREF_STANDARD::SizeOfFixedLenHeader();
|
|
|
|
break;
|
|
|
|
case OBJREF_TYPE_HANDLER:
|
|
|
|
seekTo.QuadPart = OBJREF_HANDLER::SizeOfFixedLenHeader();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = cloned->Seek(seekTo, STREAM_SEEK_CUR, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += seekTo.LowPart;
|
|
|
|
|
|
|
|
uint16_t numEntries;
|
|
|
|
hr = cloned->Read(&numEntries, sizeof(numEntries), &bytesRead);
|
|
|
|
if (FAILED(hr) || bytesRead != sizeof(numEntries)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
accumulatedSize += DUALSTRINGARRAY::SizeFromNumEntries(numEntries);
|
|
|
|
return accumulatedSize;
|
|
|
|
}
|
|
|
|
|
2017-09-24 23:32:36 +03:00
|
|
|
bool SetIID(NotNull<IStream*> aStream, const uint64_t aStart, REFIID aNewIid) {
|
|
|
|
ULARGE_INTEGER initialStreamPos;
|
|
|
|
|
|
|
|
LARGE_INTEGER seekTo;
|
|
|
|
seekTo.QuadPart = 0LL;
|
|
|
|
HRESULT hr = aStream->Seek(seekTo, STREAM_SEEK_CUR, &initialStreamPos);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto resetStreamPos = MakeScopeExit([&]() {
|
|
|
|
seekTo.QuadPart = initialStreamPos.QuadPart;
|
|
|
|
hr = aStream->Seek(seekTo, STREAM_SEEK_SET, nullptr);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(SUCCEEDED(hr));
|
|
|
|
});
|
|
|
|
|
|
|
|
seekTo.QuadPart =
|
|
|
|
aStart + sizeof(OBJREF::mSignature) + sizeof(OBJREF::mFlags);
|
|
|
|
hr = aStream->Seek(seekTo, STREAM_SEEK_SET, nullptr);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG bytesWritten;
|
|
|
|
hr = aStream->Write(&aNewIid, sizeof(IID), &bytesWritten);
|
|
|
|
return SUCCEEDED(hr) && bytesWritten == sizeof(IID);
|
|
|
|
}
|
|
|
|
|
2017-06-07 02:35:51 +03:00
|
|
|
} // namespace mscom
|
|
|
|
} // namespace mozilla
|