Search code examples
cwindowsdevice-driver

Accessing same resource across restarts in Windows


I will write some thing in a file/memory just before system shutdown or a service shutdown. In the next restart of system, Is it possible to access same file or same memory on the disk, before filesystem loads? Actual requirement is like this, we have a driver that sits between volume level drivers and filesystem driver...in that part of the driver code, I want to access some memory or file.

Thanks & Regards,
calvin


Solution

  • The logical thing here is to read/write this into the registry if it is not too big. Is there a reason you do not want to use the registry?

    If you need to access large data and you are writing a volume or device filter and cannot rely on ZwOpen/Read/Write/Close functions in the kernel an approach would be to create the file in user mode, get its device name and cluster chain and store them in the registry. On the next boot, you can get the device and clusters from registry, and do direct I/O on them.