Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to directly write to the frame buffer in windows driver

I am writing the driver that can directly write data to the frame buffer, so that I can show the secret message on the screen while the applications in user space can't get it. Below is my code that trying to write the value to the frame buffer, but after I write the value to the frame buffer, the values i retrieved from the frame buffer are all 0.

I am puzzled, anyone knows the reason? Or anyone knows how to display a message on the screen while the applications in the user space can't get the content of the message? Thanks a lot!

#define FRAME_BUFFER_PHYSICAL_ADDRESS 0xA0000
#define BUFFER_SIZE 0x20000

void showMessage()
{
    int i;
    int *vAddr;
    PHYSICAL_ADDRESS pAddr;

    pAddr.QuadPart = FRAME_BUFFER_PHYSICAL_ADDRESS;
    vAddr = (int *)MmMapIoSpace(pAddr, BUFFER_SIZE, MmNonCached);
    KdPrint(("Virtual address is %p", vAddr));

    for(i = 0; i < BUFFER_SIZE / 4; i++)
    {
        vAddr[i] = 0x11223344;
    }

    for(i = 0; i < 0x80; i++)
    {
        KdPrint(("Value: %d", vAddr[i])); // output are all zero
    }
    MmUnmapIoSpace(vAddr, BUFFER_SIZE);
}
like image 861
yorath Avatar asked Nov 05 '22 03:11

yorath


1 Answers

You must map the shared memory during device start up. I assume that showMessage isn't called during the start up. See more here.

Regarding displaying message on the screen - it must involve user-space interaction since GUI is a user-space component. I suppose you could notify some GUI listener without other applications involvement.

like image 59
SomeWittyUsername Avatar answered Nov 09 '22 09:11

SomeWittyUsername