I've read some documentations about Alternate Data Streams
and I'm thinking about using them in my own projects. However there is so much unknown knowledge and open questions that I still have before I decide to use them. That's why I made this question list:
streams
?LoadLibrary
API to load a DLL from a stream?ShellExecute
) a stream?Alternate Data Streams
?Alternate Data Streams
?I'm looking forward to your answers/infos/summarys. The preferable language is Delphi but any other language will do too, as long as it uses the WinAPI
.
To answer your questions one by one:
Enumeration: Use NtQueryInformationFile
. Beginning with Windows Vista, you can also enumerate streams on the commandline using dir /r
.
Checksums: As you usually open only the unnamed data stream when you access a file by name, only the contents of this stream are used when calculating checksums.
Copying to NTFS: Windows Explorer and the copy commandline utility copy all streams.
Copying to other FS: The alternate data streams are lost.
Nested streams: Not possible. A file simply consists of a list of streams, they cannot be nested.
Attributes: Some attributes are file-based, some (encrypted, compressed, sparse) are stream-based.
LoadLibrary
seems to work on alternate data streams.
ShellExecute
on an ADS failed with ERROR_FILE_NOT_FOUND
(2) on my computer.
Note that is is possible to run an ADS from the commandline (not that this is a good idea):
type calc.exe > dummy.txt:calc
wmic process call create "dummy.txt:calc"
ADS are useful to store some non-critical information associated with a file. For example, executable files downloaded from the internet will have an ADS which causes Explorer to display a warning before the file is executed.
Don't use them for critical data as the data may be lost during backup.