ReactOS 0.4.16-dev-2274-gc61d98f
mntpointansi.c File Reference
#include <k32.h>
Include dependency graph for mntpointansi.c:

Go to the source code of this file.

Functions

BOOL WINAPI GetVolumeNameForVolumeMountPointA (IN LPCSTR lpszVolumeMountPoint, IN LPSTR lpszVolumeName, IN DWORD cchBufferLength)
 

Function Documentation

◆ GetVolumeNameForVolumeMountPointA()

BOOL WINAPI GetVolumeNameForVolumeMountPointA ( IN LPCSTR  lpszVolumeMountPoint,
IN LPSTR  lpszVolumeName,
IN DWORD  cchBufferLength 
)

Definition at line 19 of file mntpointansi.c.

22{
23 BOOL Ret;
25 UNICODE_STRING VolumeNameU;
26 PUNICODE_STRING VolumeMountPointU;
27
28 /* Convert mount point to unicode */
29 VolumeMountPointU = Basep8BitStringToStaticUnicodeString(lpszVolumeMountPoint);
30 if (VolumeMountPointU == NULL)
31 {
32 return FALSE;
33 }
34
35 /* Initialize the strings we'll use for convention */
36 VolumeName.Buffer = lpszVolumeName;
38 VolumeName.MaximumLength = cchBufferLength - 1;
39
40 VolumeNameU.Length = 0;
41 VolumeNameU.MaximumLength = (cchBufferLength - 1) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
42 /* Allocate a buffer big enough to contain the returned name */
43 VolumeNameU.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, VolumeNameU.MaximumLength);
44 if (VolumeNameU.Buffer == NULL)
45 {
47 return FALSE;
48 }
49
50 /* Query -W */
51 Ret = GetVolumeNameForVolumeMountPointW(VolumeMountPointU->Buffer, VolumeNameU.Buffer, cchBufferLength);
52 /* If it succeed, perform -A conversion */
53 if (Ret)
54 {
56
57 /* Reinit our string for length */
58 RtlInitUnicodeString(&VolumeNameU, VolumeNameU.Buffer);
59 /* Convert to ANSI */
61 /* If conversion failed, force failure, otherwise, just null terminate */
62 if (!NT_SUCCESS(Status))
63 {
64 Ret = FALSE;
66 }
67 else
68 {
70 }
71 }
72
73 /* Internal buffer no longer needed */
74 RtlFreeHeap(RtlGetProcessHeap(), 0, VolumeNameU.Buffer);
75
76 return Ret;
77}
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define SetLastError(x)
Definition: compat.h:752
PUNICODE_STRING WINAPI Basep8BitStringToStaticUnicodeString(IN LPCSTR String)
Definition: utils.c:189
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
Status
Definition: gdiplustypes.h:25
BOOL WINAPI GetVolumeNameForVolumeMountPointW(IN LPCWSTR VolumeMountPoint, OUT LPWSTR VolumeName, IN DWORD VolumeNameLength)
Definition: mntpoint.c:496
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
#define ANSI_NULL
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
USHORT MaximumLength
Definition: env_spec_w32.h:370
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_dos_devices(), test_enum_vols(), test_GetDiskFreeSpaceA(), test_GetVolumeInformationA(), test_GetVolumeInformationByHandle(), test_GetVolumeNameForVolumeMountPointA(), test_GetVolumePathNamesForVolumeNameA(), and test_mounted_folder().