https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0231c8baec0974dd19039a...
commit 0231c8baec0974dd19039aac9c2dcc487a6b2eee Author: Ged Murphy gedmurphy@reactos.org AuthorDate: Sun Nov 11 17:57:56 2018 +0000 Commit: Ged Murphy gedmurphy@reactos.org CommitDate: Sun Nov 11 17:58:39 2018 +0000
[FLTMC] Implement 'fltmc volumes' --- base/applications/fltmc/fltmc.cpp | 116 +++++++++++++++++++++++++++++++++- base/applications/fltmc/lang/en-US.rc | 2 + base/applications/fltmc/resource.h | 3 + 3 files changed, 120 insertions(+), 1 deletion(-)
diff --git a/base/applications/fltmc/fltmc.cpp b/base/applications/fltmc/fltmc.cpp index 1aca074499..3220a6e863 100644 --- a/base/applications/fltmc/fltmc.cpp +++ b/base/applications/fltmc/fltmc.cpp @@ -202,6 +202,64 @@ PrintFilterInfo(_In_ PVOID Buffer, } }
+void +PrintVolumeInfo(_In_ PVOID Buffer) +{ + PFILTER_VOLUME_STANDARD_INFORMATION FilterVolInfo; + WCHAR DosName[16] = { 0 }; + WCHAR VolName[128] = { 0 }; + WCHAR FileSystem[32] = { 0 }; + + FilterVolInfo = (PFILTER_VOLUME_STANDARD_INFORMATION)Buffer; + + if (FilterVolInfo->FilterVolumeNameLength < 128) + { + CopyMemory(VolName, + (PCHAR)FilterVolInfo->FilterVolumeName, + FilterVolInfo->FilterVolumeNameLength); + VolName[FilterVolInfo->FilterVolumeNameLength] = UNICODE_NULL; + } + + (void)FilterGetDosName(VolName, DosName, 16); + + switch (FilterVolInfo->FileSystemType) + { + case FLT_FSTYPE_MUP: + StringCchCopyW(FileSystem, 32, L"Remote"); + break; + + case FLT_FSTYPE_NTFS: + StringCchCopyW(FileSystem, 32, L"NTFS"); + break; + + case FLT_FSTYPE_FAT: + StringCchCopyW(FileSystem, 32, L"FAT"); + break; + + case FLT_FSTYPE_EXFAT: + StringCchCopyW(FileSystem, 32, L"exFAT"); + break; + + case FLT_FSTYPE_NPFS: + StringCchCopyW(FileSystem, 32, L"NamedPipe"); + break; + + case FLT_FSTYPE_MSFS: + StringCchCopyW(FileSystem, 32, L"Mailslot"); + break; + + case FLT_FSTYPE_UNKNOWN: + default: + StringCchCopyW(FileSystem, 32, L"<Unknown>"); + break; + } + + wprintf(L"%-31s %-40s %-10s\n", + DosName, + VolName, + FileSystem); +} + void ListFilters() { @@ -260,7 +318,51 @@ ListFilters()
if (!SUCCEEDED(hr) && hr != HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)) { - LoadAndPrintString(IDS_ERROR_PRIV, hr); + LoadAndPrintString(IDS_ERROR_FILTERS, hr); + PrintErrorText(hr); + } +} + +void +ListVolumes() +{ + HANDLE FindHandle; + BYTE Buffer[1024]; + ULONG BytesReturned; + HRESULT hr; + + hr = FilterVolumeFindFirst(FilterVolumeStandardInformation, + Buffer, + 1024, + &BytesReturned, + &FindHandle); + if (SUCCEEDED(hr)) + { + LoadAndPrintString(IDS_DISPLAY_VOLUMES); + wprintf(L"------------------------------ --------------------------------------- ---------- --------\n"); + + PrintVolumeInfo(Buffer); + + do + { + hr = FilterVolumeFindNext(FindHandle, + FilterVolumeStandardInformation, + Buffer, + 1024, + &BytesReturned); + if (SUCCEEDED(hr)) + { + PrintVolumeInfo(Buffer); + } + + } while (SUCCEEDED(hr)); + + FilterVolumeFindClose(FindHandle); + } + + if (!SUCCEEDED(hr) && hr != HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS)) + { + LoadAndPrintString(IDS_ERROR_VOLUMES, hr); PrintErrorText(hr); } } @@ -309,6 +411,18 @@ int wmain(int argc, WCHAR *argv[]) wprintf(L"fltmc.exe unload [name]\n\n"); } } + else if (!_wcsicmp(argv[1], L"volumes")) + { + if (argc == 2) + { + ListVolumes(); + } + else + { + LoadAndPrintString(IDS_USAGE_VOLUMES); + wprintf(L"fltmc.exe volumes [name]\n\n"); + } + }
return 0; } diff --git a/base/applications/fltmc/lang/en-US.rc b/base/applications/fltmc/lang/en-US.rc index 95e0338242..721855ef2c 100644 --- a/base/applications/fltmc/lang/en-US.rc +++ b/base/applications/fltmc/lang/en-US.rc @@ -16,6 +16,7 @@ STRINGTABLE BEGIN IDS_DISPLAY_FILTERS1 "Filter Name Num Instances Altitude Frame\n" IDS_DISPLAY_FILTERS2 "Filter Name Num Instances Frame\n" + IDS_DISPLAY_VOLUMES "Dos Name Volume Name FileSystem Status\n" END
STRINGTABLE @@ -24,4 +25,5 @@ BEGIN IDS_ERROR_FILTERS "Failed to list the filters (0x%X)\n" IDS_ERROR_LOAD "Failed to load the filter (0x%X)\n" IDS_ERROR_UNLOAD "Failed to unload the filter (0x%X)\n" + IDS_ERROR_VOLUMES "Failed to list the volumes (0x%X)\n" END diff --git a/base/applications/fltmc/resource.h b/base/applications/fltmc/resource.h index 366b6bd6e4..b3a0543b80 100644 --- a/base/applications/fltmc/resource.h +++ b/base/applications/fltmc/resource.h @@ -4,11 +4,14 @@ #define IDS_USAGE_LOAD 1 #define IDS_USAGE_UNLOAD 2 #define IDS_USAGE_FILTERS 3 +#define IDS_USAGE_VOLUMES 4
#define IDS_DISPLAY_FILTERS1 10 #define IDS_DISPLAY_FILTERS2 11 +#define IDS_DISPLAY_VOLUMES 12
#define IDS_ERROR_PRIV 20 #define IDS_ERROR_FILTERS 21 #define IDS_ERROR_LOAD 22 #define IDS_ERROR_UNLOAD 23 +#define IDS_ERROR_VOLUMES 24