ReactOS 0.4.16-dev-303-g11d5cb8
QueryPoints.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for QueryPoints IOCTL
5 * PROGRAMMER: Pierre Schweitzer
6 */
7
8#include "precomp.h"
9
10VOID
12 PMOUNTMGR_MOUNT_POINT MountPoint)
13{
14 trace("MountPoint: %p\n", MountPoint);
15 trace("\tSymbolicOffset: %ld\n", MountPoint->SymbolicLinkNameOffset);
16 trace("\tSymbolicLinkName: %.*S\n", MountPoint->SymbolicLinkNameLength / sizeof(WCHAR), (PWSTR)((ULONG_PTR)MountPoints + MountPoint->SymbolicLinkNameOffset));
17 trace("\tDeviceOffset: %ld\n", MountPoint->DeviceNameOffset);
18 trace("\tDeviceName: %.*S\n", MountPoint->DeviceNameLength / sizeof(WCHAR), (PWSTR)((ULONG_PTR)MountPoints + MountPoint->DeviceNameOffset));
19}
20
21START_TEST(QueryPoints)
22{
23 BOOL Ret;
24 HANDLE MountMgrHandle;
25 DWORD BytesReturned, Drives, i;
26 struct {
28 WCHAR Buffer[sizeof(L"\\DosDevice\\A:")];
29 } SinglePoint;
30 MOUNTMGR_MOUNT_POINTS MountPoints;
31 PMOUNTMGR_MOUNT_POINTS AllocatedPoints;
32
33 MountMgrHandle = CreateFileW(MOUNTMGR_DOS_DEVICE_NAME, 0,
37 if (MountMgrHandle == INVALID_HANDLE_VALUE)
38 {
39 win_skip("MountMgr unavailable: %lx\n", GetLastError());
40 return;
41 }
42
43 ZeroMemory(&SinglePoint, sizeof(SinglePoint));
44
45 Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
46 &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
47 &MountPoints, sizeof(MOUNTMGR_MOUNT_POINTS),
49 ok(Ret == FALSE, "IOCTL unexpectedly succeed\n");
50 ok(GetLastError() == ERROR_MORE_DATA, "Unexcepted failure: %lx\n", GetLastError());
51
52 AllocatedPoints = RtlAllocateHeap(RtlGetProcessHeap(), 0, MountPoints.Size);
53 if (AllocatedPoints == NULL)
54 {
55 win_skip("Insufficiant memory\n");
56 }
57 else
58 {
59 AllocatedPoints->NumberOfMountPoints = 0;
60
61 Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
62 &SinglePoint, sizeof(MOUNTMGR_MOUNT_POINT),
63 AllocatedPoints, MountPoints.Size,
65 ok(Ret == TRUE, "IOCTL unexpectedly failed %lx\n", GetLastError());
66
67 for (i = 0; i < AllocatedPoints->NumberOfMountPoints; ++i)
68 {
69 TraceMountPoint(AllocatedPoints, &AllocatedPoints->MountPoints[i]);
70 }
71
72 RtlFreeHeap(RtlGetProcessHeap(), 0, AllocatedPoints);
73 }
74
75 Drives = GetLogicalDrives();
76 if (Drives == 0)
77 {
78 win_skip("Drives map unavailable: %lx\n", GetLastError());
79 goto Done;
80 }
81
82 for (i = 0; i < 26; i++)
83 {
84 if (!(Drives & (1 << i)))
85 {
86 break;
87 }
88 }
89
90 if (i == 26)
91 {
92 win_skip("All the drive letters are in use, skipping\n");
93 goto Done;
94 }
95
96 SinglePoint.SymbolicLinkNameOffset = sizeof(MOUNTMGR_MOUNT_POINT);
97 SinglePoint.SymbolicLinkNameLength = sizeof(L"\\DosDevice\\A:") - sizeof(UNICODE_NULL);
98 StringCbPrintfW((PWSTR)((ULONG_PTR)&SinglePoint + sizeof(MOUNTMGR_MOUNT_POINT)),
99 sizeof(L"\\DosDevice\\A:"),
100 L"\\DosDevice\\%C:",
101 i + L'A');
102
103 Ret = DeviceIoControl(MountMgrHandle, IOCTL_MOUNTMGR_QUERY_POINTS,
104 &SinglePoint, sizeof(SinglePoint),
105 &MountPoints, sizeof(MOUNTMGR_MOUNT_POINTS),
107 ok(Ret == FALSE, "IOCTL unexpectedly succeed\n");
108 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Unexcepted failure: %lx\n", GetLastError());
109
110Done:
111 CloseHandle(MountMgrHandle);
112}
VOID TraceMountPoint(PMOUNTMGR_MOUNT_POINTS MountPoints, PMOUNTMGR_MOUNT_POINT MountPoint)
Definition: QueryPoints.c:11
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
Definition: bufpool.h:45
#define ERROR_MORE_DATA
Definition: dderror.h:13
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
struct _MOUNTMGR_MOUNT_POINT MOUNTMGR_MOUNT_POINT
#define IOCTL_MOUNTMGR_QUERY_POINTS
Definition: mountmgr.h:49
#define MOUNTMGR_DOS_DEVICE_NAME
Definition: mountmgr.h:37
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define win_skip
Definition: test.h:163
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
MOUNTMGR_MOUNT_POINT MountPoints[1]
Definition: imports.h:175
USHORT DeviceNameLength
Definition: imports.h:169
USHORT SymbolicLinkNameLength
Definition: imports.h:165
ULONG SymbolicLinkNameOffset
Definition: imports.h:164
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
#define ZeroMemory
Definition: winbase.h:1737
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetLogicalDrives(void)
Definition: disk.c:110
__wchar_t WCHAR
Definition: xmlstorage.h:180