static void test_nonalertable(void) { IO_STATUS_BLOCK iosb; HANDLE hEvent; HANDLE hPipe; NTSTATUS res; HANDLE hThread; DWORD ret; memset(&iosb, 0x55, sizeof(iosb)); hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError()); res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT); ok(!res, "NtCreateNamedPipeFile returned %x\n", res); hThread = CreateThread(NULL, 0, &thread, 0, 0, 0); ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %x\n", GetLastError()); userapc_called = FALSE; ret = pQueueUserAPC(&userapc, GetCurrentThread(), 0); ok(ret, "can't queue user apc, GetLastError: %x\n", GetLastError()); res = listen_pipe(hPipe, hEvent, &iosb, TRUE); todo_wine ok(!res, "NtFsControlFile returned %x\n", res); ok(open_succeeded, "couldn't open client side pipe\n"); todo_wine ok(!U(iosb).Status, "Wrong iostatus %x\n", U(iosb).Status); todo_wine ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n"); ok(!ioapc_called, "IOAPC ran too early\n"); ok(!userapc_called, "user apc ran too early\n"); SleepEx(0, TRUE); /* alertable wait state */ ok(ioapc_called, "IOAPC didn't run\n"); ok(userapc_called, "user apc didn't run\n"); WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread); CloseHandle(hEvent); CloseHandle(hPipe); }
static void test_cancelio(void) { IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK cancel_sb; HANDLE hEvent; HANDLE hPipe; NTSTATUS res; hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError()); res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */); ok(!res, "NtCreateNamedPipeFile returned %x\n", res); memset(&iosb, 0x55, sizeof(iosb)); res = listen_pipe(hPipe, hEvent, &iosb, TRUE); ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res); res = pNtCancelIoFile(hPipe, &cancel_sb); todo_wine ok(!res, "NtCancelIoFile returned %x\n", res); todo_wine { ok(U(iosb).Status == STATUS_CANCELLED, "Wrong iostatus %x\n", U(iosb).Status); ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n"); } ok(!ioapc_called, "IOAPC ran too early\n"); SleepEx(0, TRUE); /* alertable wait state */ ok(ioapc_called, "IOAPC didn't run\n"); CloseHandle(hEvent); CloseHandle(hPipe); }
static void test_overlapped(void) { IO_STATUS_BLOCK iosb; HANDLE hEvent; HANDLE hPipe; HANDLE hClient; NTSTATUS res; hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError()); res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, 0 /* OVERLAPPED */); ok(!res, "NtCreateNamedPipeFile returned %x\n", res); memset(&iosb, 0x55, sizeof(iosb)); /* try with event and apc */ res = listen_pipe(hPipe, hEvent, &iosb, TRUE); ok(res == STATUS_PENDING, "NtFsControlFile returned %x\n", res); hClient = CreateFileW(testpipe, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); ok(hClient != INVALID_HANDLE_VALUE, "can't open pipe, GetLastError: %x\n", GetLastError()); ok(U(iosb).Status == 0, "Wrong iostatus %x\n", U(iosb).Status); ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n"); ok(!ioapc_called, "IOAPC ran too early\n"); SleepEx(0, TRUE); /* alertable wait state */ ok(ioapc_called, "IOAPC didn't run\n"); CloseHandle(hEvent); CloseHandle(hPipe); CloseHandle(hClient); }
static void test_alertable(void) { IO_STATUS_BLOCK iosb; HANDLE hEvent; HANDLE hPipe; NTSTATUS res; HANDLE hThread; DWORD ret; memset(&iosb, 0x55, sizeof(iosb)); hEvent = CreateEventW(NULL, TRUE, FALSE, NULL); ok(hEvent != INVALID_HANDLE_VALUE, "can't create event, GetLastError: %x\n", GetLastError()); res = create_pipe(&hPipe, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_ALERT); ok(!res, "NtCreateNamedPipeFile returned %x\n", res); /* queue an user apc before calling listen */ userapc_called = FALSE; ret = pQueueUserAPC(&userapc, GetCurrentThread(), 0); ok(ret, "can't queue user apc, GetLastError: %x\n", GetLastError()); res = listen_pipe(hPipe, hEvent, &iosb, TRUE); todo_wine ok(res == STATUS_CANCELLED, "NtFsControlFile returned %x\n", res); todo_wine ok(userapc_called, "user apc didn't run\n"); ok(U(iosb).Status == 0x55555555, "iosb.Status got changed to %x\n", U(iosb).Status); todo_wine ok(WaitForSingleObjectEx(hEvent, 0, TRUE) == WAIT_TIMEOUT, "hEvent signaled\n"); ok(!ioapc_called, "IOAPC ran\n"); /* queue an user apc from a different thread */ hThread = CreateThread(NULL, 0, &thread, pOpenThread(MAXIMUM_ALLOWED, FALSE, GetCurrentThreadId()), 0, 0); ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %x\n", GetLastError()); /* wine_todo: the earlier NtFsControlFile call gets cancelled after the pipe gets set into listen state instead of before, so this NtFsControlFile will fail STATUS_INVALID_HANDLE */ res = listen_pipe(hPipe, hEvent, &iosb, TRUE); todo_wine ok(res == STATUS_CANCELLED, "NtFsControlFile returned %x\n", res); ok(userapc_called, "user apc didn't run\n"); todo_wine ok(U(iosb).Status == 0x55555555, "iosb.Status got changed to %x\n", U(iosb).Status); ok(WaitForSingleObjectEx(hEvent, 0, TRUE) == WAIT_TIMEOUT, "hEvent signaled\n"); ok(!ioapc_called, "IOAPC ran\n"); WaitForSingleObject(hThread, INFINITE); SleepEx(0, TRUE); /* get rid of the userapc, if NtFsControlFile failed */ ok(open_succeeded, "couldn't open client side pipe\n"); CloseHandle(hThread); DisconnectNamedPipe(hPipe); /* finally try without an apc */ hThread = CreateThread(NULL, 0, &thread, 0, 0, 0); ok(hThread != INVALID_HANDLE_VALUE, "can't create thread, GetLastError: %x\n", GetLastError()); res = listen_pipe(hPipe, hEvent, &iosb, TRUE); todo_wine ok(!res, "NtFsControlFile returned %x\n", res); ok(open_succeeded, "couldn't open client side pipe\n"); ok(!U(iosb).Status, "Wrong iostatus %x\n", U(iosb).Status); todo_wine ok(WaitForSingleObject(hEvent, 0) == 0, "hEvent not signaled\n"); WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread); CloseHandle(hEvent); CloseHandle(hPipe); }
void redirect_pipe_to_fifo(params_t *params) { WINE_TRACE("\n"); listen_pipe(params->pipe,onclient,params); }