News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Example program(s) using debug registers ?

Started by dsouza123, July 23, 2006, 09:51:07 PM

Previous topic - Next topic

dsouza123

Does anyone have any working example code using the debug registers DR0, DR1, DR2, DR3, DR6, DR7 ?

Do or can debuggers use these six 32 bit registers ?  If so how ?

What is required to use the debug registers ?

I was hoping to use them as extra register storage.

The following minimal program triggers something in XP Pro SP2
then the OS brings up the tell MS about this problem dialogbox.


.686p
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.code
start:
  mov eax, dr0
  invoke ExitProcess,0
end start

; so does this program

.data
  get32  dd 0
  szfmtD db "%lu",0
  szC    db "The Caption",0
  szM    db "The Message ",13,10
  szZ    db 256 dup (0)

.code
start:
  mov eax, -1
  mov dr0, eax
  mov eax, 7
  mov eax, dr0
  mov get32, eax
  invoke wsprintf,ADDR szZ,ADDR szfmtD, get32
  invoke MessageBox, NULL, addr szM, addr szC, MB_OK
  invoke ExitProcess,0
end start


Just tested on an older PC, they do work correctly in Windows 95.
Attached the longer program, source and executable in the zip file.

What has to be done to get them to work in XP ?

What about other versions of Windows ?

[attachment deleted by admin]

PBrennick

Your problem is you are in protected mode.  Read upon protected mode on MSDN.  This is the age old problem, so much to do and nothing to do it with!  :bg

Paul
The GeneSys Project is available from:
The Repository or My crappy website

dsouza123

I didn't find anything about protected mode but from

http://en.wikipedia.org/wiki/Debug_register

The debug registers are privileged resources; the MOV instructions that access them can only be executed at privilege level zero.
An attempt to read or write the debug registers when executing at any other privilege level causes a general protection exception.

So why does it work in Windows 95 ?

What is necessary to write a program that can run at privilege level zero ?

Also tried it under Bochs 2.2.6 with Windows 98 SE with an emulated Athlon 64 CPU, it worked correctly.

Will it work in the other members of the Windows 95 OS family 95, 98, 98 SE, ME ?

What about NT 4 SP?, 2000 SP? ?