CSecurity
asked on
C++ hook printed documents and save
I want a piece of code which will hook printer jobs, if a document was going to be printed, I want to save that as an image. How it is possible? I can hook printer jobs, but I want to see and save also document itself. Is it possible? Please advice.
Thanks from now!
Thanks from now!
ASKER
How about if I have a shared printer and a person sent it via share and send document to my printer to be printed?
Or
I print it to a remote printer?
Hooking WritePrinter will intercept both of these 2 methods?
Or
I print it to a remote printer?
Hooking WritePrinter will intercept both of these 2 methods?
here's a good article, it may not be explicitly relevant but should help in guiding you
http://www.thedbcommunity.com/index.php?option=com_content&task=view&id=218&Itemid=56
http://www.thedbcommunity.com/index.php?option=com_content&task=view&id=218&Itemid=56
ASKER
Thanks but I wasn't able to find any method for hooking Printer or getting document data of currently printing jobs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also If someone is Printing from remote computer to your Pc(On which Printer is installed), Your spoolsv will be getting the data to Print. and it will be directed to WritePrinter.
If Print is going from Your PC to a network Printer, you will be getting two or three prints for the same document in Spoolsv, that is because of windows trying to send it across the network , but You will get only one StartDocPrinter and EndDocPrinter for corresponding printer.
If Print is going from Your PC to a network Printer, you will be getting two or three prints for the same document in Spoolsv, that is because of windows trying to send it across the network , but You will get only one StartDocPrinter and EndDocPrinter for corresponding printer.
ASKER
Do you know any piece of code for hooking printer?
I can't give you a code now, but you can use MadHOOK and carry on your working.
The MadDLL helps you to make a hooking chain of API's .
You will find it here
http://www.madshi.net/madCodeHookDescription.htm
The MadDLL helps you to make a hooking chain of API's .
You will find it here
http://www.madshi.net/madCodeHookDescription.htm
You have to hook Pinter Api -- WritePrinter for Spoolsv.exe
But If User is printing through windows application it will call
ExttextOutA/W, TextOutA/W functions directly to Printer DC
Once You get the data you can save in your desired format