Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/scrrun/filesystem.c | 7 +++ dlls/scrrun/scrrun.spec | 2 +- dlls/scrrun/tests/filesystem.c | 88 ++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 2b2255e1dfc..d16ecb722dc 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -839,6 +839,13 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod return S_OK; }
+HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **stream) +{ + FIXME("%p, %d, %p.\n", pipe, mode, stream); + + return E_NOTIMPL; +} + static HRESULT WINAPI drive_QueryInterface(IDrive *iface, REFIID riid, void **obj) { struct drive *This = impl_from_IDrive(iface); diff --git a/dlls/scrrun/scrrun.spec b/dlls/scrrun/scrrun.spec index e71b683c64c..2751b5f66de 100644 --- a/dlls/scrrun/scrrun.spec +++ b/dlls/scrrun/scrrun.spec @@ -3,4 +3,4 @@ @ stdcall -private DllGetClassObject(ptr ptr ptr) @ stdcall -private DllRegisterServer() @ stdcall -private DllUnregisterServer() -@ stub DoOpenPipeStream +@ stdcall DoOpenPipeStream(long long ptr) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index da1ca316382..24b52384aa5 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -35,6 +35,8 @@
static IFileSystem3 *fs3;
+static HRESULT (WINAPI *pDoOpenPipeStream)(HANDLE pipe, DWORD mode, ITextStream **stream); + /* w2k and 2k3 error code. */ #define E_VAR_NOT_SET 0x800a005b
@@ -2590,6 +2592,91 @@ static void test_MoveFile(void) SysFreeString(str); }
+static void test_DoOpenPipeStream(void) +{ + static const char testdata[] = "test"; + ITextStream *stream_read, *stream_write; + SECURITY_ATTRIBUTES pipe_attr; + HANDLE piperead, pipewrite; + DWORD written; + HRESULT hr; + BSTR str; + BOOL ret; + + pDoOpenPipeStream = (void *)GetProcAddress(GetModuleHandleA("scrrun.dll"), "DoOpenPipeStream"); + + pipe_attr.nLength = sizeof(SECURITY_ATTRIBUTES); + pipe_attr.bInheritHandle = TRUE; + pipe_attr.lpSecurityDescriptor = NULL; + ret = CreatePipe(&piperead, &pipewrite, &pipe_attr, 0); + ok(ret, "Failed to create pipes.\n"); + + hr = pDoOpenPipeStream(piperead, ForReading, &stream_read); + todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(!!stream_read, "Unexpected stream pointer.\n"); + + ret = WriteFile(pipewrite, testdata, sizeof(testdata), &written, NULL); + ok(ret, "Failed to write to the pipe.\n"); + ok(written == sizeof(testdata), "Write to anonymous pipe wrote %d bytes.\n", written); + + hr = ITextStream_Read(stream_read, 4, &str); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!wcscmp(str, L"test"), "Unexpected data read %s.\n", wine_dbgstr_w(str)); + SysFreeString(str); + + ITextStream_Release(stream_read); + } + + ret = CloseHandle(pipewrite); + ok(ret, "Unexpected return value.\n"); + /* Stream takes ownership. */ + ret = CloseHandle(piperead); + todo_wine + ok(!ret, "Unexpected return value.\n"); + + /* Streams on both ends. */ + ret = CreatePipe(&piperead, &pipewrite, &pipe_attr, 0); + ok(ret, "Failed to create pipes.\n"); + + stream_read = NULL; + hr = pDoOpenPipeStream(piperead, ForReading, &stream_read); + todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + stream_write = NULL; + hr = pDoOpenPipeStream(pipewrite, ForWriting, &stream_write); + todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + if (SUCCEEDED(hr)) + { + str = SysAllocString(L"data"); + hr = ITextStream_Write(stream_write, str); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = ITextStream_Write(stream_read, str); + ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#x.\n", hr); + + SysFreeString(str); + + hr = ITextStream_Read(stream_write, 1, &str); + ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#x.\n", hr); + + hr = ITextStream_Read(stream_read, 4, &str); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!wcscmp(str, L"data"), "Unexpected data.\n"); + SysFreeString(str); + } + + if (stream_read) + ITextStream_Release(stream_read); + if (stream_write) + ITextStream_Release(stream_write); +} + START_TEST(filesystem) { HRESULT hr; @@ -2632,6 +2719,7 @@ START_TEST(filesystem) test_GetExtensionName(); test_GetSpecialFolder(); test_MoveFile(); + test_DoOpenPipeStream();
IFileSystem3_Release(fs3);