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.
I define a temporary data segment that saves GDTR,and then I
want to read the second descriptor data in GDT using instruction
sgdt,but when I want to get the data by base address in GDTR,
I don't know what data segment I must use,How to read data?
Look:
;Temporary data segment
tseg segment use16
db 100 dup(0)
tseg ends
;In P-Mode
mov ax,datat_sel ;datat_sel is the temporary data segment selector
mov ds,ax
mov bx,0
sgdt fword ptr [bx] ;To save GDTR into temporary data segment
mov esi,[bx+2] ;Save GDT base address into ESI
;Following instruction is error,the PC is always restart when it run,How to correct it?
mov dh,[esi+7] ;I wand to read the second descriptor
The GDT itself is exempt from segmentation, so if nontrivial segmentation is actually in use, you'll have to find a way to determine what virtual address corresponds to the linear address returned by sgdt.
And even then, paging may still refuse access. If you're running in ring 3 or it's not your OS, the amount of data you can probably get is either not apparently useful or leads to a potential security breach. Which leads to the question: what do you want to achieve with the GDT contents, and for what reason do you think you need SGDT for that?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:The GDT itself is exempt from segmentation, so if nontrivial segmentation is actually in use, you'll have to find a way to determine what virtual address corresponds to the linear address returned by sgdt.
And even then, paging may still refuse access. If you're running in ring 3 or it's not your OS, the amount of data you can probably get is either not apparently useful or leads to a potential security breach. Which leads to the question: what do you want to achieve with the GDT contents, and for what reason do you think you need SGDT for that?
In a segment description,its property bit 0 expresses
if the segment is accessed,so I want to read the value about accessed property,
Could you tell me how to do?
SGDT expects a 48 bit operand. None of the 32 bit registers can hold this value. If you do use a 32 bit resister only LIMIT portion of the GDT is stored in the register. Hence, it is recommended to dynamically allocate memory and pass this address as an operand to the SGDT instruction. I use something like this in my debugging utility, works awesome.
As Combuster said, paging might be a trouble in some cases. This can be resolved by identity mapping the 1st megabyte of the memory and then copying the GDT to somewhere inside this memory range. At most, paging can be kept disabled until you complete this task.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
leetow2003 wrote:I want to read the value about accessed property,
Could you tell me how to do?
Why did you spam a new thread when the real question is asked and answered in an old thread, created by yourself? You created the GDT, you installed the same GDT, so you should know the actual locations to read/write to get the necessary information. You do not need SGDT or any segmentation opcode for it.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]