summaryrefslogtreecommitdiff
path: root/zen/FindFilePlus
diff options
context:
space:
mode:
Diffstat (limited to 'zen/FindFilePlus')
-rw-r--r--zen/FindFilePlus/find_file_plus.cpp21
-rw-r--r--zen/FindFilePlus/find_file_plus.h1
2 files changed, 14 insertions, 8 deletions
diff --git a/zen/FindFilePlus/find_file_plus.cpp b/zen/FindFilePlus/find_file_plus.cpp
index 19f43998..a6e82617 100644
--- a/zen/FindFilePlus/find_file_plus.cpp
+++ b/zen/FindFilePlus/find_file_plus.cpp
@@ -107,13 +107,13 @@ bool findplus::initDllBinding() //evaluate in ::DllMain() when attaching process
class findplus::FileSearcher
{
public:
- FileSearcher(const wchar_t* dirname); //throw FileError
+ FileSearcher(const wchar_t* dirname); //throw NtFileError
~FileSearcher();
- void readDir(FileInformation& output); //throw FileError
+ void readDir(FileInformation& output); //throw NtFileError
private:
- template <class QueryPolicy> void readDirImpl(FileInformation& output); //throw FileError
+ template <class QueryPolicy> void readDirImpl(FileInformation& output); //throw NtFileError
UNICODE_STRING dirnameNt; //it seems hDir implicitly keeps a reference to this, at least ::FindFirstFile() does no cleanup before ::FindClose()!
HANDLE hDir;
@@ -136,7 +136,7 @@ FileSearcher::FileSearcher(const wchar_t* dirname) :
dirnameNt.Length = 0;
dirnameNt.MaximumLength = 0;
- zen::ScopeGuard guardConstructor = zen::makeGuard([&]() { this->~FileSearcher(); });
+ zen::ScopeGuard guardConstructor = zen::makeGuard([&] { this->~FileSearcher(); });
//--------------------------------------------------------------------------------------------------------------
//convert dosFileName, e.g. C:\Users or \\?\C:\Users to ntFileName \??\C:\Users
@@ -222,11 +222,11 @@ struct DirQueryFileId
inline
-void FileSearcher::readDir(FileInformation& output) { readDirImpl<DirQueryFileId>(output); } //throw FileError
+void FileSearcher::readDir(FileInformation& output) { readDirImpl<DirQueryFileId>(output); } //throw NtFileError
template <class QueryPolicy>
-void FileSearcher::readDirImpl(FileInformation& output) //throw FileError
+void FileSearcher::readDirImpl(FileInformation& output) //throw NtFileError
{
//although FILE_ID_FULL_DIR_INFORMATION should suffice for our purposes, there are problems on Windows XP for certain directories, e.g. "\\Vboxsvr\build"
//making NtQueryDirectoryFile() return with STATUS_INVALID_PARAMETER while other directories, e.g. "C:\" work fine for some reason
@@ -335,6 +335,11 @@ void FileSearcher::readDirImpl(FileInformation& output) //throw FileError
output.fileAttributes = dirInfo.FileAttributes;
output.shortNameLength = dirInfo.FileNameLength / sizeof(TCHAR); //FileNameLength is in bytes!
+ if (dirInfo.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) //analog to FindFirstFile(), confirmed for Win XP and Win 7
+ output.reparseTag = dirInfo.EaSize; //
+ else
+ output.reparseTag = 0;
+
if (dirInfo.FileNameLength + sizeof(TCHAR) > sizeof(output.shortName)) //this may actually happen if ::NtQueryDirectoryFile() decides to return a
throw NtFileError(STATUS_BUFFER_OVERFLOW); //short name of length MAX_PATH + 1, 0-termination is not required!
@@ -352,7 +357,7 @@ FindHandle findplus::openDir(const wchar_t* dirname)
{
try
{
- return new FileSearcher(dirname); //throw FileError
+ return new FileSearcher(dirname); //throw NtFileError
}
catch (const NtFileError& e)
{
@@ -366,7 +371,7 @@ bool findplus::readDir(FindHandle hnd, FileInformation& output)
{
try
{
- hnd->readDir(output); //throw FileError
+ hnd->readDir(output); //throw NtFileError
return true;
}
catch (const NtFileError& e)
diff --git a/zen/FindFilePlus/find_file_plus.h b/zen/FindFilePlus/find_file_plus.h
index 3799a1e1..49b18733 100644
--- a/zen/FindFilePlus/find_file_plus.h
+++ b/zen/FindFilePlus/find_file_plus.h
@@ -36,6 +36,7 @@ struct FileInformation
ULARGE_INTEGER fileSize;
ULARGE_INTEGER fileId; //optional: may be 0 if not supported
DWORD fileAttributes;
+ DWORD reparseTag; //set if "fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT"
DWORD shortNameLength;
WCHAR shortName[MAX_PATH + 1]; //shortName is 0-terminated
}; //no need for #pragma pack -> all members are perfectly 4, 8 byte aligned!
bgstack15