Put bit_cast<>() into the base:: namespace.
This helps prevent ambiguous symbol issues in C++20 and should have been
the case anyway.
Bug: 1284275
Change-Id: I86210c7b1c8133e8c872930e9e1fdf86b663e104
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3615258
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#998789}
NOKEYCHECK=True
GitOrigin-RevId: cc88ac052b7d86a19a2f553e1b47037e0250c639
diff --git a/win/src/service_resolver_32.cc b/win/src/service_resolver_32.cc
index d95ce00..ee038e8 100644
--- a/win/src/service_resolver_32.cc
+++ b/win/src/service_resolver_32.cc
@@ -245,7 +245,7 @@
if (kCallEdx != function_code.call_ptr_edx) {
DWORD ki_system_call;
if (!::ReadProcessMemory(process_,
- bit_cast<const void*>(function_code.stub),
+ base::bit_cast<const void*>(function_code.stub),
&ki_system_call, sizeof(ki_system_call), &read)) {
return false;
}
@@ -257,7 +257,7 @@
// last check, call_stub should point to a KiXXSystemCall function on ntdll
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
- bit_cast<const wchar_t*>(ki_system_call),
+ base::bit_cast<const wchar_t*>(ki_system_call),
&module_1)) {
return false;
}
@@ -299,7 +299,8 @@
intercepted_code.mov_eax = kMovEax;
intercepted_code.service_id = full_local_thunk->original.service_id;
intercepted_code.mov_edx = kMovEdx;
- intercepted_code.stub = bit_cast<ULONG>(&full_remote_thunk->internal_thunk);
+ intercepted_code.stub =
+ base::bit_cast<ULONG>(&full_remote_thunk->internal_thunk);
intercepted_code.call_ptr_edx = kJmpEdx;
bytes_to_write = kMinServiceSize;
@@ -357,7 +358,8 @@
ULONG relative = function_code.service_id;
// First, fix our copy of their patch.
- relative += bit_cast<ULONG>(target_) - bit_cast<ULONG>(remote_thunk);
+ relative +=
+ base::bit_cast<ULONG>(target_) - base::bit_cast<ULONG>(remote_thunk);
function_code.service_id = relative;
@@ -367,8 +369,8 @@
const ULONG kJmp32Size = 5;
- relative_jump_ = bit_cast<ULONG>(&full_thunk->internal_thunk) -
- bit_cast<ULONG>(target_) - kJmp32Size;
+ relative_jump_ = base::bit_cast<ULONG>(&full_thunk->internal_thunk) -
+ base::bit_cast<ULONG>(target_) - kJmp32Size;
}
// Save the verified code
diff --git a/win/src/service_resolver_unittest.cc b/win/src/service_resolver_unittest.cc
index cc91a75..96f29b6 100644
--- a/win/src/service_resolver_unittest.cc
+++ b/win/src/service_resolver_unittest.cc
@@ -96,8 +96,8 @@
Code* patched = reinterpret_cast<Code*>(source);
EXPECT_EQ(kJump32, patched->jump);
- ULONG source_addr = bit_cast<ULONG>(source);
- ULONG target_addr = bit_cast<ULONG>(target);
+ ULONG source_addr = base::bit_cast<ULONG>(source);
+ ULONG target_addr = base::bit_cast<ULONG>(target);
EXPECT_EQ(target_addr + 19 - source_addr, patched->delta);
#endif
}