Re: Question about FILE_OBJECT



the use of FsContext and FsContext2 are dictated by each driver in the
stack. you must make sure that no other driver (like NDIS itself) is using
these fields. Once you know that you can use either field, you can set it
and you own own. you don't have to validate it unless you are freeing it
before IRP_MJ_CLOSE, you can blindly use the pointer b/c no one else knows
about it. Every i/o that is sent on that handle will have the same
PFILE_OBJECT pointer and the same pointer value you put into FsContext(2).

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.


"John S" <John S@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0EFAF252-02EC-4550-BD0E-0B2030CD5435@xxxxxxxxxxxxxxxx
Ok, here is the scenario. I have an ndis intermetiate driver.
Basically a
new handle to my intermdiate driver is opened for each nic adapter that a
user application wants to talk to.

On the open call (IRP_MJ_CREATE) I allocate a context structure and add it
to a global list. I also store the pointer of the allocated context
memory
in IoGetCurrentIrpStackLocation(pIrp)->FileObject->FsContext2; I also
want
to save the pointer of the FileObject to a member in the the context
structure I allocated. Note that i will never attempt to read or write to
the location i will just be using it later for validation.

Now, on susequent irp's instead of accessing the context memory at
FileObject->FsContext2 object directly, I want to use FsContext2 to match
the
context structure in my global list (to assure that its valid). When i
find i match i also want to make sure the FileObject pointer i stored in
the
context memory matches the pointer to FileObject of the current irp.

So my question is.. Will a FILE_OBJECT change memory locations? I.E.
whence a file object is established, is it always found at that location,
or can the os re-allocate and copy it to another memory location.

I know that this is probably a ridiculous amount of verification but the
situation is a little more complicated than stated above, it's just
easier
to explain this way.
John.





.



Relevant Pages

  • Re: NativeOverlapped, does it work??
    ... You need to keep that fixed in memory, and if you are using a fixed statement the memory location of the structure is subject to change. ... Instead, I would pin the structure (and then get the unsafe pointer to the structure), or marshal it to unmanaged memory, where you can hold onto the pointer for the life of the call. ... I'm trying to read some messages from a kernel mode mini-filter driver. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: sleeping and waiting and tasklets
    ... care must be used when accessing user space from kernel code. ... being addressed might not be currently present in memory, ... The net result for the driver writer is that any ... they also check whether the user space pointer is valid. ...
    (comp.os.linux.development.system)
  • Re: Question about FILE_OBJECT
    ... I.E. every time they allocated a new context object they ... FsContext2 is in my table only lets me know that the memory is valid, ... PFILE_OBJECT pointer and the same pointer value you put into ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Question about FILE_OBJECT
    ... I.E. every time they allocated a new context object they ... FsContext2 is in my table only lets me know that the memory is valid, ... PFILE_OBJECT pointer and the same pointer value you put into ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Reserved Memory Access Question CE 6.0 vs. 5.0
    ... but you should be able to allocate memory in the ... K.S.'s mechanism had the allocation done in the application, and the driver ... loaded into the kernel memory space. ... data pointer up to the application and all was peachy. ...
    (microsoft.public.windowsce.platbuilder)