ReactOS 0.4.16-dev-340-g0540c21
IoVolume.c File Reference
#include <kmt_test.h>
Include dependency graph for IoVolume.c:

Go to the source code of this file.

Functions

static void TestIoVolumeDeviceToDosName (void)
 
 START_TEST (IoVolume)
 

Function Documentation

◆ START_TEST()

START_TEST ( IoVolume  )

Definition at line 78 of file IoVolume.c.

79{
81}
static void TestIoVolumeDeviceToDosName(void)
Definition: IoVolume.c:13

◆ TestIoVolumeDeviceToDosName()

static void TestIoVolumeDeviceToDosName ( void  )
static

Definition at line 13 of file IoVolume.c.

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,
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}
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define READ_CONTROL
Definition: nt_native.h:58
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
NTSTATUS NTAPI IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName)
Definition: volume.c:1279
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 L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203
_Out_ PUNICODE_STRING DosName
Definition: rtlfuncs.h:1286
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().