Device Access From User space

Hi,
I want to write a simple program in C which will write a text file into a USB stick.
How can I do this from user space ? (without writing any filter driver to handle my request)

Regards,
Barun

I’m not sure what you mean exactly. Do you mean write the USB device as
a physical drive, or do you mean write to a USB drive that has no driver
loaded, or neither?

mm

xxxxx@gmail.com wrote:

Hi,
I want to write a simple program in C which will write a text file into a USB stick.
How can I do this from user space ? (without writing any filter driver to handle my request)

Regards,
Barun

> ----------

From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
Reply To: Windows System Software Devs Interest List
Sent: Friday, November 16, 2007 5:43 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Device Access From User space

Hi,
I want to write a simple program in C which will write a text file into a USB stick.
How can I do this from user space ? (without writing any filter driver to handle my request)

"copy file.txt X:" where X is your USB stick driver letter.

Well, maybe you want to formulate your question better :wink:

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

In Unix/Linux OS we can access device from user space by opening the
corresponding device node under /dev (e.g. /dev/usb/lp for printer ).
My question is whether we can do such things in windows user space
too.

On Nov 16, 2007 3:35 PM, Michal Vodicka wrote:
> > ----------
> > From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
> > Reply To: Windows System Software Devs Interest List
> > Sent: Friday, November 16, 2007 5:43 AM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] Device Access From User space
> >
> > Hi,
> > I want to write a simple program in C which will write a text file into a USB stick.
> > How can I do this from user space ? (without writing any filter driver to handle my request)
> >
> "copy file.txt X:" where X is your USB stick driver letter.
>
> Well, maybe you want to formulate your question better :wink:
>
> Best regards,
>
> Michal Vodicka
> UPEK, Inc.
> [xxxxx@upek.com, http://www.upek.com]
>
>
>
>
>
>
>
>
> —
> 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
>


Barun Kumar Parichha,
Research Scholar,
Dept of Computer Science & Engg.
I.I.T. Madras
Chennai - 36

-----Original Message-----
From: Doron Holan
Sent: Thursday, November 15, 2007 8:56 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Device Access From User space

Assume e:\ is the stick…how about CreateFile(“e:\file.txt”, …) ? or is the stick not a usb mass storage device?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, November 15, 2007 8:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Device Access From User space

Hi,
I want to write a simple program in C which will write a text file into a USB stick.
How can I do this from user space ? (without writing any filter driver to handle my request)

Regards,
Barun


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

Yes. Read the MSDN documentation for CreateFile:

http://msdn2.microsoft.com/en-us/library/aa363858.aspx

In particular, you’ll be interested in the “Physical Disks and Volumes.”
section. Add WriteFile() to this, and you should be all set, as long
as you satisfy the security issues that are described in CreateFile().
Also, I assume that you are talking about an unformatted volume on the
USB device. If you’re talking about one with a file system, you are
either going to trash it, or I apparently don’t understand your question.

Good luck,

mm

barun parichha wrote:

In Unix/Linux OS we can access device from user space by opening the
corresponding device node under /dev (e.g. /dev/usb/lp for printer ).
My question is whether we can do such things in windows user space
too.

On Nov 16, 2007 3:35 PM, Michal Vodicka wrote:
>>> ----------
>>> From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
>>> Reply To: Windows System Software Devs Interest List
>>> Sent: Friday, November 16, 2007 5:43 AM
>>> To: Windows System Software Devs Interest List
>>> Subject: [ntdev] Device Access From User space
>>>
>>> Hi,
>>> I want to write a simple program in C which will write a text file into a USB stick.
>>> How can I do this from user space ? (without writing any filter driver to handle my request)
>>>
>> "copy file.txt X:" where X is your USB stick driver letter.
>>
>> Well, maybe you want to formulate your question better :wink:
>>
>> Best regards,
>>
>> Michal Vodicka
>> UPEK, Inc.
>> [xxxxx@upek.com, http://www.upek.com]
>>
>>
>>
>>
>>
>>
>>
>>
>> —
>> 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
>>
>
>
>

barun parichha wrote:

In Unix/Linux OS we can access device from user space by opening the
corresponding device node under /dev (e.g. /dev/usb/lp for printer ).
My question is whether we can do such things in windows user space
too.

What you say is true for printers. For USB sticks, Linux works exactly
like Windows. The stick is exposed as a file system, and you write to
it by creating a file using the ordinary file I/O. You do not talk
directly to a USB stick in Linux either.

As others have said, you need to explain what you want to do that is
different from writing a file.


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

Tim Roberts wrote:

For USB sticks, Linux works exactly like Windows. The stick is
exposed as a file system, and you write to it by creating a file
using the ordinary file I/O. You do not talk directly to a USB
stick in Linux either.

Assuming you don’t have the mass storage kernel module loaded, you could talk directly to a USB stick using libusb.

xxxxx@gmail.com wrote:

Tim Roberts wrote:

> For USB sticks, Linux works exactly like Windows. The stick is
> exposed as a file system, and you write to it by creating a file
> using the ordinary file I/O. You do not talk directly to a USB
> stick in Linux either.
>

Assuming you don’t have the mass storage kernel module loaded, you could talk directly to a USB stick using libusb.

Yes, but no human being would ever want to do so for the purpose of
writing a file to the stick. You would have to generate the pseudo-SCSI
command set, AND simulate the file system structures and commands as well.


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