flat assembler
Message board for the users of flat assembler.

flat assembler > OS Construction > Debug register

Author
Thread Post new topic Reply to topic
Fulgurance



Joined: 27 Nov 2017
Posts: 62
Hello, i have just little question. Do you know an tutorial or good documentation about debug register ? I would like to use it, but i don't found many docs about it. I search code example.
Post 14 Dec 2018, 16:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16782
Location: In your JS exploiting you and your system
I think the best place to see how the x86 debug registers are used is in the official Intel and AMD documents.
Post 14 Dec 2018, 16:35
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 62
I just use Intel. I have search on Intel Book, i have found section about Debug Register, but i don't understand when this register are writting by processor and how.

How i use this interrupt? It's not very clear

https://software.intel.com/sites/default/files/managed/a4/60/325384-sdm-vol-3abcd.pdf

Is it with stack only ? I don't understand very well
Post 15 Dec 2018, 13:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16782
Location: In your JS exploiting you and your system
You can use the MOV instruction read and write the debug registers.
Code:
mov dr0,eax
mov ebx,dr1    
These are privileged instructions available in Ring 0.
Post 15 Dec 2018, 14:20
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 62
Okay. And how I interpret value of this register ? And when ?
Post 15 Dec 2018, 17:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16782
Location: In your JS exploiting you and your system
The layout of DR0..7 is quite complicated. Some registers enable various features with bit settings, and others hold linear breakpoint addresses.

Your code would write to the registers and the CPU will fault/trap when all the conditions are met. Then you catch the fault/trap with the normal exception mechanisms in your OS and show the user a breakpoint was reached.
Post 16 Dec 2018, 00:55
View user's profile Send private message Visit poster's website Reply with quote
Fulgurance



Joined: 27 Nov 2017
Posts: 62
No example ? Confused

Without example, it's quite difficult, this fonction isn't very documented...
Post 17 Dec 2018, 10:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16782
Location: In your JS exploiting you and your system
I assume you are writing your own OS based upon the forum you selected. So any example will rely upon how your OS works when exceptions happen, and how you interface with applications to allow setting the DR registers.

At the CPU level it is just a matter of setting the registers and waiting for the triggers to fire. Everything else is handled by the OS/debugger/application code.
Post 17 Dec 2018, 10:33
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.