From 45f4cd39649deeffb620ba8e947b31fee5b81606 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Fri, 22 Jul 2011 09:09:05 +0000 Subject: [PATCH] [KERNEL32]: Fix Bug #2: FindFirstChangeNotificationA actually returns FALSE instead of INVALID_HANDLE_VALUE if the name conversion failed. In fact, up until Win7, all the *A object APIs do so, even though MSDN has always claimed the APIs return INVALID_HANDLE_VALUE. Since we don't have the Shim Database Microsoft has to unbreak apps on Win7 that probably depend on the old behavior, we'll keep the old behavior (especially since we target NT 5.2 -- and even Vista does it this way). [KERNEL32]: Bug was fixed by using the new macros implemented last commit. svn path=/trunk/; revision=52777 --- .../dll/win32/kernel32/client/file/cnotify.c | 25 ++++--------------- reactos/dll/win32/kernel32/include/base_x.h | 10 ++++++++ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/file/cnotify.c b/reactos/dll/win32/kernel32/client/file/cnotify.c index 37814a13384..f5aca59b284 100644 --- a/reactos/dll/win32/kernel32/client/file/cnotify.c +++ b/reactos/dll/win32/kernel32/client/file/cnotify.c @@ -43,26 +43,11 @@ FindFirstChangeNotificationA(IN LPCSTR lpPathName, IN BOOL bWatchSubtree, IN DWORD dwNotifyFilter) { - NTSTATUS Status; - ANSI_STRING PathNameString; - - RtlInitAnsiString(&PathNameString, lpPathName); - Status = RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString), &PathNameString, FALSE); - if (!NT_SUCCESS(Status)) - { - if (Status != STATUS_BUFFER_OVERFLOW) - { - SetLastError(ERROR_FILENAME_EXCED_RANGE); - } - else - { - BaseSetLastNTError(Status); - } - return INVALID_HANDLE_VALUE; - } - - return FindFirstChangeNotificationW(NtCurrentTeb()->StaticUnicodeString.Buffer, - bWatchSubtree, dwNotifyFilter); + /* Call the W(ide) function */ + ConvertWin32AnsiChangeApiToUnicodeApi(FindFirstChangeNotification, + lpPathName, + bWatchSubtree, + dwNotifyFilter); } diff --git a/reactos/dll/win32/kernel32/include/base_x.h b/reactos/dll/win32/kernel32/include/base_x.h index 9b9d9ea17b5..421b4c10551 100644 --- a/reactos/dll/win32/kernel32/include/base_x.h +++ b/reactos/dll/win32/kernel32/include/base_x.h @@ -50,3 +50,13 @@ if (NT_SUCCESS(Status)) return Create##obj##W(args, UnicodeCache->Buffer); \ ConvertAnsiToUnicodeEpilogue +// +// This macro uses the ConvertAnsiToUnicode macros above to convert a FindFirst*A +// Win32 API into its equivalent FindFirst*W API. +// +#define ConvertWin32AnsiChangeApiToUnicodeApi(obj, name, args...) \ + ConvertAnsiToUnicodePrologue \ + ConvertAnsiToUnicodeBody(name) \ + if (NT_SUCCESS(Status)) return obj##W(UnicodeCache->Buffer, args); \ + ConvertAnsiToUnicodeEpilogue +