Re: [NTDEV][WINXP] Cute code in AllocateAdapterChannel

Hi Gary,

Just “checked in” on the list after weeks of not having read it.

OK, I’ll bite: Why would you want to call AllocateAdapterChannel() for a
zero length transfer??

Why not

if(iostack->Parameters.Write.Length == 0) {
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, 0);
return(STATUS_SUCCESS);
}

I know that’s now what you’re asking…

Now to the REAL reason I’m writing… Regarding why you’re seeing “deadf00d”
as the map register base (this is not presently for public consumption…
please do not post):

This is caused by Driver Verifier. It turns out that there are some drivers
that do “clever” things when MapRegisterBase is zero. Perhaps your driver
is one of them, eh? In any case, MapRegisterBase is essentially supposed to
be opaque. It has no real meaning outside the HAL, and is merely supposed
to be passed TO the driver, and later BACK to the HAL.

To “fool” these drivers, Driver Verifier passes “deadf00d” back to the
driver, instead of zero, anytime MapRegisterBase is returned by the HAL as
zero. This is SUPPOSED to result in the driver doing the right thing (and
treating the request as a real transfer and flushing the adapter buffers,
etc.)

HTH,

Peter

“Gary Little” wrote in message news:…
>
> Windows XP, Whistler build 2462.
>
> Don’t ya just love it when somebody gets “cute” in critical code and costs
> you hours so they could get a giggle? I do hope this is purely
coincidence,
> but here is what happened to me on the way to the forum while debugging my
> infamous zero length transfer problem.
>
> To do zero length transfers, I sense a zero buffer length and instead of
> calling DmaOperations->GetScatterGatherList, I call
> DmaOperations->AllocateAdapterChannel, passing it valid parameters with
> NumberOfMapRegisters set to 0. In the callback I then used MapRegisterBase
> to sense if the transfer length is zero. But things kept going bump in the
> night. So, off I trek into the debugger to take a trip through the call
back
> function.
>
> When what to my wondering eyes I beheld … not a value of 0 … noooo not
> even a 1, which I could understand, but “deadf00d”. that’s right … pass
> AllopcateAdapterChannel a 0 NumberOfMapRegisters, and you get “deadf00d”.
>
> Ha Ha Ha … said I. I do hope that is simply the coincidental result of a
> bug, or that I missed something in setting up to call
> AllocateAdapterChannel. I really really do, because if it’s a genuine
“cute”
> code giggle I think we need to ban the son-of-a-bitch, and break all of
> his/her/its fingers. (and that’s when I’m thinking NICE thoughts)
>
> There. That’s off my chest. I needed that.
>
> By the way … side by side, Windows 2000 does not return “deadf00d”, it
> returns 0.
>
> Gary
>
>
> —
> 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
>
>


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