https://git.reactos.org/?p=reactos.git;a=commitdiff;h=657f7287675007ac9f08ad6a0835d926138f95c0
commit 657f7287675007ac9f08ad6a0835d926138f95c0 Author: Ratin Gao <ra...@knsoft.org> AuthorDate: Sun Aug 27 07:20:08 2023 +0800 Commit: GitHub <nore...@github.com> CommitDate: Sun Aug 27 02:20:08 2023 +0300 [KERNEL32] Little fixes for FindFirstFileExW() behavior (#5592) - Don't forget to release RTL_RELATIVE_NAME_U before return - Ignore lpSearchFilter correctly as on Windows Fixes 6 failures in kernel32:FindFiles test in LiveCD. --- dll/win32/kernel32/client/file/find.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dll/win32/kernel32/client/file/find.c b/dll/win32/kernel32/client/file/find.c index 0fa21ae34be..59470e8d7a3 100644 --- a/dll/win32/kernel32/client/file/find.c +++ b/dll/win32/kernel32/client/file/find.c @@ -653,6 +653,8 @@ FindFirstFileExW(IN LPCWSTR lpFileName, LPVOID lpSearchFilter, IN DWORD dwAdditionalFlags) { + UNREFERENCED_PARAMETER(lpSearchFilter); + TRACE("FindFirstFileExW(lpFileName %S)\n", lpFileName); if ((fInfoLevelId != FindExInfoStandard && fInfoLevelId != FindExInfoBasic) || @@ -692,13 +694,6 @@ FindFirstFileExW(IN LPCWSTR lpFileName, DECLSPEC_ALIGN(4) BYTE DirectoryInfo[FIND_DATA_SIZE]; DIR_INFORMATION DirInfo = { .DirInfo = &DirectoryInfo }; - /* The search filter is always unused */ - if (lpSearchFilter) - { - SetLastError(ERROR_INVALID_PARAMETER); - return INVALID_HANDLE_VALUE; - } - RtlInitUnicodeString(&FileName, lpFileName); if (FileName.Length != 0 && FileName.Buffer[FileName.Length / sizeof(WCHAR) - 1] == L'.') { @@ -735,6 +730,7 @@ FindFirstFileExW(IN LPCWSTR lpFileName, DeviceNameInfo = RtlIsDosDeviceName_U(lpFileName); if (DeviceNameInfo != 0) { + RtlReleaseRelativeName(&RelativePath); RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); /* OK, it's really a DOS device */ @@ -798,6 +794,7 @@ FindFirstFileExW(IN LPCWSTR lpFileName, if (!NT_SUCCESS(Status)) { + RtlReleaseRelativeName(&RelativePath); RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); /* Adjust the last error codes */ @@ -817,6 +814,7 @@ FindFirstFileExW(IN LPCWSTR lpFileName, if (FilePattern.Length == 0) { NtClose(hDirectory); + RtlReleaseRelativeName(&RelativePath); RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); SetLastError(ERROR_FILE_NOT_FOUND); @@ -891,6 +889,7 @@ FindFirstFileExW(IN LPCWSTR lpFileName, &FilePattern, TRUE); + RtlReleaseRelativeName(&RelativePath); RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); if (!NT_SUCCESS(Status))