Capturing bits copied beyond primary display in a mirror driver

Discussion in 'Windows Vista Drivers' started by Ronny S, Apr 3, 2006.

  1. Ronny S

    Ronny S Guest


    I'm trying to mirror the output of a BitBlt executed in user mode at a
    position beyond the primary display (1024,0) in a mirror driver. The user
    application executes the following code:

    // initialize DEVMODE
    DEVMODE devmode;
    FillMemory(&devmode, sizeof(DEVMODE), 0);
    devmode.dmSize = sizeof(DEVMODE);
    devmode.dmBitsPerPel = 32;
    devmode.dmPelsWidth = 50;
    devmode.dmPelsHeight = 50;
    devmode.dmPosition.x = 1024;
    devmode.dmPosition.y = 0;

    // change display settings
    int code = ChangeDisplaySettingsEx(deviceName, &devmode, NULL,
    code = ChangeDisplaySettingsEx(deviceName, &devmode, NULL, 0, NULL);

    HDC hdc = CreateDC("DISPLAY", deviceName, NULL, NULL);

    // we should be hooked as layered at this point
    HDC hdc2 = CreateCompatibleDC(hdc);

    // call DrvCreateDeviceBitmap
    HBITMAP hbm = CreateCompatibleBitmap(hdc, 50, 50);
    SelectObject(hdc2, hbm);

    // blt 50x50 to destination 1024,0
    BitBlt(hdc2, 0, 0, 50, 50, hdc, 1024, 0, SRCCOPY);

    Using WinDbg, I can verify that DrvBitBlt function (hooked in the kernel
    driver) was not being called in response to BitBlt. However, changing
    devmode.dmPosition.x to 0 resulted in the calls being routed to DrvBitBlt.

    Can anyone explain what is missing from the above code? Any suggestions are
    much appreciated.
    Ronny S, Apr 3, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.