Closed Bug 1018477 Opened 10 years ago Closed 10 years ago

Fix R/M check in x86 detour code

Categories

(Core :: General, defect)

32 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: away, Assigned: away)

Details

Attachments

(1 file)

I tried to hook a function containing this instruction:

8b7c240c        mov     edi,dword ptr [esp+0Ch]

CreateTrampoline thought that this was a 3-byte instruction, so then it failed to understand the next byte 0x0C. 

The code was trying to avoid REG 5 (with the 0x38 mask) but it should actually avoid R/M 5 (using 0x07 mask). I fixed that and added the case for R/M==5 as well.

I used this reference: http://www.c-jump.com/CIS77/CPU/x86/lecture.html#X77_0090_addressing_modes
Assignee: nobody → dmajor
Attachment #8431945 - Flags: review?(m_kato)
> The code was trying to avoid REG 5 (with the 0x38 mask) but it should
> actually avoid R/M 5 (using 0x07 mask). I fixed that and added the case for
> R/M==5 as well.

Typo: The special case for SIB is R/M==4.
Attachment #8431945 - Flags: review?(m_kato) → review+
https://hg.mozilla.org/mozilla-central/rev/8c3664b5e1a2
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: