Re: irp cloning...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Martin Harvey \(work\) (m.harvey_at_nospam.snellwilcox.com)
Date: 01/07/05


Date: Fri, 7 Jan 2005 12:31:14 -0000


"Greg Becker" <greg@codeconcepts.com> wrote in message
news:ohs0b2-5pa2.ln1@gromit.codeconcepts.com...

> However, if I instruct the driver to perform mirroring, the data sent
> to the primary device is always corrupted (I am currently unable to
> verify the secondary as it is not written in the original format).

> It's probably worth admitting that while I have programmed drivers for
> Unix for many years I've only been working with NT for a month or so.

First impressions?

> I would greatly appreciate any insight into how to solve this problem
> correctly. I have scoured this list and the web for similar examples
> but haven't found anything relevant thus far.

I could be totally wrong here (I'm not a guru or anything) but my thoughts
are:

> #define CLONE_IRP(src, dst, zoffset) \
> do { \
> IO_STACK_LOCATION *srcstk, *dststk; \
> srcstk = IoGetCurrentIrpStackLocation(src); \
> dststk = IoGetCurrentIrpStackLocation(dst); \
> *dststk = *srcstk; \

This seems a trifle on the "ambitious" side to me. In particularly, there's
quite a lot of stuff in an IO_STACK_LOCATION that you might want to
consider....

For a start, just looking at copying stack locations which are on the same
stack, the DDK gives you:

#define IoCopyCurrentIrpStackLocationToNext( Irp ) { \
PIO_STACK_LOCATION irpSp; \
PIO_STACK_LOCATION nextIrpSp; \
irpSp = IoGetCurrentIrpStackLocation( (Irp) ); \
nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); \
RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION,
CompletionRoutine)); \
nextIrpSp->Control = 0; }

So copying the completion routine or anything after might possibly be a bad
idea, and you may need to look at the control field.

Secondly, if you're copying to/from different stacks, then you're likely to
need to be a great deal more cautious in what you overwrite - the device
object & file object pointers might not take kindly to being overwritten.
After that, how you handle the actual parameters depends on the type of IRP,
and some things may not be as re-usable as one might think...

MH.



Relevant Pages

  • Re: FAQ 5.4 How do I delete the last N lines from a file?
    ... reduce the number of repeated questions as well as allow the community ... "or how to do it with a lot of copying." ... read each line, store line in stack, increment a counter ... when the counter equals N, drop the oldest line into a new file, newest line to stack. ...
    (comp.lang.perl.misc)
  • Re: Why does the stack have a fixed size?
    ... environments on 32-bit platforms because when you assign a multi-megabyte stack to each thread, address space runs out pretty quickly, even if just a few pages in each stack are ever used. ... Correct AR copying/sharing on stack is as we know very difficult, especially in MT environments. ... how actually do they implement stackless runtimes, there has to be some stack anyway, right? ... I mean both tuned mark'n'sweep and copying allocators should be faster. ...
    (comp.lang.functional)
  • Re: make tree-map tail recursive
    ... Marcin 'Qrczak' Kowalczyk writes: ... call-with-current-continuation efficiently (without copying the stack), ... already have a flexible call stack with no artificial size limit. ... I can't flatten the tree first, ...
    (comp.lang.scheme)
  • Re: Dynamic data structures
    ... If the stack if full, create a new one with double of the old size. ... For any simple resizable array, this is the standard approach to limit ... Certainly for a stack you can use linked nodes or blocks of nodes to ... There are many other approaches that don't require any copying even ...
    (comp.programming)