Go to the source code of this file.
Classes | |
struct | WinEntry |
Windows file system file-entry. More... | |
struct | WinDirectory |
Windows file system directory-entry. More... | |
Functions | |
int | ScanNTFSStreams (Entry *entry, HANDLE hFile) |
int ScanNTFSStreams | ( | Entry * | entry, |
HANDLE | hFile | ||
) |
Definition at line 36 of file winfs.cpp.
References Entry::_data, Entry::_down, Entry::_expanded, Entry::_level, _MAX_FNAME, Entry::_next, Entry::_scanned, and THROW_EXCEPTION.
Referenced by WinDirectory::read_directory(), and ShellDirectory::read_directory().
{ PVOID ctx = 0; DWORD read, seek_high; Entry** pnext = &entry->_down; int cnt = 0; for(;;) { struct NTFS_StreamHdr : public WIN32_STREAM_ID { WCHAR name_padding[_MAX_FNAME]; // room for reading stream name } hdr; if (!BackupRead(hFile, (LPBYTE)&hdr, (LPBYTE)&hdr.cStreamName-(LPBYTE)&hdr, &read, FALSE, FALSE, &ctx) || (long)read!=(LPBYTE)&hdr.cStreamName-(LPBYTE)&hdr) break; if (hdr.dwStreamId == BACKUP_ALTERNATE_DATA) { if (hdr.dwStreamNameSize && BackupRead(hFile, (LPBYTE)hdr.cStreamName, hdr.dwStreamNameSize, &read, FALSE, FALSE, &ctx) && read==hdr.dwStreamNameSize) { ++cnt; int l = hdr.dwStreamNameSize / sizeof(WCHAR); LPCWSTR p = hdr.cStreamName; LPCWSTR e = hdr.cStreamName + l; if (l>0 && *p==':') { ++p, --l; e = p; while(l>0 && *e!=':') ++e, --l; l = e - p; } Entry* stream_entry = new WinEntry(entry); memcpy(&stream_entry->_data, &entry->_data, sizeof(WIN32_FIND_DATA)); lstrcpy(stream_entry->_data.cFileName, String(p, l)); stream_entry->_down = NULL; stream_entry->_expanded = false; stream_entry->_scanned = false; stream_entry->_level = entry->_level + 1; *pnext = stream_entry; pnext = &stream_entry->_next; } } // jump to the next stream header if (!BackupSeek(hFile, ~0, ~0, &read, &seek_high, &ctx)) { DWORD error = GetLastError(); if (error != ERROR_SEEK) { BackupRead(hFile, 0, 0, &read, TRUE, FALSE, &ctx); // terminate BackupRead() loop THROW_EXCEPTION(error); //break; } hdr.Size.QuadPart -= read; hdr.Size.HighPart -= seek_high; BYTE buffer[4096]; while(hdr.Size.QuadPart > 0) { if (!BackupRead(hFile, buffer, sizeof(buffer), &read, FALSE, FALSE, &ctx) || read!=sizeof(buffer)) break; hdr.Size.QuadPart -= read; } } } if (ctx) if (!BackupRead(hFile, 0, 0, &read, TRUE, FALSE, &ctx)) // terminate BackupRead() loop THROW_EXCEPTION(GetLastError()); return cnt; }
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |