In one of my DeviceIoControl, the BytesReturned is always 3435973836
(0xCCCCCCCC). In the driver I set the value of
Irp->IoStatus.Information to 4 and I have verified this value many
times. I even initialized the value of BytesReturned to 0 prior to
DeviceIoControl and verified that is is 0.

Has anyone else encountered this problem?

Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Doron

Doron
Sat Dec 31 02:47:51 CST 2005

are you sending a synchronous IOCTL on an overlapped HANDLE? if so,
BytesReturned is meaningless in this scenario.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Tierrie" <tierrie@gmail.com> wrote in message
news:1135997002.416797.41330@g43g2000cwa.googlegroups.com...
> In one of my DeviceIoControl, the BytesReturned is always 3435973836
> (0xCCCCCCCC). In the driver I set the value of
> Irp->IoStatus.Information to 4 and I have verified this value many
> times. I even initialized the value of BytesReturned to 0 prior to
> DeviceIoControl and verified that is is 0.
>
> Has anyone else encountered this problem?
>



Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Alexander

Alexander
Sat Dec 31 10:22:17 CST 2005

I think if the IRP is completed synchronously (even on OVERLAPPED handle),
the result will be placed to BytesReturned.

I guess the OP problem might be because of incorrect
IoMarkIrpPending/STATUS_PENDING matching.

"Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
news:%232LnjbeDGHA.2924@tk2msftngp13.phx.gbl...
> are you sending a synchronous IOCTL on an overlapped HANDLE? if so,
> BytesReturned is meaningless in this scenario.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> "Tierrie" <tierrie@gmail.com> wrote in message
> news:1135997002.416797.41330@g43g2000cwa.googlegroups.com...
>> In one of my DeviceIoControl, the BytesReturned is always 3435973836
>> (0xCCCCCCCC). In the driver I set the value of
>> Irp->IoStatus.Information to 4 and I have verified this value many
>> times. I even initialized the value of BytesReturned to 0 prior to
>> DeviceIoControl and verified that is is 0.
>>
>> Has anyone else encountered this problem?
>>
>
>



Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Doron

Doron
Sat Dec 31 12:48:00 CST 2005

if you mark the irp pending, complete the irp and return STATUS_PENDING
(which is a synchronous complete), BytesReturned is not valid. If you have
an OVERLAPPED HANDLE, you should never rely on BytesReturned and should
always use GetOverlappedResult to get the final bytes transfered. You
cannot rely on BytesReturned b/c you don't know if the driver or some filter
pended the irp.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:OLNBiZiDGHA.1264@TK2MSFTNGP09.phx.gbl...
>I think if the IRP is completed synchronously (even on OVERLAPPED handle),
>the result will be placed to BytesReturned.
>
> I guess the OP problem might be because of incorrect
> IoMarkIrpPending/STATUS_PENDING matching.
>
> "Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
> news:%232LnjbeDGHA.2924@tk2msftngp13.phx.gbl...
>> are you sending a synchronous IOCTL on an overlapped HANDLE? if so,
>> BytesReturned is meaningless in this scenario.
>>
>> d
>>
>> --
>> Please do not send e-mail directly to this alias. this alias is for
>> newsgroup purposes only.
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> "Tierrie" <tierrie@gmail.com> wrote in message
>> news:1135997002.416797.41330@g43g2000cwa.googlegroups.com...
>>> In one of my DeviceIoControl, the BytesReturned is always 3435973836
>>> (0xCCCCCCCC). In the driver I set the value of
>>> Irp->IoStatus.Information to 4 and I have verified this value many
>>> times. I even initialized the value of BytesReturned to 0 prior to
>>> DeviceIoControl and verified that is is 0.
>>>
>>> Has anyone else encountered this problem?
>>>
>>
>>
>
>



Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Alexander

Alexander
Sat Dec 31 16:38:39 CST 2005

I think we have a little disagreement.
If you return STATUS_PENDING, the IRP is considered asynchronous, and
asynchronous completion path is invoked on IoCompleteRequest, even though
the driver logic guaranteed its completion before return from dispatch
routine. In this case DeviceIoControl returns
FALSE/GetLastError=ERROR_IO_PENDING. If the handle is overlapped, the app
must in this case use GetOverlappedResult.

If the driver calls IoCompleteRequest and returns NON STATUS_PENDING, the
IRP is considered synchronous. Even if the handle is overlapped, the result
will be placed to BytesReturned. I'm not sure the OVERLAPPED.event will even
be signalled in that case.

Some applications incorrectly assume that some IPRs are always completed
synchronously and expect DeviceIoControl return TRUE for those. For example,
I've had a problem with a virtual COM driver of mine, which always used
asynchronous completion for READ IRP, even though the requested amount of
data was guaranteed available in the buffer. Microsoft's MCCOMM32.OCX
erroneously assumed that those IRPs should be completed synchronously (it is
using ClearCommError/COMSTAT::cbInQueue to get number of avilable bytes).

"Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
news:eQfI6qjDGHA.2292@tk2msftngp13.phx.gbl...
> if you mark the irp pending, complete the irp and return STATUS_PENDING
> (which is a synchronous complete), BytesReturned is not valid. If you
> have an OVERLAPPED HANDLE, you should never rely on BytesReturned and
> should always use GetOverlappedResult to get the final bytes transfered.
> You cannot rely on BytesReturned b/c you don't know if the driver or some
> filter pended the irp.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> "Alexander Grigoriev" <alegr@earthlink.net> wrote in message
> news:OLNBiZiDGHA.1264@TK2MSFTNGP09.phx.gbl...
>>I think if the IRP is completed synchronously (even on OVERLAPPED handle),
>>the result will be placed to BytesReturned.
>>
>> I guess the OP problem might be because of incorrect
>> IoMarkIrpPending/STATUS_PENDING matching.
>>
>> "Doron Holan [MS]" <doronh@nospam.microsoft.com> wrote in message
>> news:%232LnjbeDGHA.2924@tk2msftngp13.phx.gbl...
>>> are you sending a synchronous IOCTL on an overlapped HANDLE? if so,
>>> BytesReturned is meaningless in this scenario.
>>>
>>> d
>>>
>>> --
>>> Please do not send e-mail directly to this alias. this alias is for
>>> newsgroup purposes only.
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>>
>>> "Tierrie" <tierrie@gmail.com> wrote in message
>>> news:1135997002.416797.41330@g43g2000cwa.googlegroups.com...
>>>> In one of my DeviceIoControl, the BytesReturned is always 3435973836
>>>> (0xCCCCCCCC). In the driver I set the value of
>>>> Irp->IoStatus.Information to 4 and I have verified this value many
>>>> times. I even initialized the value of BytesReturned to 0 prior to
>>>> DeviceIoControl and verified that is is 0.
>>>>
>>>> Has anyone else encountered this problem?
>>>>
>>>
>>>
>>
>>
>
>



Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Tierrie

Tierrie
Mon Jan 02 20:00:16 CST 2006

Actually it is IoMarkPending() and not returned.

Later on when it is returned, it is returned with STATUS_SUCCESS for
testing purposes.

It works on one machine but not another.


Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Doron

Doron
Mon Jan 02 21:05:35 CST 2006

you definitely must use GetOverlappedResult to get this data. it works on
one machine by luck, it might be slower/faster then the other.

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Tierrie" <tierrie@gmail.com> wrote in message
news:1136253615.995824.236320@f14g2000cwb.googlegroups.com...
> Actually it is IoMarkPending() and not returned.
>
> Later on when it is returned, it is returned with STATUS_SUCCESS for
> testing purposes.
>
> It works on one machine but not another.
>



Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Alexander

Alexander
Mon Jan 02 22:02:03 CST 2006

If you call IoMarkIrpPending, you MUST return STATUS_PENDING, even if you
complete the IRP immediately with STATUS_SUCCESS..

If you return STATUS_PENDING, you MUST call IoMarkIrpPending before you pass
the IRP down or put it to any queue, or complete it.

"Tierrie" <tierrie@gmail.com> wrote in message
news:1136253615.995824.236320@f14g2000cwb.googlegroups.com...
> Actually it is IoMarkPending() and not returned.
>
> Later on when it is returned, it is returned with STATUS_SUCCESS for
> testing purposes.
>
> It works on one machine but not another.
>



Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Tierrie

Tierrie
Tue Jan 03 01:11:24 CST 2006

I'm confused "you MUST return STATUS_PENDING"? You mean the IOCTL
handler must return a valid STATUS?


Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Tierrie

Tierrie
Tue Jan 03 01:39:41 CST 2006

They are not using Overlapped. I was under the impression that if I am
not the call to DeviceIoControl would be blocking until IoCompleteIrp
was called by the driver. And when IoCompleteIrp is called,
BytesWritten would then already be valid.


Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Tierrie

Tierrie
Tue Jan 03 01:43:37 CST 2006

Let me rephrase this one.

I was under the impression that if I IoMarkPending() an IRP, the actual
return valid of the IRP is not important since you never return the IRP
via IoCompleteIrp(), and control of the system, back to the
DeviceIoControl that called it. (For non overlapped calls)

Do I need to call IoCompleteIrp() even while the IRP is pending?


Re: DeviceIoControl's BytesReturned shows 0xCCCCCCCC by Doron

Doron
Tue Jan 03 04:27:59 CST 2006

if you mark an irp as pending with IoMarkIrpPending you *must* return
STATUS_PENDING even if you are going to complete the request in the dispatch
routine.

d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Tierrie" <tierrie@gmail.com> wrote in message
news:1136274217.235434.141020@g49g2000cwa.googlegroups.com...
> Let me rephrase this one.
>
> I was under the impression that if I IoMarkPending() an IRP, the actual
> return valid of the IRP is not important since you never return the IRP
> via IoCompleteIrp(), and control of the system, back to the
> DeviceIoControl that called it. (For non overlapped calls)
>
> Do I need to call IoCompleteIrp() even while the IRP is pending?
>