Display Mirror Driver:: Screen Updates in BYTEs

Discussion in 'Windows Vista Drivers' started by manmeeth.k, Jun 24, 2008.

  1. manmeeth.k

    manmeeth.k Guest


    I am developing a display mirror driver for a VNC type
    application .The following is a description of the work so far I did
    and some of the issues faced. Please let me know where i have gone

    I dont have device driver experience, so I depend on the DDK sample
    and the group archive.

    First of my objective was to get the screen updates in BYTEs from the
    Mirror driver. I hope this is possible from mirror driver,, isnt it ?.
    and in the next stage i will try to transfer this data to a user mode
    componet to send to the viewing client.

    Taking DrvCopyBits as an example, my concept was the sourc surface
    (SURFOBJ*) in this API will have the sreeen data in BYTEs and the
    CLIPOBJ will have the RECT where updates done. This yield me a buffer
    "psoSrc->pvBits". But I found this buffer is not at all changing.

    On reading the archives, I got a feeling that, punting back to GDI may
    change the buffer, so that I could get the exact data that I am
    looking for.

    For punting, I did the following..(for clarity, i have removed return
    type checking and some initializations in the below code)

    HSURF DrvEnableSurface(DHPDEV dhpdev)
    PPDEV ppdev;
    HSURF hsurf = NULL, hsurf1 = NULL;
    SIZEL sizl;
    ULONG ulBitmapType;
    FLONG flHooks;
    ULONG mirrorsize;
    MIRRSURF *mirrsurf;
    DHSURF dhsurf;
    PPDEV ppdev = (PPDEV) dhpdev;

    // Create engine bitmap around frame buffer.
    SURFOBJ* surf1; SURFOBJ* surf2;

    ppdev->ulBitCount = 32;
    ulBitmapType = BMF_32BPP;
    flHooks = HOOKS_BMF32BPP;

    mirrorsize = (ULONG)(sizeof(MIRRSURF) + ppdev->lDeltaScreen *

    mirrsurf = (MIRRSURF *) EngAllocMem(FL_ZERO_MEMORY,mirrorsize,

    //let GDI create an eng managed surface, and GDI
    allocates the space
    hsurf1 = (HSURF)EngCreateBitmap(sizl, ppdev->lDeltaScreen,
    ulBitmapType, BMF_NOZEROINIT,NULL);

    dhsurf = (DHSURF) mirrsurf;

    //ask GDI create a device managed surface
    hsurf = (HSURF)EngCreateDeviceBitmap(dhsurf, sizl, ulBitmapType);

    surf1 = EngLockSurface(hsurf);
    surf2 = EngLockSurface(hsurf1);

    surf1->dhsurf = (DHSURF)surf2;

    EngAssociateSurface(hsurf, ppdev->hdevEng, flHooks);

    ppdev->hsurfEng = (HSURF) hsurf;
    ppdev->pvTmpBuffer = (PVOID) dhsurf;

    mirrsurf->cx = ppdev->cxScreen;
    mirrsurf->cy = ppdev->cyScreen;
    mirrsurf->lDelta = ppdev->lDeltaScreen;
    mirrsurf->ulBitCount = ppdev->ulBitCount;
    mirrsurf->bIsScreen = TRUE;

    and i punt it like

    BOOL DrvCopyBits(OUT SURFOBJ *psoDst,IN SURFOBJ *psoSrc,
    IN CLIPOBJ *pco,IN XLATEOBJ *pxlo,IN RECTL *prclDst,
    IN POINTL *pptlSrc)

    SURFOBJ *surfObj ;
    BOOL retVal = FALSE;

    if (psoSrc && pco)
    DISPDBG((0, "psoSrc->cjBits %d", psoSrc->cjBits));
    if(psoSrc->pvBits != NULL)
    DISPDBG((0, "psoSrc->pvBits is Valid"));
    dbg_pkt((PBYTE) psoSrc->pvBits, 50);

    if (psoDst)
    if (psoDst->dhsurf)
    surfObj = (SURFOBJ *)psoDst->dhsurf;
    retVal = EngCopyBits(surfObj,psoSrc,pco,pxlo,prclDst,pptlSrc);
    // debug message
    return FALSE;
    I punt back only the "DrvCopyBits". Anyway, this code run without blue
    screen as EngCopyBits return TRUE. Now I could see the "psoSrc-
    buffer of length 0xFFFF.

    Please advice me, where I have gone wrong and what else I need to do
    for getting the screen data from Mirror driver continuously. ?. Any
    sort of info will be helpfull as I an new to windows driver

    Manmeeth Kaur
    manmeeth.k, Jun 24, 2008
    1. Advertisements

  2. manmeeth.k

    Tim Roberts Guest

    Remember that a mirror driver is entirely separate from the main display
    driver. You don't have access to the main frame buffer. The principle is
    that every drawing request that goes to the main display driver ALSO goes
    to your mirror driver. If you want a copy of the screen image, then your
    mirror driver must MAKE the changes, just like it was the main driver.

    Then, after you make the changes, you can send the changed bytes back.

    Also, the CLIPOBJ is just the outer limits on what can be drawn. Usually,
    the CLIPOBJ is the same as the window that is being drawn. The actual
    drawing rectangle is different for each operation. For DrvCopyBits, the
    changed rectangle will be the intersection of prclDst with the CLIPOBJ.
    Of course. To get the result of the CopyBits, you'll have to DO the
    CopyBits first.
    Tim Roberts, Jun 26, 2008
    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.