diff options
-rw-r--r-- | lib/interception/interception_win.cc | 1 | ||||
-rw-r--r-- | lib/interception/tests/interception_win_test.cc | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/interception/interception_win.cc b/lib/interception/interception_win.cc index 994961adc..1db8ac481 100644 --- a/lib/interception/interception_win.cc +++ b/lib/interception/interception_win.cc @@ -461,6 +461,7 @@ static size_t GetInstructionSize(uptr address) { case 0x5541: // push r13 case 0x5641: // push r14 case 0x5741: // push r15 + case 0x9066: // Two-byte NOP return 2; } diff --git a/lib/interception/tests/interception_win_test.cc b/lib/interception/tests/interception_win_test.cc index 642afd545..611354f03 100644 --- a/lib/interception/tests/interception_win_test.cc +++ b/lib/interception/tests/interception_win_test.cc @@ -234,8 +234,18 @@ static void LoadActiveCode( // Add the detour instruction (i.e. mov edi, edi) if (prefix_kind == FunctionPrefixDetour) { +#if SANITIZER_WINDOWS64 + // Note that "mov edi,edi" is NOP in 32-bit only, in 64-bit it clears + // higher bits of RDI. + // Use 66,90H as NOP for Windows64. + ActiveCode[position++] = 0x66; + ActiveCode[position++] = 0x90; +#else + // mov edi,edi. ActiveCode[position++] = 0x8B; ActiveCode[position++] = 0xFF; +#endif + } // Copy the function body. |