Ctl code problem

Hi All,
I am trying to pass some input data to driver through ctl code based on input data driver is supposed to do read and write operation .

Although i am getting the ctl code but with some garbage value not the actual value that i am passing from user mode.

I want to know in which condition this kind of problem are likely to happen and what i should do so that i can overcome from this problem.

Just for cheking i tried every combination like METHOD_BUFFERED,METHOD_IN_DIRECT,METHOD_OUT_DIRECT with FILE_READ_ACCESS,
FILE_WRITE_ACCESS in every case i am getting the ctl code but with garbage value.

i set the flags as DO_BUFFERED_IO in add device.

Regards


Call friends with PC-to-PC calling – FREE
http://get.live.com/messenger/overview

Show us the user mode code, the issue may be there.

d

Sent using my smartphone, apologies forany typos

-----Original Message-----
From: “nayan kumar”
To: “Windows System Software Devs Interest List”
Sent: 10/26/07 6:09 PM
Subject: [ntdev] Ctl code problem

Hi All,
I am trying to pass some input data to driver through ctl code based on input data driver is supposed to do read and write operation .

Although i am getting the ctl code but with some garbage value not the actual value that i am passing from user mode.

I want to know in which condition this kind of problem are likely to happen and what i should do so that i can overcome from this problem.

Just for cheking i tried every combination like METHOD_BUFFERED,METHOD_IN_DIRECT,METHOD_OUT_DIRECT with FILE_READ_ACCESS,
FILE_WRITE_ACCESS in every case i am getting the ctl code but with garbage value.

i set the flags as DO_BUFFERED_IO in add device.

Regards

________________________________
Call friends with PC-to-PC calling – FREE Try it now!http:

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</http:>

Hi ,
Thanks for your reply.
Acyually i was using pragma pack(push,1) in user mode code because of which i was not getting the proper value in the driver .

if we are using this in driver is it same like it behave in user mode application .

If you can throw some light about advantage and disadvantage of using this in driver or can give some pointer or link of tutorial which describes about this as far as using this in driver i would be very thankfull to you.Regards

From: xxxxx@microsoft.comTo: xxxxx@lists.osr.comDate: Fri, 26 Oct 2007 18:32:02 -0700Subject: RE: [ntdev] Ctl code problem

Show us the user mode code, the issue may be there.

d

Sent using my smartphone, apologies forany typos

-----Original Message-----
From: “nayan kumar”
To: “Windows System Software Devs Interest List”
Sent: 10/26/07 6:09 PM
Subject: [ntdev] Ctl code problem

Hi All, I am trying to pass some input data to driver through ctl code based on input data driver is supposed to do read and write operation . Although i am getting the ctl code but with some garbage value not the actual value that i am passing from user mode. I want to know in which condition this kind of problem are likely to happen and what i should do so that i can overcome from this problem. Just for cheking i tried every combination like METHOD_BUFFERED,METHOD_IN_DIRECT,METHOD_OUT_DIRECT with FILE_READ_ACCESS,FILE_WRITE_ACCESS in every case i am getting the ctl code but with garbage value. i set the flags as DO_BUFFERED_IO in add device. Regards

Call friends with PC-to-PC calling – FREE Try it now!— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
_________________________________________________________________
Call friends with PC-to-PC calling – FREE
http://get.live.com/messenger/overview

Unless you need a specific byte packing b/c you are creating a structure that represents hardware registers or you are sending it over a network, you typically do not use 1 byte packing and leave the structure at its natural alignment. You can see performance degradation on certain processors when you access 2- or 4- or 8- byte fields that are not naturally aligned for their respective sizes.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of nayan kumar
Sent: Sunday, October 28, 2007 10:07 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Ctl code problem

Hi ,
Thanks for your reply.
Acyually i was using pragma pack(push,1) in user mode code because of which i was not getting the proper value in the driver .

if we are using this in driver is it same like it behave in user mode application .

If you can throw some light about advantage and disadvantage of using this in driver or can give some pointer or link of tutorial which describes about this as far as using this in driver i would be very thankfull to you.
Regards


From: xxxxx@microsoft.com
To: xxxxx@lists.osr.com
Date: Fri, 26 Oct 2007 18:32:02 -0700
Subject: RE: [ntdev] Ctl code problem

Show us the user mode code, the issue may be there.

d

Sent using my smartphone, apologies forany typos

-----Original Message-----

From: “nayan kumar”

To: “Windows System Software Devs Interest List”

Sent: 10/26/07 6:09 PM

Subject: [ntdev] Ctl code problem

Hi All,
I am trying to pass some input data to driver through ctl code based on input data driver is supposed to do read and write operation .

Although i am getting the ctl code but with some garbage value not the actual value that i am passing from user mode.

I want to know in which condition this kind of problem are likely to happen and what i should do so that i can overcome from this problem.

Just for cheking i tried every combination like METHOD_BUFFERED,METHOD_IN_DIRECT,METHOD_OUT_DIRECT with FILE_READ_ACCESS,
FILE_WRITE_ACCESS in every case i am getting the ctl code but with garbage value.

i set the flags as DO_BUFFERED_IO in add device.

Regards

Call friends with PC-to-PC calling – FREE Try it now!http:

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Call friends with PC-to-PC calling – FREE Try it now!http:

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</http:></http:>

Hi,
Thank you very much for your guidence i will keep in my mind your suggession.

Regards

From: xxxxx@microsoft.comTo: xxxxx@lists.osr.comDate: Sun, 28 Oct 2007 13:57:22 -0700Subject: RE: [ntdev] Ctl code problem

Unless you need a specific byte packing b/c you are creating a structure that represents hardware registers or you are sending it over a network, you typically do not use 1 byte packing and leave the structure at its natural alignment. You can see performance degradation on certain processors when you access 2- or 4- or 8- byte fields that are not naturally aligned for their respective sizes.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of nayan kumarSent: Sunday, October 28, 2007 10:07 AMTo: Windows System Software Devs Interest ListSubject: RE: [ntdev] Ctl code problem

Hi , Thanks for your reply.Acyually i was using pragma pack(push,1) in user mode code because of which i was not getting the proper value in the driver . if we are using this in driver is it same like it behave in user mode application . If you can throw some light about advantage and disadvantage of using this in driver or can give some pointer or link of tutorial which describes about this as far as using this in driver i would be very thankfull to you.Regards

From: xxxxx@microsoft.comTo: xxxxx@lists.osr.comDate: Fri, 26 Oct 2007 18:32:02 -0700Subject: RE: [ntdev] Ctl code problemShow us the user mode code, the issue may be there. d Sent using my smartphone, apologies forany typos -----Original Message-----From: “nayan kumar” To: “Windows System Software Devs Interest List” Sent: 10/26/07 6:09 PMSubject: [ntdev] Ctl code problem

Hi All, I am trying to pass some input data to driver through ctl code based on input data driver is supposed to do read and write operation . Although i am getting the ctl code but with some garbage value not the actual value that i am passing from user mode. I want to know in which condition this kind of problem are likely to happen and what i should do so that i can overcome from this problem. Just for cheking i tried every combination like METHOD_BUFFERED,METHOD_IN_DIRECT,METHOD_OUT_DIRECT with FILE_READ_ACCESS,FILE_WRITE_ACCESS in every case i am getting the ctl code but with garbage value. i set the flags as DO_BUFFERED_IO in add device. Regards

Call friends with PC-to-PC calling – FREE Try it now!— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Call friends with PC-to-PC calling – FREE Try it now!— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
_________________________________________________________________
Check out some new online services at Windows Live Ideas?so new they haven?t even been officially released yet.
http://www.msnspecials.in/windowslive/

nayan kumar wrote:

Hi ,
Thanks for your reply.
Acyually i was using pragma pack(push,1) in user mode code because of
which i was not getting the proper value in the driver .

if we are using this in driver is it same like it behave in user mode
application .

If you can throw some light about advantage and disadvantage of using
this in driver or can give some pointer or link of tutorial which
describes about this as far as using this in driver i would be very
thankfull to you.

#pragma pack has no effect on a control code. It only affects
structures. So, it can certainly change the meaning of the data
structures that you pass WITH the ioctl.

The rule (and it should be obvious) is that the producer (user-mode) and
the consumer (kernel mode) must use the same packing. I do that by
putting all of my ioctl definitions in a single file, along with their
structures, explicitly specify the packing in that file, and then
include that file in both the driver and the applications.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.