Skip to content

Commit fb977a3

Browse files
committed
Bug 1571875: Part 2 - Change over all existing static local uses of DynamicallyLinkedFunctionPtr to use StaticDynamicallyLinkedFunctionPtr instead; r=mhowell
Depends on D40885 Differential Revision: https://phabricator.services.mozilla.com/D40886 --HG-- extra : moz-landing-system : lando
1 parent d46e27a commit fb977a3

File tree

8 files changed

+30
-24
lines changed

8 files changed

+30
-24
lines changed

browser/app/winlauncher/LauncherProcessWin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ Maybe<int> LauncherMain(int& argc, wchar_t* argv[],
231231

232232
// Make sure that the launcher process itself has image load policies set
233233
if (IsWin10AnniversaryUpdateOrLater()) {
234-
const DynamicallyLinkedFunctionPtr<decltype(&SetProcessMitigationPolicy)>
234+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
235+
&SetProcessMitigationPolicy)>
235236
pSetProcessMitigationPolicy(L"kernel32.dll",
236237
"SetProcessMitigationPolicy");
237238
if (pSetProcessMitigationPolicy) {

ipc/mscom/AgileReference.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ void AgileReference::AssignInternal(IUnknown* aObject) {
5959
* If that API is not available, we fall back to using the Global Interface
6060
* Table.
6161
*/
62-
static const DynamicallyLinkedFunctionPtr<decltype(&::RoGetAgileReference)>
62+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
63+
&::RoGetAgileReference)>
6364
pRoGetAgileReference(L"ole32.dll", "RoGetAgileReference");
6465

6566
MOZ_ASSERT(aObject);

mozglue/build/Authenticode.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct CertContextDeleter {
5454
struct CATAdminContextDeleter {
5555
typedef HCATADMIN pointer;
5656
void operator()(pointer aCtx) {
57-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
57+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
5858
&::CryptCATAdminReleaseContext)>
5959
pCryptCATAdminReleaseContext(L"wintrust.dll",
6060
"CryptCATAdminReleaseContext");
@@ -202,7 +202,7 @@ bool SignedBinary::VerifySignature(const wchar_t* aFilePath) {
202202
// Windows 7 also exports the CryptCATAdminAcquireContext2 API, but it does
203203
// *not* sign its binaries with SHA-256, so we use the old API in that case.
204204
if (mozilla::IsWin8OrLater()) {
205-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
205+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
206206
&::CryptCATAdminAcquireContext2)>
207207
pCryptCATAdminAcquireContext2(L"wintrust.dll",
208208
"CryptCATAdminAcquireContext2");
@@ -220,7 +220,7 @@ bool SignedBinary::VerifySignature(const wchar_t* aFilePath) {
220220
return false;
221221
}
222222
} else {
223-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
223+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
224224
&::CryptCATAdminAcquireContext)>
225225
pCryptCATAdminAcquireContext(L"wintrust.dll",
226226
"CryptCATAdminAcquireContext");
@@ -247,7 +247,7 @@ bool SignedBinary::VerifySignature(const wchar_t* aFilePath) {
247247
DWORD hashLen = 0;
248248
mozilla::UniquePtr<BYTE[]> hashBuf;
249249

250-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
250+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
251251
&::CryptCATAdminCalcHashFromFileHandle2)>
252252
pCryptCATAdminCalcHashFromFileHandle2(
253253
L"wintrust.dll", "CryptCATAdminCalcHashFromFileHandle2");
@@ -265,7 +265,7 @@ bool SignedBinary::VerifySignature(const wchar_t* aFilePath) {
265265
return false;
266266
}
267267
} else {
268-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
268+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
269269
&::CryptCATAdminCalcHashFromFileHandle)>
270270
pCryptCATAdminCalcHashFromFileHandle(
271271
L"wintrust.dll", "CryptCATAdminCalcHashFromFileHandle");
@@ -290,15 +290,15 @@ bool SignedBinary::VerifySignature(const wchar_t* aFilePath) {
290290
// Now that we've hashed the file, query the catalog system to see if any
291291
// catalogs reference a binary with our hash.
292292

293-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
293+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
294294
&::CryptCATAdminEnumCatalogFromHash)>
295295
pCryptCATAdminEnumCatalogFromHash(L"wintrust.dll",
296296
"CryptCATAdminEnumCatalogFromHash");
297297
if (!pCryptCATAdminEnumCatalogFromHash) {
298298
return false;
299299
}
300300

301-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
301+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
302302
&::CryptCATAdminReleaseCatalogContext)>
303303
pCryptCATAdminReleaseCatalogContext(L"wintrust.dll",
304304
"CryptCATAdminReleaseCatalogContext");
@@ -321,7 +321,7 @@ bool SignedBinary::VerifySignature(const wchar_t* aFilePath) {
321321

322322
// We found a catalog! Now query for the path to the catalog file.
323323

324-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
324+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
325325
&::CryptCATCatalogInfoFromContext)>
326326
pCryptCATCatalogInfoFromContext(L"wintrust.dll",
327327
"CryptCATCatalogInfoFromContext");

mozglue/misc/WindowsMapRemoteView.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ NTSTATUS NTAPI NtMapViewOfSection(
3838
NTSTATUS NTAPI NtUnmapViewOfSection(HANDLE aProcess, PVOID aBaseAddress);
3939

4040
static DWORD GetWin32ErrorCode(NTSTATUS aNtStatus) {
41-
static const mozilla::DynamicallyLinkedFunctionPtr<decltype(
41+
static const mozilla::StaticDynamicallyLinkedFunctionPtr<decltype(
4242
&RtlNtStatusToDosError)>
4343
pRtlNtStatusToDosError(L"ntdll.dll", "RtlNtStatusToDosError");
4444

@@ -56,7 +56,7 @@ MFBT_API void* MapRemoteViewOfFile(HANDLE aFileMapping, HANDLE aProcess,
5656
ULONG64 aOffset, PVOID aBaseAddress,
5757
SIZE_T aViewSize, ULONG aAllocationType,
5858
ULONG aProtectionFlags) {
59-
static const DynamicallyLinkedFunctionPtr<decltype(&MapViewOfFileNuma2)>
59+
static const StaticDynamicallyLinkedFunctionPtr<decltype(&MapViewOfFileNuma2)>
6060
pMapViewOfFileNuma2(L"Api-ms-win-core-memory-l1-1-5.dll",
6161
"MapViewOfFileNuma2");
6262

@@ -66,7 +66,7 @@ MFBT_API void* MapRemoteViewOfFile(HANDLE aFileMapping, HANDLE aProcess,
6666
NUMA_NO_PREFERRED_NODE);
6767
}
6868

69-
static const DynamicallyLinkedFunctionPtr<decltype(&NtMapViewOfSection)>
69+
static const StaticDynamicallyLinkedFunctionPtr<decltype(&NtMapViewOfSection)>
7070
pNtMapViewOfSection(L"ntdll.dll", "NtMapViewOfSection");
7171

7272
MOZ_ASSERT(!!pNtMapViewOfSection);
@@ -100,14 +100,15 @@ MFBT_API void* MapRemoteViewOfFile(HANDLE aFileMapping, HANDLE aProcess,
100100
}
101101

102102
MFBT_API bool UnmapRemoteViewOfFile(HANDLE aProcess, PVOID aBaseAddress) {
103-
static const DynamicallyLinkedFunctionPtr<decltype(&UnmapViewOfFile2)>
103+
static const StaticDynamicallyLinkedFunctionPtr<decltype(&UnmapViewOfFile2)>
104104
pUnmapViewOfFile2(L"kernel32.dll", "UnmapViewOfFile2");
105105

106106
if (!!pUnmapViewOfFile2) {
107107
return !!pUnmapViewOfFile2(aProcess, aBaseAddress, 0);
108108
}
109109

110-
static const DynamicallyLinkedFunctionPtr<decltype(&NtUnmapViewOfSection)>
110+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
111+
&NtUnmapViewOfSection)>
111112
pNtUnmapViewOfSection(L"ntdll.dll", "NtUnmapViewOfSection");
112113

113114
MOZ_ASSERT(!!pNtUnmapViewOfSection);

mozglue/misc/WindowsProcessMitigations.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@ BOOL WINAPI GetProcessMitigationPolicy(
1717

1818
namespace mozilla {
1919

20-
static const DynamicallyLinkedFunctionPtr<
21-
decltype(&::GetProcessMitigationPolicy)>&
20+
static decltype(&::GetProcessMitigationPolicy)
2221
FetchGetProcessMitigationPolicyFunc() {
23-
static const DynamicallyLinkedFunctionPtr<decltype(
22+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
2423
&::GetProcessMitigationPolicy)>
2524
pGetProcessMitigationPolicy(L"kernel32.dll",
2625
"GetProcessMitigationPolicy");
2726
return pGetProcessMitigationPolicy;
2827
}
2928

3029
MFBT_API bool IsWin32kLockedDown() {
31-
auto& pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
30+
auto pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
3231
if (!pGetProcessMitigationPolicy) {
3332
return false;
3433
}
@@ -44,7 +43,7 @@ MFBT_API bool IsWin32kLockedDown() {
4443
}
4544

4645
MFBT_API bool IsDynamicCodeDisabled() {
47-
auto& pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
46+
auto pGetProcessMitigationPolicy = FetchGetProcessMitigationPolicyFunc();
4847
if (!pGetProcessMitigationPolicy) {
4948
return false;
5049
}

mozglue/misc/interceptor/MMPolicies.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ class MOZ_TRIVIAL_CTOR_DTOR MMPolicyInProcess : public MMPolicyBase {
473473
auto reserveWithinRangeFn =
474474
[](HANDLE aProcess, uint32_t aSize, const uint8_t* aRangeMin,
475475
const uint8_t* aRangeMaxExcl) -> Maybe<PVOID> {
476-
static const DynamicallyLinkedFunctionPtr<decltype(&::VirtualAlloc2)>
476+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
477+
&::VirtualAlloc2)>
477478
pVirtualAlloc2(L"kernelbase.dll", "VirtualAlloc2");
478479
if (!pVirtualAlloc2) {
479480
return Nothing();
@@ -722,7 +723,8 @@ class MMPolicyOutOfProcess : public MMPolicyBase {
722723
[mapping = mMapping](HANDLE aProcess, uint32_t aSize,
723724
const uint8_t* aRangeMin,
724725
const uint8_t* aRangeMaxExcl) -> Maybe<PVOID> {
725-
static const DynamicallyLinkedFunctionPtr<decltype(&::MapViewOfFile3)>
726+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
727+
&::MapViewOfFile3)>
726728
pMapViewOfFile3(L"kernelbase.dll", "MapViewOfFile3");
727729
if (!pMapViewOfFile3) {
728730
return Nothing();

widget/windows/WinHeaderOnlyUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ class WindowsError final {
167167
}
168168

169169
static DWORD NtStatusToWin32Error(NTSTATUS aNtStatus) {
170-
static const DynamicallyLinkedFunctionPtr<decltype(&RtlNtStatusToDosError)>
170+
static const StaticDynamicallyLinkedFunctionPtr<decltype(
171+
&RtlNtStatusToDosError)>
171172
pRtlNtStatusToDosError(L"ntdll.dll", "RtlNtStatusToDosError");
172173

173174
MOZ_ASSERT(!!pRtlNtStatusToDosError);

xpcom/threads/nsThread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ void nsThread::InitCommon() {
564564

565565
pthread_attr_destroy(&attr);
566566
#elif defined(XP_WIN)
567-
static const DynamicallyLinkedFunctionPtr<GetCurrentThreadStackLimitsFn>
567+
static const StaticDynamicallyLinkedFunctionPtr<
568+
GetCurrentThreadStackLimitsFn>
568569
sGetStackLimits(L"kernel32.dll", "GetCurrentThreadStackLimits");
569570

570571
if (sGetStackLimits) {

0 commit comments

Comments
 (0)