kernel32: Fail properly for unsupported classes in GetFileInformationByHandleEx.

This commit is contained in:
Nikolay Sivov 2015-06-07 00:56:14 +03:00 committed by Alexandre Julliard
parent 6db93689b1
commit b17e4376d5
3 changed files with 63 additions and 6 deletions

View File

@ -897,14 +897,9 @@ BOOL WINAPI GetFileInformationByHandleEx( HANDLE handle, FILE_INFO_BY_HANDLE_CLA
switch (class)
{
case FileRenameInfo:
case FileDispositionInfo:
case FileAllocationInfo:
case FileEndOfFileInfo:
case FileStreamInfo:
case FileCompressionInfo:
case FileAttributeTagInfo:
case FileIoPriorityHintInfo:
case FileRemoteProtocolInfo:
case FileFullDirectoryInfo:
case FileFullDirectoryRestartInfo:
@ -936,6 +931,11 @@ BOOL WINAPI GetFileInformationByHandleEx( HANDLE handle, FILE_INFO_BY_HANDLE_CLA
(class == FileIdBothDirectoryRestartInfo) );
break;
case FileRenameInfo:
case FileDispositionInfo:
case FileAllocationInfo:
case FileIoPriorityHintInfo:
case FileEndOfFileInfo:
default:
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;

View File

@ -3830,6 +3830,12 @@ static void test_GetFileInformationByHandleEx(void)
FILE_STANDARD_INFO *standardInfo;
FILE_NAME_INFO *nameInfo;
LARGE_INTEGER prevWrite;
FILE_IO_PRIORITY_HINT_INFO priohintinfo;
FILE_ALLOCATION_INFO allocinfo;
FILE_DISPOSITION_INFO dispinfo;
FILE_END_OF_FILE_INFO eofinfo;
FILE_RENAME_INFO renameinfo;
struct {
FILE_INFO_BY_HANDLE_CLASS handleClass;
void *ptr;
@ -3952,8 +3958,29 @@ static void test_GetFileInformationByHandleEx(void)
for (i = 0; i < nameInfo->FileNameLength/2; i++)
ok(strPtr[i] == nameInfo->FileName[i], "Incorrect filename char %d: %c vs %c\n",
i, strPtr[i], nameInfo->FileName[i]);
CloseHandle(file);
/* invalid classes */
SetLastError(0xdeadbeef);
ret = pGetFileInformationByHandleEx(file, FileEndOfFileInfo, &eofinfo, sizeof(eofinfo));
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pGetFileInformationByHandleEx(file, FileIoPriorityHintInfo, &priohintinfo, sizeof(priohintinfo));
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pGetFileInformationByHandleEx(file, FileAllocationInfo, &allocinfo, sizeof(allocinfo));
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pGetFileInformationByHandleEx(file, FileDispositionInfo, &dispinfo, sizeof(dispinfo));
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pGetFileInformationByHandleEx(file, FileRenameInfo, &renameinfo, sizeof(renameinfo));
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
CloseHandle(file);
DeleteFileA(tempFileName);
}

View File

@ -844,6 +844,36 @@ typedef struct _FILE_NAME_INFO {
WCHAR FileName[1];
} FILE_NAME_INFO, *PFILE_NAME_INFO;
typedef enum _PRIORITY_HINT {
IoPriorityHintVeryLow,
IoPriorityHintLow,
IoPriorityHintNormal,
MaximumIoPriorityHintType
} PRIORITY_HINT;
typedef struct _FILE_IO_PRIORITY_HINT_INFO {
PRIORITY_HINT PriorityHint;
} FILE_IO_PRIORITY_HINT_INFO;
typedef struct _FILE_ALLOCATION_INFO {
LARGE_INTEGER AllocationSize;
} FILE_ALLOCATION_INFO, *PFILE_ALLOCATION_INFO;
typedef struct _FILE_DISPOSITION_INFO {
BOOLEAN DeleteFile;
} FILE_DISPOSITION_INFO, *PFILE_DISPOSITION_INFO;
typedef struct _FILE_END_OF_FILE_INFO {
LARGE_INTEGER EndOfFile;
} FILE_END_OF_FILE_INFO, *PFILE_END_OF_FILE_INFO;
typedef struct _FILE_RENAME_INFO {
BOOLEAN ReplaceIfExists;
HANDLE RootDirectory;
DWORD FileNameLength;
WCHAR FileName[1];
} FILE_RENAME_INFO, *PFILE_RENAME_INFO;
#define PIPE_ACCESS_INBOUND 1
#define PIPE_ACCESS_OUTBOUND 2
#define PIPE_ACCESS_DUPLEX 3