Hi, I had an impression that I don't need to call IoMarkIrpPending before
IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
anyway. Is this correct?

Thanks

--

Re: CSQ and IoMarkIrpPending by Mark

Mark
Mon Feb 06 19:44:42 CST 2006

On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
<anonymous@discussions.microsoft.com> wrote:

>Hi, I had an impression that I don't need to call IoMarkIrpPending before
>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>anyway. Is this correct?
>
>Thanks

That is actually an excellent question. The documentation doesn't say
anything. The cancel sample implies that the IRP is marked pending by
a call to IoCsqInsertIrp. So we have undocumented behavior with a
sample as the only guide. As far as I know IoMarkIrpPending can be
called repeatedly and do no harm. I would not rely on undocumented
behavior and just mark the IRP pending.


=====================
Mark Roddy DDK MVP
Windows Vista/2003/XP/2000 Consulting
Device and Filesystem Drivers
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: CSQ and IoMarkIrpPending by Calvin

Calvin
Mon Feb 06 19:56:19 CST 2006

And make sure mark it pending before inserting to queue, not the other way.

--
Calvin Guan (Windows DDK MVP)
NetXtreme Longhorn Miniport Prime
Broadcom Corp. www.broadcom.com

"Mark Roddy" <markr@hollistech.com> wrote in message
news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
> <anonymous@discussions.microsoft.com> wrote:
>
>>Hi, I had an impression that I don't need to call IoMarkIrpPending before
>>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>>anyway. Is this correct?
>>
>>Thanks
>
> That is actually an excellent question. The documentation doesn't say
> anything. The cancel sample implies that the IRP is marked pending by
> a call to IoCsqInsertIrp. So we have undocumented behavior with a
> sample as the only guide. As far as I know IoMarkIrpPending can be
> called repeatedly and do no harm. I would not rely on undocumented
> behavior and just mark the IRP pending.
>
>
> =====================
> Mark Roddy DDK MVP
> Windows Vista/2003/XP/2000 Consulting
> Device and Filesystem Drivers
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com



Re: CSQ and IoMarkIrpPending by Gerald

Gerald
Mon Feb 06 20:22:34 CST 2006

Thanks for the reply, however, I'd like to know the exact answer - whether
the cancel sample contains a horrific bug or IoCsqInsertIrp calls
IoMarkIrpPending? In other words, should I rush to update my old drivers or
this can wait?

--

"Mark Roddy" <markr@hollistech.com> wrote in message
news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
> <anonymous@discussions.microsoft.com> wrote:
>
>>Hi, I had an impression that I don't need to call IoMarkIrpPending before
>>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>>anyway. Is this correct?
>>
>>Thanks
>
> That is actually an excellent question. The documentation doesn't say
> anything. The cancel sample implies that the IRP is marked pending by
> a call to IoCsqInsertIrp. So we have undocumented behavior with a
> sample as the only guide. As far as I know IoMarkIrpPending can be
> called repeatedly and do no harm. I would not rely on undocumented
> behavior and just mark the IRP pending.
>
>
> =====================
> Mark Roddy DDK MVP
> Windows Vista/2003/XP/2000 Consulting
> Device and Filesystem Drivers
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com



Re: CSQ and IoMarkIrpPending by Skywing

Skywing
Mon Feb 06 20:51:56 CST 2006

I'm curious too, so I did a bit of looking around.

A bit of disassembly shows that IoCsqInsertIrp does in fact do this. It was
easy to determine this through the use of WinDbg in LKD mode against an x64
Win2003SP1 machine, and dumpbin /disasm csq.lib with _NT_SYMBOL_PATH set
appropriately.

I am of the opinion that this is a documentation omission and that csq was
always supposed to do IoMarkIrpPending(Irp).

From the 3790.1830 DDK for the x64 csq.lib:

WdmlibIoCsqInsertIrp:
0000000000000000: 45 33 C9 xor r9d,r9d
0000000000000003: E9 00 00 00 00 jmp WdmlibIoCsqInsertIrpEx

; .
; .
; .

WdmlibIoCsqInsertIrpEx:
0000000000000000: 48 83 EC 38 sub rsp,38h
0000000000000004: 48 89 5C 24 40 mov qword ptr [rsp+40h],rbx
0000000000000009: 48 89 6C 24 48 mov qword ptr [rsp+48h],rbp
000000000000000E: 48 89 74 24 50 mov qword ptr [rsp+50h],rsi
0000000000000013: 48 89 7C 24 58 mov qword ptr [rsp+58h],rdi
0000000000000018: 33 ED xor ebp,ebp
000000000000001A: 4D 85 C0 test r8,r8
000000000000001D: 4C 89 64 24 30 mov qword ptr [rsp+30h],r12
0000000000000022: 49 8B F0 mov rsi,r8
0000000000000025: 48 8B D9 mov rbx,rcx
0000000000000028: 4D 8B E1 mov r12,r9
000000000000002B: 48 8B FA mov rdi,rdx ; rdi = Irp

; .
; .
; .

00000000000000A9: 48 8B 87 B8 00 00 mov rax,qword ptr [rdi+0B8h]
; Irp+0xb8 == Irp->Tail.Overlay.CurrentStackLocation (x64)
00
00000000000000B0: 80 48 03 01 or byte ptr [rax+3],1 ;
IO_STACK_LOCATION+3 == Control, 0x1 == SL_PENDING_RETURNED (x64)

;
; And this is what IoMarkIrpPending() corresponds to in ntddk.h
;
; #define IoMarkIrpPending( Irp ) ( \
; IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED )
;
;
; And here is IoGetCurrentIrpStackLocation()
;
; #define IoGetCurrentIrpStackLocation( Irp ) (
(Irp)->Tail.Overlay.CurrentStackLocation )
;

; The prototype for IoCsqInsertIrpEx is as follows:

; NTSTATUS
; IoCsqInsertIrpEx(
; IN PIO_CSQ Csq, // rcx
; IN PIRP Irp, // rdx
; IN PIO_CSQ_IRP_CONTEXT Context, // r8
; IN PVOID InsertContext // r9
; );




"Gerald S." <anonymous@discussions.microsoft.com> wrote in message
news:e1%23jc14KGHA.964@tk2msftngp13.phx.gbl...
> Thanks for the reply, however, I'd like to know the exact answer - whether
> the cancel sample contains a horrific bug or IoCsqInsertIrp calls
> IoMarkIrpPending? In other words, should I rush to update my old drivers
> or this can wait?
>
> --
>
> "Mark Roddy" <markr@hollistech.com> wrote in message
> news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
>> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
>> <anonymous@discussions.microsoft.com> wrote:
>>
>>>Hi, I had an impression that I don't need to call IoMarkIrpPending before
>>>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>>>anyway. Is this correct?
>>>
>>>Thanks
>>
>> That is actually an excellent question. The documentation doesn't say
>> anything. The cancel sample implies that the IRP is marked pending by
>> a call to IoCsqInsertIrp. So we have undocumented behavior with a
>> sample as the only guide. As far as I know IoMarkIrpPending can be
>> called repeatedly and do no harm. I would not rely on undocumented
>> behavior and just mark the IRP pending.
>>
>>
>> =====================
>> Mark Roddy DDK MVP
>> Windows Vista/2003/XP/2000 Consulting
>> Device and Filesystem Drivers
>> Hollis Technology Solutions 603-321-1032
>> www.hollistech.com
>
>



Re: CSQ and IoMarkIrpPending by Mark

Mark
Mon Feb 06 21:18:35 CST 2006

On Mon, 6 Feb 2006 21:51:56 -0500, "Skywing"
<skywing_NO_SPAM_@valhallalegends.com> wrote:

>I'm curious too, so I did a bit of looking around.
>
>A bit of disassembly shows that IoCsqInsertIrp does in fact do this. It was
>easy to determine this through the use of WinDbg in LKD mode against an x64
>Win2003SP1 machine, and dumpbin /disasm csq.lib with _NT_SYMBOL_PATH set
>appropriately.
>
>I am of the opinion that this is a documentation omission and that csq was
>always supposed to do IoMarkIrpPending(Irp).
>

Nice work.

I'd still not rely on this behavior until it gets documented.

>From the 3790.1830 DDK for the x64 csq.lib:
>
>WdmlibIoCsqInsertIrp:
> 0000000000000000: 45 33 C9 xor r9d,r9d
> 0000000000000003: E9 00 00 00 00 jmp WdmlibIoCsqInsertIrpEx
>
>; .
>; .
>; .
>
>WdmlibIoCsqInsertIrpEx:
> 0000000000000000: 48 83 EC 38 sub rsp,38h
> 0000000000000004: 48 89 5C 24 40 mov qword ptr [rsp+40h],rbx
> 0000000000000009: 48 89 6C 24 48 mov qword ptr [rsp+48h],rbp
> 000000000000000E: 48 89 74 24 50 mov qword ptr [rsp+50h],rsi
> 0000000000000013: 48 89 7C 24 58 mov qword ptr [rsp+58h],rdi
> 0000000000000018: 33 ED xor ebp,ebp
> 000000000000001A: 4D 85 C0 test r8,r8
> 000000000000001D: 4C 89 64 24 30 mov qword ptr [rsp+30h],r12
> 0000000000000022: 49 8B F0 mov rsi,r8
> 0000000000000025: 48 8B D9 mov rbx,rcx
> 0000000000000028: 4D 8B E1 mov r12,r9
> 000000000000002B: 48 8B FA mov rdi,rdx ; rdi = Irp
>
>; .
>; .
>; .
>
> 00000000000000A9: 48 8B 87 B8 00 00 mov rax,qword ptr [rdi+0B8h]
>; Irp+0xb8 == Irp->Tail.Overlay.CurrentStackLocation (x64)
> 00
> 00000000000000B0: 80 48 03 01 or byte ptr [rax+3],1 ;
>IO_STACK_LOCATION+3 == Control, 0x1 == SL_PENDING_RETURNED (x64)
>
>;
>; And this is what IoMarkIrpPending() corresponds to in ntddk.h
>;
>; #define IoMarkIrpPending( Irp ) ( \
>; IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED )
>;
>;
>; And here is IoGetCurrentIrpStackLocation()
>;
>; #define IoGetCurrentIrpStackLocation( Irp ) (
>(Irp)->Tail.Overlay.CurrentStackLocation )
>;
>
>; The prototype for IoCsqInsertIrpEx is as follows:
>
>; NTSTATUS
>; IoCsqInsertIrpEx(
>; IN PIO_CSQ Csq, // rcx
>; IN PIRP Irp, // rdx
>; IN PIO_CSQ_IRP_CONTEXT Context, // r8
>; IN PVOID InsertContext // r9
>; );
>
>
>
>
>"Gerald S." <anonymous@discussions.microsoft.com> wrote in message
>news:e1%23jc14KGHA.964@tk2msftngp13.phx.gbl...
>> Thanks for the reply, however, I'd like to know the exact answer - whether
>> the cancel sample contains a horrific bug or IoCsqInsertIrp calls
>> IoMarkIrpPending? In other words, should I rush to update my old drivers
>> or this can wait?
>>
>> --
>>
>> "Mark Roddy" <markr@hollistech.com> wrote in message
>> news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
>>> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
>>> <anonymous@discussions.microsoft.com> wrote:
>>>
>>>>Hi, I had an impression that I don't need to call IoMarkIrpPending before
>>>>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>>>>anyway. Is this correct?
>>>>
>>>>Thanks
>>>
>>> That is actually an excellent question. The documentation doesn't say
>>> anything. The cancel sample implies that the IRP is marked pending by
>>> a call to IoCsqInsertIrp. So we have undocumented behavior with a
>>> sample as the only guide. As far as I know IoMarkIrpPending can be
>>> called repeatedly and do no harm. I would not rely on undocumented
>>> behavior and just mark the IRP pending.
>>>
>>>
>>> =====================
>>> Mark Roddy DDK MVP
>>> Windows Vista/2003/XP/2000 Consulting
>>> Device and Filesystem Drivers
>>> Hollis Technology Solutions 603-321-1032
>>> www.hollistech.com
>>
>>
>


=====================
Mark Roddy DDK MVP
Windows Vista/2003/XP/2000 Consulting
Device and Filesystem Drivers
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: CSQ and IoMarkIrpPending by Skywing

Skywing
Mon Feb 06 21:27:20 CST 2006

I just sent a mail to the DDK doc feedback alias pointing this little
omission out; perhaps we shall see it clarified in the official
documentation.

"Mark Roddy" <markr@hollistech.com> wrote in message
news:va4gu19k1afjf7t4dq3mo2veh46d13jt75@4ax.com...
> On Mon, 6 Feb 2006 21:51:56 -0500, "Skywing"
> <skywing_NO_SPAM_@valhallalegends.com> wrote:
>
>>I'm curious too, so I did a bit of looking around.
>>
>>A bit of disassembly shows that IoCsqInsertIrp does in fact do this. It
>>was
>>easy to determine this through the use of WinDbg in LKD mode against an
>>x64
>>Win2003SP1 machine, and dumpbin /disasm csq.lib with _NT_SYMBOL_PATH set
>>appropriately.
>>
>>I am of the opinion that this is a documentation omission and that csq was
>>always supposed to do IoMarkIrpPending(Irp).
>>
>
> Nice work.
>
> I'd still not rely on this behavior until it gets documented.
>
>>From the 3790.1830 DDK for the x64 csq.lib:
>>
>>WdmlibIoCsqInsertIrp:
>> 0000000000000000: 45 33 C9 xor r9d,r9d
>> 0000000000000003: E9 00 00 00 00 jmp WdmlibIoCsqInsertIrpEx
>>
>>; .
>>; .
>>; .
>>
>>WdmlibIoCsqInsertIrpEx:
>> 0000000000000000: 48 83 EC 38 sub rsp,38h
>> 0000000000000004: 48 89 5C 24 40 mov qword ptr [rsp+40h],rbx
>> 0000000000000009: 48 89 6C 24 48 mov qword ptr [rsp+48h],rbp
>> 000000000000000E: 48 89 74 24 50 mov qword ptr [rsp+50h],rsi
>> 0000000000000013: 48 89 7C 24 58 mov qword ptr [rsp+58h],rdi
>> 0000000000000018: 33 ED xor ebp,ebp
>> 000000000000001A: 4D 85 C0 test r8,r8
>> 000000000000001D: 4C 89 64 24 30 mov qword ptr [rsp+30h],r12
>> 0000000000000022: 49 8B F0 mov rsi,r8
>> 0000000000000025: 48 8B D9 mov rbx,rcx
>> 0000000000000028: 4D 8B E1 mov r12,r9
>> 000000000000002B: 48 8B FA mov rdi,rdx ; rdi = Irp
>>
>>; .
>>; .
>>; .
>>
>> 00000000000000A9: 48 8B 87 B8 00 00 mov rax,qword ptr
>> [rdi+0B8h]
>>; Irp+0xb8 == Irp->Tail.Overlay.CurrentStackLocation (x64)
>> 00
>> 00000000000000B0: 80 48 03 01 or byte ptr [rax+3],1 ;
>>IO_STACK_LOCATION+3 == Control, 0x1 == SL_PENDING_RETURNED (x64)
>>
>>;
>>; And this is what IoMarkIrpPending() corresponds to in ntddk.h
>>;
>>; #define IoMarkIrpPending( Irp ) ( \
>>; IoGetCurrentIrpStackLocation( (Irp) )->Control |=
>>SL_PENDING_RETURNED )
>>;
>>;
>>; And here is IoGetCurrentIrpStackLocation()
>>;
>>; #define IoGetCurrentIrpStackLocation( Irp ) (
>>(Irp)->Tail.Overlay.CurrentStackLocation )
>>;
>>
>>; The prototype for IoCsqInsertIrpEx is as follows:
>>
>>; NTSTATUS
>>; IoCsqInsertIrpEx(
>>; IN PIO_CSQ Csq, // rcx
>>; IN PIRP Irp, // rdx
>>; IN PIO_CSQ_IRP_CONTEXT Context, // r8
>>; IN PVOID InsertContext // r9
>>; );
>>
>>
>>
>>
>>"Gerald S." <anonymous@discussions.microsoft.com> wrote in message
>>news:e1%23jc14KGHA.964@tk2msftngp13.phx.gbl...
>>> Thanks for the reply, however, I'd like to know the exact answer -
>>> whether
>>> the cancel sample contains a horrific bug or IoCsqInsertIrp calls
>>> IoMarkIrpPending? In other words, should I rush to update my old drivers
>>> or this can wait?
>>>
>>> --
>>>
>>> "Mark Roddy" <markr@hollistech.com> wrote in message
>>> news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
>>>> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
>>>> <anonymous@discussions.microsoft.com> wrote:
>>>>
>>>>>Hi, I had an impression that I don't need to call IoMarkIrpPending
>>>>>before
>>>>>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>>>>>anyway. Is this correct?
>>>>>
>>>>>Thanks
>>>>
>>>> That is actually an excellent question. The documentation doesn't say
>>>> anything. The cancel sample implies that the IRP is marked pending by
>>>> a call to IoCsqInsertIrp. So we have undocumented behavior with a
>>>> sample as the only guide. As far as I know IoMarkIrpPending can be
>>>> called repeatedly and do no harm. I would not rely on undocumented
>>>> behavior and just mark the IRP pending.
>>>>
>>>>
>>>> =====================
>>>> Mark Roddy DDK MVP
>>>> Windows Vista/2003/XP/2000 Consulting
>>>> Device and Filesystem Drivers
>>>> Hollis Technology Solutions 603-321-1032
>>>> www.hollistech.com
>>>
>>>
>>
>
>
> =====================
> Mark Roddy DDK MVP
> Windows Vista/2003/XP/2000 Consulting
> Device and Filesystem Drivers
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com



Re: CSQ and IoMarkIrpPending by ning

ning
Tue Feb 07 11:53:39 CST 2006

But what if I happen to queue the irp and then complete the IRP
synchronously? Wouldn't that violate the "IoMarkIrpPending() and
STATUS_PENDING go together" rule?

Ning

"Skywing" <skywing_NO_SPAM_@valhallalegends.com> wrote in message
news:%23cPu3Z5KGHA.3272@tk2msftngp13.phx.gbl...
>I just sent a mail to the DDK doc feedback alias pointing this little
>omission out; perhaps we shall see it clarified in the official
>documentation.
>
> "Mark Roddy" <markr@hollistech.com> wrote in message
> news:va4gu19k1afjf7t4dq3mo2veh46d13jt75@4ax.com...
>> On Mon, 6 Feb 2006 21:51:56 -0500, "Skywing"
>> <skywing_NO_SPAM_@valhallalegends.com> wrote:
>>
>>>I'm curious too, so I did a bit of looking around.
>>>
>>>A bit of disassembly shows that IoCsqInsertIrp does in fact do this. It
>>>was
>>>easy to determine this through the use of WinDbg in LKD mode against an
>>>x64
>>>Win2003SP1 machine, and dumpbin /disasm csq.lib with _NT_SYMBOL_PATH set
>>>appropriately.
>>>
>>>I am of the opinion that this is a documentation omission and that csq
>>>was
>>>always supposed to do IoMarkIrpPending(Irp).
>>>
>>
>> Nice work.
>>
>> I'd still not rely on this behavior until it gets documented.
>>
>>>From the 3790.1830 DDK for the x64 csq.lib:
>>>
>>>WdmlibIoCsqInsertIrp:
>>> 0000000000000000: 45 33 C9 xor r9d,r9d
>>> 0000000000000003: E9 00 00 00 00 jmp WdmlibIoCsqInsertIrpEx
>>>
>>>; .
>>>; .
>>>; .
>>>
>>>WdmlibIoCsqInsertIrpEx:
>>> 0000000000000000: 48 83 EC 38 sub rsp,38h
>>> 0000000000000004: 48 89 5C 24 40 mov qword ptr
>>> [rsp+40h],rbx
>>> 0000000000000009: 48 89 6C 24 48 mov qword ptr
>>> [rsp+48h],rbp
>>> 000000000000000E: 48 89 74 24 50 mov qword ptr
>>> [rsp+50h],rsi
>>> 0000000000000013: 48 89 7C 24 58 mov qword ptr
>>> [rsp+58h],rdi
>>> 0000000000000018: 33 ED xor ebp,ebp
>>> 000000000000001A: 4D 85 C0 test r8,r8
>>> 000000000000001D: 4C 89 64 24 30 mov qword ptr
>>> [rsp+30h],r12
>>> 0000000000000022: 49 8B F0 mov rsi,r8
>>> 0000000000000025: 48 8B D9 mov rbx,rcx
>>> 0000000000000028: 4D 8B E1 mov r12,r9
>>> 000000000000002B: 48 8B FA mov rdi,rdx ; rdi = Irp
>>>
>>>; .
>>>; .
>>>; .
>>>
>>> 00000000000000A9: 48 8B 87 B8 00 00 mov rax,qword ptr
>>> [rdi+0B8h]
>>>; Irp+0xb8 == Irp->Tail.Overlay.CurrentStackLocation (x64)
>>> 00
>>> 00000000000000B0: 80 48 03 01 or byte ptr [rax+3],1 ;
>>>IO_STACK_LOCATION+3 == Control, 0x1 == SL_PENDING_RETURNED (x64)
>>>
>>>;
>>>; And this is what IoMarkIrpPending() corresponds to in ntddk.h
>>>;
>>>; #define IoMarkIrpPending( Irp ) ( \
>>>; IoGetCurrentIrpStackLocation( (Irp) )->Control |=
>>>SL_PENDING_RETURNED )
>>>;
>>>;
>>>; And here is IoGetCurrentIrpStackLocation()
>>>;
>>>; #define IoGetCurrentIrpStackLocation( Irp ) (
>>>(Irp)->Tail.Overlay.CurrentStackLocation )
>>>;
>>>
>>>; The prototype for IoCsqInsertIrpEx is as follows:
>>>
>>>; NTSTATUS
>>>; IoCsqInsertIrpEx(
>>>; IN PIO_CSQ Csq, // rcx
>>>; IN PIRP Irp, // rdx
>>>; IN PIO_CSQ_IRP_CONTEXT Context, // r8
>>>; IN PVOID InsertContext // r9
>>>; );
>>>
>>>
>>>
>>>
>>>"Gerald S." <anonymous@discussions.microsoft.com> wrote in message
>>>news:e1%23jc14KGHA.964@tk2msftngp13.phx.gbl...
>>>> Thanks for the reply, however, I'd like to know the exact answer -
>>>> whether
>>>> the cancel sample contains a horrific bug or IoCsqInsertIrp calls
>>>> IoMarkIrpPending? In other words, should I rush to update my old
>>>> drivers
>>>> or this can wait?
>>>>
>>>> --
>>>>
>>>> "Mark Roddy" <markr@hollistech.com> wrote in message
>>>> news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
>>>>> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
>>>>> <anonymous@discussions.microsoft.com> wrote:
>>>>>
>>>>>>Hi, I had an impression that I don't need to call IoMarkIrpPending
>>>>>>before
>>>>>>IoCsqInsertIrp, as the latter internally marks the inserted IRP
>>>>>>pending
>>>>>>anyway. Is this correct?
>>>>>>
>>>>>>Thanks
>>>>>
>>>>> That is actually an excellent question. The documentation doesn't say
>>>>> anything. The cancel sample implies that the IRP is marked pending by
>>>>> a call to IoCsqInsertIrp. So we have undocumented behavior with a
>>>>> sample as the only guide. As far as I know IoMarkIrpPending can be
>>>>> called repeatedly and do no harm. I would not rely on undocumented
>>>>> behavior and just mark the IRP pending.
>>>>>
>>>>>
>>>>> =====================
>>>>> Mark Roddy DDK MVP
>>>>> Windows Vista/2003/XP/2000 Consulting
>>>>> Device and Filesystem Drivers
>>>>> Hollis Technology Solutions 603-321-1032
>>>>> www.hollistech.com
>>>>
>>>>
>>>
>>
>>
>> =====================
>> Mark Roddy DDK MVP
>> Windows Vista/2003/XP/2000 Consulting
>> Device and Filesystem Drivers
>> Hollis Technology Solutions 603-321-1032
>> www.hollistech.com
>
>



Re: CSQ and IoMarkIrpPending by Calvin

Calvin
Tue Feb 07 12:24:55 CST 2006

You can synchronously complete an IRP which had been marked pending as long
as you return pending from the dispatch routine.

--
Calvin Guan (Windows DDK MVP)
NetXtreme Longhorn Miniport Prime
Broadcom Corp. www.broadcom.com

"ning" <ning@newsgroup.nospam> wrote in message
news:e5Zhv9ALGHA.344@TK2MSFTNGP11.phx.gbl...
> But what if I happen to queue the irp and then complete the IRP
> synchronously? Wouldn't that violate the "IoMarkIrpPending() and
> STATUS_PENDING go together" rule?
>
> Ning
>
> "Skywing" <skywing_NO_SPAM_@valhallalegends.com> wrote in message
> news:%23cPu3Z5KGHA.3272@tk2msftngp13.phx.gbl...
>>I just sent a mail to the DDK doc feedback alias pointing this little
>>omission out; perhaps we shall see it clarified in the official
>>documentation.
>>
>> "Mark Roddy" <markr@hollistech.com> wrote in message
>> news:va4gu19k1afjf7t4dq3mo2veh46d13jt75@4ax.com...
>>> On Mon, 6 Feb 2006 21:51:56 -0500, "Skywing"
>>> <skywing_NO_SPAM_@valhallalegends.com> wrote:
>>>
>>>>I'm curious too, so I did a bit of looking around.
>>>>
>>>>A bit of disassembly shows that IoCsqInsertIrp does in fact do this. It
>>>>was
>>>>easy to determine this through the use of WinDbg in LKD mode against an
>>>>x64
>>>>Win2003SP1 machine, and dumpbin /disasm csq.lib with _NT_SYMBOL_PATH set
>>>>appropriately.
>>>>
>>>>I am of the opinion that this is a documentation omission and that csq
>>>>was
>>>>always supposed to do IoMarkIrpPending(Irp).
>>>>
>>>
>>> Nice work.
>>>
>>> I'd still not rely on this behavior until it gets documented.
>>>
>>>>From the 3790.1830 DDK for the x64 csq.lib:
>>>>
>>>>WdmlibIoCsqInsertIrp:
>>>> 0000000000000000: 45 33 C9 xor r9d,r9d
>>>> 0000000000000003: E9 00 00 00 00 jmp
>>>> WdmlibIoCsqInsertIrpEx
>>>>
>>>>; .
>>>>; .
>>>>; .
>>>>
>>>>WdmlibIoCsqInsertIrpEx:
>>>> 0000000000000000: 48 83 EC 38 sub rsp,38h
>>>> 0000000000000004: 48 89 5C 24 40 mov qword ptr
>>>> [rsp+40h],rbx
>>>> 0000000000000009: 48 89 6C 24 48 mov qword ptr
>>>> [rsp+48h],rbp
>>>> 000000000000000E: 48 89 74 24 50 mov qword ptr
>>>> [rsp+50h],rsi
>>>> 0000000000000013: 48 89 7C 24 58 mov qword ptr
>>>> [rsp+58h],rdi
>>>> 0000000000000018: 33 ED xor ebp,ebp
>>>> 000000000000001A: 4D 85 C0 test r8,r8
>>>> 000000000000001D: 4C 89 64 24 30 mov qword ptr
>>>> [rsp+30h],r12
>>>> 0000000000000022: 49 8B F0 mov rsi,r8
>>>> 0000000000000025: 48 8B D9 mov rbx,rcx
>>>> 0000000000000028: 4D 8B E1 mov r12,r9
>>>> 000000000000002B: 48 8B FA mov rdi,rdx ; rdi = Irp
>>>>
>>>>; .
>>>>; .
>>>>; .
>>>>
>>>> 00000000000000A9: 48 8B 87 B8 00 00 mov rax,qword ptr
>>>> [rdi+0B8h]
>>>>; Irp+0xb8 == Irp->Tail.Overlay.CurrentStackLocation (x64)
>>>> 00
>>>> 00000000000000B0: 80 48 03 01 or byte ptr [rax+3],1 ;
>>>>IO_STACK_LOCATION+3 == Control, 0x1 == SL_PENDING_RETURNED (x64)
>>>>
>>>>;
>>>>; And this is what IoMarkIrpPending() corresponds to in ntddk.h
>>>>;
>>>>; #define IoMarkIrpPending( Irp ) ( \
>>>>; IoGetCurrentIrpStackLocation( (Irp) )->Control |=
>>>>SL_PENDING_RETURNED )
>>>>;
>>>>;
>>>>; And here is IoGetCurrentIrpStackLocation()
>>>>;
>>>>; #define IoGetCurrentIrpStackLocation( Irp ) (
>>>>(Irp)->Tail.Overlay.CurrentStackLocation )
>>>>;
>>>>
>>>>; The prototype for IoCsqInsertIrpEx is as follows:
>>>>
>>>>; NTSTATUS
>>>>; IoCsqInsertIrpEx(
>>>>; IN PIO_CSQ Csq, // rcx
>>>>; IN PIRP Irp, // rdx
>>>>; IN PIO_CSQ_IRP_CONTEXT Context, // r8
>>>>; IN PVOID InsertContext // r9
>>>>; );
>>>>
>>>>
>>>>
>>>>
>>>>"Gerald S." <anonymous@discussions.microsoft.com> wrote in message
>>>>news:e1%23jc14KGHA.964@tk2msftngp13.phx.gbl...
>>>>> Thanks for the reply, however, I'd like to know the exact answer -
>>>>> whether
>>>>> the cancel sample contains a horrific bug or IoCsqInsertIrp calls
>>>>> IoMarkIrpPending? In other words, should I rush to update my old
>>>>> drivers
>>>>> or this can wait?
>>>>>
>>>>> --
>>>>>
>>>>> "Mark Roddy" <markr@hollistech.com> wrote in message
>>>>> news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
>>>>>> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
>>>>>> <anonymous@discussions.microsoft.com> wrote:
>>>>>>
>>>>>>>Hi, I had an impression that I don't need to call IoMarkIrpPending
>>>>>>>before
>>>>>>>IoCsqInsertIrp, as the latter internally marks the inserted IRP
>>>>>>>pending
>>>>>>>anyway. Is this correct?
>>>>>>>
>>>>>>>Thanks
>>>>>>
>>>>>> That is actually an excellent question. The documentation doesn't say
>>>>>> anything. The cancel sample implies that the IRP is marked pending by
>>>>>> a call to IoCsqInsertIrp. So we have undocumented behavior with a
>>>>>> sample as the only guide. As far as I know IoMarkIrpPending can be
>>>>>> called repeatedly and do no harm. I would not rely on undocumented
>>>>>> behavior and just mark the IRP pending.
>>>>>>
>>>>>>
>>>>>> =====================
>>>>>> Mark Roddy DDK MVP
>>>>>> Windows Vista/2003/XP/2000 Consulting
>>>>>> Device and Filesystem Drivers
>>>>>> Hollis Technology Solutions 603-321-1032
>>>>>> www.hollistech.com
>>>>>
>>>>>
>>>>
>>>
>>>
>>> =====================
>>> Mark Roddy DDK MVP
>>> Windows Vista/2003/XP/2000 Consulting
>>> Device and Filesystem Drivers
>>> Hollis Technology Solutions 603-321-1032
>>> www.hollistech.com
>>
>>
>
>



Re: CSQ and IoMarkIrpPending by Maxim

Maxim
Tue Feb 07 19:23:01 CST 2006

> sample as the only guide. As far as I know IoMarkIrpPending can be
> called repeatedly and do no harm.

Yes, it just sets a bitwise flag in the current stack location.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: CSQ and IoMarkIrpPending by Mark

Mark
Wed Feb 08 06:27:56 CST 2006

On Wed, 8 Feb 2006 04:23:01 +0300, "Maxim S. Shatskih"
<maxim@storagecraft.com> wrote:

>> sample as the only guide. As far as I know IoMarkIrpPending can be
>> called repeatedly and do no harm.
>
>Yes, it just sets a bitwise flag in the current stack location.

However that is also an undocumented feature, which leaves the
programmer stuck depending on one undocumented feature or the other.


=====================
Mark Roddy DDK MVP
Windows Vista/2003/XP/2000 Consulting
Device and Filesystem Drivers
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: CSQ and IoMarkIrpPending by Alexander

Alexander
Wed Feb 08 10:11:44 CST 2006

Since it's a macro, it will never change to avoid breaking binary
compatibility.

"Mark Roddy" <markr@hollistech.com> wrote in message
news:5toju1hg69aq7h7rmas2maftcuq6p9pb95@4ax.com...
> On Wed, 8 Feb 2006 04:23:01 +0300, "Maxim S. Shatskih"
> <maxim@storagecraft.com> wrote:
>
>>> sample as the only guide. As far as I know IoMarkIrpPending can be
>>> called repeatedly and do no harm.
>>
>>Yes, it just sets a bitwise flag in the current stack location.
>
> However that is also an undocumented feature, which leaves the
> programmer stuck depending on one undocumented feature or the other.
>
>
> =====================
> Mark Roddy DDK MVP
> Windows Vista/2003/XP/2000 Consulting
> Device and Filesystem Drivers
> Hollis Technology Solutions 603-321-1032
> www.hollistech.com



Re: CSQ and IoMarkIrpPending by Skywing

Skywing
Wed Feb 08 10:21:35 CST 2006

It could have changed from x86->x64 (although it didn't in this case).
Binary compatibility is thrown out the window when you switch processor
architectures and Windows drivers are supposed to be highly portable to
different architectures.

"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:uPxNcpMLGHA.3936@TK2MSFTNGP10.phx.gbl...
> Since it's a macro, it will never change to avoid breaking binary
> compatibility.
>
> "Mark Roddy" <markr@hollistech.com> wrote in message
> news:5toju1hg69aq7h7rmas2maftcuq6p9pb95@4ax.com...
>> On Wed, 8 Feb 2006 04:23:01 +0300, "Maxim S. Shatskih"
>> <maxim@storagecraft.com> wrote:
>>
>>>> sample as the only guide. As far as I know IoMarkIrpPending can be
>>>> called repeatedly and do no harm.
>>>
>>>Yes, it just sets a bitwise flag in the current stack location.
>>
>> However that is also an undocumented feature, which leaves the
>> programmer stuck depending on one undocumented feature or the other.
>>
>>
>> =====================
>> Mark Roddy DDK MVP
>> Windows Vista/2003/XP/2000 Consulting
>> Device and Filesystem Drivers
>> Hollis Technology Solutions 603-321-1032
>> www.hollistech.com
>
>



Re: CSQ and IoMarkIrpPending by Eliyas

Eliyas
Sat Feb 11 14:15:50 CST 2006

Yes, IoCsqInsertIrp calls IoMarkIrpPending. I will make sure the doc is
explicit about this.

If you call IoCsqInsertIrpEx and your callback CsqInsertIrpEx returns error,
then it doesn't mark the IRP pending.

-Eliyas


"Gerald S." <anonymous@discussions.microsoft.com> wrote in message
news:e1%23jc14KGHA.964@tk2msftngp13.phx.gbl...
> Thanks for the reply, however, I'd like to know the exact answer - whether
> the cancel sample contains a horrific bug or IoCsqInsertIrp calls
> IoMarkIrpPending? In other words, should I rush to update my old drivers
> or this can wait?
>
> --
>
> "Mark Roddy" <markr@hollistech.com> wrote in message
> news:3nufu1962s13pe0rdnmgmr13dcf7tipqut@4ax.com...
>> On Tue, 7 Feb 2006 12:30:48 +1300, "Gerald S."
>> <anonymous@discussions.microsoft.com> wrote:
>>
>>>Hi, I had an impression that I don't need to call IoMarkIrpPending before
>>>IoCsqInsertIrp, as the latter internally marks the inserted IRP pending
>>>anyway. Is this correct?
>>>
>>>Thanks
>>
>> That is actually an excellent question. The documentation doesn't say
>> anything. The cancel sample implies that the IRP is marked pending by
>> a call to IoCsqInsertIrp. So we have undocumented behavior with a
>> sample as the only guide. As far as I know IoMarkIrpPending can be
>> called repeatedly and do no harm. I would not rely on undocumented
>> behavior and just mark the IRP pending.
>>
>>
>> =====================
>> Mark Roddy DDK MVP
>> Windows Vista/2003/XP/2000 Consulting
>> Device and Filesystem Drivers
>> Hollis Technology Solutions 603-321-1032
>> www.hollistech.com
>
>