Hi jorge,
I am working on the exact task as you.
I’m not a driver professional, but I am sharing my experience with you. for any technical question you should ask other professionals here.
- Let’s say I create one file with 500bytes. When IRP_MJ_WRITE is called, on
pre-write, I’ll change the buffer size and write on disk 500bytes+200bytes of
xml header. So it would look like […Originalfile].
- If IRP_MJ_READ is called, on pre-read, I change the buffer size to read
500bytes+200 bytes and on post-read I’ll parse that xml header and return only
the 500bytes to the application.
So, on disk, the file size is 700 bytes, but every application will see the file
with 500 bytes. So, my questions are:
your specific question is managing file size but since you addressed the encryption\decryption filter people are giving you the correct solution for the whole problem and not answering your specific question.
for your question about file size. I exactly implemented the approach you described just recently.
It works. and the decrypted file is usable by common applications I tested against (MS word, Adobe acrobat, image viewers, notepad, etc).
But there is some issues:
- you can Alter the offset for read write, hiding the xml header but you can’t change the file size with this approach. the decrypted file had zero bytes at the end of it with the exact size of the header in my case. however the zero bytes did not break the applications I mentioned above, but I think in some cases this may cause problem with some applications.
Is so hard to manage size changes in isolation filters?
As I said before Isolation filter is a suggested design (some people here stated it as the only correct design) to implement enc\dec minifilter. However, implementing that approach will probably remove the need to fake the file size, since you provide 2 different views(virtual files) one encrypted and one plain to the consumers in that design.
So, if I change my design and I remove that header, so the only size change of
the file is related to encryption (AES), do I still need to implement that
isolation filter? Or how do you manage that file size change on disk?
This is not a windows kernel development concept, But if you use a stream cipher algorithm or Mode of encryption you can keep the file size un-touched. however in my experience with this filter so far you will need that header and have to keep it.