kernel32: Create(Named)Pipe uses an nonalertable io mode.
This commit is contained in:
parent
4e4bdbe53e
commit
3623b9d4c9
|
@ -1396,7 +1396,7 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
|
|||
}
|
||||
access |= SYNCHRONIZE;
|
||||
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH) options |= FILE_WRITE_THROUGH;
|
||||
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED)) options |= FILE_SYNCHRONOUS_IO_ALERT;
|
||||
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED)) options |= FILE_SYNCHRONOUS_IO_NONALERT;
|
||||
pipe_type = (dwPipeMode & PIPE_TYPE_MESSAGE) ? TRUE : FALSE;
|
||||
read_mode = (dwPipeMode & PIPE_READMODE_MESSAGE) ? TRUE : FALSE;
|
||||
non_block = (dwPipeMode & PIPE_NOWAIT) ? TRUE : FALSE;
|
||||
|
@ -1848,7 +1848,7 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
|
|||
RtlInitUnicodeString(&nt_name, name);
|
||||
status = NtCreateNamedPipeFile(&hr, GENERIC_READ | SYNCHRONIZE, &attr, &iosb,
|
||||
0, FILE_OVERWRITE_IF,
|
||||
FILE_SYNCHRONOUS_IO_ALERT | FILE_PIPE_INBOUND,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT | FILE_PIPE_INBOUND,
|
||||
FALSE, FALSE, FALSE,
|
||||
1, size, size, &timeout);
|
||||
if (status)
|
||||
|
@ -1861,7 +1861,7 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
|
|||
if (hr == INVALID_HANDLE_VALUE) return FALSE;
|
||||
|
||||
status = NtOpenFile(&hw, GENERIC_WRITE | SYNCHRONIZE, &attr, &iosb, 0,
|
||||
FILE_SYNCHRONOUS_IO_ALERT | FILE_NON_DIRECTORY_FILE);
|
||||
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
|
||||
|
||||
if (status)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,13 @@
|
|||
static HANDLE alarm_event;
|
||||
static BOOL (WINAPI *pDuplicateTokenEx)(HANDLE,DWORD,LPSECURITY_ATTRIBUTES,
|
||||
SECURITY_IMPERSONATION_LEVEL,TOKEN_TYPE,PHANDLE);
|
||||
static DWORD WINAPI (*pQueueUserAPC)(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData);
|
||||
|
||||
static BOOL user_apc_ran;
|
||||
static void CALLBACK user_apc(ULONG_PTR param)
|
||||
{
|
||||
user_apc_ran = TRUE;
|
||||
}
|
||||
|
||||
static void test_CreateNamedPipe(int pipemode)
|
||||
{
|
||||
|
@ -471,6 +477,12 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
|
|||
DWORD readden;
|
||||
DWORD success;
|
||||
|
||||
user_apc_ran = FALSE;
|
||||
if (i == 0 && pQueueUserAPC) {
|
||||
trace("Queueing an user APC\n"); /* verify the pipe is non alerable */
|
||||
ok(pQueueUserAPC(&user_apc, GetCurrentThread(), 0), "QueueUserAPC failed: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
/* Wait for client to connect */
|
||||
trace("Server calling ConnectNamedPipe...\n");
|
||||
ok(ConnectNamedPipe(hnp, NULL)
|
||||
|
@ -494,6 +506,11 @@ static DWORD CALLBACK serverThreadMain2(LPVOID arg)
|
|||
ok(FlushFileBuffers(hnp), "FlushFileBuffers\n");
|
||||
ok(DisconnectNamedPipe(hnp), "DisconnectNamedPipe\n");
|
||||
|
||||
ok(user_apc_ran == FALSE, "UserAPC ran, pipe using alertable io mode\n");
|
||||
|
||||
if (i == 0 && pQueueUserAPC)
|
||||
SleepEx(0, TRUE); /* get rid of apc */
|
||||
|
||||
/* Set up next echo server */
|
||||
hnpNext =
|
||||
CreateNamedPipe(PIPENAME "serverThreadMain2", PIPE_ACCESS_DUPLEX,
|
||||
|
@ -916,9 +933,13 @@ static void test_CreatePipe(void)
|
|||
BYTE *buffer;
|
||||
char readbuf[32];
|
||||
|
||||
user_apc_ran = FALSE;
|
||||
if (pQueueUserAPC)
|
||||
ok(pQueueUserAPC(user_apc, GetCurrentThread(), 0), "couldn't create user apc\n");
|
||||
|
||||
pipe_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
pipe_attr.bInheritHandle = TRUE;
|
||||
pipe_attr.lpSecurityDescriptor = NULL;
|
||||
pipe_attr.lpSecurityDescriptor = NULL;
|
||||
ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n");
|
||||
ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n");
|
||||
ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %d bytes\n", written);
|
||||
|
@ -956,6 +977,9 @@ static void test_CreatePipe(void)
|
|||
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL) == 0, "Broken pipe not detected\n");
|
||||
ok(CloseHandle(piperead), "CloseHandle for the read pipe failed\n");
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
|
||||
ok(user_apc_ran == FALSE, "user apc ran, pipe using alertable io mode\n");
|
||||
SleepEx(0, TRUE); /* get rid of apc */
|
||||
}
|
||||
|
||||
struct named_pipe_client_params
|
||||
|
@ -1588,6 +1612,8 @@ START_TEST(pipe)
|
|||
|
||||
hmod = GetModuleHandle("advapi32.dll");
|
||||
pDuplicateTokenEx = (void *) GetProcAddress(hmod, "DuplicateTokenEx");
|
||||
hmod = GetModuleHandle("kernel32.dll");
|
||||
pQueueUserAPC = (void *) GetProcAddress(hmod, "QueueUserAPC");
|
||||
|
||||
if (test_DisconnectNamedPipe())
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue