Mirror driver again,,, How can I access surface(?) data?

I’ve development remote desktop…

I’ve done shared memory, and etc…

And then the next step is… read the dummy(?) screen data,

not through BitBlt GDI function(due to operation speed).

I’ve tryed… like follows…

---- DrvEnableSurface/Enable.c/dll/mirror –

// ++ objects
ppdev->lDeltaScreen = sizl.cx * (ppdev->ulBitCount/8);
// – objects
mirrorsize = (ULONG)(sizeof(MIRRSURF) +
ppdev->lDeltaScreen * sizl.cy);

mirrsurf = (MIRRSURF *) EngAllocMem(FL_ZERO_MEMORY,
mirrorsize,
0x4D495252);
DISPDBG((0, “MIRROR SIZE: %d - delta: %d - Addr: %X\n”,
mirrorsize, ppdev->lDeltaScreen, mirrsurf));

dhsurf = (DHSURF) mirrsurf;

hsurf = EngCreateDeviceSurface(dhsurf,
sizl,
ulBitmapType);

if (!EngModifySurface( hsurf,
ppdev->hdevEng,
flHooks,
MS_SHAREDACCESS,
dhsurf,
(mirrsurf + sizeof(MIRRSURF)), // Kernel Va
ppdev->lDeltaScreen, // nDelta
NULL) // Reserved
)
{
RIP(“DISRP DrvEnableSurface failed EngModifySurface\n”);
EngDeleteSurface(hsurf);
return (FALSE); // ERROR
}

And in DrvEscape

– DrvEscape/Escape.c(I added the file to communicate with App) –

switch(iEsc)
{
case …

// Allocate screen buffer & mapbuffer.
case ESC_MAP_SCREEN_INITBUF:
{
// Allocate kernel memory & mapping address.
PSHARED_BUF_INFO pBufInfo;
PPDEV pPDev;

if (cjIn != 0 || cjOut != sizeof(SHARED_BUF_INFO))
return 0;

pPDev = (PPDEV)pso->dhpdev;
pBufInfo = (PSHARED_BUF_INFO)pvOut;
pBufInfo->nSize = pPDev->cxScreen*pPDev->cyScreen
*(pPDev->ulBitCount/8);

pBufInfo->pBuf = (PVOID)(pso->dhsurf + sizeof(MIRRSURF));

if ( MemMapping( IN OUT pBufInfo) )
return 0; // ERROR

return iEsc - 0x10000;
}

case ESC_UNMAP_SCREEN_INITBUF:
{
// Free kernel memory & unmapping address.
PSHARED_BUF_INFO pBufInfo;
PPDEV pPDev;

if (cjIn != sizeof(SHARED_BUF_INFO) || cjOut != 0)
return 0;

pPDev = (PPDEV)pso->dhpdev;
pBufInfo = (PSHARED_BUF_INFO)pvIn;

if ( MemUnmapping( IN pBufInfo) )
{
DISPDBG((0, “FreeAndMemUnmapping Error\n”));
}
return iEsc - 0x10000;
}

MemMapping & MemUnmapping is wrapper function of using kernel dll.

And in application.

– main/Main.cxx/Mirror/app –
printf(“\n\n** Press ESC_MAP_SCREEN_INITBUF\n”); getchar();
nR = ExtEscape( hdc, ESC_MAP_SCREEN_INITBUF,
0, 0,
sizeof(SHARED_BUF_INFO), (LPSTR)&bi);
if (nR)
{
printf(“SIZE: %d, Buf(K:U): %X:%X, MDL: %X”,
bi.nSize, bi.pBuf, bi.pUserVa, bi.pmdl);

FILE* fp = fopen(“Dump.dat”, “w”);
if (fp == NULL)
{
printf(“fopen error\n”);
}
else
{
fwrite(bi.pUserVa, bi.nSize, 1, fp);
fclose(fp);
}

}
else
{
printf(“MAP Error!!!\n”);
bi.pmdl = NULL;
}

printf(“\n\n** Press ESC_UNMAP_SCREEN_INITBUF\n”); getchar();
nR = ExtEscape( hdc, ESC_UNMAP_SCREEN_INITBUF,
sizeof(SHARED_BUF_INFO), (LPSTR)&bi,
0, 0);

Dump.dat has so many 0 value, though my desktop background is blue or
white.

I mean the dump.dat hasn’t changed by real screen data(bitmap).

Anyway, How can I access screen bitmap data???

PS) I’ve read many article in this site, and other newgroup…
Thanks all who post the article… Thanks…

VideoPortMapMemory() will do the job.

VideoPortMapMemory is working at miniport driver level…

I mean… at display driver level…

Anyway Thanks reply…

VideoPortMapMemory() will do the job.

Hi

You need to have the page table mapped into the Driver Process to access
the frame buffer with the cpu. VideoPortMapMemory() will do that for you.
You could do it different way I would think.

I would use windbg to see if you can access the framebuffer with the eb
command. I would also use windbg to look at the page tables for the
framebuffer. Do it with windbg first.