Hello All,
I am using FindFirstStreamW() and FindNextStreamW() to iterate over all file streams and get the name and size.
However, it returns on the data stream and alternate data streams and skips all other.
BackupRead() used on the same file returns the above along with object identifiers and security data.
Why is this and how can I get all streams without using BackupRead() ?
Below is the code :
Code:
#include<stdio.h>
#include<windows.h>
#include<winbase.h>
#include<stdlib.h>
void FindAllStreams(HANDLE file)
{
void *buffer;
int err;
WIN32_FIND_STREAM_DATA stream;
while(1)
{
err = FindNextStreamW(file, &stream);
if(err == 0)
{
if (GetLastError() == ERROR_HANDLE_EOF)
printf("\nNo more streams available\n");
else
printf("error = 0x%x\n", GetLastError());
break;
}
else
{
printf("StreamSize = 0x%x\n", stream.StreamSize.QuadPart);
wprintf(L"StreamName = %s\n", stream.cStreamName);
}
}
}
int wmain(int argc, wchar_t *argv[])
{
HANDLE file;
WIN32_FIND_STREAM_DATA stream;
{
file = FindFirstStreamW(argv[1], FindStreamInfoStandard, &stream, 0);
if (file == INVALID_HANDLE_VALUE)
{
printf("Could not crerate file handle\n");
printf("error = 0x%x\n", GetLastError());
}
else
{
printf("\nStreamSize = 0x%x\n", stream.StreamSize.QuadPart);
wprintf(L"StreamName = %s\n\n", stream.cStreamName);
FindAllStreams(file);
FindClose(file);
}
}
return 0;
}
Thanks