Im playing in 64bit longmode
Can i directly transfer control from ring 0 to ring 3
i use far jmp to ring 3 GDT but the code raise exception.
Code: Select all
jmp gdt_code_ring3:ring3_code
ring3_code:
thanks...
Code: Select all
jmp gdt_code_ring3:ring3_code
ring3_code:

Yes and No. If you mean 'can I do it with a far jump', the answer is no. You do it in the same way as you currently do your task switches (I assume if you have got to playing with ring 3, you do have a scheduler by now?).orange wrote: Can i directly transfer control from ring 0 to ring 3


I have OCD too!Caps your I's!!!
Sorry OCD

Are you serious?orange wrote:Sorry what that mean OCD????![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Code: Select all
ORG 0x7C00
USE16
cli
lgdt [cs:GDTR]
mov eax,cr0
or al,1
mov cr0,eax
jmp 8:PM_Start
GDTR: dw 5*8-1
dd GDT
GDT: dw 0x0000,0x0000,0x0000,0x0000 ; (0) NUll Selector
dw 0xFFFF,0x0000,0x9A00,0x00CF ; (8) Code Segment 32bit ring 0
dw 0xFFFF,0x0000,0x9200,0x00CF ; (16) Data Segment 32bit ring 0
dw 0xFFFF,0x0000,0xFA00,0x00CF ; (24) Code Segment 32bit ring 3
dw 0xFFFF,0x0000,0xF200,0x00CF ; (32) Data Segment 32bit ring 3
USE32
PM_Start:
mov ax,16
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov gs,ax
mov eax,'P M '
mov [0xB8000],eax
push dword 32 ; SS
push dword Stack_Top ; ESP
push dword 0 ; EFLAGS
push dword 24 ; CS
push dword PM_Ring3 ; EIP
iret ; Jmp to ring 3
PM_Ring3:
mov ax,32
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov eax,'R 3 '
mov [0B8000h],eax
jmp PM_Ring3
db 512 dup (0)
Stack_Top:
Thank's AdamAJ wrote:You need the RPL of the segment to be 3. That means, or the value 24 with 3. I must say, I prefer these things to be shown in hex, especially when setting / clearing bits. This means it becomes 0x18 | 0x03.
I test in vmware, because i can't use bochs. How to load img file without floppy in bochs??.If you test it in Bochs first, it will tell you what the error is which makes debugging a lot easier!
Code: Select all
push dword 35 ; SS
push dword Stack_Top ; ESP
push dword 0 ; RFLAGS
push dword 27 ; CS
push dword PM_Ring3 ; EIP
iret ; Jmp to ring 3