VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/SharedFolders/testcase/queryfileinfo-1.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: queryfileinfo-1.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VirtualBox Windows Guest Shared Folders FSD - Simple Testcase.
4 */
5
6/*
7 * Copyright (C) 2019-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#include <iprt/nt/nt-and-windows.h>
29#include <stdio.h>
30
31static const char * const g_apszFileInfoNames[] =
32{
33 "0",
34 "FileDirectoryInformation",
35 "FileFullDirectoryInformation",
36 "FileBothDirectoryInformation",
37 "FileBasicInformation",
38 "FileStandardInformation",
39 "FileInternalInformation",
40 "FileEaInformation",
41 "FileAccessInformation",
42 "FileNameInformation",
43 "FileRenameInformation",
44 "FileLinkInformation",
45 "FileNamesInformation",
46 "FileDispositionInformation",
47 "FilePositionInformation",
48 "FileFullEaInformation",
49 "FileModeInformation",
50 "FileAlignmentInformation",
51 "FileAllInformation",
52 "FileAllocationInformation",
53 "FileEndOfFileInformation",
54 "FileAlternateNameInformation",
55 "FileStreamInformation",
56 "FilePipeInformation",
57 "FilePipeLocalInformation",
58 "FilePipeRemoteInformation",
59 "FileMailslotQueryInformation",
60 "FileMailslotSetInformation",
61 "FileCompressionInformation",
62 "FileObjectIdInformation",
63 "FileCompletionInformation",
64 "FileMoveClusterInformation",
65 "FileQuotaInformation",
66 "FileReparsePointInformation",
67 "FileNetworkOpenInformation",
68 "FileAttributeTagInformation",
69 "FileTrackingInformation",
70 "FileIdBothDirectoryInformation",
71 "FileIdFullDirectoryInformation",
72 "FileValidDataLengthInformation",
73 "FileShortNameInformation",
74 "FileIoCompletionNotificationInformation",
75 "FileIoStatusBlockRangeInformation",
76 "FileIoPriorityHintInformation",
77 "FileSfioReserveInformation",
78 "FileSfioVolumeInformation",
79 "FileHardLinkInformation",
80 "FileProcessIdsUsingFileInformation",
81 "FileNormalizedNameInformation",
82 "FileNetworkPhysicalNameInformation",
83 "FileIdGlobalTxDirectoryInformation",
84 "FileIsRemoteDeviceInformation",
85 "FileUnusedInformation",
86 "FileNumaNodeInformation",
87 "FileStandardLinkInformation",
88 "FileRemoteProtocolInformation",
89 "FileRenameInformationBypassAccessCheck",
90 "FileLinkInformationBypassAccessCheck",
91 "FileVolumeNameInformation",
92 "FileIdInformation",
93 "FileIdExtdDirectoryInformation",
94 "FileReplaceCompletionInformation",
95 "FileHardLinkFullIdInformation",
96 "FileIdExtdBothDirectoryInformation",
97 "FileDispositionInformationEx",
98 "FileRenameInformationEx",
99 "FileRenameInformationExBypassAccessCheck",
100 "FileDesiredStorageClassInformation",
101 "FileStatInformation",
102 "FileMemoryPartitionInformation",
103 "FileStatLxInformation",
104 "FileCaseSensitiveInformation",
105 "FileLinkInformationEx",
106 "FileLinkInformationExBypassAccessCheck",
107 "FileStorageReserveIdInformation",
108 "FileCaseSensitiveInformationForceAccessCheck",
109 "FileMaximumInformation",
110 "FileMaximumInformation+1",
111 "FileMaximumInformation+2",
112 "FileMaximumInformation+3",
113 "FileMaximumInformation+4",
114 "FileMaximumInformation+5",
115 "FileMaximumInformation+6",
116 "FileMaximumInformation+7",
117 "FileMaximumInformation+8",
118 "FileMaximumInformation+9",
119 "FileMaximumInformation+10",
120 "FileMaximumInformation+11",
121 "FileMaximumInformation+12",
122};
123
124static const char *GetStatusName(NTSTATUS rcNt)
125{
126 switch (rcNt)
127 {
128 case STATUS_SUCCESS: return " (STATUS_SUCCESS)";
129 case STATUS_INVALID_INFO_CLASS: return " (STATUS_INVALID_INFO_CLASS)";
130 case STATUS_INVALID_PARAMETER: return " (STATUS_INVALID_PARAMETER)";
131 case STATUS_INVALID_DEVICE_REQUEST: return " (STATUS_INVALID_DEVICE_REQUEST)";
132 case STATUS_NO_SUCH_DEVICE: return " (STATUS_NO_SUCH_DEVICE)";
133 case STATUS_NOT_SUPPORTED: return " (STATUS_NOT_SUPPORTED)";
134 }
135 return "";
136}
137
138static void DoQueries(HANDLE hFile)
139{
140 union
141 {
142 uint8_t abBuf[4096];
143 } uBuf;
144
145 IO_STATUS_BLOCK const VirginIos = RTNT_IO_STATUS_BLOCK_INITIALIZER;
146 for (unsigned iClass = 0; iClass < RT_ELEMENTS(g_apszFileInfoNames); iClass++)
147 {
148 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
149 NTSTATUS rcNt = NtQueryInformationFile(hFile, &Ios, &uBuf, sizeof(uBuf), (FILE_INFORMATION_CLASS)iClass);
150 printf(" %45s: rcNt=%#x%s", g_apszFileInfoNames[iClass], rcNt, GetStatusName(rcNt));
151 if ( Ios.Information == VirginIos.Information
152 && Ios.Status == VirginIos.Status)
153 printf(" Ios=<not modified>\n", Ios.Status, Ios.Information);
154 else
155 printf(" Ios.Status=%#x%s Ios.Information=%p\n", Ios.Status, GetStatusName(Ios.Status), Ios.Information);
156 if (NT_SUCCESS(rcNt))
157 {
158 }
159 }
160}
161
162
163int main(int argc, char **argv)
164{
165 for (int i = 1; i < argc; i++)
166 {
167 printf("Querying info for: %s\n", argv[i]);
168 HANDLE hFile = CreateFileA(argv[i], GENERIC_READ, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
169 NULL /*pSecAttr*/, OPEN_EXISTING,
170 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
171 NULL /*hTemplate*/);
172 if (hFile != INVALID_HANDLE_VALUE)
173 {
174 DoQueries(hFile);
175 CloseHandle(hFile);
176 }
177 else
178 fprintf(stderr, "error opening '%s': %u\n", GetLastError());
179 }
180 return 0;
181}
182
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use