User mode addresses

Hi all,

I have to deal with an user defined IOCTL which uses METHOD_NEITHER to
pass 2 buffer addresses. In my driver I use the information contained in
these buffers to create IRP_MJ_SCSI IPR’s which I sent to some device.
The problem I am having is that a) I get no data copied to my buffers or
b) I get a BUFFER_OVERRUN somewhere down in the driver I am calling. I
am having trouble debugging what is going on here. Does anyone know how
I can ensure that the addresses these pointers point to remain valid ? I
have created MDL’s for these buffers and locked them down., is that
sufficient or is it necessary for me to allocate non-paged buffers and
copy them back into the user buffer on completion ?

Does anyone know of a good example which deals with User mode virtual
addresses ?

Thanks all,
Jos.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

My first question would be are you passing the user
virtual address, or do you use MmGetSystemAddressForMdl
(or the Safe version) to get the system address and pass
that. If there is a context swap, the user virtual address
will still not be valid.

Don Burn
Windows 2000 Device Driver and Filesystem consulting

----- Original Message -----
From: “Jos Scherders”
To: “NT Developers Interest List”
Sent: Thursday, July 05, 2001 11:24 PM
Subject: [ntdev] User mode addresses

> Hi all,
>
> I have to deal with an user defined IOCTL which uses METHOD_NEITHER to
> pass 2 buffer addresses. In my driver I use the information contained in
> these buffers to create IRP_MJ_SCSI IPR’s which I sent to some device.
> The problem I am having is that a) I get no data copied to my buffers or
> b) I get a BUFFER_OVERRUN somewhere down in the driver I am calling. I
> am having trouble debugging what is going on here. Does anyone know how
> I can ensure that the addresses these pointers point to remain valid ? I
> have created MDL’s for these buffers and locked them down., is that
> sufficient or is it necessary for me to allocate non-paged buffers and
> copy them back into the user buffer on completion ?
>
> Does anyone know of a good example which deals with User mode virtual
> addresses ?
>
> Thanks all,
> Jos.
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@acm.org
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Don Burn wrote:

My first question would be are you passing the user
virtual address, or do you use MmGetSystemAddressForMdl
(or the Safe version) to get the system address and pass
that. If there is a context swap, the user virtual address
will still not be valid.

At this moment I use IoAllocateMld with the usermode address, then I
call MmProbeAndLockPages on the MLD I created. I then call some device
with a new Irp with which I associate the MLD, e.g. Irp->MldAddress is
the MLD I created.

Are you suggesting I should copy the data first ? I

JOs


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

No,

Your original statement said you are passing this
buffer to another driver. Use MmGetSystemAddressForMdl
to get the system address and pass this address, not the
user address.

Don Burn
Windows 2000 Device Driver and Filesystem consulting

----- Original Message -----
From: “Jos Scherders”
To: “NT Developers Interest List”
Sent: Friday, July 06, 2001 3:30 AM
Subject: [ntdev] Re: User mode addresses

>
>
> Don Burn wrote:
>
> > My first question would be are you passing the user
> > virtual address, or do you use MmGetSystemAddressForMdl
> > (or the Safe version) to get the system address and pass
> > that. If there is a context swap, the user virtual address
> > will still not be valid.
>
> At this moment I use IoAllocateMld with the usermode address, then I
> call MmProbeAndLockPages on the MLD I created. I then call some device
> with a new Irp with which I associate the MLD, e.g. Irp->MldAddress is
> the MLD I created.
>
> Are you suggesting I should copy the data first ? I
>
> JOs
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@acm.org
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi , don

well i really dont know weather this reply wud
suffice you or not .
but i had several problems while mapping the kernel
mode address to user mode.

This is what i did and it worked.

I got the vitual address of the buffer allocated in
the kernel mode.Now i had to pass this to the user
mode.

IOCTL was the only way out.

Now the problem was how to pass an ‘adress’ to the
user mode. so i converted the adress to a string and
then passed it to the outbuffer of the
DeviceIoControl.

In user mode i converted the string back to the adress
and then it was possible to read the data back and
forth.

I hope this helps.

– thank you

— Don Burn wrote:
> My first question would be are you passing the user
> virtual address, or do you use
> MmGetSystemAddressForMdl
> (or the Safe version) to get the system address and
> pass
> that. If there is a context swap, the user virtual
> address
> will still not be valid.
>
> Don Burn
> Windows 2000 Device Driver and Filesystem consulting
>
> ----- Original Message -----
> From: “Jos Scherders”
> To: “NT Developers Interest List”
>
> Sent: Thursday, July 05, 2001 11:24 PM
> Subject: [ntdev] User mode addresses
>
>
> > Hi all,
> >
> > I have to deal with an user defined IOCTL which
> uses METHOD_NEITHER to
> > pass 2 buffer addresses. In my driver I use the
> information contained in
> > these buffers to create IRP_MJ_SCSI IPR’s which I
> sent to some device.
> > The problem I am having is that a) I get no data
> copied to my buffers or
> > b) I get a BUFFER_OVERRUN somewhere down in the
> driver I am calling. I
> > am having trouble debugging what is going on here.
> Does anyone know how
> > I can ensure that the addresses these pointers
> point to remain valid ? I
> > have created MDL’s for these buffers and locked
> them down., is that
> > sufficient or is it necessary for me to allocate
> non-paged buffers and
> > copy them back into the user buffer on completion
> ?
> >
> > Does anyone know of a good example which deals
> with User mode virtual
> > addresses ?
> >
> > Thanks all,
> > Jos.
> >
> >
> > —
> > You are currently subscribed to ntdev as:
> xxxxx@acm.org
> > To unsubscribe send a blank email to
> leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Rock, have you considered quiting coding ?

----- Original Message -----
From: “Rock Is Dead”
To: “NT Developers Interest List”
Sent: Friday, July 06, 2001 7:56 PM
Subject: [ntdev] Re: User mode addresses

> Hi , don
>
> well i really dont know weather this reply wud
> suffice you or not .
> but i had several problems while mapping the kernel
> mode address to user mode.
>
> This is what i did and it worked.
>
> I got the vitual address of the buffer allocated in
> the kernel mode.Now i had to pass this to the user
> mode.
>
> IOCTL was the only way out.
>
> Now the problem was how to pass an ‘adress’ to the
> user mode. so i converted the adress to a string and
> then passed it to the outbuffer of the
> DeviceIoControl.
>
> In user mode i converted the string back to the adress
> and then it was possible to read the data back and
> forth.
>
> I hope this helps.
>
>
> – thank you
>
>
>
> — Don Burn wrote:
> > My first question would be are you passing the user
> > virtual address, or do you use
> > MmGetSystemAddressForMdl
> > (or the Safe version) to get the system address and
> > pass
> > that. If there is a context swap, the user virtual
> > address
> > will still not be valid.
> >
> > Don Burn
> > Windows 2000 Device Driver and Filesystem consulting
> >
> > ----- Original Message -----
> > From: “Jos Scherders”
> > To: “NT Developers Interest List”
> >
> > Sent: Thursday, July 05, 2001 11:24 PM
> > Subject: [ntdev] User mode addresses
> >
> >
> > > Hi all,
> > >
> > > I have to deal with an user defined IOCTL which
> > uses METHOD_NEITHER to
> > > pass 2 buffer addresses. In my driver I use the
> > information contained in
> > > these buffers to create IRP_MJ_SCSI IPR’s which I
> > sent to some device.
> > > The problem I am having is that a) I get no data
> > copied to my buffers or
> > > b) I get a BUFFER_OVERRUN somewhere down in the
> > driver I am calling. I
> > > am having trouble debugging what is going on here.
> > Does anyone know how
> > > I can ensure that the addresses these pointers
> > point to remain valid ? I
> > > have created MDL’s for these buffers and locked
> > them down., is that
> > > sufficient or is it necessary for me to allocate
> > non-paged buffers and
> > > copy them back into the user buffer on completion
> > ?
> > >
> > > Does anyone know of a good example which deals
> > with User mode virtual
> > > addresses ?
> > >
> > > Thanks all,
> > > Jos.
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as:
> > xxxxx@acm.org
> > > To unsubscribe send a blank email to
> > leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as:
> > xxxxx@yahoo.com
> > To unsubscribe send a blank email to
> leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
> —
> You are currently subscribed to ntdev as: danp@jb.rdsor.ro
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Well at least his moniker is well-chosen.

Rock, have you considered quiting coding ?

>
> Now the problem was how to pass an ‘adress’ to the
> user mode. so i converted the adress to a string and
> then passed it to the outbuffer of the
> DeviceIoControl.
>
> In user mode i converted the string back to the adress
> and then it was possible to read the data back and
> forth.
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Don Burn wrote:

No,

Your original statement said you are passing this
buffer to another driver. Use MmGetSystemAddressForMdl
to get the system address and pass this address, not the
user address.

Don Burn
Windows 2000 Device Driver and Filesystem consulting

In my driver I create a new IRP with Major code IRP_MJ_SCSI. In the Irp
I insert a MDL (for the buffer from user space) and I pass the user mode
address into the Srb->DataBuffer. If I pass the address I get from
MmGetSystemAddressForMdl in the Srb I get a blue screen. So right now I
am not sure what is going on here. Does anyone how the MdlAddress in the
IRP relate to the address I pass into the Srb->DataBuffer ?

Jos.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Just a thought, 'cos I can’t believe anyone with the
nouse to write a driver would seriously write the
code described.

In Terry Pratchet’s Disk World Trolls are
silicon based life forms, i.e. Rock.

Evan

-----Original Message-----
From: COX,DAVID (HP-Roseville,ex1) [mailto:david_cox2@hp.com]
Sent: 07 July 2001 03:51
To: NT Developers Interest List
Subject: [ntdev] Re: User mode addresses

Well at least his moniker is well-chosen.

Rock, have you considered quiting coding ?

>
> Now the problem was how to pass an ‘adress’ to the
> user mode. so i converted the adress to a string and
> then passed it to the outbuffer of the
> DeviceIoControl.
>
> In user mode i converted the string back to the adress
> and then it was possible to read the data back and
> forth.
>


You are currently subscribed to ntdev as: xxxxx@eicon.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

hi,
i have been a silent spectator of this mailing list and must say that i
have learnt a lot of stuff from it in the short time i have been associated
with it .This is in reff to rock is dead.I was thinking is this list for
beginners.?I mean even i have just started coding with device drivers so
probably there will be somethings which sound stupid to you guys and the way
you guys answered his mail kinda got me thinking.
thanks for reading,
ntdevguy


Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi all,
Ok i read all the flames regarding my solution to
the passing of kernel mode address to user mode which
was stupid.
I used some method which was kind of crazy.
I just wanted to say that all you people could have
even replied that this solution was stupid and could
have suggested some other solution.But you didnt.
people started suggesting
“have you thought of quitting coding?”
One of the mails which i got from one of the members
on the mailing list (offlist mail) called Mike Zirolli
reads this

"Hey you fucking “Harshal Vaidya” or whatever the fuck
you
call yourself “Your Dick is dead”.

Don’t write your fucked up solutions in the mailing
list.

From now on I will block your email ID, becoz you
suck.

You bastard."

how do you guys justify this!!!
I guess instead of me reading the netiquette document
you guys should read it first coz i must have posted
some begineer query / answer but at least i dont write
such shit mails and discourage anybody the way you
guys have done.

– Thanks!! and please dont reply to this mail
continuing the flame war .

— s a wrote:
> hi,
> i have been a silent spectator of this mailing
> list and must say that i
> have learnt a lot of stuff from it in the short time
> i have been associated
> with it .This is in reff to rock is dead.I was
> thinking is this list for
> beginners.?I mean even i have just started coding
> with device drivers so
> probably there will be somethings which sound stupid
> to you guys and the way
> you guys answered his mail kinda got me thinking.
> thanks
> for reading,
>
> ntdevguy
>
>
_________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at
> http://www.hotmail.com.
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Harshal/Rock

This is not a flame, this is an attempt to encourage you to keep on, but
maybe take a different approach. I don’t justify a flame like the e-mail
you received. I haven’t seen messages from the person who sent you that
flame, so I don’t know anything about him. I do know that he does not
represent the majority of users on this list.

The question about quitting was rude, but understandable. Most of the
regular contributors to this list are busy professionals who work to
deadlines that don’t allow for too much wasted time. They are very willing
to help you if you demonstrate that you have done your due diligence in
trying to get the answer you are looking for. The questions you started
asking appeared to indicate that you haven’t done your homework in trying to
find the answers yourself. That, and the way that you solved some of your
problems suggest that you are not an experienced programmer. That may not
be true, but that’s what it looks like. If that is true, consider taking a
few months to learn the basics of programming first. Trying to learn
programming and device driver development simultaneously is several orders
of magnitude harder than trying to do one or the other.

Do read the other responses to ntdevguy’s questions, and compare how you
approached this list to them. Then if you have additional problems, try to
solve them, then ask direct, intelligent questions about the specific
problem you are trying to solve. The regulars of this group will be very
nice to anyone, even beginners, who don’t waste their time with questions
that they can’t decipher. But they get very annoyed when asked confusing
questions.

Phil
* Philip D. Barila | (503) 264-8386
* Intel Corp. | Not speaking for Intel

-----Original Message-----
From: Rock Is Dead [mailto:xxxxx@yahoo.com]
Sent: Monday, July 09, 2001 8:43 AM
To: NT Developers Interest List
Subject: [ntdev] Re: User mode addresses

Hi all,
Ok i read all the flames regarding my solution to
the passing of kernel mode address to user mode which
was stupid.
I used some method which was kind of crazy.
I just wanted to say that all you people could have
even replied that this solution was stupid and could
have suggested some other solution.But you didnt.
people started suggesting
“have you thought of quitting coding?”
One of the mails which i got from one of the members
on the mailing list (offlist mail) called Mike Zirolli
reads this

"Hey you fucking “Harshal Vaidya” or whatever the fuck
you
call yourself “Your Dick is dead”.

Don’t write your fucked up solutions in the mailing
list.

From now on I will block your email ID, becoz you
suck.

You bastard."

how do you guys justify this!!!
I guess instead of me reading the netiquette document
you guys should read it first coz i must have posted
some begineer query / answer but at least i dont write
such shit mails and discourage anybody the way you
guys have done.

– Thanks!! and please dont reply to this mail
continuing the flame war .

— s a wrote:
> hi,
> i have been a silent spectator of this mailing
> list and must say that i
> have learnt a lot of stuff from it in the short time
> i have been associated
> with it .This is in reff to rock is dead.I was
> thinking is this list for
> beginners.?I mean even i have just started coding
> with device drivers so
> probably there will be somethings which sound stupid
> to you guys and the way
> you guys answered his mail kinda got me thinking.
> thanks
> for reading,
>
> ntdevguy
>
>
_________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at
> http://www.hotmail.com.
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


You are currently subscribed to ntdev as: xxxxx@intel.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

No flames here. Just a few comments:

how do you guys justify this!!!

No one has to. The mail you quote was, as you said, private
(was not sent to the list); thus, you should be answering privately
to that person (and not here, to the list). By “publishing” that
kind of language here, you’re completely loosing your point… no
one has insulted you. In fact, Evan Hillman has posted a quite
comprehensive, polite and useful mail.

I just wanted to say that all you people could have
even replied that this solution was stupid and could
have suggested some other solution.But you didnt.

You could have a point here. But as you say, the solution is
quite obvious (addresses are merely numbers; why should you
be converting numbers to strings, etc. and all that mess?). So,
instead of posting such a basic question, you should have wasted
a couple of minutes trying to find out the answer for yourself,
first. The way I see it, developers in this list rarely use rude
language as you did right now (by posting the mail you received);
also, people tend to treat you well - but, as Evan says, you
shouldn’t expect to receive answers to ALL of your questions.
(Usually, not receiving an answers is an answer itself: it often
means “oh not, not that question again; come on, read the docs”).

Miguel Monteiro
xxxxx@criticalsoftware.com

Critical Software, S.A. - http://www.criticalsoftware.com
R. Pedro Nunes, IPN, 3030-199 Coimbra, Portugal
Tel: 351.239.700945 - Fax: 351.239.700905

DISCLAIMER: This mail contents represent
my own personal opinions and do not, in any way,
represent the opinion or policy of Critical Software, S.A.

“Humour and love are God’s answers
to Human weaknesses”

----- Original Message -----
From: “Rock Is Dead”
To: “NT Developers Interest List”
Sent: Monday, July 09, 2001 4:42 PM
Subject: [ntdev] Re: User mode addresses

Hi all,
Ok i read all the flames regarding my solution to
the passing of kernel mode address to user mode which
was stupid.
I used some method which was kind of crazy.
I just wanted to say that all you people could have
even replied that this solution was stupid and could
have suggested some other solution.But you didnt.
people started suggesting
“have you thought of quitting coding?”
One of the mails which i got from one of the members
on the mailing list (offlist mail) called Mike Zirolli
reads this

“Hey you fucking “Harshal Vaidya” or whatever the fuck
you
call yourself “Your Dick is dead”.

Don’t write your fucked up solutions in the mailing
list.

>From now on I will block your email ID, becoz you
suck.

You bastard.”

how do you guys justify this!!!
I guess instead of me reading the netiquette document
you guys should read it first coz i must have posted
some begineer query / answer but at least i dont write
such shit mails and discourage anybody the way you
guys have done.

– Thanks!! and please dont reply to this mail
continuing the flame war .

— s a wrote:
> hi,
> i have been a silent spectator of this mailing
> list and must say that i
> have learnt a lot of stuff from it in the short time
> i have been associated
> with it .This is in reff to rock is dead.I was
> thinking is this list for
> beginners.?I mean even i have just started coding
> with device drivers so
> probably there will be somethings which sound stupid
> to you guys and the way
> you guys answered his mail kinda got me thinking.
> thanks
> for reading,
>
> ntdevguy
>
>
_____________________

> Get Your Private, Free E-mail from MSN Hotmail at
> http://www.hotmail.com.
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/


You are currently subscribed to ntdev as: xxxxx@criticalsoftware.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com