[PATCH 2/2] [Kernel32]: in CreateFile, when trying to open the CON special DOS file, force OPEN_EXISTING as creation flag, as MS does
Eric Pouech
eric.pouech at orange.fr
Tue May 10 15:02:35 CDT 2011
fix for #24876
A+
---
dlls/kernel32/file.c | 4 ++--
dlls/kernel32/tests/console.c | 17 -----------------
2 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index 6ee243e..537ea0a 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -1322,10 +1322,10 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing,
switch (access & (GENERIC_READ|GENERIC_WRITE))
{
case GENERIC_READ:
- ret = OpenConsoleW(coninW, access, (sa && sa->bInheritHandle), creation);
+ ret = OpenConsoleW(coninW, access, (sa && sa->bInheritHandle), OPEN_EXISTING);
goto done;
case GENERIC_WRITE:
- ret = OpenConsoleW(conoutW, access, (sa && sa->bInheritHandle), creation);
+ ret = OpenConsoleW(conoutW, access, (sa && sa->bInheritHandle), OPEN_EXISTING);
goto done;
default:
SetLastError( ERROR_FILE_NOT_FOUND );
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 318b9b8..bbd8785 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -1002,7 +1002,6 @@ static void test_OpenCON(void)
for (i = 0; i < sizeof(accesses) / sizeof(accesses[0]); i++)
{
- if (accesses[i] != OPEN_EXISTING) todo_wine {
h = CreateFileW(conW, GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
ok(h != INVALID_HANDLE_VALUE, "Expected to open the CON device on write (%x)\n", accesses[i]);
CloseHandle(h);
@@ -1018,23 +1017,7 @@ static void test_OpenCON(void)
ok(h != INVALID_HANDLE_VALUE, "Expected to open the CON device on read (%x)\n", accesses[i]);
}
CloseHandle(h);
- } else {
- h = CreateFileW(conW, GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
- ok(h != INVALID_HANDLE_VALUE, "Expected to open the CON device on write (%x)\n", accesses[i]);
- CloseHandle(h);
- h = CreateFileW(conW, GENERIC_READ, 0, NULL, accesses[i], 0, NULL);
- /* Windows version differ here:
- * MSDN states in CreateFile that TRUNCATE_EXISTING requires GENERIC_WRITE
- * NT, XP, Vista comply, but Win7 doesn't and allow to open CON with TRUNCATE_EXISTING
- * So don't test when disposition is TRUNCATE_EXISTING
- */
- if (accesses[i] != TRUNCATE_EXISTING)
- {
- ok(h != INVALID_HANDLE_VALUE, "Expected to open the CON device on read (%x)\n", accesses[i]);
- }
- CloseHandle(h);
- }
h = CreateFileW(conW, GENERIC_READ|GENERIC_WRITE, 0, NULL, accesses[i], 0, NULL);
ok(h == INVALID_HANDLE_VALUE, "Expected not to open the CON device on read-write (%x)\n", accesses[i]);
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Unexpected error %x\n", GetLastError());
More information about the wine-patches
mailing list