Commit 5742497a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

kernel32/tests: Some tests for invalid classes in SetFileInformationByHandle().

parent b95d3184
......@@ -55,6 +55,7 @@ static NTSTATUS (WINAPI *pNtCreateFile)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES
PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG);
static BOOL (WINAPI *pRtlDosPathNameToNtPathName_U)(LPCWSTR, PUNICODE_STRING, PWSTR*, CURDIR*);
static NTSTATUS (WINAPI *pRtlAnsiStringToUnicodeString)(PUNICODE_STRING, PCANSI_STRING, BOOLEAN);
static BOOL (WINAPI *pSetFileInformationByHandle)(HANDLE, FILE_INFO_BY_HANDLE_CLASS, void*, DWORD);
static const char filename[] = "testfile.xxx";
static const char sillytext[] =
......@@ -99,6 +100,7 @@ static void InitFunctionPointers(void)
pCreateFile2 = (void *) GetProcAddress(hkernel32, "CreateFile2");
pGetFinalPathNameByHandleA = (void *) GetProcAddress(hkernel32, "GetFinalPathNameByHandleA");
pGetFinalPathNameByHandleW = (void *) GetProcAddress(hkernel32, "GetFinalPathNameByHandleW");
pSetFileInformationByHandle = (void *) GetProcAddress(hkernel32, "SetFileInformationByHandle");
}
static void test__hread( void )
......@@ -4581,6 +4583,62 @@ static void test_GetFinalPathNameByHandleW(void)
CloseHandle(file);
}
static void test_SetFileInformationByHandle(void)
{
FILE_ATTRIBUTE_TAG_INFO fileattrinfo = { 0 };
FILE_REMOTE_PROTOCOL_INFO protinfo = { 0 };
FILE_STANDARD_INFO stdinfo = { };
FILE_COMPRESSION_INFO compressinfo;
char tempFileName[MAX_PATH];
char tempPath[MAX_PATH];
HANDLE file;
BOOL ret;
if (!pSetFileInformationByHandle)
{
win_skip("SetFileInformationByHandle is not supported\n");
return;
}
ret = GetTempPathA(sizeof(tempPath), tempPath);
ok(ret, "GetTempPathA failed, got error %u.\n", GetLastError());
/* ensure the existence of a file in the temp folder */
ret = GetTempFileNameA(tempPath, "abc", 0, tempFileName);
ok(ret, "GetTempFileNameA failed, got error %u.\n", GetLastError());
file = CreateFileA(tempFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
ok(file != INVALID_HANDLE_VALUE, "failed to open the temp file, error %u.\n", GetLastError());
/* invalid classes */
SetLastError(0xdeadbeef);
ret = pSetFileInformationByHandle(file, FileStandardInfo, &stdinfo, sizeof(stdinfo));
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
memset(&compressinfo, 0, sizeof(compressinfo));
SetLastError(0xdeadbeef);
ret = pSetFileInformationByHandle(file, FileCompressionInfo, &compressinfo, sizeof(compressinfo));
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
SetLastError(0xdeadbeef);
ret = pSetFileInformationByHandle(file, FileAttributeTagInfo, &fileattrinfo, sizeof(fileattrinfo));
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
memset(&protinfo, 0, sizeof(protinfo));
protinfo.StructureVersion = 1;
protinfo.StructureSize = sizeof(protinfo);
SetLastError(0xdeadbeef);
ret = pSetFileInformationByHandle(file, FileRemoteProtocolInfo, &protinfo, sizeof(protinfo));
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %d, error %d\n", ret, GetLastError());
CloseHandle(file);
}
START_TEST(file)
{
InitFunctionPointers();
......@@ -4636,4 +4694,5 @@ START_TEST(file)
test_file_access();
test_GetFinalPathNameByHandleA();
test_GetFinalPathNameByHandleW();
test_SetFileInformationByHandle();
}
......@@ -874,6 +874,37 @@ typedef struct _FILE_RENAME_INFO {
WCHAR FileName[1];
} FILE_RENAME_INFO, *PFILE_RENAME_INFO;
typedef struct _FILE_ATTRIBUTE_TAG_INFO {
DWORD FileAttributes;
DWORD ReparseTag;
} FILE_ATTRIBUTE_TAG_INFO, *PFILE_ATTRIBUTE_TAG_INFO;
typedef struct _FILE_COMPRESSION_INFO {
LARGE_INTEGER CompressedFileSize;
WORD CompressionFormat;
UCHAR CompressionUnitShift;
UCHAR ChunkShift;
UCHAR ClusterShift;
UCHAR Reserved[3];
} FILE_COMPRESSION_INFO, *PFILE_COMPRESSION_INFO;
typedef struct _FILE_REMOTE_PROTOCOL_INFO {
USHORT StructureVersion;
USHORT StructureSize;
ULONG Protocol;
USHORT ProtocolMajorVersion;
USHORT ProtocolMinorVersion;
USHORT ProtocolRevision;
USHORT Reserved;
ULONG Flags;
struct {
ULONG Reserved[8];
} GenericReserved;
struct {
ULONG Reserved[16];
} ProtocolSpecificReserved;
} FILE_REMOTE_PROTOCOL_INFO, *PFILE_REMOTE_PROTOCOL_INFO;
#define PIPE_ACCESS_INBOUND 1
#define PIPE_ACCESS_OUTBOUND 2
#define PIPE_ACCESS_DUPLEX 3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment