Skip to content

Commit e3198dd

Browse files
committed
Backed out 4 changesets (bug 1674904) for Build bustage in worker/checkouts/gecko/config/rules.mk. CLOSED TREE
Backed out changeset 50576e0fbd98 (bug 1674904) Backed out changeset b3b7d68c33f6 (bug 1674904) Backed out changeset 660cdea23685 (bug 1674904) Backed out changeset 7322c3af8006 (bug 1674904)
1 parent 8b0bf43 commit e3198dd

File tree

8 files changed

+104
-411
lines changed

8 files changed

+104
-411
lines changed

accessible/ipc/win/handler/moz.build

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,3 @@ LIBRARY_DEFINES["UNICODE"] = True
121121
LIBRARY_DEFINES["_UNICODE"] = True
122122
LIBRARY_DEFINES["MOZ_NO_MOZALLOC"] = True
123123
DisableStlWrapping()
124-
125-
DELAYLOAD_DLLS += [
126-
"advapi32.dll",
127-
"ktmw32.dll",
128-
]

ipc/mscom/Registration.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,10 @@ static bool RegisterPSClsids(const ProxyFileInfo** aProxyInfo,
107107
return true;
108108
}
109109

110-
#if !defined(MOZILLA_INTERNAL_API)
111-
using GetProxyDllInfoFnT = decltype(&GetProxyDllInfo);
112-
113-
static GetProxyDllInfoFnT ResolveGetProxyDllInfo() {
114-
HMODULE thisModule = reinterpret_cast<HMODULE>(GetContainingModuleHandle());
115-
if (!thisModule) {
116-
return nullptr;
117-
}
118-
119-
return reinterpret_cast<GetProxyDllInfoFnT>(
120-
GetProcAddress(thisModule, "GetProxyDllInfo"));
121-
}
122-
#endif // !defined(MOZILLA_INTERNAL_API)
123-
124110
UniquePtr<RegisteredProxy> RegisterProxy() {
125-
#if !defined(MOZILLA_INTERNAL_API)
126-
GetProxyDllInfoFnT GetProxyDllInfoFn = ResolveGetProxyDllInfo();
127-
MOZ_ASSERT(!!GetProxyDllInfoFn);
128-
if (!GetProxyDllInfoFn) {
129-
return nullptr;
130-
}
131-
#endif // !defined(MOZILLA_INTERNAL_API)
132-
133111
const ProxyFileInfo** proxyInfo = nullptr;
134112
const CLSID* proxyClsid = nullptr;
135-
#if defined(MOZILLA_INTERNAL_API)
136113
GetProxyDllInfo(&proxyInfo, &proxyClsid);
137-
#else
138-
GetProxyDllInfoFn(&proxyInfo, &proxyClsid);
139-
#endif // defined(MOZILLA_INTERNAL_API)
140114
if (!proxyInfo || !proxyClsid) {
141115
return nullptr;
142116
}

ipc/mscom/Utils.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
# endif
1717
#endif
1818

19-
#include "mozilla/ArrayUtils.h"
20-
#include "mozilla/DebugOnly.h"
2119
#include "mozilla/mscom/Objref.h"
2220
#include "mozilla/mscom/Utils.h"
2321
#include "mozilla/RefPtr.h"
@@ -141,50 +139,6 @@ uintptr_t GetContainingModuleHandle() {
141139
return reinterpret_cast<uintptr_t>(thisModule);
142140
}
143141

144-
namespace detail {
145-
146-
long BuildRegGuidPath(REFGUID aGuid, const GuidType aGuidType, wchar_t* aBuf,
147-
const size_t aBufLen) {
148-
constexpr wchar_t kClsid[] = L"CLSID\\";
149-
constexpr wchar_t kAppid[] = L"AppID\\";
150-
constexpr wchar_t kSubkeyBase[] = L"SOFTWARE\\Classes\\";
151-
152-
// We exclude null terminators in these length calculations because we include
153-
// the stringified GUID's null terminator at the end. Since kClsid and kAppid
154-
// have identical lengths, we just choose one to compute this length.
155-
constexpr size_t kSubkeyBaseLen = mozilla::ArrayLength(kSubkeyBase) - 1;
156-
constexpr size_t kSubkeyLen =
157-
kSubkeyBaseLen + mozilla::ArrayLength(kClsid) - 1;
158-
// Guid length as formatted for the registry (including curlies and dashes),
159-
// but excluding null terminator.
160-
constexpr size_t kGuidLen = kGuidRegFormatCharLenInclNul - 1;
161-
constexpr size_t kExpectedPathLenInclNul = kSubkeyLen + kGuidLen + 1;
162-
163-
if (aBufLen < kExpectedPathLenInclNul) {
164-
// Buffer is too short
165-
return E_INVALIDARG;
166-
}
167-
168-
if (wcscpy_s(aBuf, aBufLen, kSubkeyBase)) {
169-
return E_INVALIDARG;
170-
}
171-
172-
const wchar_t* strGuidType = aGuidType == GuidType::CLSID ? kClsid : kAppid;
173-
if (wcscat_s(aBuf, aBufLen, strGuidType)) {
174-
return E_INVALIDARG;
175-
}
176-
177-
int guidConversionResult =
178-
::StringFromGUID2(aGuid, &aBuf[kSubkeyLen], aBufLen - kSubkeyLen);
179-
if (!guidConversionResult) {
180-
return E_INVALIDARG;
181-
}
182-
183-
return S_OK;
184-
}
185-
186-
} // namespace detail
187-
188142
long CreateStream(const uint8_t* aInitBuf, const uint32_t aInitBufSize,
189143
IStream** aOutStream) {
190144
if (!aInitBufSize || !aOutStream) {
@@ -317,15 +271,6 @@ void GUIDToString(REFGUID aGuid, nsAString& aOutString) {
317271
}
318272
}
319273

320-
#else
321-
322-
void GUIDToString(REFGUID aGuid,
323-
wchar_t (&aOutBuf)[kGuidRegFormatCharLenInclNul]) {
324-
DebugOnly<int> result =
325-
::StringFromGUID2(aGuid, aOutBuf, ArrayLength(aOutBuf));
326-
MOZ_ASSERT(result);
327-
}
328-
329274
#endif // defined(MOZILLA_INTERNAL_API)
330275

331276
#if defined(ACCESSIBILITY)

ipc/mscom/Utils.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ struct IUnknown;
1919

2020
namespace mozilla {
2121
namespace mscom {
22-
namespace detail {
23-
24-
enum class GuidType {
25-
CLSID,
26-
AppID,
27-
};
28-
29-
long BuildRegGuidPath(REFGUID aGuid, const GuidType aGuidType, wchar_t* aBuf,
30-
const size_t aBufLen);
31-
32-
} // namespace detail
3322

3423
bool IsCOMInitializedOnCurrentThread();
3524
bool IsCurrentThreadMTA();
@@ -42,16 +31,6 @@ bool IsProxy(IUnknown* aUnknown);
4231
bool IsValidGUID(REFGUID aCheckGuid);
4332
uintptr_t GetContainingModuleHandle();
4433

45-
template <size_t N>
46-
inline long BuildAppidPath(REFGUID aAppId, wchar_t (&aPath)[N]) {
47-
return detail::BuildRegGuidPath(aAppId, detail::GuidType::AppID, aPath, N);
48-
}
49-
50-
template <size_t N>
51-
inline long BuildClsidPath(REFCLSID aClsid, wchar_t (&aPath)[N]) {
52-
return detail::BuildRegGuidPath(aClsid, detail::GuidType::CLSID, aPath, N);
53-
}
54-
5534
/**
5635
* Given a buffer, create a new IStream object.
5736
* @param aBuf Buffer containing data to initialize the stream. This parameter
@@ -99,9 +78,6 @@ long CopySerializedProxy(IStream* aInStream, IStream** aOutStream);
9978
bool IsClassThreadAwareInprocServer(REFCLSID aClsid);
10079

10180
void GUIDToString(REFGUID aGuid, nsAString& aOutString);
102-
#else
103-
void GUIDToString(REFGUID aGuid,
104-
wchar_t (&aOutBuf)[kGuidRegFormatCharLenInclNul]);
10581
#endif // defined(MOZILLA_INTERNAL_API)
10682

10783
#if defined(ACCESSIBILITY)

ipc/mscom/oop/Handler.cpp

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,116 @@ Handler::DisconnectObject(DWORD dwReserved) {
267267
return mUnmarshal->DisconnectObject(dwReserved);
268268
}
269269

270+
template <size_t N>
271+
static HRESULT BuildClsidPath(wchar_t (&aPath)[N], REFCLSID aClsid) {
272+
const wchar_t kSubkey[] = L"SOFTWARE\\Classes\\CLSID\\";
273+
274+
// We exclude kSubkey's null terminator in the length because we include
275+
// the stringified GUID's null terminator.
276+
constexpr uint32_t kSubkeyLen = mozilla::ArrayLength(kSubkey) - 1;
277+
278+
const size_t kReqdGuidLen = 39;
279+
static_assert(N >= kReqdGuidLen + kSubkeyLen, "aPath array is too short");
280+
if (wcsncpy_s(aPath, kSubkey, kSubkeyLen)) {
281+
return E_INVALIDARG;
282+
}
283+
284+
int guidConversionResult =
285+
StringFromGUID2(aClsid, &aPath[kSubkeyLen], N - kSubkeyLen);
286+
if (!guidConversionResult) {
287+
return E_INVALIDARG;
288+
}
289+
290+
return S_OK;
291+
}
292+
270293
HRESULT
271294
Handler::Unregister(REFCLSID aClsid) {
272-
return Module::Deregister(aClsid);
295+
wchar_t path[256] = {};
296+
HRESULT hr = BuildClsidPath(path, aClsid);
297+
if (FAILED(hr)) {
298+
return hr;
299+
}
300+
301+
hr = HRESULT_FROM_WIN32(SHDeleteKey(HKEY_LOCAL_MACHINE, path));
302+
if (FAILED(hr)) {
303+
return hr;
304+
}
305+
306+
return S_OK;
273307
}
274308

275309
HRESULT
276310
Handler::Register(REFCLSID aClsid) {
277-
return Module::Register(aClsid, Module::ThreadingModel::DedicatedUiThreadOnly,
278-
Module::ClassType::InprocHandler);
311+
wchar_t path[256] = {};
312+
HRESULT hr = BuildClsidPath(path, aClsid);
313+
if (FAILED(hr)) {
314+
return hr;
315+
}
316+
317+
HKEY rawClsidKey;
318+
DWORD disposition;
319+
LONG result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, path, 0, nullptr,
320+
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
321+
&rawClsidKey, &disposition);
322+
if (result != ERROR_SUCCESS) {
323+
return HRESULT_FROM_WIN32(result);
324+
}
325+
nsAutoRegKey clsidKey(rawClsidKey);
326+
327+
if (wcscat_s(path, L"\\InprocHandler32")) {
328+
return E_UNEXPECTED;
329+
}
330+
331+
HKEY rawInprocHandlerKey;
332+
result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, path, 0, nullptr,
333+
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
334+
&rawInprocHandlerKey, &disposition);
335+
if (result != ERROR_SUCCESS) {
336+
Unregister(aClsid);
337+
return HRESULT_FROM_WIN32(result);
338+
}
339+
nsAutoRegKey inprocHandlerKey(rawInprocHandlerKey);
340+
341+
wchar_t absLibPath[MAX_PATH + 1] = {};
342+
HMODULE thisModule;
343+
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
344+
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
345+
reinterpret_cast<LPCTSTR>(&Handler::Register),
346+
&thisModule)) {
347+
return HRESULT_FROM_WIN32(GetLastError());
348+
}
349+
350+
DWORD size = GetModuleFileName(thisModule, absLibPath,
351+
mozilla::ArrayLength(absLibPath));
352+
if (!size || (size == mozilla::ArrayLength(absLibPath) &&
353+
GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
354+
DWORD lastError = GetLastError();
355+
Unregister(aClsid);
356+
return HRESULT_FROM_WIN32(lastError);
357+
}
358+
359+
// The result of GetModuleFileName excludes the null terminator
360+
DWORD valueSizeWithNullInBytes = (size + 1) * sizeof(wchar_t);
361+
362+
result = RegSetValueEx(inprocHandlerKey, L"", 0, REG_EXPAND_SZ,
363+
reinterpret_cast<const BYTE*>(absLibPath),
364+
valueSizeWithNullInBytes);
365+
if (result != ERROR_SUCCESS) {
366+
Unregister(aClsid);
367+
return HRESULT_FROM_WIN32(result);
368+
}
369+
370+
const wchar_t kApartment[] = L"Apartment";
371+
result = RegSetValueEx(inprocHandlerKey, L"ThreadingModel", 0, REG_SZ,
372+
reinterpret_cast<const BYTE*>(kApartment),
373+
sizeof(kApartment));
374+
if (result != ERROR_SUCCESS) {
375+
Unregister(aClsid);
376+
return HRESULT_FROM_WIN32(result);
377+
}
378+
379+
return S_OK;
279380
}
280381

281382
} // namespace mscom

0 commit comments

Comments
 (0)