Why cannot I get dmCopies from DEVMODE when I print in MSWORD?

Hello,

I am trying to develop a print monitor.But I get a serveral problem.Wish
somebody could give me any help.

First,I hooked EndDocPrinter API and use GetJob to retrive information of
Job.Most parameter in DEVMODE structure is right,but when I print a document
in MSWORD, dmCopies always is set “1”. This is why? Is this a bug of
Microsoft?

Second, I hooked Windows API PrintDlg, but when I print in notepad,MSWORD
etc…PrintDlg is not be passthrough.This is why? PrintDlg is not be
invoked when printing in Notpad,MSWORD?

Third,In DEVMODE structure,there is a parameter named “dmNup”, and it has
relation with two const “DMNUP_SYSTEM” and “DMNUP_ONEUP”,all of them is not
available.That means I cannot find their protype or declaration in
wingdi.h.This is why? What on earch is Microsoft doing?

Who can help me?

Hello,

First thing is you are asking wrong questions at wrong place, you should post them on NTDEV.

Following are my comments about ur questions

First:
I dont know

Second:
Couple of reasons:

  1. The function is not called at all. Make sure that notepad/MSWORD invokes PrintDlg(A/W) function.
  2. Since you are having a user mode hook make sure that u are actually hooking the functions in that process’s address space. Well this is a most fundamental thing of user mode hooking and you might already be doing it.
  3. Your hooking logic has gone wrong. May be your DLL is not getting injected properly, you are not hooking the proper functions etc. What function are u hooking PrintDlgA or PrintDlgW?

Third:
These are the values which I have copied form wingdi.h. I think you are using a very old SDK version. Upgrade the SDK to the latest version.
#define DMNUP_SYSTEM 1
#define DMNUP_ONEUP 2

Coming back to what Microsoft is doing on this earth, I think Microsoft is distributing platform SDKs which MS expects ppl to install and upgrade periodically, secondly it is distributing MSDN which contains ample of information on how to do user mode hooking properly, and lastly it is supporting the NTFSD mailing list which is meant for File System related discussions but still ppl on this list do answer totally unrelated questions of user mode hooking…

thanks
-Kiran

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of (SCT)???
Sent: Wednesday, November 26, 2003 2:28 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Why cannot I get dmCopies from DEVMODE when I print in
MSWORD?

Hello,

I am trying to develop a print monitor.But I get a serveral problem.Wish
somebody could give me any help.

First,I hooked EndDocPrinter API and use GetJob to retrive information of
Job.Most parameter in DEVMODE structure is right,but when I print a document
in MSWORD, dmCopies always is set “1”. This is why? Is this a bug of
Microsoft?

Second, I hooked Windows API PrintDlg, but when I print in notepad,MSWORD
etc…PrintDlg is not be passthrough.This is why? PrintDlg is not be
invoked when printing in Notpad,MSWORD?

Third,In DEVMODE structure,there is a parameter named “dmNup”, and it has
relation with two const “DMNUP_SYSTEM” and “DMNUP_ONEUP”,all of them is not
available.That means I cannot find their protype or declaration in
wingdi.h.This is why? What on earch is Microsoft doing?

Who can help me?


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@calsoftinc.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Dear Kiran,

Thank you for answering my question.

For Second question:
I am sure my hook is correct, because other hook function like
StartDocPrinter(A\W), EndDocPrinter etc… runs well.
Then I think maybe Notepad/MSWORD does not invoke PrintDlg(A/W) function at
all.
How can I get user input information(eg. nCopies) when printing a document.
For your question, I am developing a print monitor and need to get print
information like copies and totalpages.
I invoke GetJob API to get what I want when EndDocPrinter API is invoked by
system.
Next is my result:
PrintedDocPage UserInputCopies GetJobReturnedPages
GetJobReturnedCopies RealPrintedPages
1 1 1
1 1
1 3 1
1 3
3 3 3
1 9
The result is bothering , all right ?
Now I think maybe my thought is not correct,Could you give me any advice?
Thank you very much,you are so kind.
For third question :
I am so sorry. My sdk is old.Thank you!

----- Original Message -----
From: “Kiran Joshi”
To: “Windows File Systems Devs Interest List”
Sent: Wednesday, November 26, 2003 5:47 PM
Subject: [ntfsd] RE: Why cannot I get dmCopies from DEVMODE when I print in
MSWORD?

Hello,

First thing is you are asking wrong questions at wrong place, you should
post them on NTDEV.

Following are my comments about ur questions

First:
I dont know

Second:
Couple of reasons:
1. The function is not called at all. Make sure that notepad/MSWORD invokes
PrintDlg(A/W) function.
2. Since you are having a user mode hook make sure that u are actually
hooking the functions in that process’s address space. Well this is a most
fundamental thing of user mode hooking and you might already be doing it.
3. Your hooking logic has gone wrong. May be your DLL is not getting
injected properly, you are not hooking the proper functions etc. What
function are u hooking PrintDlgA or PrintDlgW?

Third:
These are the values which I have copied form wingdi.h. I think you are
using a very old SDK version. Upgrade the SDK to the latest version.
#define DMNUP_SYSTEM 1
#define DMNUP_ONEUP 2

Coming back to what Microsoft is doing on this earth, I think Microsoft is
distributing platform SDKs which MS expects ppl to install and upgrade
periodically, secondly it is distributing MSDN which contains ample of
information on how to do user mode hooking properly, and lastly it is
supporting the NTFSD mailing list which is meant for File System related
discussions but still ppl on this list do answer totally unrelated questions
of user mode hooking…

thanks
-Kiran

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of (SCT)???
Sent: Wednesday, November 26, 2003 2:28 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Why cannot I get dmCopies from DEVMODE when I print in
MSWORD?

Hello,

I am trying to develop a print monitor.But I get a serveral problem.Wish
somebody could give me any help.

First,I hooked EndDocPrinter API and use GetJob to retrive information of
Job.Most parameter in DEVMODE structure is right,but when I print a document
in MSWORD, dmCopies always is set “1”. This is why? Is this a bug of
Microsoft?

Second, I hooked Windows API PrintDlg, but when I print in notepad,MSWORD
etc…PrintDlg is not be passthrough.This is why? PrintDlg is not be
invoked when printing in Notpad,MSWORD?

Third,In DEVMODE structure,there is a parameter named “dmNup”, and it has
relation with two const “DMNUP_SYSTEM” and “DMNUP_ONEUP”,all of them is not
available.That means I cannot find their protype or declaration in
wingdi.h.This is why? What on earch is Microsoft doing?

Who can help me?


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@calsoftinc.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: lijp@sh.sct-grp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com