? Hello,
I was discussing this issue in Microsoft Forums, but it has hit a dead end… No one has any ideas, so our project is stuck, so I hope that someone may have some fresh ideas here… Here is the link in case you would like to see the discussion at Microsoft:
http://social.msdn.microsoft.com/Forums/en-US/wdk/thread/f38c0fd3-aa89-420a-9568-aab9dbd90514
So, our kernel mode driver uses ZwQueryInformationFile() to enumerate Alternate Data Streams in a file. I have a test file that has 3 streams in it and when I run lads (www.securityfocus.comhttp:) to enumerate them, it shows two ADS streams in addition to ::$DATA… Which is what I expected…
? Here is what lads shows for the file streams on my test file:
Scanning directory C:\TESTFOLDER<br>
size ADS in file
---------- ---------------------------------
32 C:\TESTFOLDER\alternateFileStreams.txt:stream1.txt
32 C:\TESTFOLDER\alternateFileStreams.txt:stream2.txt
64 bytes in 2 ADS listed
When I execute the following code, there are no NTSTATUS errors, and the buffer is large enough for the enumerated information, but I am only receiving the ::$DATA stream. FILE_STREAM_INFORMATION’s NextEntryOffset is always zero. Is there a special flag that I need when I open the file, or am I missing something?
I’ve read the documentation and it says that “No specific access rights are required to query this information”, so I’d expect my code to work without any special privileges. Arggg… But, the fact that I can get the default stream and the function calls is successful, makes me suspicious about needing to grant a privilege like SE_BACKUP_NAME.
Thank you for your help! The relevant code follows…
status = ZwCreateFile(
theHandle,
(READ_CONTROL | SYNCHRONIZE),
&attributes, &ioStatus,
NULL,
FILE_ATTRIBUTE_NORMAL,
(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE),
FILE_OPEN,
(FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT),
NULL,
0);
.
.
.
.
status = ZwQueryInformationFile(theOutputHandle,
&ioStatus,
fileStreamInfo,
sizeof(FILE_STREAM_INFORMATION) * multiple[attempt],
FileStreamInformation);
? Here is the info that I collected…
FILENAME BEING PROCESSED…
1: kd> dt fileName
Local var @ 0xfffffa600cfd3e08 Type MYUNICODE_STRING*
0xfffff8800a543690<br> +0x000 Length : 0n100<br> +0x002 MaximumLength : 0n100<br> +0x008 Buffer : 0xfffff8800b54d550 -> 0n92
1: kd> db 0xfffff8800b54d550<br>fffff8800b54d550 5c 00 44 00 6f 00 73 00-44 00 65 00 76 00 69 00 .D.o.s.D.e.v.i.
fffff8800b54d560 63 00 65 00 73 00 5c 00-63 00 3a 00 5c 00 74 00 c.e.s.\.c.:.\.t.<br>fffff8800b54d570 65 00 73 00 74 00 66 00-6f 00 6c 00 64 00 65 00 e.s.t.f.o.l.d.e.
fffff8800b54d580 72 00 5c 00 61 00 6c 00-74 00 65 00 72 00 6e 00 r.\.a.l.t.e.r.n.<br>fffff8800b54d590 61 00 74 00 65 00 46 00-69 00 6c 00 65 00 53 00 a.t.e.F.i.l.e.S.
fffff8800b54d5a0 74 00 72 00 65 00 61 00-6d 00 73 00 2e 00 74 00 t.r.e.a.m.s...t.<br>fffff8800b54d5b0 78 00 74 00 00 00 00 00-00 00 00 00 00 00 00 00 x.t…
fffff8800b54d5c0 08 01 03 03 50 66 46 4b-00 b4 b2 fc fe 07 00 00 ....PfFK........<br>------------------------------------------------------------------------------------<br><br>IOSTATUS AFTER ZWQUERYINFORMATIONFILE<br><br>1: kd> dt ioStatus<br>Local var @ 0xfffffa600cfd3e20 Type _IO_STATUS_BLOCK<br> +0x000 Status : 0n0<br> +0x000 Pointer : (null)<br> +0x008 Information : 0n38<br>-----------------------------------------------------------------------------------<br><br>STREAM BUFFER INFO AFTER ZW... NOTE THAT IT INDICATES NO MORE ENTRIES TO PROCESS...<br><br>1: kd> dt fileStreamInfo<br>Local var @ 0xfffffa600cfd3dd8 Type _FILE_STREAM_INFORMATION*<br>0xfffff8800b346d10
+0x000 NextEntryOffset : 0
+0x004 StreamNameLength : 0n14
+0x008 StreamSize : _LARGE_INTEGER 0x23b
+0x010 StreamAllocationSize : _LARGE_INTEGER 0x1000
+0x018 StreamName : [1] “:”
1: kd> db 0xfffff8800b346d10+0x18<br>fffff8800b346d28 3a 00 3a 00 24 00 44 00-41 00 54 00 41 00 00 00 :.:.$.D.A.T.A…
fffff8800b346d38 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................<br>fffff8800b346d48 00 00 00 00 00 00 00 00-05 01 06 03 46 49 76 6e …FIvn
fffff8800b346d58 10 ec 60 04 80 fa ff ff-5c 00 44 00 65 00 76 00 ..….D.e.v.
fffff8800b346d68 69 00 63 00 65 00 5c 00-48 00 61 00 72 00 64 00 i.c.e.\.H.a.r.d.<br>fffff8800b346d78 64 00 69 00 73 00 6b 00-56 00 6f 00 6c 00 75 00 d.i.s.k.V.o.l.u.
fffff8800b346d88 6d 00 65 00 53 00 68 00-61 00 64 00 6f 00 77 00 m.e.S.h.a.d.o.w.<br>fffff8800b346d98 43 00 6f 00 70 00 79 00-34 00 00 00 12 00 00 00 C.o.p.y.4…</http:>