Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results
The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
I am trying to read a config.txt file that contains a list of paths separated by ";" from a minifilter.
config.txt file looks like:
\\Device\\HarddiskVolume2\\path1;\\Device\\HarddiskVolume2\\path2
Then, in instance_setup()
method I do:
HANDLE fileHandle = NULL; OBJECT_ATTRIBUTES objectAttributes; PVOID result; result = ExAllocatePool(NonPagedPool, 65536); PFILE_OBJECT fileObject = NULL; UNICODE_STRING myUnicodeStr; RtlInitUnicodeString(&myUnicodeStr, config_file_path); InitializeObjectAttributes(&objectAttributes, &myUnicodeStr, OBJ_CASE_INSENSITIVE | OBJ_OPENIF, NULL,NULL); IO_STATUS_BLOCK ioStatus; FltCreateFile(flt_objects->Filter, flt_objects->Instance, &fileHandle, GENERIC_READ, &objectAttributes, &ioStatus, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_SEQUENTIAL_ONLY, NULL, 0, 0); ObReferenceObjectByHandle(fileHandle, GENERIC_READ, NULL, KernelMode, &fileObject, NULL); ULONG bytes_read; FltReadFile(flt_objects->Instance, fileObject, NULL, 65536, result, FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET, &bytes_read, NULL, NULL); FltClose(fileHandle); //result should have the content of file
I am getting a blue screen when starting the minifilter. I´ve tested that the code works properly until FltCreateFile
(I am able to get a proper fileHandler). I do not see what I am doing wrong after this.
Upcoming OSR Seminars | ||
---|---|---|
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead! | ||
Kernel Debugging | 13-17 May 2024 | Live, Online |
Developing Minifilters | 1-5 Apr 2024 | Live, Online |
Internals & Software Drivers | 11-15 Mar 2024 | Live, Online |
Writing WDF Drivers | 26 Feb - 1 Mar 2024 | Live, Online |
Comments
More data needed:
analyze -v
say?I'll also observer that ExAllocatePool is deprecated and that there is a variant FltCreateFile which sets up an FO for you.
I can provide for the moment just this data because I am not using a debugger:
Missed this. I´ve allocated space for PFILE_OBJECT with ExAllocatePool2(), but same blue screen.
Yes, but the .txt file is generated by other application that does not use ; but for separation, not for filenames.