Printer driver GDI punting problem
- From: bookmark <bookmark@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 25 Jan 2008 02:52:00 -0800
I am writing my first printer driver, based on the DDK sample. It is a
user-mode driver for a monochrome printer.
I want to hook the GDI DrvXxx graphics calls (DrvBitBlt, DrvStrokePath
etc.), punt back to GDI to perform the drawing operation, and then access the
resulting bitmap so that I can transmit the relevant portion of it to the
printer. In DrvEnableSurface I create an engine-managed surface to use when
punting back to GDI, and a device-managed surface so that I can hook the
DrvXxx drawing functions :-
HSURF DrvEnableSurface( DHPDEV dhpdev )
{
PPDEV pPDev = (PPDEV) dhpdev;
SIZEL SurfaceSize;
LONG lWidth;
SurfaceSize.cx = 808;
SurfaceSize.cy = 592;
lWidth = 101;
// create bitmap...
pPDev->pbBitmap = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
(SIZE_T) ( 808 * 592 ) );
// create engine-managed surface using our bitmap...
if ( ! ( pPDev->hsurfEng = (HSURF) EngCreateBitmap( SurfaceSize, lWidth,
BMF_1BPP, BMF_TOPDOWN, pPDev->pbBitmap ) ) )
{
return NULL;
}
// create device-managed surface so that we can hook the DrvXxx drawing
functions...
if ( ! ( pPDev->hsurfDev = (HSURF) EngCreateDeviceSurface( (DHSURF)
pPDev, SurfaceSize, BMF_1BPP ) ) )
{
EngDeleteSurface( pPDev->hsurfEng );
return NULL;
}
// associate device-managed surface with GDI engine's hpdev...
if ( ! EngAssociateSurface( pPDev->hsurfDev, (HDEV) pPDev->hpdev,
HOOK_BITBLT | HOOK_STRETCHBLT | HOOK_COPYBITS | HOOK_STROKEPATH |
HOOK_FILLPATH | HOOK_STROKEANDFILLPATH | HOOK_TEXTOUT ) )
{
EngDeleteSurface( pPDev->hsurfEng );
EngDeleteSurface( pPDev->hsurfDev );
return NULL;
}
return pPDev->hsurfDev;
}
And then in the DrvXxx drawing routines I punt back using the engine-managed
surface. For example, in DrvTextOut :-
BOOL DrvTextOut(
SURFOBJ *pso,
STROBJ *pstro,
FONTOBJ *pfo,
CLIPOBJ *pco,
RECTL *prclExtra,
RECTL *prclOpaque,
BRUSHOBJ *pboFore,
BRUSHOBJ *pboOpaque,
POINTL *pptlBrushOrg,
MIX mix
)
{
BOOL bResult;
SURFOBJ *pSurfObj;
PPDEV pPDev = (PPDEV) pso->dhpdev;
// obtain a SURFOBJ for our engine-managed surface...
pSurfObj = EngLockSurface( pPDev->hsurfEng );
// punt back to GDI using our engine-managed surface...
bResult = EngTextOut( pSurfObj, pstro, pfo, pco, prclExtra, prclOpaque,
pboFore, pboOpaque, pptlBrushOrg, mix );
EngUnlockSurface( pSurfObj );
return bResult;
}
The problem that I have is that although EngTextOut returns TRUE, nothing is
drawn onto the bitmap. This is true for all the DrvXxx drawing functions that
I hook.
Can anybody tell me why this should be so?
.
- Follow-Ups:
- Re: Printer driver GDI punting problem
- From: Tim Roberts
- Re: Printer driver GDI punting problem
- From: Ivan Brugiolo [MSFT]
- Re: Printer driver GDI punting problem
- Prev by Date: Re: NDIS driver and interface name
- Next by Date: Re: How to use MSVAD wave on terminal server
- Previous by thread: Re: How to Call IoRegisterFsRegistrationChangeEx?
- Next by thread: Re: Printer driver GDI punting problem
- Index(es):
Relevant Pages
|