Bug 1018477: Fix R/M check in x86 detour code. r=m_kato
authorDavid Major <dmajor@mozilla.com>
Tue, 03 Jun 2014 16:47:43 +1200
changeset 205462 8c3664b5e1a29eba46a89e430be5f534505c3249
parent 205461 c1acd3bf21ed742b11c26e3b5a026871f251ce2c
child 205463 817ede736aab62fe7cec62d4826dd5318eb2b894
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1018477
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1018477: Fix R/M check in x86 detour code. r=m_kato
xpcom/build/nsWindowsDllInterceptor.h
--- a/xpcom/build/nsWindowsDllInterceptor.h
+++ b/xpcom/build/nsWindowsDllInterceptor.h
@@ -350,19 +350,24 @@ protected:
         // various MOVs
         unsigned char b = origBytes[nBytes+1];
         if (((b & 0xc0) == 0xc0) ||
             (((b & 0xc0) == 0x00) &&
              ((b & 0x07) != 0x04) && ((b & 0x07) != 0x05)))
         {
           // REG=r, R/M=r or REG=r, R/M=[r]
           nBytes += 2;
-        } else if (((b & 0xc0) == 0x40) && ((b & 0x38) != 0x20)) {
-          // REG=r, R/M=[r + disp8]
-          nBytes += 3;
+        } else if ((b & 0xc0) == 0x40) {
+          if ((b & 0x07) == 0x04) {
+            // REG=r, R/M=[SIB + disp8]
+            nBytes += 4;
+          } else {
+            // REG=r, R/M=[r + disp8]
+            nBytes += 3;
+          }
         } else {
           // complex MOV, bail
           return;
         }
       } else if (origBytes[nBytes] == 0xB8) {
         // MOV 0xB8: http://ref.x86asm.net/coder32.html#xB8
         nBytes += 5;
       } else if (origBytes[nBytes] == 0x83) {