Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jmp FWORD PTR [eax-0x67]?

Tags:

x86

assembly

The FWORD data type is defined as 6 bytes so how is it translated to a 32 bit virtual address in the jmp instruction:

    jmp FWORD PTR [eax-0x67]

?...

like image 819
Bhubhu Hbuhdbus Avatar asked Sep 14 '12 21:09

Bhubhu Hbuhdbus


2 Answers

When you jump to an FWORD PTR, what you're doing is a "far jump" -- that is, the memory being pointed at contains a 16-bit "selector" (which refers to a segment entry in either the GDT or LDT), and a 32-bit offset from the beginning of the segment the selector refers to. The segment descriptor contains data about the segment, of course...including where in memory it starts.

During the jump, the CPU does some privilege checks to make sure the selector is valid and permitted (there's privilege levels and segment types and such involved), then it effectively loads the first 16 bits into CS, and the rest into EIP. From then on, code addresses effectively get the CS segment's base address added to them to turn them into virtual addresses.

like image 65
cHao Avatar answered Nov 16 '22 17:11

cHao


A far jump use the full segment base:offset value as an absolute address, so it is composed from 16bit segment and 32bit address. It perform jump to an instruction located in a different segment than the current code segment but it should be at the same privilege level.

like image 29
GJ. Avatar answered Nov 16 '22 18:11

GJ.