ReactOS  0.4.15-dev-2972-gda2a567
IoVolume.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE: Kernel-Mode Test Suite Volume Device test
5  * COPYRIGHT: Copyright 2019 Thomas Faber (thomas.faber@reactos.org)
6  */
7 
8 #include <kmt_test.h>
9 
10 
11 static
12 void
14 {
16  ULONG VolumeNumber;
17  WCHAR VolumeDeviceNameBuffer[32];
18  UNICODE_STRING VolumeDeviceName;
22  UNICODE_STRING DosVolumePrefix = RTL_CONSTANT_STRING(L"\\\\?\\Volume");
23 
24  RtlInitEmptyUnicodeString(&VolumeDeviceName,
25  VolumeDeviceNameBuffer,
26  sizeof(VolumeDeviceNameBuffer));
27  VolumeNumber = 0;
28  while (1)
29  {
30  VolumeNumber++;
31  Status = RtlStringCbPrintfW(VolumeDeviceName.Buffer,
32  VolumeDeviceName.MaximumLength,
33  L"\\Device\\HarddiskVolume%lu",
34  VolumeNumber);
35  if (!NT_SUCCESS(Status))
36  {
37  trace("RtlStringCbPrintfW(0x%lx) failed with %lx\n",
38  VolumeNumber, Status);
39  break;
40  }
41 
42  RtlInitUnicodeString(&VolumeDeviceName, VolumeDeviceNameBuffer);
43  Status = IoGetDeviceObjectPointer(&VolumeDeviceName,
45  &FileObject,
46  &DeviceObject);
47  if (!NT_SUCCESS(Status))
48  {
49  trace("IoGetDeviceObjectPointer(%wZ) failed with %lx\n",
50  &VolumeDeviceName, Status);
51  continue;
52  }
53 
56  if (!skip(NT_SUCCESS(Status), "No DOS name\n"))
57  {
58  trace("DOS name for %wZ is %wZ\n", &VolumeDeviceName, &DosName);
59  if (DosName.Length == 2 * sizeof(WCHAR))
60  {
61  ok(DosName.Buffer[0] >= L'A' &&
62  DosName.Buffer[0] <= L'Z' &&
63  DosName.Buffer[1] == L':',
64  "Unexpected drive letter: %wZ\n", &DosName);
65  }
66  else
67  {
68  ok(RtlPrefixUnicodeString(&DosVolumePrefix, &DosName, FALSE),
69  "Unexpected volume path: %wZ\n", &DosName);
70  }
72  }
74  }
75  ok(VolumeNumber > 1, "No volumes found\n");
76 }
77 
78 START_TEST(IoVolume)
79 {
81 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
LONG NTSTATUS
Definition: precomp.h:26
static void TestIoVolumeDeviceToDosName(void)
Definition: IoVolume.c:13
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
START_TEST(IoVolume)
Definition: IoVolume.c:78
NTSTATUS NTAPI IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName)
Definition: volume.c:1279
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
Status
Definition: gdiplustypes.h:24
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define ObDereferenceObject
Definition: obfuncs.h:203
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
* PFILE_OBJECT
Definition: iotypes.h:1998
#define READ_CONTROL
Definition: nt_native.h:58
static const WCHAR L[]
Definition: oid.c:1250
#define ok(value,...)
Definition: atltest.h:57
_Out_ PUNICODE_STRING DosName
Definition: rtlfuncs.h:1269
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ok_eq_hex(value, expected)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14