From c19d166529008dcc48ab4f713febff4a9922c810 Mon Sep 17 00:00:00 2001 From: Bernhard Loos Date: Tue, 23 Aug 2011 11:33:51 +0200 Subject: [PATCH] kernel32: CreateFile uses an nonalertable io mode. --- dlls/kernel32/file.c | 2 +- dlls/kernel32/tests/file.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index 79cfc974f10..194960bedfa 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -1361,7 +1361,7 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing, if (attributes & FILE_FLAG_NO_BUFFERING) options |= FILE_NO_INTERMEDIATE_BUFFERING; if (!(attributes & FILE_FLAG_OVERLAPPED)) - options |= FILE_SYNCHRONOUS_IO_ALERT; + options |= FILE_SYNCHRONOUS_IO_NONALERT; if (attributes & FILE_FLAG_RANDOM_ACCESS) options |= FILE_RANDOM_ACCESS; attributes &= FILE_ATTRIBUTE_VALID_FLAGS; diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 59803c631e2..df2ab3738c5 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -38,6 +38,7 @@ static BOOL (WINAPI *pReplaceFileA)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOI static BOOL (WINAPI *pReplaceFileW)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID); static UINT (WINAPI *pGetSystemWindowsDirectoryA)(LPSTR, UINT); static BOOL (WINAPI *pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD); +static DWORD WINAPI (*pQueueUserAPC)(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData); /* keep filename and filenameW the same */ static const char filename[] = "testfile.xxx"; @@ -71,6 +72,7 @@ static void InitFunctionPointers(void) pReplaceFileW=(void*)GetProcAddress(hkernel32, "ReplaceFileW"); pGetSystemWindowsDirectoryA=(void*)GetProcAddress(hkernel32, "GetSystemWindowsDirectoryA"); pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hkernel32, "GetVolumeNameForVolumeMountPointA"); + pQueueUserAPC = (void *) GetProcAddress(hkernel32, "QueueUserAPC"); } static void test__hread( void ) @@ -2362,6 +2364,12 @@ static void test_async_file_errors(void) HeapFree(GetProcessHeap(), 0, lpBuffer); } +static BOOL user_apc_ran; +static void CALLBACK user_apc(ULONG_PTR param) +{ + user_apc_ran = TRUE; +} + static void test_read_write(void) { DWORD bytes, ret, old_prot; @@ -2382,6 +2390,12 @@ static void test_read_write(void) CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0); ok(hFile != INVALID_HANDLE_VALUE, "CreateFileA: error %d\n", GetLastError()); + user_apc_ran = FALSE; + if (pQueueUserAPC) { + trace("Queueing an user APC\n"); /* verify the file is non alerable */ + ok(pQueueUserAPC(&user_apc, GetCurrentThread(), 0), "QueueUserAPC failed: %d\n", GetLastError()); + } + SetLastError(12345678); bytes = 12345678; ret = WriteFile(hFile, NULL, 0, &bytes, NULL); @@ -2418,6 +2432,10 @@ static void test_read_write(void) "ret = %d, error %d\n", ret, GetLastError()); ok(!bytes, "bytes = %d\n", bytes); + ok(user_apc_ran == FALSE, "UserAPC ran, file using alertable io mode\n"); + if (pQueueUserAPC) + SleepEx(0, TRUE); /* get rid of apc */ + /* test passing protected memory as buffer */ mem = VirtualAlloc( NULL, 0x4000, MEM_COMMIT, PAGE_READWRITE );