Why would RDR return STATUS_INVALID_HANDLE on a valid handle?

Hi,
I am totally confused with some behaviour on XP SP0.

I have a driver which exports a file as a disk to user. The file is a
network file, it is mounted properly.
I have problem while unmounting. The code is not written by me, its written
by some one long time ago. works well on Win2K, and NT.
The driver creates a system thread and impersonates the logonuser. The
system thread works well with writes before i initiate an unmount.

As soon as i initiate an unmount, the write(ZwWriteFile) from the system
thread returns STATUS_INVALID_HANDLE. This sytem thread is the impersonated
thread. What is going on in the system is following.

  1. User initiates unmount.
  2. Driver receives the request.
  3. Driver tries to open the Drive to get the file object, the unmount is
    done in the driver. The driver needs the file object to send fctl IOCTLS to
    lockā€¦ For this it uses ZwCreateFile
  4. ZwCreateFile causes to write something to $Log file on NTFS volume on
    this drive, which is exported by my driver.
  5. Driver tries to write to the network file and these writes fail with
    STATUS_INVALID_HANDLE.

I break into debugger after the ZwWriteFile failed, and if i do !handle on
the handle value, the handle looks good.
I ran FileMon, and see the request going to redirector and returning
STATUS_INVALID_HANDLE.

The OS i have problems on is Win XP SP0.

Please can some one give me a hint on whats going wrong on XP thats works
fine on Win2k and NT.
I would be happy to provide any info you need.

Thanks,
-Srin.