Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/quartz/filesource.c | 13 ++++++++----- dlls/quartz/tests/filesource.c | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 3b19d6e7df..8983f7317b 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -64,6 +64,7 @@ struct async_reader LPOLESTR pszFileName; AM_MEDIA_TYPE mt; HANDLE file, port, io_thread; + LARGE_INTEGER file_size; CRITICAL_SECTION sample_cs; BOOL flushing; struct request *requests; @@ -474,6 +475,12 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi return HRESULT_FROM_WIN32(GetLastError()); }
+ if (!GetFileSizeEx(hFile, &This->file_size)) + { + WARN("Could not get file size.\n"); + return HRESULT_FROM_WIN32(GetLastError()); + } + if (This->pszFileName) { free(This->pszFileName); @@ -883,14 +890,10 @@ static HRESULT WINAPI FileAsyncReader_SyncRead(IAsyncReader *iface, static HRESULT WINAPI FileAsyncReader_Length(IAsyncReader *iface, LONGLONG *total, LONGLONG *available) { struct async_reader *filter = impl_from_IAsyncReader(iface); - DWORD low, high;
TRACE("iface %p, total %p, available %p.\n", iface, total, available);
- if ((low = GetFileSize(filter->file, &high)) == -1 && GetLastError() != NO_ERROR) - return HRESULT_FROM_WIN32(GetLastError()); - - *available = *total = (LONGLONG)low | (LONGLONG)high << (sizeof(DWORD) * 8); + *available = *total = filter->file_size.QuadPart;
return S_OK; } diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 2040910516..87bbf1ee13 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -1035,6 +1035,9 @@ static void test_async_reader(void) } CloseHandle(file);
+ hr = IBaseFilter_FindPin(filter, L"Output", &pin); + ok(hr == VFW_E_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource); IFileSourceFilter_Load(filesource, filename, NULL); IBaseFilter_FindPin(filter, L"Output", &pin);
On Vista+ ReadFile() returns FALSE and sets ERROR_IO_PENDING even if the requested read results in ERROR_HANDLE_EOF. This change fixes filesource test with Wine quartz.dll on Windows and avoids regression otherwise triggered by the next patch.
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/quartz/filesource.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 8983f7317b..a553b8517e 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -723,6 +723,9 @@ static HRESULT WINAPI FileAsyncReader_Request(IAsyncReader *iface, IMediaSample if (FAILED(hr = IMediaSample_GetTime(sample, &start, &end))) return hr;
+ if (BYTES_FROM_MEDIATIME(start) >= filter->file_size.QuadPart) + return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); + if (FAILED(hr = IMediaSample_GetPointer(sample, &data))) return hr;
Signed-off-by: Zebediah Figura z.figura12@gmail.com
Fixes crashes in "Planet Zoo" during character or game save.
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/ntdll/file.c | 6 +++--- dlls/ntdll/tests/file.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index a9770290e0..9997a5e1cd 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c @@ -1018,13 +1018,13 @@ done:
err: if (needs_close) close( unix_handle ); - if (status == STATUS_SUCCESS || (status == STATUS_END_OF_FILE && !async_read)) + if (status == STATUS_SUCCESS || (status == STATUS_END_OF_FILE && (!async_read || type == FD_TYPE_FILE))) { io_status->u.Status = status; io_status->Information = total; TRACE("= SUCCESS (%u)\n", total); if (hEvent) NtSetEvent( hEvent, NULL ); - if (apc && !status) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, + if (apc && (!status || async_read)) NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)apc, (ULONG_PTR)apc_user, (ULONG_PTR)io_status, 0 ); } else @@ -1033,7 +1033,7 @@ err: if (status != STATUS_PENDING && hEvent) NtResetEvent( hEvent, NULL ); }
- ret_status = async_read && type == FD_TYPE_FILE && status == STATUS_SUCCESS + ret_status = async_read && type == FD_TYPE_FILE && (status == STATUS_SUCCESS || status == STATUS_END_OF_FILE) ? STATUS_PENDING : status;
if (send_completion) NTDLL_AddCompletion( hFile, cvalue, status, total, ret_status == STATUS_PENDING ); diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 68c6a79e79..31c18454f0 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -652,7 +652,8 @@ static void read_file_test(void) iosb.Information = 0xdeadbeef; offset.QuadPart = strlen(text) + 2; status = pNtReadFile( handle, event, apc, &apc_count, &iosb, buffer, 2, &offset, NULL ); - ok(status == STATUS_PENDING || status == STATUS_END_OF_FILE /* before Vista */, "expected STATUS_PENDING or STATUS_END_OF_FILE, got %#x\n", status); + ok(status == STATUS_PENDING || broken(status == STATUS_END_OF_FILE) /* before Vista */, + "expected STATUS_PENDING, got %#x\n", status); if (status == STATUS_PENDING) /* vista */ { WaitForSingleObject( event, 1000 ); @@ -4540,7 +4541,8 @@ static void test_read_write(void) ret = ReadFile(hfile, buf, sizeof(buf), &bytes, &ovl); ok(!ret, "ReadFile should fail\n"); ret = GetLastError(); - ok(ret == ERROR_IO_PENDING || ret == ERROR_HANDLE_EOF /* before Vista */, "expected ERROR_IO_PENDING or ERROR_HANDLE_EOF, got %d\n", ret); + ok(ret == ERROR_IO_PENDING || broken(ret == ERROR_HANDLE_EOF) /* before Vista */, + "expected ERROR_IO_PENDING, got %d\n", ret); ok(bytes == 0, "bytes %u\n", bytes);
off = SetFilePointer(hfile, 0, NULL, FILE_CURRENT);
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/kernel32/tests/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 29620654bd..2e26e2ace8 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -5418,7 +5418,7 @@ static void test_overlapped_read(void) err = GetLastError(); /* Win8+ return ERROR_IO_PENDING like stated in MSDN, while older ones * return ERROR_HANDLE_EOF right away. */ - ok(!ret && (err == ERROR_HANDLE_EOF || err == ERROR_IO_PENDING), + ok(!ret && (err == ERROR_IO_PENDING || broken(err == ERROR_HANDLE_EOF)), "Unexpected ReadFile result, ret %#x, GetLastError() %u.\n", ret, GetLastError()); if (err == ERROR_IO_PENDING) {
On 4/19/20 6:05 PM, Paul Gofman wrote:
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 2040910516..87bbf1ee13 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -1035,6 +1035,9 @@ static void test_async_reader(void) } CloseHandle(file);
- hr = IBaseFilter_FindPin(filter, L"Output", &pin);
- ok(hr == VFW_E_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
Did you mean to put this here?
IBaseFilter_QueryInterface(filter, &IID_IFileSourceFilter, (void **)&filesource); IFileSourceFilter_Load(filesource, filename, NULL); IBaseFilter_FindPin(filter, L"Output", &pin);
On 4/20/20 03:11, Zebediah Figura wrote:
On 4/19/20 6:05 PM, Paul Gofman wrote:
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 2040910516..87bbf1ee13 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -1035,6 +1035,9 @@ static void test_async_reader(void) } CloseHandle(file);
- hr = IBaseFilter_FindPin(filter, L"Output", &pin);
- ok(hr == VFW_E_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
Did you mean to put this here?
I wanted to be sure that there is no way to call _Length() before file is loaded as otherwise I would be curious what it returns if that happens. So yes, I meant that, but I see now that exactly the same is already tested in test_find_pin(), I will resend without.