why cannot i access GDT with PL changed

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kybyw
Posts: 2
Joined: Sun Jun 15, 2008 7:48 am

why cannot i access GDT with PL changed

Post by kybyw »

i>amibition:access GDT
ii>enviroment:
windows2003sp2;syser debugger;masm32v9.
iii>method:
1.asm code:

Code: Select all

    sgdt gdtr               ;this ins can be run in ring3
    lea eax,gdtr
    mov eax,[eax+2]         ;eax<--->GDT baseaddress<---->8003f000
    add eax,48h             ;in my computer 48h is reserved
    
    mov esi,eax             
    lea edi,bakgdt
    movsd
    movsd
   
2.change PL
1>segement protection:
stage1:es=23h;RPL=3;TI=0[GDT];Index=4;
stage2:GDTR=8003f000;PA=3f000;GDT[4](3f020h---3f028h)=00cff3000000ffff;
base=0;G=1&D=1&E=0&ED=0&R/W=1--->code32 readable.
--
DPL=3;NO NEED TO CHANGE.
2>page protection:
LA=8003f048;cr3=39000
stage1:page directory table.peekd 39800--->3b163
U/S=0;---->NEED CHANGE--->poked 39800 3b167.
stage2:page table.peekd 3b0fc--->3f163.
NEED CHANGE--->poked 3b0fc 3f167...
---------------------
iv>question:
All done then why i got a ACESS_VOLIDATION error???
----------
thx in advance...
regs from kybyw
kybyw
Posts: 2
Joined: Sun Jun 15, 2008 7:48 am

Re: why cannot i access GDT with PL changed

Post by kybyw »

i have solved this question.
----
i didn't consider the factor of task swtich.after a task switch,the cr3 will refresh,so does the page directory table.
so i edited the wrong page directory entry.the page directory entry changed belong to system's or explores?
---
reason:
directly using Ctrl+f12 to active syser then change the PDE(page directory entry)
--
solution:
use syser to load the exe and then get the right cr3 value and change the right page directory entry.
Post Reply