const XRaySledEntry &Sled) XRAY_NEVER_INSTRUMENT {
// Here we do the dance of replacing the following sled:
//
- // In Version 0:
- //
// xray_sled_n:
- // jmp +20 // 2 bytes
+ // jmp +15 // 2 bytes
// ...
//
// With the following:
// ...
//
//
- // The "unpatch" should just turn the 'nopw' back to a 'jmp +20'.
- //
- // ---
- //
- // In Version 1 or 2:
- //
- // The jump offset is now 15 bytes (0x0f), so when restoring the nopw back
- // to a jmp, use 15 bytes instead.
- //
+ // The "unpatch" should just turn the 'nopw' back to a 'jmp +15'.
const uint64_t Address = Sled.address();
if (Enable) {
std::atomic_store_explicit(
reinterpret_cast<std::atomic<uint16_t> *>(Address), NopwSeq,
std::memory_order_release);
} else {
- switch (Sled.Version) {
- case 1:
- case 2:
- std::atomic_store_explicit(
- reinterpret_cast<std::atomic<uint16_t> *>(Address), Jmp15Seq,
- std::memory_order_release);
- break;
- case 0:
- default:
- std::atomic_store_explicit(
- reinterpret_cast<std::atomic<uint16_t> *>(Address), Jmp20Seq,
- std::memory_order_release);
- break;
- }
- }
+ std::atomic_store_explicit(
+ reinterpret_cast<std::atomic<uint16_t> *>(Address), Jmp15Seq,
+ std::memory_order_release);
+ }
return false;
}