Printer API hooking
Printer API hooking
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.
Re: Printer API hooking
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...
Re: Printer API hooking
@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
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
Re: Printer API hooking
Thanks iconic, I will give that tool a try.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
Re: Printer API hooking
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?
Thanks to madshi and iconic! I really like API Monitor tool - does it use madCodeHook internally?
Re: Printer API hooking
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
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