From: Jess Howe on
Hi,

I'm trying to interface to a usb to serial com port at the driver (kernel
mode) level. I need to open it, read, and write from it. I have looked around
and haven't found any obvious sample code on how to do this at the kernel
level (tons of samples at user mode). I have tried using ZwCreateFile

status = ZwCreateFile(&pDeviceToOpen->hLowerDevice,
FILE_READ_DATA|FILE_WRITE_DATA, &ObjectAttr,
&IoStatusBlock, NULL, 0 ,0,
FILE_OPEN, 0,
NULL, 0) ; )

after initializing an object based on the device name obtained from the
symbolic link returned from the pnp detection of the
GUID_DEVINTERFACE_COMPORT interface class. This device name happens to be
\Device\USBPDO-6, if it matters. From there I've tried using ZwWriteFile

status = ZwWriteFile(pDeviceToOpen->hLowerDevice,
0,
NULL,
NULL,
&IoStatusBlock,
&ttt, // PUCHAR buf
1, // ULONG Length
NULL, // PLARGE_INTEGER ofStartingOffsetfset
NULL);

with the handle returned from ZwCreateFile but that returns an invalid
parameter error (c000000d).

I've also tried using IoGetDeviceObjectPointer and sending IRP_MJ_WRITE down
to the device object via IoAllocateIrp and IoCallDriver and their attendant
setup paths. Can anyone give me some pointers and what I may be doing wrong
here? I've been banging my head on this one trying to see what obvious thing
I'm missing.

Thanks and Regards,
Jess Howe
From: Eliyas Yakub [MSFT] on
Take a look at the src\kmdf\toastmon sample from the Vista WDK. It
demonstrates how to open a device in kernel and talk to it in a PNP friendly
way. Just change the interface from toaster to GUID_DEVINTERFACE_COMPORT and
see if you can open the device.

-Eliyas


"Jess Howe" <JessHowe(a)discussions.microsoft.com> wrote in message
news:182C5AF8-E30C-4C3F-B0F7-DA5EB471CE5F(a)microsoft.com...
> Hi,
>
> I'm trying to interface to a usb to serial com port at the driver (kernel
> mode) level. I need to open it, read, and write from it. I have looked
> around
> and haven't found any obvious sample code on how to do this at the kernel
> level (tons of samples at user mode). I have tried using ZwCreateFile
>
> status = ZwCreateFile(&pDeviceToOpen->hLowerDevice,
> FILE_READ_DATA|FILE_WRITE_DATA, &ObjectAttr,
> &IoStatusBlock, NULL, 0 ,0,
> FILE_OPEN, 0,
> NULL, 0) ; )
>
> after initializing an object based on the device name obtained from the
> symbolic link returned from the pnp detection of the
> GUID_DEVINTERFACE_COMPORT interface class. This device name happens to be
> \Device\USBPDO-6, if it matters. From there I've tried using ZwWriteFile
>
> status = ZwWriteFile(pDeviceToOpen->hLowerDevice,
> 0,
> NULL,
> NULL,
> &IoStatusBlock,
> &ttt, // PUCHAR buf
> 1, // ULONG Length
> NULL, // PLARGE_INTEGER ofStartingOffsetfset
> NULL);
>
> with the handle returned from ZwCreateFile but that returns an invalid
> parameter error (c000000d).
>
> I've also tried using IoGetDeviceObjectPointer and sending IRP_MJ_WRITE
> down
> to the device object via IoAllocateIrp and IoCallDriver and their
> attendant
> setup paths. Can anyone give me some pointers and what I may be doing
> wrong
> here? I've been banging my head on this one trying to see what obvious
> thing
> I'm missing.
>
> Thanks and Regards,
> Jess Howe


From: Jess Howe on
Is there an example I can look at in the server 2003 ddk, or elsewhere? I
started looking at the code in the wdk and it has a bunch of different
structs and types and I want my stuff to compile in the 2003 ddk. . .

Thanks,
Jess
"Eliyas Yakub [MSFT]" wrote:

> Take a look at the src\kmdf\toastmon sample from the Vista WDK. It
> demonstrates how to open a device in kernel and talk to it in a PNP friendly
> way. Just change the interface from toaster to GUID_DEVINTERFACE_COMPORT and
> see if you can open the device.
>
> -Eliyas
>
>
From: Don Burn on
Why would you want to use an obsolete version of the DDK? The WDK builds
drivers fine for every OS the 2003 DDK did.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"Jess Howe" <JessHowe(a)discussions.microsoft.com> wrote in message
news:7EEF9BA6-ADC8-49EE-A337-FBBBA475AA5B(a)microsoft.com...
> Is there an example I can look at in the server 2003 ddk, or elsewhere? I
> started looking at the code in the wdk and it has a bunch of different
> structs and types and I want my stuff to compile in the 2003 ddk. . .
>
> Thanks,
> Jess
> "Eliyas Yakub [MSFT]" wrote:
>
>> Take a look at the src\kmdf\toastmon sample from the Vista WDK. It
>> demonstrates how to open a device in kernel and talk to it in a PNP
>> friendly
>> way. Just change the interface from toaster to GUID_DEVINTERFACE_COMPORT
>> and
>> see if you can open the device.
>>
>> -Eliyas
>>
>>


From: Jess Howe on
Don,

Thanks for the reply. What features does the WDK give me that I don't
already have as a driver writer in the older DDK? All I see in the WDK
example are structs I've never heard of, and though I could figure them out,
what motivation do I have to do so if the old DDK works? When I need Vista
compatible stuff, I'll change over.

Surely folks needed to open, read, and write com ports from the kernel level
in the windows server 2003 days.

Thanks again,
Jess

"Don Burn" wrote:

> Why would you want to use an obsolete version of the DDK? The WDK builds
> drivers fine for every OS the 2003 DDK did.
>
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
> "Jess Howe" <JessHowe(a)discussions.microsoft.com> wrote in message
> news:7EEF9BA6-ADC8-49EE-A337-FBBBA475AA5B(a)microsoft.com...
> > Is there an example I can look at in the server 2003 ddk, or elsewhere? I
> > started looking at the code in the wdk and it has a bunch of different
> > structs and types and I want my stuff to compile in the 2003 ddk. . .
> >
> > Thanks,
> > Jess
> > "Eliyas Yakub [MSFT]" wrote:
> >
> >> Take a look at the src\kmdf\toastmon sample from the Vista WDK. It
> >> demonstrates how to open a device in kernel and talk to it in a PNP
> >> friendly
> >> way. Just change the interface from toaster to GUID_DEVINTERFACE_COMPORT
> >> and
> >> see if you can open the device.
> >>
> >> -Eliyas
> >>
> >>
>
>
>