GDI hook driver

Hello everyone,

I've been looking around for some printer/display driver which can hook a 
GDI function. I would like to understand how you can 'catch' a function like 
'CDC.LineTo(...)' in an application and do something else like saving these 
instructions to perhaps a textfile.

In the DDK I've found some samples like MSPlot (Printer), Mirror (Video). 
But they're so different from eachother, except from their initialization 
proces.

Now I've read about the Source file, Makefile and the operation when 
createDC(...) is called. 

So the basic idea:

In the application
some_event()
{
  CDC dc = createDC(...);
 dc.LineTo(...);
}

I would like to catch this dc.LineTo() and do something else with it, 
instead of letting it draw on screen.

Does anyone know where I can find easy understandable information? Or where 
the hooking process is broken down in pieces?
0
Utf
3/2/2010 9:54:01 AM
development.device.drivers 941 articles. 0 followers. Follow

4 Replies
958 Views

Similar Articles

[PageSpeed] 37

One of the best books on the topic is still
(10+ years after its publication, and despite being out-of-print)
Windows Graphics Programming: Win32 GDI and DirectDraw
Hewlett-Packard Professional Books
Feng Yuan

That will take you in the details of why a driver for a printer and
a display driver are the same (in a given context), and, you'll understand 
why
what you are trying to do can be accomplished with a mirror driver.
-- 

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Metroickha" <Metroickha@discussions.microsoft.com> wrote in message 
news:5FC8E95B-9122-47D8-BBB5-F511FC888F40@microsoft.com...
> Hello everyone,
>
> I've been looking around for some printer/display driver which can hook a
> GDI function. I would like to understand how you can 'catch' a function 
> like
> 'CDC.LineTo(...)' in an application and do something else like saving 
> these
> instructions to perhaps a textfile.
>
> In the DDK I've found some samples like MSPlot (Printer), Mirror (Video).
> But they're so different from eachother, except from their initialization
> proces.
>
> Now I've read about the Source file, Makefile and the operation when
> createDC(...) is called.
>
> So the basic idea:
>
> In the application
> some_event()
> {
>  CDC dc = createDC(...);
> dc.LineTo(...);
> }
>
> I would like to catch this dc.LineTo() and do something else with it,
> instead of letting it draw on screen.
>
> Does anyone know where I can find easy understandable information? Or 
> where
> the hooking process is broken down in pieces? 

0
Ivan
3/2/2010 11:05:03 AM
Thanks, but this books seems out-of-print. And not available here in the 
Netherlands. :( Any other options?

"Ivan Brugiolo [MSFT]" wrote:

> One of the best books on the topic is still
> (10+ years after its publication, and despite being out-of-print)
> Windows Graphics Programming: Win32 GDI and DirectDraw
> Hewlett-Packard Professional Books
> Feng Yuan
> 
> That will take you in the details of why a driver for a printer and
> a display driver are the same (in a given context), and, you'll understand 
> why
> what you are trying to do can be accomplished with a mirror driver.
> -- 
> 
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of any included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> 
> 
> "Metroickha" <Metroickha@discussions.microsoft.com> wrote in message 
> news:5FC8E95B-9122-47D8-BBB5-F511FC888F40@microsoft.com...
> > Hello everyone,
> >
> > I've been looking around for some printer/display driver which can hook a
> > GDI function. I would like to understand how you can 'catch' a function 
> > like
> > 'CDC.LineTo(...)' in an application and do something else like saving 
> > these
> > instructions to perhaps a textfile.
> >
> > In the DDK I've found some samples like MSPlot (Printer), Mirror (Video).
> > But they're so different from eachother, except from their initialization
> > proces.
> >
> > Now I've read about the Source file, Makefile and the operation when
> > createDC(...) is called.
> >
> > So the basic idea:
> >
> > In the application
> > some_event()
> > {
> >  CDC dc = createDC(...);
> > dc.LineTo(...);
> > }
> >
> > I would like to catch this dc.LineTo() and do something else with it,
> > instead of letting it draw on screen.
> >
> > Does anyone know where I can find easy understandable information? Or 
> > where
> > the hooking process is broken down in pieces? 
> 
> .
> 
0
Utf
3/4/2010 11:28:01 AM
You can try to find the book as used in the Amazon Marketplace,
or equivalent services.

That said, the landscape for mirror drivers is, more or less, the following:
There are about 70+ commercial solutions that I know of
built on the WDK 'mirror' example.
(Anything from screen reader, screen magnifier, accessibility application,
network projector, wannabe TS replacement, remote-access solutions).
All of them seems to suffer from common classes of problems
(device bitmap support, alphablend/transparentblt support) but,
they get the job done.
You can start from there, and, forget about intercepting NtGdi
at a higher level in the stack.

-- 

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Metroickha" <Metroickha@discussions.microsoft.com> wrote in message 
news:9270E9BF-8E8C-43BF-84A7-B21A38FAA254@microsoft.com...
> Thanks, but this books seems out-of-print. And not available here in the
> Netherlands. :( Any other options?
>
> "Ivan Brugiolo [MSFT]" wrote:
>
>> One of the best books on the topic is still
>> (10+ years after its publication, and despite being out-of-print)
>> Windows Graphics Programming: Win32 GDI and DirectDraw
>> Hewlett-Packard Professional Books
>> Feng Yuan
>>
>> That will take you in the details of why a driver for a printer and
>> a display driver are the same (in a given context), and, you'll 
>> understand
>> why
>> what you are trying to do can be accomplished with a mirror driver.
>> -- 
>>
>> --
>> This posting is provided "AS IS" with no warranties, and confers no 
>> rights.
>> Use of any included script samples are subject to the terms specified at
>> http://www.microsoft.com/info/cpyright.htm
>>
>>
>> "Metroickha" <Metroickha@discussions.microsoft.com> wrote in message
>> news:5FC8E95B-9122-47D8-BBB5-F511FC888F40@microsoft.com...
>> > Hello everyone,
>> >
>> > I've been looking around for some printer/display driver which can hook 
>> > a
>> > GDI function. I would like to understand how you can 'catch' a function
>> > like
>> > 'CDC.LineTo(...)' in an application and do something else like saving
>> > these
>> > instructions to perhaps a textfile.
>> >
>> > In the DDK I've found some samples like MSPlot (Printer), Mirror 
>> > (Video).
>> > But they're so different from eachother, except from their 
>> > initialization
>> > proces.
>> >
>> > Now I've read about the Source file, Makefile and the operation when
>> > createDC(...) is called.
>> >
>> > So the basic idea:
>> >
>> > In the application
>> > some_event()
>> > {
>> >  CDC dc = createDC(...);
>> > dc.LineTo(...);
>> > }
>> >
>> > I would like to catch this dc.LineTo() and do something else with it,
>> > instead of letting it draw on screen.
>> >
>> > Does anyone know where I can find easy understandable information? Or
>> > where
>> > the hooking process is broken down in pieces?
>>
>> .
>> 
0
Ivan
3/5/2010 6:51:44 PM
can you explain a bit more the "common classes of problems"...I didn't get 
that part?


"Ivan Brugiolo [MSFT]" wrote:

> You can try to find the book as used in the Amazon Marketplace,
> or equivalent services.
> 
> That said, the landscape for mirror drivers is, more or less, the following:
> There are about 70+ commercial solutions that I know of
> built on the WDK 'mirror' example.
> (Anything from screen reader, screen magnifier, accessibility application,
> network projector, wannabe TS replacement, remote-access solutions).
> All of them seems to suffer from common classes of problems
> (device bitmap support, alphablend/transparentblt support) but,
> they get the job done.
> You can start from there, and, forget about intercepting NtGdi
> at a higher level in the stack.
> 
> -- 
> 
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of any included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> 
> 
> "Metroickha" <Metroickha@discussions.microsoft.com> wrote in message 
> news:9270E9BF-8E8C-43BF-84A7-B21A38FAA254@microsoft.com...
> > Thanks, but this books seems out-of-print. And not available here in the
> > Netherlands. :( Any other options?
> >
> > "Ivan Brugiolo [MSFT]" wrote:
> >
> >> One of the best books on the topic is still
> >> (10+ years after its publication, and despite being out-of-print)
> >> Windows Graphics Programming: Win32 GDI and DirectDraw
> >> Hewlett-Packard Professional Books
> >> Feng Yuan
> >>
> >> That will take you in the details of why a driver for a printer and
> >> a display driver are the same (in a given context), and, you'll 
> >> understand
> >> why
> >> what you are trying to do can be accomplished with a mirror driver.
> >> -- 
> >>
> >> --
> >> This posting is provided "AS IS" with no warranties, and confers no 
> >> rights.
> >> Use of any included script samples are subject to the terms specified at
> >> http://www.microsoft.com/info/cpyright.htm
> >>
> >>
> >> "Metroickha" <Metroickha@discussions.microsoft.com> wrote in message
> >> news:5FC8E95B-9122-47D8-BBB5-F511FC888F40@microsoft.com...
> >> > Hello everyone,
> >> >
> >> > I've been looking around for some printer/display driver which can hook 
> >> > a
> >> > GDI function. I would like to understand how you can 'catch' a function
> >> > like
> >> > 'CDC.LineTo(...)' in an application and do something else like saving
> >> > these
> >> > instructions to perhaps a textfile.
> >> >
> >> > In the DDK I've found some samples like MSPlot (Printer), Mirror 
> >> > (Video).
> >> > But they're so different from eachother, except from their 
> >> > initialization
> >> > proces.
> >> >
> >> > Now I've read about the Source file, Makefile and the operation when
> >> > createDC(...) is called.
> >> >
> >> > So the basic idea:
> >> >
> >> > In the application
> >> > some_event()
> >> > {
> >> >  CDC dc = createDC(...);
> >> > dc.LineTo(...);
> >> > }
> >> >
> >> > I would like to catch this dc.LineTo() and do something else with it,
> >> > instead of letting it draw on screen.
> >> >
> >> > Does anyone know where I can find easy understandable information? Or
> >> > where
> >> > the hooking process is broken down in pieces?
> >>
> >> .
> >> 
> .
> 
0
Utf
3/23/2010 7:01:01 AM
Reply:

Similar Artilces:

Print Driver Problem
Hello, I have office 2003 that includes publisher. I also have an HP Office Jet Pro 8K50. I can print successfully to this printer with a test print and all other office applications like word and outlook. However, when I try to print a publisher file, I get an error message that says "Cannot load printer driver". I click OK but the documents do not print. I loaded this driver from the CD that came with the printer and did a full install at the time. The printer is only two months old so it is very new and designed to work with XP Professional which is what I have on my ...

GDI+ and resizing a PictureBox
I am using GDI+ in one of my VB6 apps(mainly for anti aliasing support). It works fine, but when I create the Graphics object, which takes a PictureBox hDC. It never draws outside the PictureBox original size if I make it bigger later, as if the Graphics object gets the hDC size only when it's created, and truncates any drawing to that. Is there a way to tell the Graphics object the new width and height? Also, hDC remains the same throughout the life of the control, except when you make the control bigger and AutoRedraw=True(because VB needs to create a bigger bitmap). Whe...

OPOS Driver #2
I'm using an Epson TM88IV, I am using a cable that converts the parrellel to a USB port. I have downloaded the Epson ADK program. I can not get it to work. If I select the TM88IVU it can not find the USB port. I don't know what to do. Any help? You have a parallel printer that you are trying to plug into a USB Port, or you have a USB Printer that you are trying to plug into a Parallel port? I think the first thing above is the only one that exists, but you described the second... Anyway, if you have a parallel printer, select the TM88ivP (for both the printer and the cash draw...

To draw to GDI within a thread
Hello, i have a thread running with a loop of methods, they are drawing to the GDI (not GDI+). But there are no results on screen. It is like i would draw into a null-device. I've tested the following soultion: dont draw itself within a thread, but changing in this thread some parameters and call InvalidateRect. On WM_PAINT my main-program draws with the changed Parameters. But if there are more threads than one, it is very strange what happends. In my draw- and change-routine i've testet EnterCriticalSection and all that, it doesnt matter. When i have a simple thread with a unti...

GDI handles
In taskmanager I see the amount of used GDI and user objects per process. How can I achieve this using a powershell script on Windows XP using PowerShell 1.0? The result should be a list with all process names, PIDs and amount of used GDI objects. I played with the following: PS H:\> (Get-WmiObject -Class Win32_OperatingSystem -ComputerName ..).InvokeMethod("GetGuiResources",0) Method invocation failed because [System.Management.ManagementObject#root\cimv2\Win32_OperatingSystem] doesn't contain a method named 'InvokeMethod'. At line:1 char:74 + (G...

Building a common driver binary for both XP, Vista and 7
I would like to build a device driver binary (.sys file) that can be used in both Windows XP, Vista and 7. I know I have to build a separate driver binary for 32-bit (x86) and 64-bit (x64), but is it possible to use each of these drivers on both XP, Vista and 7? Should I use the WDK build environment for the oldest OS (XP in this case) to build the driver? We do something similar. We build 32-bit for Windows XP, and 64-bit for Windows Server 2003. That will run on all those OSes. Latest (Win7) WDK is fine. Also - If your driver uses WDF, you will need to decide on a WDF ver...

Code to hook and monitor Registry and File access?
Does anyone have code or a link to some documentation on how to hook and monitor Registry and File access in Windows 2000/XP? Thanks a lot in advance. Have a look here. http://www.sysinternals.com . May not have all the source code your looking for but loaded with good stuff! Regards, Paul Lyons "Chad" <serey_sweet@yahoo.com> wrote in message news:092701c38ebe$ee7b1500$a101280a@phx.gbl... > Does anyone have code or a link to some documentation on > how to hook and monitor Registry and File access in > Windows 2000/XP? > > Thanks a lot in advance. ...

GDI+ mfc save Bitmap to File Stream
Hi, I am using GDI+ in mfc. I have a file pointer declared as File *fpOut; This file pointer is also used for writing to other text data to the file. I am not sure how to save an image to this file stream. When Bitmap.Save function to save to stream the first parameter is of type IStream and not FILE. Any suggestions on what can be done? Thanks, -Asfar ...

Can't link to a driver support DLL from MFC application
I have build a support DLL for modification of some printer properties and have now difficulties to link to the DLL and the functions in it. For 1. when looking into the DLL with Dependency Walker I see that there are two DLL's included which seem not to be on systems before Win 7 (IEShims.DLL and Wer.Dll) and 2. when trying to load the support DLL with LoadLibrary I get error 127 (The specified procedure could not be found) and the function fails to provide a handle and 3. When linking to the DLL I am getting a fatal error LNK1107: invalid or corrupt file: cannot read at...

Streaming Video Using GDI+
Hello, I am having trouble trying to stream the pixel data, being feed to the computer by a framegrabber. Using GDI+ i have managed to display the image but it is just one image and nothing more, and the program begin to slow. I cannot see what it is i am doing wrong? Can anybody help me? I feed it the data from the framegrabbers in as InterBuffer. I use the while loop to spit the images to the screen. while(welcome==false){ BYTE* InterBuffer = new BYTE[bufSize]; Rect rect12(0,0,acqWinWidth,acqWinHeight); Rect rc(50,60,abs(acqWinWidt...

GDI/GDI+ stop drawing after a while on Windows 7
I have an app that I developed some time ago for W2K. The app draws text and graphics onto a CView derived window using GDI+. It also hosts shockwave flash player that occasionally plays a clip in the same window. The app could work 24x7 on W2K and XP. I'm now testing the app on Windows 7 Home Premium. I'm running into a strange problem. After running it for a while - sometimes it could be a couple of hours, another times a couple of days - the app simply stops drawing to the screen. That is, the app still calls the necessary APIs but nothing happens on the screen...

Camera Driver
I work for a hardware manufacturer and we're including a still camera in our PC. We need to provide an interface for applications to access and control this camera and don't know how best to do this. My reading so far suggests there are 3 options: A DirectX filter, a WIA driver or a WPD driver. Most documentation seems to suggest that we should use WPD, but as an application developer, I would expect to be provided with a DirectX filter, and as far as I can see WPD does not provide this. Given that we need to support windows XP onwards, which route should we take? Al...

Planner for Driver's weekly journeys
I require a weekly/monthly planner for driver's journeys some of which occur on a regular basis ...

GDI+ vs GDI
for Visual Studio 2003.NET MFC application, how to set the config to use GDI+ instead of GDI? #include "GDIPlus.h" using namespace Gdiplus; AliR. "kathy" <yqin_99@yahoo.com> wrote in message news:1142011037.071111.256860@j52g2000cwj.googlegroups.com... > for Visual Studio 2003.NET MFC application, how to set the config to > use GDI+ instead of GDI? > http://www.codeproject.com/vcpp/gdiplus/gdi__and_mfc.asp Tom "kathy" <yqin_99@yahoo.com> wrote in message news:1142011037.071111.256860@j52g2000cwj.googlegroups.com... > for Visual ...

gdi -> gdi+ in a programm
Hello, I have a native C++ programm with own classes Label, Button, List, ... for everything and an own font-list.... Up to now, I use GDI, only in special case like 'display png-files' I use GDI+. Now the programm has to draw text transparent with 40..80%. My plan is to change the whole painting of all classes to GDI+. I make a test with WinNT - it works, so the operating system is not a problem. Has anybody experiences with GDI+ - is it quick enough ? Are there other restrictions ? -- Frank Iversen "fiversen" <fiversen@wedding.in-berlin.de> wrote in messa...

OFN_OVERWRITEPROMPT and Save As Hook Proc
I'm using CFileDialog with a Save As hook proc so that I can validate the extension when I receive the CDN_FILEOK notification. I have the OFN_OVERWRITEPROMPT flag set so that the dialog should check whether the file exists before closing. If the user enters a filename with an extension, and the file already exists, all is well; CFileDialog puts up an alert asking the user if he really wanted to replace the file. If, however, the user does *not* enter an extension, then, even if my hook proc *adds* the extension to the file name, no alert appears. This seems to be because the chec...

problem with GDI+
Hello, I've got a problem with GDI+. I want to draw some shapes in a view class CPlotView which is a child of CScrollView. In OnDraw section I use this code: void CPlotView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); Gdiplus::Graphics g(pDC->m_hDC); Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 255)); g.DrawLine(&pen,0,0,100,100); } But nothig appears in the window. If I use standard GDI, for example pDC->LineTo(10,10,100,100); everything works. Where do I do a mistake? Thank you in advance for help, Tomek The Gdiplus.dll must be copied to the system d...

WS2003/XP/2000 Driver signing
I'm trying to sign a winxp USB driver which is for USB serial emulation using usbser.sys. If I self-sign with a local certificate, it will install without the warning and looks to be fine. When I try to install the driver signed with my Class 3 code signing VeriSign certificate, it shows that the .cat file is signed properly, but the installer says it isn't signed. I'm not sure what my problem is. I'm trying to walk through the documentation to see what I could have missed. I'm wondering if it is related to having it WHQL signed, but if that were the ca...

OPOS Drivers Scale
Hi there I was wondering if any one had previously used a ACOM scale with RMS. I am trying o located the OPOS for it. if not what other options are availabe. -- Cheers Topi ...

GDI+
hi, i am working with GDI+. when i tried the following in OnPaint() of my dialog class (i am working with dialog based application) Graphics graphics(&dc); // Create a GDI+ graphics object Image image(L"F:\\testg.Gif"); // Construct an image graphics.DrawImage(&image, 0, 0, image.GetWidth, image.GetHeight()); got an error message 'Graphics' : undeclared identifier i have included gdiplus.h in my stdafx.h and given the path to include,library files and gdiplus.lib in my settings tab. anu hi anu #include <GdiPlusGraphics.h> sreeram &quo...

How to hook maximize/restore button in system menu
I need my application to hook (intercept) when the user has clicked "restore/maximice" buttom, so that the behabiour of the window will not be the standard one, but customized (the button will make the window bigger or smaller, swapping between two possible sizes of using it, but there is no use in a whole-screen-window) To get this my code should be executed before the actual maximizing/restoring of the window, and after my code has been executed this maximizing/restoring should never happen. Which window messages should I catch to get this? Thanks a lot!! Ricardo. You need to ...

Post Script Print Driver
I need to build a post script print driver that pulls an xml manifest from a server on our intranet and then displays custom options in the print dialog. In other words, I need to customize an area of a post script print driver dialog box to collect user info, before sending the print job and of course send the collected variables along with the print job. How do you suggest I go about this? Are there any drivers in the wdk I should use as the base code? One more thing I should mention.. I am a senior C# coder, I have never built a driver before, and I realize I must learn C...

GDI+ #3
hi, i want to load an image in the InitDilog() and also on a mouse click. when i tried it in OnPaint() i am getting the image. but using InitDialog()its not coming.the coding is as follows CClientDC dc(this); Graphics graphics(dc.m_hDC); Image image(L"F:\\testg.gif",FALSE); // Construct an image graphics.DrawImage(&image, 10, 10, image.GetWidth(), image.GetHeight()); please help. anu anu wrote: > > hi, > > i want to load an image in the InitDilog() and also on a > mouse click. when i tried it in OnPaint() i am getting the > image. but using InitDia...

MFC and GDi+
I have just a little experience with MFC in VS6. I had occasion to use CDC::AngleArc() for a small, 180 degree arc with pen width 2 and the results looked pretty poor. I understand that GDI+ does edge anti-aliasing but I can't find clear information about the integration of MFC and GDI+. A fairly unclear article in CodeProject seems to say that MFC and GDI+ are easy to integrate by adding a few lines to a few files. Does this mean that CDC::AngleArc() results would look much better or do I need to make code changes to get GDI+ features? Alternatively, If I used VC++ and MFC in VS.NET ...

Vista Unsigned Driver Issue
I have a File System Filter driver that we have designed and built. We went through the signing process and have received the signed .cat files from Winqual. I have a custom installer application (32-bit) for our product. When I try and install the driver with this installer application, it goes through the entire process of installing it and completes. Looking at the setupapi.app log file there was no error in there. However, after a number of moments the "Program Compatibility Assistant" message box appears saying that "Windows requires a digitally signed driv...