From 362c277e2f7893ea69112a706a9b6f7c85be5b3a Mon Sep 17 00:00:00 2001 From: Louis Lenders Date: Thu, 29 Oct 2009 22:55:19 +0100 Subject: kernel32: fix SetLastError in FormatMessage{A,W} for special language-id's if message-id cannot be found modified: dlls/kernel32/format_msg.c modified: dlls/kernel32/tests/format_msg.c --- dlls/kernel32/format_msg.c | 24 ++++++++++++++++++++++-- dlls/kernel32/tests/format_msg.c | 8 ++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/format_msg.c b/dlls/kernel32/format_msg.c index 7145479..84b725c 100644 --- a/dlls/kernel32/format_msg.c +++ b/dlls/kernel32/format_msg.c @@ -177,7 +177,17 @@ DWORD WINAPI FormatMessageA( if (!from) { - SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND); + switch(dwLanguageId){ + case MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL): + case MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT): + case MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT): + case MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US): + SetLastError (ERROR_MR_MID_NOT_FOUND); + break; + + default: + SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND); + } return 0; } } @@ -408,7 +418,17 @@ DWORD WINAPI FormatMessageW( if (!from) { - SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND); + switch(dwLanguageId){ + case MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL): + case MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT): + case MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT): + case MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US): + SetLastError (ERROR_MR_MID_NOT_FOUND); + break; + + default: + SetLastError (ERROR_RESOURCE_LANG_NOT_FOUND); + } return 0; } } diff --git a/dlls/kernel32/tests/format_msg.c b/dlls/kernel32/tests/format_msg.c index 2bbcfc8..15064b2 100644 --- a/dlls/kernel32/tests/format_msg.c +++ b/dlls/kernel32/tests/format_msg.c @@ -668,28 +668,28 @@ static void test_message_from_hmodule(void) MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), out, sizeof(out)/sizeof(CHAR), NULL); error = GetLastError(); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); - todo_wine ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); + ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); SetLastError(0xdeadbeef); ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL); error = GetLastError(); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); - todo_wine ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); + ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); SetLastError(0xdeadbeef); ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), out, sizeof(out)/sizeof(CHAR), NULL); error = GetLastError(); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); - todo_wine ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); + ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); SetLastError(0xdeadbeef); ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), out, sizeof(out)/sizeof(CHAR), NULL); error = GetLastError(); ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret); - todo_wine ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); + ok(error == ERROR_MR_MID_NOT_FOUND, "last error %u\n", error); SetLastError(0xdeadbeef); ret = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE, h, 3044, -- 1.6.0.4