Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/file.c | 133 ++++++++++------------------------------ 1 file changed, 34 insertions(+), 99 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 539ce44e0a4..21889870499 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -3146,131 +3146,66 @@ todo_wine
static void test_file_name_information(void) { - WCHAR *file_name, *volume_prefix, *expected; - FILE_NAME_INFORMATION *info; + char buffer[300]; + FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buffer; ULONG old_redir = 1, tmp; - UINT file_name_size; IO_STATUS_BLOCK io; - UINT info_size; - HRESULT hr; + NTSTATUS status; HANDLE h; - UINT len; - - /* GetVolumePathName is not present before w2k */ - if (!pGetVolumePathNameW) { - win_skip("GetVolumePathNameW not found\n"); - return; - } - - file_name_size = GetSystemDirectoryW( NULL, 0 ); - file_name = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*file_name) ); - volume_prefix = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) ); - expected = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) ); - - len = GetSystemDirectoryW( file_name, file_name_size ); - ok(len == file_name_size - 1, - "GetSystemDirectoryW returned %u, expected %u.\n", - len, file_name_size - 1); - - len = pGetVolumePathNameW( file_name, volume_prefix, file_name_size ); - ok(len, "GetVolumePathNameW failed.\n"); - - len = lstrlenW( volume_prefix ); - if (len && volume_prefix[len - 1] == '\') --len; - memcpy( expected, file_name + len, (file_name_size - len - 1) * sizeof(WCHAR) ); - expected[file_name_size - len - 1] = '\0'; - - /* A bit more than we actually need, but it keeps the calculation simple. */ - info_size = sizeof(*info) + (file_name_size * sizeof(WCHAR)); - info = HeapAlloc( GetProcessHeap(), 0, info_size );
if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( TRUE, &old_redir ); - h = CreateFileW( file_name, GENERIC_READ, + h = CreateFileW( L"C:/windows/system32", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ); if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( old_redir, &tmp ); ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n");
- hr = pNtQueryInformationFile( h, &io, info, sizeof(*info) - 1, FileNameInformation ); - ok(hr == STATUS_INFO_LENGTH_MISMATCH, "NtQueryInformationFile returned %#x.\n", hr); + status = pNtQueryInformationFile( h, &io, info, sizeof(*info) - 1, FileNameInformation ); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryInformationFile returned %#x.\n", status);
- memset( info, 0xcc, info_size ); - hr = pNtQueryInformationFile( h, &io, info, sizeof(*info), FileNameInformation ); - ok(hr == STATUS_BUFFER_OVERFLOW, "NtQueryInformationFile returned %#x, expected %#x.\n", - hr, STATUS_BUFFER_OVERFLOW); - ok(U(io).Status == STATUS_BUFFER_OVERFLOW, "io.Status is %#x, expected %#x.\n", - U(io).Status, STATUS_BUFFER_OVERFLOW); - ok(info->FileNameLength == lstrlenW( expected ) * sizeof(WCHAR), "info->FileNameLength is %u\n", info->FileNameLength); + memset( info, 0xcc, sizeof(buffer) ); + status = pNtQueryInformationFile( h, &io, info, sizeof(*info), FileNameInformation ); + ok(status == STATUS_BUFFER_OVERFLOW, "NtQueryInformationFile returned %#x.\n", status); + ok(U(io).Status == STATUS_BUFFER_OVERFLOW, "io.Status is %#x.\n", U(io).Status); + ok(info->FileNameLength == wcslen( L"\windows\system32" ) * sizeof(WCHAR), + "info->FileNameLength is %u\n", info->FileNameLength); + ok(!wcsnicmp( info->FileName, L"\w", 2 ), "Got file name %s.\n", debugstr_wn( info->FileName, 2 )); ok(info->FileName[2] == 0xcccc, "info->FileName[2] is %#x, expected 0xcccc.\n", info->FileName[2]); - ok(CharLowerW((LPWSTR)(UINT_PTR)info->FileName[1]) == CharLowerW((LPWSTR)(UINT_PTR)expected[1]), - "info->FileName[1] is %p, expected %p.\n", - CharLowerW((LPWSTR)(UINT_PTR)info->FileName[1]), CharLowerW((LPWSTR)(UINT_PTR)expected[1])); ok(io.Information == sizeof(*info), "io.Information is %lu\n", io.Information);
- memset( info, 0xcc, info_size ); - hr = pNtQueryInformationFile( h, &io, info, info_size, FileNameInformation ); - ok(hr == STATUS_SUCCESS, "NtQueryInformationFile returned %#x, expected %#x.\n", hr, STATUS_SUCCESS); - ok(U(io).Status == STATUS_SUCCESS, "io.Status is %#x, expected %#x.\n", U(io).Status, STATUS_SUCCESS); - ok(info->FileNameLength == lstrlenW( expected ) * sizeof(WCHAR), "info->FileNameLength is %u\n", info->FileNameLength); + memset( info, 0xcc, sizeof(buffer) ); + status = pNtQueryInformationFile( h, &io, info, sizeof(buffer), FileNameInformation ); + ok(!status, "Got status %#x.\n", status); + ok(!U(io).Status, "Got io.Status %#x.\n", U(io).Status); + ok(info->FileNameLength == wcslen( L"\windows\system32" ) * sizeof(WCHAR), + "info->FileNameLength is %u\n", info->FileNameLength); ok(info->FileName[info->FileNameLength / sizeof(WCHAR)] == 0xcccc, "info->FileName[len] is %#x, expected 0xcccc.\n", info->FileName[info->FileNameLength / sizeof(WCHAR)]); info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0'; - ok(!lstrcmpiW( info->FileName, expected ), "info->FileName is %s, expected %s.\n", - wine_dbgstr_w( info->FileName ), wine_dbgstr_w( expected )); + ok(!wcsicmp( info->FileName, L"\windows\system32" ), "Got file name %s.\n", debugstr_w( info->FileName )); ok(io.Information == FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength, "io.Information is %lu, expected %u.\n", io.Information, FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength);
CloseHandle( h ); - HeapFree( GetProcessHeap(), 0, info ); - HeapFree( GetProcessHeap(), 0, expected ); - HeapFree( GetProcessHeap(), 0, volume_prefix );
- if (old_redir || !pGetSystemWow64DirectoryW || !(file_name_size = pGetSystemWow64DirectoryW( NULL, 0 ))) + if (!old_redir && pGetSystemWow64DirectoryW && pGetSystemWow64DirectoryW( NULL, 0 )) { - skip("Not running on WoW64, skipping test.\n"); - HeapFree( GetProcessHeap(), 0, file_name ); - return; - } - - h = CreateFileW( file_name, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ); - ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n"); - HeapFree( GetProcessHeap(), 0, file_name ); - - file_name = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*file_name) ); - volume_prefix = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*volume_prefix) ); - expected = HeapAlloc( GetProcessHeap(), 0, file_name_size * sizeof(*expected) ); - - len = pGetSystemWow64DirectoryW( file_name, file_name_size ); - ok(len == file_name_size - 1, - "GetSystemWow64DirectoryW returned %u, expected %u.\n", - len, file_name_size - 1); - - len = pGetVolumePathNameW( file_name, volume_prefix, file_name_size ); - ok(len, "GetVolumePathNameW failed.\n"); + h = CreateFileW( L"C:/windows/system32", GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0 ); + ok(h != INVALID_HANDLE_VALUE, "Failed to open file.\n");
- len = lstrlenW( volume_prefix ); - if (len && volume_prefix[len - 1] == '\') --len; - memcpy( expected, file_name + len, (file_name_size - len - 1) * sizeof(WCHAR) ); - expected[file_name_size - len - 1] = '\0'; - - info_size = sizeof(*info) + (file_name_size * sizeof(WCHAR)); - info = HeapAlloc( GetProcessHeap(), 0, info_size ); - - memset( info, 0xcc, info_size ); - hr = pNtQueryInformationFile( h, &io, info, info_size, FileNameInformation ); - ok(hr == STATUS_SUCCESS, "NtQueryInformationFile returned %#x, expected %#x.\n", hr, STATUS_SUCCESS); - info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0'; - ok(!lstrcmpiW( info->FileName, expected ), "info->FileName is %s, expected %s.\n", - wine_dbgstr_w( info->FileName ), wine_dbgstr_w( expected )); + memset( info, 0xcc, sizeof(buffer) ); + status = pNtQueryInformationFile( h, &io, info, sizeof(buffer), FileNameInformation ); + ok(!status, "Got status %#x.\n", status); + info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0'; + ok(!wcsicmp( info->FileName, L"\windows\syswow64" ), "Got file name %s.\n", debugstr_w( info->FileName ));
- CloseHandle( h ); - HeapFree( GetProcessHeap(), 0, info ); - HeapFree( GetProcessHeap(), 0, expected ); - HeapFree( GetProcessHeap(), 0, volume_prefix ); - HeapFree( GetProcessHeap(), 0, file_name ); + CloseHandle( h ); + } + else + skip("Not running on WoW64, skipping test.\n"); }
static void test_file_all_name_information(void)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/file.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 21889870499..dde5441cd9e 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -3149,9 +3149,11 @@ static void test_file_name_information(void) char buffer[300]; FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buffer; ULONG old_redir = 1, tmp; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING string; IO_STATUS_BLOCK io; NTSTATUS status; - HANDLE h; + HANDLE root, h;
if (pRtlWow64EnableFsRedirectionEx) pRtlWow64EnableFsRedirectionEx( TRUE, &old_redir ); h = CreateFileW( L"C:/windows/system32", GENERIC_READ, @@ -3206,6 +3208,35 @@ static void test_file_name_information(void) } else skip("Not running on WoW64, skipping test.\n"); + + pRtlInitUnicodeString(&string, L"\??\C:\windows\"); + InitializeObjectAttributes(&attr, &string, 0, 0, NULL); + status = pNtCreateFile(&root, GENERIC_READ | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0); + ok(!status, "Got status %#x.\n", status); + + pRtlInitUnicodeString(&string, L"system\"); + attr.RootDirectory = root; + status = pNtCreateFile(&h, GENERIC_READ | SYNCHRONIZE, &attr, &io, NULL, 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_DIRECTORY_FILE, NULL, 0); + ok(!status, "Got status %#x.\n", status); + + memset( info, 0xcc, sizeof(buffer) ); + status = pNtQueryInformationFile( h, &io, info, sizeof(buffer), FileNameInformation ); + ok(!status, "Got status %#x.\n", status); + ok(!U(io).Status, "Got io.Status %#x.\n", U(io).Status); + ok(info->FileNameLength == wcslen( L"\windows\system" ) * sizeof(WCHAR), + "info->FileNameLength is %u\n", info->FileNameLength); + todo_wine ok(info->FileName[info->FileNameLength / sizeof(WCHAR)] == 0xcccc, + "info->FileName[len] is %#x, expected 0xcccc.\n", info->FileName[info->FileNameLength / sizeof(WCHAR)]); + info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0'; + todo_wine ok(!wcsicmp( info->FileName, L"\windows\system" ), "Got file name %s.\n", debugstr_w( info->FileName )); + ok(io.Information == FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength, + "io.Information is %lu, expected %u.\n", + io.Information, FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength); + + pNtClose(h); + pNtClose(root); }
static void test_file_all_name_information(void)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64533
Your paranoid android.
=== debian10 (32 bit report) ===
ntdll: file.c:3228: Test failed: info->FileNameLength is 34 file.c:3230: Test succeeded inside todo block: info->FileName[len] is 0xcccc, expected 0xcccc.
=== debian10 (32 bit French report) ===
ntdll: file.c:3228: Test failed: info->FileNameLength is 34 file.c:3230: Test succeeded inside todo block: info->FileName[len] is 0xcccc, expected 0xcccc.
=== debian10 (32 bit Japanese:Japan report) ===
ntdll: file.c:3228: Test failed: info->FileNameLength is 34 file.c:3230: Test succeeded inside todo block: info->FileName[len] is 0xcccc, expected 0xcccc.
=== debian10 (32 bit Chinese:China report) ===
ntdll: file.c:3228: Test failed: info->FileNameLength is 34 file.c:3230: Test succeeded inside todo block: info->FileName[len] is 0xcccc, expected 0xcccc.
=== debian10 (32 bit WoW report) ===
ntdll: file.c:3228: Test failed: info->FileNameLength is 32 file.c:3230: Test succeeded inside todo block: info->FileName[len] is 0xcccc, expected 0xcccc.
=== debian10 (64 bit WoW report) ===
ntdll: file.c:3228: Test failed: info->FileNameLength is 32 file.c:3230: Test succeeded inside todo block: info->FileName[len] is 0xcccc, expected 0xcccc.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- Based on patch 0002 of this series, this seems like a better solution than the relevant Staging patch:
https://raw.githubusercontent.com/wine-staging/wine-staging/master/patches/n...
I know of no application that is helped by this patch.
dlls/ntdll/directory.c | 2 ++ dlls/ntdll/tests/file.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index 64b0afc4ca0..f30b7ffa2ad 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -2590,6 +2590,8 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer { if (!stat( unix_name, &st )) { + while (IS_SEPARATOR(unix_name[pos + ret])) + unix_name[pos + ret--] = 0; if (disposition == FILE_CREATE) return STATUS_OBJECT_NAME_COLLISION; return STATUS_SUCCESS; diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index dde5441cd9e..e225e180cf5 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -2097,7 +2097,7 @@ static void test_file_rename_information(void) res = pNtQueryInformationFile( handle, &io, fni, sizeof(FILE_NAME_INFORMATION) + MAX_PATH * sizeof(WCHAR), FileNameInformation ); ok( res == STATUS_SUCCESS, "res expected STATUS_SUCCESS, got %x\n", res ); fni->FileName[ fni->FileNameLength / sizeof(WCHAR) ] = 0; - todo_wine ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n", + ok( !lstrcmpiW(fni->FileName, newpath + 2), "FileName expected %s, got %s\n", wine_dbgstr_w(newpath + 2), wine_dbgstr_w(fni->FileName) ); HeapFree( GetProcessHeap(), 0, fni );
@@ -3227,10 +3227,10 @@ static void test_file_name_information(void) ok(!U(io).Status, "Got io.Status %#x.\n", U(io).Status); ok(info->FileNameLength == wcslen( L"\windows\system" ) * sizeof(WCHAR), "info->FileNameLength is %u\n", info->FileNameLength); - todo_wine ok(info->FileName[info->FileNameLength / sizeof(WCHAR)] == 0xcccc, + ok(info->FileName[info->FileNameLength / sizeof(WCHAR)] == 0xcccc, "info->FileName[len] is %#x, expected 0xcccc.\n", info->FileName[info->FileNameLength / sizeof(WCHAR)]); info->FileName[info->FileNameLength / sizeof(WCHAR)] = '\0'; - todo_wine ok(!wcsicmp( info->FileName, L"\windows\system" ), "Got file name %s.\n", debugstr_w( info->FileName )); + ok(!wcsicmp( info->FileName, L"\windows\system" ), "Got file name %s.\n", debugstr_w( info->FileName )); ok(io.Information == FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength, "io.Information is %lu, expected %u.\n", io.Information, FIELD_OFFSET(FILE_NAME_INFORMATION, FileName) + info->FileNameLength);