can someone post me how to enter in usermode (ring3) in x86-64!?!?! I've tried using the classic IRET method but i cant figure out why it doesn't work...
This is my GDT
Code: Select all
align 0x10
global gdt64
gdt64:
; null descriptor
dw 0,0,0,0
; ring 0 code segment descriptor
dw 0x0 ; limit 15:0 = 0
dw 0x0 ; base low = 0
db 0x0 ; base middle = 0
db 10011000b ; access
db 00100000b ; flags + limit 19:16
db 0x0 ; base high
; ring 0 data segment descriptor
dw 0x0 ; limit 15:0 = 0
dw 0x0 ; base address = 0
db 0x0 ; base middle = 0
db 10010000b ; access
db 00000000b ; flags + limit 19:16
db 0x0 ; base high
; ring 3 code segment descriptor
dw 0x0
dw 0x0
db 0x0
db 11111000b
db 00100000b
db 0x0
; ring 3 data segment descriptor
dw 0x0
dw 0x0
db 0x0
db 10010000b
db 00000000b
db 0x0
Code: Select all
global enter_usermode
enter_usermode:
push 0x0 ; ss
mov rax, qword 0x7f7ffffffff0 ; rsp
push rax
pushfq ; rflags
push 0x1b ; cs
mov rax, qword um ; rip
push rax
iretq
um:
I'm interested in how to enter in user mode using the SYSRET instruction as well (STAR;LSTAR etch).
I can't find any documentation about this topic for x86_64 so if someone know where is the problem...
Thanks a lot
D