@@ -41,9 +41,6 @@ DECLARE_HAS_FIELD(ShortName)
4141template <FILE_INFORMATION_CLASS fileInformationClass, class FileInformationClass >
4242struct FileInformationClassUtilsImpl
4343{
44- // minimum required size for the structure
45- std::size_t get_minimum_struct_size () { return sizeof (FileInformationClass); }
46-
4744 static void get_data (LPCVOID address, ULONG& offset, std::wstring& fileName)
4845 {
4946 const FileInformationClass* info =
@@ -101,7 +98,7 @@ struct FileInformationClassUtils<FileDirectoryInformation>
10198template <>
10299struct FileInformationClassUtils <FileFullDirectoryInformation>
103100 : FileInformationClassUtilsImpl<FileFullDirectoryInformation,
104- FILE_ID_FULL_DIR_INFORMATION >
101+ FILE_FULL_DIR_INFORMATION >
105102{};
106103template <>
107104struct FileInformationClassUtils <FileBothDirectoryInformation>
@@ -125,10 +122,6 @@ struct FileInformationClassUtils<FileNamesInformation>
125122 : FileInformationClassUtilsImpl<FileNamesInformation, FILE_NAMES_INFORMATION>
126123{};
127124template <>
128- struct FileInformationClassUtils <FileAllInformation>
129- : FileInformationClassUtilsImpl<FileAllInformation, FILE_ALL_INFORMATION>
130- {};
131- template <>
132125struct FileInformationClassUtils <FileObjectIdInformation>
133126 : FileInformationClassUtilsImpl<FileObjectIdInformation, FILE_OBJECTID_INFORMATION>
134127{};
@@ -183,21 +176,47 @@ struct FileInformationClassUtils<FileIdAllExtdBothDirectoryInformation>
183176 FILE_ID_ALL_EXTD_BOTH_DIR_INFORMATION>
184177{};
185178
179+ // FILE_ALL_INFORMATION needs to be handled differently because it has a field that
180+ // is itself a structure
181+ template <>
182+ struct FileInformationClassUtils <FileAllInformation>
183+ {
184+ static void get_data (LPCVOID address, ULONG& offset, std::wstring& fileName)
185+ {
186+ FileInformationClassUtils<FileNameInformation>::get_data (
187+ &reinterpret_cast <const FILE_ALL_INFORMATION*>(address)->NameInformation ,
188+ offset, fileName);
189+ }
190+
191+ static void set_offset (LPVOID address, ULONG offset)
192+ {
193+ // this is a no-op but it's consistent to do that everywhere
194+ FileInformationClassUtils<FileNameInformation>::set_offset (
195+ &reinterpret_cast <FILE_ALL_INFORMATION*>(address)->NameInformation , offset);
196+ }
197+
198+ static void set_filename (LPVOID address, const std::wstring& fileName)
199+ {
200+ FileInformationClassUtils<FileNameInformation>::set_filename (
201+ &reinterpret_cast <FILE_ALL_INFORMATION*>(address)->NameInformation , fileName);
202+ }
203+ };
204+
186205} // namespace usvfs::details
187206
188207#define _APP_FINFO_CASE (clazz, fn, ...) \
189208 case clazz: \
190209 return usvfs::details::FileInformationClassUtils<clazz>::fn(__VA_ARGS__);
191210
192211#define _APPLY_FILEINFO_FN (fn, ...) \
212+ _APP_FINFO_CASE (FileAllInformation, fn, __VA_ARGS__) \
193213 _APP_FINFO_CASE(FileDirectoryInformation, fn, __VA_ARGS__) \
194214 _APP_FINFO_CASE(FileFullDirectoryInformation, fn, __VA_ARGS__) \
195215 _APP_FINFO_CASE(FileBothDirectoryInformation, fn, __VA_ARGS__) \
196216 _APP_FINFO_CASE(FileStandardInformation, fn, __VA_ARGS__) \
197217 _APP_FINFO_CASE(FileNameInformation, fn, __VA_ARGS__) \
198218 _APP_FINFO_CASE(FileRenameInformation, fn, __VA_ARGS__) \
199219 _APP_FINFO_CASE(FileNamesInformation, fn, __VA_ARGS__) \
200- _APP_FINFO_CASE(FileAllInformation, fn, __VA_ARGS__) \
201220 _APP_FINFO_CASE(FileObjectIdInformation, fn, __VA_ARGS__) \
202221 _APP_FINFO_CASE(FileReparsePointInformation, fn, __VA_ARGS__) \
203222 _APP_FINFO_CASE(FileIdBothDirectoryInformation, fn, __VA_ARGS__) \
@@ -210,17 +229,6 @@ struct FileInformationClassUtils<FileIdAllExtdBothDirectoryInformation>
210229 _APP_FINFO_CASE(FileIdAllExtdDirectoryInformation, fn, __VA_ARGS__) \
211230 _APP_FINFO_CASE(FileIdAllExtdBothDirectoryInformation, fn, __VA_ARGS__)
212231
213- // minimum required size for the structure
214- // std::size_t
215- // get_file_information_minimum_struct_size(FILE_INFORMATION_CLASS fileInformationClass)
216- // {
217- // switch (fileInformationClass) {
218- // _APPLY_FILEINFO_FN(get_minimum_struct_size, );
219- // default:
220- // return 0;
221- // }
222- // }
223-
224232void GetFileInformationData(FILE_INFORMATION_CLASS fileInformationClass,
225233 LPCVOID address, ULONG& offset, std::wstring& fileName)
226234{
0 commit comments