Printer API hooking

c++ / delphi package - dll injection and api hooking
Post Reply
Kaarigar
Posts: 101
Joined: Mon Oct 23, 2006 7:43 pm

Printer API hooking

Post by Kaarigar »

What APIs should I hook in order to control the Print Dialog? I have already tried hooking into PrintDlg/Ex/A/W functions in comdlg32.dll but that doesn't seem to do the trick for me. Are there any other ways of displaying the Printer dialog? I am working on Windows 7 64bit using Delphi XE and NOT doing system wide hooking. Any help is really appreciated.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: Printer API hooking

Post by madshi »

I've zero experience with hooking the Print Dialog, so there isn't much I can tell you. Does hooking PrintDlg(Ex) not work at all? If so, seemingly a different dialog is used. In that case you could try hooking CreateWindow(Ex), ShowWindow and all the other window related APIs. Or you could use SetWindowsHookEx instead of madCodeHook. Don't really know what to recommend here...
iconic
Site Admin
Posts: 1065
Joined: Wed Jun 08, 2005 5:08 am

Re: Printer API hooking

Post by iconic »

@Karrigar,

You might try installing Rohitab's free API Monitor tool to see which calls are behind the printer dialog in Windows 7, it supports both 32-bit and 64-bit Windows OS. You can read more here http://www.rohitab.com/apimonitor

--Iconic
Kaarigar
Posts: 101
Joined: Mon Oct 23, 2006 7:43 pm

Re: Printer API hooking

Post by Kaarigar »

iconic wrote: You might try installing Rohitab's free API Monitor tool to see which calls are behind the printer dialog in Windows 7, it supports both 32-bit and 64-bit Windows OS. You can read more here http://www.rohitab.com/apimonitor
Thanks iconic, I will give that tool a try.
Kaarigar
Posts: 101
Joined: Mon Oct 23, 2006 7:43 pm

Re: Printer API hooking

Post by Kaarigar »

Ok, the print dialog was cleverly designed to look like a customized comdlg32 print dialog. That explains why no calls were being made to comdlg32. So following madshi and iconic's advice, I tried to check from where the print dialog was being created. There were many calls coming from MFCUI dll for all the controls on the window, so it became almost impossible to see which one was the real one. Finally I found one call which resulted in the showing up of the print dialog window, but that was a call to create a window whose style was combobox. Then I tried to hook ShowWindow but that also turned out to be futile. Fortunately I found an API in the app itself that I am hooking that was being used to create and show the print dialog. Hooking that has solved my problem - but it is still a mystery how the print dialog window is created a displayed - but I am not an expert.

Thanks to madshi and iconic! I really like API Monitor tool - does it use madCodeHook internally?
iconic
Site Admin
Posts: 1065
Joined: Wed Jun 08, 2005 5:08 am

Re: Printer API hooking

Post by iconic »

Kaarigar,

Glad that you have solved your issue. The tool does not use madCodeHook, instead it manipulates the import address table (IAT) to redirect function calls, depending on the method selected of course.

--Iconic
Post Reply