Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a 64bit call gate

In intel software developer maunal, the call instruction support:

call r/m64
call m16:32
call m16:64

In the user code, if I want to transfer to ring 0 via a 64-bit call-gate with selector 47. How to write the instruction in assembly using intel syntax?

Tested:

call far [mem]; wrong
call qword ptr [mem]; wrong

memory content:

[mem + 0]: qword 0x00
[mem + 8]: word 47
like image 335
Gary Yin Avatar asked Nov 01 '22 04:11

Gary Yin


1 Answers

The correct keyword to use is fword ptr. This will generate the m16:32 variant, but since for call gates the offset is ignored and the full 64 bits of RIP will be loaded from the gate, this will be fine. However if you want to keep the m16:64 pointer, then you will have to manually include a REX prefix, like rex64 call fword ptr [mem] or rex.w call fword ptr [mem].

like image 122
Jester Avatar answered Nov 09 '22 11:11

Jester