CopyBits, menu, some strange

First I want to apologize for my English. I am student from Russia. =)

I programming Mirror Driver. For now - I catch DrvCopyBits, something work.

But problem - sometimes I catch disappear menu, but sometimes no!

More strange things:

Cursor moving dont catch too.

This is good code(all catch and I happy):
BOOL DrvCopyBits(
OUT SURFOBJ *psoDst,
IN SURFOBJ *psoSrc,
IN CLIPOBJ *pco,
IN XLATEOBJ *pxlo,
IN RECTL *prclDst,
IN POINTL *pptlSrc
)
{
BOOL resu;
ULONG zet;
RECTL pRclResult;
// RECT_ENUM RectEnum; // Clip enumerator
int crects = 0;
BOOL bMore;
CLIPRECTS cr;
RECTL* prclClip;
POINTL SrcPoint;

UNREFERENCED_PARAMETER(pco);
UNREFERENCED_PARAMETER(pxlo);
UNREFERENCED_PARAMETER(prclDst);
UNREFERENCED_PARAMETER(pptlSrc);

resu=EngCopyBits(psoDst, psoSrc, pco, pxlo, prclDst, pptlSrc);
if (psoDst)
{
if (psoDst->dhpdev)
{
PPDEV ppdev = (PPDEV) psoDst->dhpdev;
if(ppdev->pvTmpBuffer)
{
if (prclDst!=NULL)
{
//zet always in 1…1999
zet=((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1;
if (zet>(MAXCHANGES_BUF-1)) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect,prclDst,sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}
}
}
}
return resu;
}

And all good. But I readed, so code above very expensive, and need find intersection pco with prclDst.

So, becouse it I write this, code(problem with disapper menu, how I said):

BOOL DrvCopyBits(
OUT SURFOBJ *psoDst,
IN SURFOBJ *psoSrc,
IN CLIPOBJ *pco,
IN XLATEOBJ *pxlo,
IN RECTL *prclDst,
IN POINTL *pptlSrc
)
{
BOOL resu;
ULONG zet;
RECTL pRclResult;
// RECT_ENUM RectEnum; // Clip enumerator
int crects = 0;
BOOL bMore;
CLIPRECTS cr;
RECTL* prclClip;
POINTL SrcPoint;

UNREFERENCED_PARAMETER(pco);
UNREFERENCED_PARAMETER(pxlo);
UNREFERENCED_PARAMETER(prclDst);
UNREFERENCED_PARAMETER(pptlSrc);
resu=EngCopyBits(psoDst, psoSrc, pco, pxlo, prclDst, pptlSrc);
//pco->rclBounds.left,pco->rclBounds.top,pco->rclBounds.right,pco->rclBounds.bottom
if (psoDst)
{
if (psoDst->dhpdev)
{
PPDEV ppdev = (PPDEV) psoDst->dhpdev;
if(ppdev->pvTmpBuffer)
{
if (pco!=NULL)
{
if (pco->iDComplexity==DC_RECT)
{
//DC_RECT
DISPDBG((0,“DC_RECT Driver DrvCopyBits: %d %d %d %d %d %d \n”,pco->rclBounds.left,pco->rclBounds.top,pco->rclBounds.right,pco->rclBounds.bottom));
//zet always in 1…1999
zet=(((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1)%MAXCHANGES_BUF;
if (zet==0) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect,&pco->rclBounds,sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}else if ((pco->iDComplexity==DC_COMPLEX)&&(prclDst!=NULL))
{
// DC_COMPLEX:

CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, CD_ANY, 0);

do
{
bMore = CLIPOBJ_bEnum(pco, sizeof(cr), (ULONG*)&cr);
for (prclClip = &cr.arcl[0]; cr.c != 0; cr.c–, prclClip++)
{
if (bIntersect(prclDst, prclClip, prclClip)) //(src,src,dest)
{
DISPDBG((0,“DC_COMPLEX Driver DrvCopyBits: %d %d %d %d \n”,prclClip->left,prclClip->top,prclClip->right,prclClip->bottom));
//zet always in 1…1999
zet=(((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1)%MAXCHANGES_BUF;
if (zet==0) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect,prclClip,sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}
}
} while (bMore);

}
} else if(prclDst!=NULL)
{
//zet always in 1…1999
zet=((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1;
if (zet>(MAXCHANGES_BUF-1)) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect,prclDst,sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}
}
}
}
return resu;
}

Please dont kill me for this hampful code - I only study.

Thank you for you reply.

By the way, I know about DrvSaveScreenBits. But I found, so:

* Why haven’t we implemented DrvSaveScreenBits? To save code.
*
* When the driver doesn’t hook DrvSaveScreenBits, USER simulates on-
* the-fly by creating a temporary device-format-bitmap, and explicitly
* calling DrvCopyBits to save/restore the bits. Since we already hook
* DrvCreateDeviceBitmap, we’ll end up using off-screen memory to store
* the bits anyway (which would have been the main reason for implementing
* DrvSaveScreenBits). So we may as well save some working set.

So I don’t hook DrvSaveScreenBits.

xxxxx@mail.ru wrote:


UNREFERENCED_PARAMETER(pco);
UNREFERENCED_PARAMETER(pxlo);
UNREFERENCED_PARAMETER(prclDst);
UNREFERENCED_PARAMETER(pptlSrc);
resu=EngCopyBits(psoDst, psoSrc, pco, pxlo, prclDst, pptlSrc);

Just as a side note, those UNREFERENCED_PARAMETER notations are wrong,
because you are using all four of those parameters in the above call.
That doesn’t affect the code in any way.

You are handling iDComplexity of DC_COMPLEX and DC_RECT, but not
DC_TRIVIAL. You should handle that the same as when pco is NULL.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you for your reply, Tim Roberts!

So if I delete these line:

UNREFERENCED_PARAMETER(pco);
UNREFERENCED_PARAMETER(pxlo);
UNREFERENCED_PARAMETER(prclDst);
UNREFERENCED_PARAMETER(pptlSrc);
resu=EngCopyBits(psoDst, psoSrc, pco, pxlo, prclDst, pptlSrc);

this not affect the work of miirror driver?

In the beginning I did so:



if (pco!=NULL)
{
if (pco->iDComplexity==DC_RECT)
{
//DC_RECT
//zet always in 1…1999
zet=(((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1)%MAXCHANGES_BUF;
if (zet==0) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect, &pco->rclBounds, sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}else if ((pco->iDComplexity==DC_COMPLEX)&&(prclDst!=NULL))
{
// DC_COMPLEX:
CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, CD_ANY, 0);
do
{
bMore = CLIPOBJ_bEnum(pco, sizeof(cr), (ULONG*)&cr);
for (prclClip = &cr.arcl[0]; cr.c != 0; cr.c–, prclClip++)
{
if (bIntersect(prclDst, prclClip, prclClip)) //(src,src,dest)
{
//zet always in 1…1999
zet=(((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1)%MAXCHANGES_BUF;
if (zet==0) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect, prclClip, sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}
}
} while (bMore);
}
}

But code above don’t catch disappear menu and moving of the cursor.
And, I append to code above, so:

if (pco!=NULL)
{
code above

} else if(prclDst!=NULL) // if pco==NULL, need for cath disappear menu
{
//zet always in 1…1999
zet=((PCHANGES_BUF) ppdev->mypchangebuf)->counter+1;
if (zet>(MAXCHANGES_BUF-1)) zet=1;
memcpy(&((PCHANGES_BUF) ppdev->mypchangebuf)->pointrect[zet].rect, prclDst, sizeof(RECTL));
((PCHANGES_BUF) ppdev->mypchangebuf)->counter=zet;
}

But at this code, some changes sometimes cath, but sometimes no. For instance - disappering of menu, sometimes cath but sometimes no, as I said.

Where I wrong? I misunderstand… =( …

xxxxx@mail.ru wrote:

Thank you for your reply, Tim Roberts!

So if I delete these line:

UNREFERENCED_PARAMETER(pco);
UNREFERENCED_PARAMETER(pxlo);
UNREFERENCED_PARAMETER(prclDst);
UNREFERENCED_PARAMETER(pptlSrc);
resu=EngCopyBits(psoDst, psoSrc, pco, pxlo, prclDst, pptlSrc);

this not affect the work of miirror driver?

You should be able to figure this out. The UNREFERENCED_PARAMETER
macros are there to suppress compiler warnings when you have function
parameters that are not used. However, you ARE using those parameters,
so the macros should not be present.

The EngCopyBits call, on the other hand, is important. That’s what does
the work of drawing on your copy of the desktop.

But at this code, some changes sometimes cath, but sometimes no. For instance - disappering of menu, sometimes cath but sometimes no, as I said.

I still don’t see you handling DC_TRIVIAL.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.