*/
#include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
#define MAX_DOS_DRIVES 26
/*
* @implemented
*/
-/* Synced to Wine-? */
-DWORD STDCALL
+/* Synced to Wine-2008/12/28 */
+DWORD WINAPI
GetLogicalDriveStringsA(DWORD nBufferLength,
LPSTR lpBuffer)
{
DWORD drive, count;
DWORD dwDriveMap;
+ LPSTR p;
dwDriveMap = GetLogicalDrives();
}
- if (count * 4 <= nBufferLength)
- {
- LPSTR p = lpBuffer;
+ if ((count * 4) + 1 > nBufferLength) return ((count * 4) + 1);
+
+ p = lpBuffer;
for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
if (dwDriveMap & (1<<drive))
*p++ = '\0';
}
*p = '\0';
- }
+
return (count * 4);
}
/*
* @implemented
*/
-/* Synced to Wine-? */
-DWORD STDCALL
+/* Synced to Wine-2008/12/28 */
+DWORD WINAPI
GetLogicalDriveStringsW(DWORD nBufferLength,
LPWSTR lpBuffer)
{
DWORD drive, count;
DWORD dwDriveMap;
+ LPWSTR p;
dwDriveMap = GetLogicalDrives();
count++;
}
- if (count * 4 <= nBufferLength)
- {
- LPWSTR p = lpBuffer;
- for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
- if (dwDriveMap & (1<<drive))
- {
- *p++ = (WCHAR)('A' + drive);
- *p++ = (WCHAR)':';
- *p++ = (WCHAR)'\\';
- *p++ = (WCHAR)'\0';
- }
- *p = (WCHAR)'\0';
- }
+ if ((count * 4) + 1 > nBufferLength) return ((count * 4) + 1);
+
+ p = lpBuffer;
+ for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
+ if (dwDriveMap & (1<<drive))
+ {
+ *p++ = (WCHAR)('A' + drive);
+ *p++ = (WCHAR)':';
+ *p++ = (WCHAR)'\\';
+ *p++ = (WCHAR)'\0';
+ }
+ *p = (WCHAR)'\0';
+
return (count * 4);
}
* @implemented
*/
/* Synced to Wine-? */
-DWORD STDCALL
+DWORD WINAPI
GetLogicalDrives(VOID)
{
NTSTATUS Status;
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetDiskFreeSpaceA (
LPCSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetDiskFreeSpaceW(
LPCWSTR lpRootPathName,
LPDWORD lpSectorsPerCluster,
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetDiskFreeSpaceExA (
LPCSTR lpDirectoryName OPTIONAL,
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetDiskFreeSpaceExW(
LPCWSTR lpDirectoryName OPTIONAL,
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
/*
* @implemented
*/
-UINT STDCALL
+UINT WINAPI
GetDriveTypeA(LPCSTR lpRootPathName)
{
PWCHAR RootPathNameW;
/*
* @implemented
*/
-UINT STDCALL
+UINT WINAPI
GetDriveTypeW(LPCWSTR lpRootPathName)
{
FILE_FS_DEVICE_INFORMATION FileFsDevice;
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetVolumeInformationA(
LPCSTR lpRootPathName,
LPSTR lpVolumeNameBuffer,
)
{
UNICODE_STRING FileSystemNameU;
- UNICODE_STRING VolumeNameU = {0};
+ UNICODE_STRING VolumeNameU = { 0, 0, NULL };
ANSI_STRING VolumeName;
ANSI_STRING FileSystemName;
PWCHAR RootPathNameW;
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetVolumeInformationW(
LPCWSTR lpRootPathName,
LPWSTR lpVolumeNameBuffer,
* @implemented
*/
BOOL
-STDCALL
+WINAPI
SetVolumeLabelA (
LPCSTR lpRootPathName,
LPCSTR lpVolumeName /* NULL if deleting label */
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
SetVolumeLabelW(
LPCWSTR lpRootPathName,
LPCWSTR lpVolumeName /* NULL if deleting label */
BOOL Result;
NTSTATUS Status;
+ if (!VolumeMountPoint || !VolumeMountPoint[0])
+ {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return FALSE;
+ }
+
/*
* First step is to convert the passed volume mount point name to
* an NT acceptable name.
BufferLength = sizeof(MOUNTDEV_NAME) + 50 * sizeof(WCHAR);
do
{
- MountDevName = RtlAllocateHeap(GetProcessHeap(), 0, BufferLength);
+ MountDevName = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength);
if (MountDevName == NULL)
{
NtClose(FileHandle);
BufferLength = sizeof(MOUNTDEV_NAME) + MountDevName->NameLength;
continue;
}
- else
+ else
{
NtClose(FileHandle);
SetLastErrorByStatus(Status);
MountPoint->DeviceNameOffset = sizeof(MOUNTMGR_MOUNT_POINT);
MountPoint->DeviceNameLength = MountDevName->NameLength;
RtlCopyMemory(MountPoint + 1, MountDevName->Name, MountDevName->NameLength);
- RtlFreeHeap(GetProcessHeap(), 0, MountDevName);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountDevName);
RtlInitUnicodeString(&NtFileName, L"\\??\\MountPointManager");
InitializeObjectAttributes(&ObjectAttributes, &NtFileName, 0, NULL, NULL);
- Status = NtOpenFile(&FileHandle, FILE_GENERIC_READ, &ObjectAttributes,
+ Status = NtOpenFile(&FileHandle, FILE_GENERIC_READ | SYNCHRONIZE, &ObjectAttributes,
&Iosb, FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
- RtlFreeHeap(GetProcessHeap(), 0, MountPoint);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint);
return FALSE;
}
BufferLength = sizeof(MOUNTMGR_MOUNT_POINTS);
do
{
- MountPoints = RtlAllocateHeap(GetProcessHeap(), 0, BufferLength);
+ MountPoints = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength);
if (MountPoints == NULL)
{
- RtlFreeHeap(GetProcessHeap(), 0, MountPoint);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint);
NtClose(FileHandle);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
MountPoints, BufferLength);
if (!NT_SUCCESS(Status))
{
- RtlFreeHeap(GetProcessHeap(), 0, MountPoints);
if (Status == STATUS_BUFFER_OVERFLOW)
{
BufferLength = MountPoints->Size;
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints);
continue;
}
else if (!NT_SUCCESS(Status))
{
- RtlFreeHeap(GetProcessHeap(), 0, MountPoint);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints);
NtClose(FileHandle);
SetLastErrorByStatus(Status);
return FALSE;
}
while (!NT_SUCCESS(Status));
- RtlFreeHeap(GetProcessHeap(), 0, MountPoint);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint);
NtClose(FileHandle);
/*
{
MountPoint = MountPoints->MountPoints + Index;
SymbolicLinkName = (PUCHAR)MountPoints + MountPoint->SymbolicLinkNameOffset;
-
+
/*
* Check for "\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\"
* (with the last slash being optional) style symbolic links.
Result = FALSE;
}
- RtlFreeHeap(GetProcessHeap(), 0, MountPoints);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints);
return Result;
}
}
}
- RtlFreeHeap(GetProcessHeap(), 0, MountPoints);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
* @implemented (Wine 13 sep 2008)
*/
BOOL
-STDCALL
+WINAPI
GetVolumeNameForVolumeMountPointA(
LPCSTR lpszVolumeMountPoint,
LPSTR lpszVolumeName,
if ((ret = GetVolumeNameForVolumeMountPointW( pathW, volumeW, len )))
FilenameW2A_N( lpszVolumeName, len, volumeW, -1 );
- RtlFreeHeap( GetProcessHeap(), 0, pathW );
+ RtlFreeHeap( RtlGetProcessHeap(), 0, pathW );
return ret;
}
* @implemented (Wine 13 sep 2008)
*/
HANDLE
-STDCALL
+WINAPI
FindFirstVolumeW(
LPWSTR volume,
DWORD len
{
DWORD size = 1024;
HANDLE mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, 0, 0 );
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, INVALID_HANDLE_VALUE );
if (mgr == INVALID_HANDLE_VALUE) return INVALID_HANDLE_VALUE;
for (;;)
MOUNTMGR_MOUNT_POINT input;
MOUNTMGR_MOUNT_POINTS *output;
- if (!(output = RtlAllocateHeap( GetProcessHeap(), 0, size )))
+ if (!(output = RtlAllocateHeap( RtlGetProcessHeap(), 0, size )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
break;
{
if (GetLastError() != ERROR_MORE_DATA) break;
size = output->Size;
- RtlFreeHeap( GetProcessHeap(), 0, output );
+ RtlFreeHeap( RtlGetProcessHeap(), 0, output );
continue;
}
CloseHandle( mgr );
output->Size = 0;
if (!FindNextVolumeW( output, volume, len ))
{
- RtlFreeHeap( GetProcessHeap(), 0, output );
+ RtlFreeHeap( RtlGetProcessHeap(), 0, output );
return INVALID_HANDLE_VALUE;
}
return (HANDLE)output;
* @implemented (Wine 13 sep 2008)
*/
HANDLE
-STDCALL
+WINAPI
FindFirstVolumeA(
LPSTR volume,
DWORD len
)
{
- WCHAR *buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) );
- HANDLE handle = FindFirstVolumeW( buffer, len );
+ WCHAR *buffer = NULL;
+ HANDLE handle;
+
+ buffer = RtlAllocateHeap( RtlGetProcessHeap(), 0, len * sizeof(WCHAR) );
+
+ if (!buffer)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return INVALID_HANDLE_VALUE;
+ }
+
+ handle = FindFirstVolumeW( buffer, len );
if (handle != INVALID_HANDLE_VALUE)
{
handle = INVALID_HANDLE_VALUE;
}
}
- RtlFreeHeap( GetProcessHeap(), 0, buffer );
+ RtlFreeHeap( RtlGetProcessHeap(), 0, buffer );
return handle;
}
* @implemented (Wine 13 sep 2008)
*/
BOOL
-STDCALL
+WINAPI
FindVolumeClose(
HANDLE hFindVolume
)
{
- return RtlFreeHeap(GetProcessHeap(), 0, hFindVolume);
+ return RtlFreeHeap(RtlGetProcessHeap(), 0, hFindVolume);
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetVolumePathNameA(LPCSTR lpszFileName,
+ LPSTR lpszVolumePathName,
+ DWORD cchBufferLength)
+{
+ PWCHAR FileNameW = NULL;
+ WCHAR VolumePathName[MAX_PATH];
+ BOOL Result;
+
+ if (lpszFileName)
+ {
+ if (!(FileNameW = FilenameA2W(lpszFileName, FALSE)))
+ return FALSE;
+ }
+
+ Result = GetVolumePathNameW(FileNameW, VolumePathName, cchBufferLength);
+
+ if (Result)
+ FilenameW2A_N(lpszVolumePathName, MAX_PATH, VolumePathName, -1);
+
+ return Result;
+}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+GetVolumePathNameW(LPCWSTR lpszFileName,
+ LPWSTR lpszVolumePathName,
+ DWORD cchBufferLength)
+{
+ DWORD PathLength;
+ UNICODE_STRING UnicodeFilePath;
+ LPWSTR FilePart;
+ PWSTR FullFilePath, FilePathName;
+ ULONG PathSize;
+ WCHAR VolumeName[MAX_PATH];
+ DWORD ErrorCode;
+ BOOL Result = FALSE;
+
+ if (!(PathLength = GetFullPathNameW(lpszFileName, 0, NULL, NULL)))
+ {
+ return Result;
+ }
+ else
+ {
+ PathLength = PathLength + 10;
+ PathSize = PathLength * sizeof(WCHAR);
+
+ if (!(FullFilePath = RtlAllocateHeap(RtlGetProcessHeap(), 0, PathSize)))
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return Result;
+ }
+
+ if (!GetFullPathNameW(lpszFileName, PathLength, FullFilePath, &FilePart))
+ {
+ RtlFreeHeap(RtlGetProcessHeap(), 0, FullFilePath);
+ return Result;
+ }
+
+ RtlInitUnicodeString(&UnicodeFilePath, FullFilePath);
+
+ if (UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR) - 1] != '\\')
+ {
+ UnicodeFilePath.Length += sizeof(WCHAR);
+ UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR) - 1] = '\\';
+ UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
+ }
+
+ if (!(FilePathName = RtlAllocateHeap(RtlGetProcessHeap(), 0, PathSize)))
+ {
+ RtlFreeHeap(RtlGetProcessHeap(), 0, FullFilePath);
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return Result;
+ }
+
+ while (!GetVolumeNameForVolumeMountPointW(UnicodeFilePath.Buffer,
+ VolumeName,
+ MAX_PATH))
+ {
+ if (((UnicodeFilePath.Length == 4) && (UnicodeFilePath.Buffer[0] == '\\') &&
+ (UnicodeFilePath.Buffer[1] == '\\')) || ((UnicodeFilePath.Length == 6) &&
+ (UnicodeFilePath.Buffer[1] == ':')))
+ {
+ break;
+ }
+
+ UnicodeFilePath.Length -= sizeof(WCHAR);
+ UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
+
+ memcpy(FilePathName, UnicodeFilePath.Buffer, UnicodeFilePath.Length);
+ FilePathName[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
+
+ if (!GetFullPathNameW(FilePathName, PathLength, FullFilePath, &FilePart))
+ {
+ goto Cleanup2;
+ }
+
+ if (!FilePart)
+ {
+ RtlInitUnicodeString(&UnicodeFilePath, FullFilePath);
+ UnicodeFilePath.Length += sizeof(WCHAR);
+ UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR) - 1] = '\\';
+ UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
+ break;
+ }
+
+ FilePart[0] = '\0';
+ RtlInitUnicodeString(&UnicodeFilePath, FullFilePath);
+ }
+ }
+
+ if (UnicodeFilePath.Length > (cchBufferLength * sizeof(WCHAR)) - sizeof(WCHAR))
+ {
+ ErrorCode = ERROR_FILENAME_EXCED_RANGE;
+ goto Cleanup1;
+ }
+
+ memcpy(lpszVolumePathName, UnicodeFilePath.Buffer, UnicodeFilePath.Length);
+ lpszVolumePathName[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
+
+ Result = TRUE;
+ goto Cleanup2;
+
+Cleanup1:
+ SetLastError(ErrorCode);
+Cleanup2:
+ RtlFreeHeap(RtlGetProcessHeap(), 0, FullFilePath);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, FilePathName);
+ return Result;
}
/* EOF */