[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
This commit is contained in:
Alex Ionescu
2011-07-22 09:09:05 +00:00
parent d19dfaa93c
commit 45f4cd3964
2 changed files with 15 additions and 20 deletions
@@ -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);
}
@@ -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