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

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jun 9 08:25:52 CDT 2015


Module: wine
Branch: master
Commit: 5742497a35691abc4fad7133265a0a69784679f6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5742497a35691abc4fad7133265a0a69784679f6

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Jun  8 13:59:05 2015 +0300

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

---

 dlls/kernel32/tests/file.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 include/winbase.h          | 31 ++++++++++++++++++++++++
 2 files changed, 90 insertions(+)

diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index 9480bd4..384dd8d 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -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();
 }
diff --git a/include/winbase.h b/include/winbase.h
index 4795d87..c558b21 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -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




More information about the wine-cvs mailing list