Mail Archives: djgpp/1999/03/08/17:10:46
> I have an application where I need to set up an exception handler for
> page faults and have access to the value of cr2 (linear address to which
> access faulted). But:
> * mov cr2 is a privileged instruction.
> * There is a DPMI 1.0 exception handling function that passes it, but it
> will be tricky to make it interoperate with DJGPP's exception handlers,
> and anyway CWSDPMI doesn't support it.
Yes, this is all correct.
> I could, I suppose, use CWSDPR0 and read cr2 directly, but that's
> difficult, since virtual memory will probably be required. (It's a
> malloc debugger whose memory usage is extremely inefficient, and I want
> it to run on small boxes if possible.)
> So: Does anyone know of another way to find the value of cr2? I don't
> care about it working in anything but CWSDPMI.
There are some tricks that can probably be done to get the value:
1) Pull it out of the memory data structure using some tricks to find it.
2) Set up a ring-0 call gate and point it to some routine in your code.
This is a hole in the CWSDPMI ring-3 security on purpose to allow
such things. You will need to have an Intel reference manual and
probably the CWSDPMI source to know what needs to be done, however.
- Raw text -