Oops. Surprised to see it crashed :). Never I have seen a crash on my system. <br><br>Regards,<br>Prabhu<br><br><br><div class="gmail_quote">On Tue, Jan 18, 2011 at 1:29 PM, Alexandre Courbot <span dir="ltr"><<a href="mailto:gnurou@gmail.com">gnurou@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Tue, Jan 18, 2011 at 3:40 PM, Prabhu nath <<a href="mailto:gprabhunath@gmail.com">gprabhunath@gmail.com</a>> wrote:<br>
> If you are working on a desktop machine, then the following idea works.<br>
> Usually, the VGA compatible controller memory will be mapped to the physical<br>
> address space which can be viewed with the help of "lspci -vv" command. Then<br>
> open the device file "/dev/mem" and mmap with the offset equal to the<br>
> physical address of the Graphics card. Here is a small snippet which works<br>
> on my machine<br>
</div><div class="im">> Now open the device mem as<br>
> fd = open = ("/dev/mem", O_RDWR)<br>
> and do an mmap as<br>
> vgamem = mmap (NULL, 0x10000000, PROT_READ | PROT_WRITE,<br>
> MAP_SHARED, fd, 0xd0000000)<br>
> 0x10000000 = 256MB of graphics card memory<br>
> 0xd0000000 = base of the physical address of graphics card memory<br>
><br>
> vgamem will be the user virtual address which is mapped to the physical<br>
> address of Graphics card memory.<br>
><br>
> To verify the mapping, write some bit patterns to 256MB of memory starting<br>
> from vgamem.<br>
> If you see distortion on your desktop, then you have written on to your<br>
> graphics card<br>
> memory.<br>
<br>
</div>Just gave it a shot, for the fun of it (program attached - needs root<br>
rights). Indeed after running it my screen was stripped with little<br>
black dots, as one could expect. However it also screwed my fonts and<br>
after a few seconds crashed my system. ;) Indeed, the video memory<br>
does not only contain the screen framebuffer, it also hosts other data<br>
related to 3d management, compositing, and probably data structures<br>
that X rely on. But at least this validates your approach to easily<br>
access video memory.<br>
<br>
Now all that is needed for Elvis to get the screen contents is to know<br>
the boundaries of the screen's buffer, as well as its format.<br>
Following your idea, he could probably access the memory-mapped<br>
registers of his video card, but this is highly vendor-dependant.<br>
Cannot think of a more generic way though.<br>
<br>
Alex.<br>
</blockquote></div><br>