From: Alex Ionescu Date: Wed, 9 Nov 2005 03:02:33 +0000 (+0000) Subject: - Unbreak build X-Git-Tag: backups/ros-branch-0_2_9@19949~814 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=a6e23ab5cf0cb828e73a8eb2f1ae0567fd1e1abc;hp=4cafc71bd899e5500b60db810455d62351dd62f3 - Unbreak build - Fix CallNamedPipeW, the pipe mode should also be set to PIPE_WAIT. svn path=/trunk/; revision=19086 --- diff --git a/reactos/lib/kernel32/file/npipe.c b/reactos/lib/kernel32/file/npipe.c index 91d654626a5..70480021481 100644 --- a/reactos/lib/kernel32/file/npipe.c +++ b/reactos/lib/kernel32/file/npipe.c @@ -674,12 +674,12 @@ CallNamedPipeA(LPCSTR lpNamedPipeName, LPDWORD lpBytesRead, DWORD nTimeOut) { - UNICODE_STRING PipeName = &NtCurrentTeb()->StaticUnicodeString; + PUNICODE_STRING PipeName = &NtCurrentTeb()->StaticUnicodeString; ANSI_STRING AnsiPipe; /* Initialize the string as ANSI_STRING and convert to Unicode */ - RtlInitAnsiString(&NameA, (LPSTR)lpName); - RtlAnsiStringToUnicodeString(NameU, &NameA, FALSE); + RtlInitAnsiString(&AnsiPipe, (LPSTR)lpNamedPipeName); + RtlAnsiStringToUnicodeString(PipeName, &AnsiPipe, FALSE); /* Call the Unicode function */ return CallNamedPipeW(PipeName->Buffer, @@ -694,65 +694,69 @@ CallNamedPipeA(LPCSTR lpNamedPipeName, /* * @implemented */ -BOOL STDCALL +BOOL +WINAPI CallNamedPipeW(LPCWSTR lpNamedPipeName, - LPVOID lpInBuffer, - DWORD nInBufferSize, - LPVOID lpOutBuffer, - DWORD nOutBufferSize, - LPDWORD lpBytesRead, - DWORD nTimeOut) + LPVOID lpInBuffer, + DWORD nInBufferSize, + LPVOID lpOutBuffer, + DWORD nOutBufferSize, + LPDWORD lpBytesRead, + DWORD nTimeOut) { - HANDLE hPipe = INVALID_HANDLE_VALUE; - BOOL bRetry = TRUE; - BOOL bError = FALSE; - DWORD dwPipeMode; + HANDLE hPipe; + BOOL bRetry = TRUE; + BOOL bError; + DWORD dwPipeMode; - while (TRUE) + while (TRUE) { - hPipe = CreateFileW(lpNamedPipeName, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hPipe != INVALID_HANDLE_VALUE) - break; - - if (bRetry == FALSE) - return(FALSE); - - WaitNamedPipeW(lpNamedPipeName, - nTimeOut); - - bRetry = FALSE; + /* Try creating it */ + hPipe = CreateFileW(lpNamedPipeName, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + /* Success, break out */ + if (hPipe != INVALID_HANDLE_VALUE) break; + + /* Already tried twice, give up */ + if (bRetry == FALSE) return FALSE; + + /* Wait on it */ + WaitNamedPipeW(lpNamedPipeName, nTimeOut); + + /* Get ready to try again */ + bRetry = FALSE; } - dwPipeMode = PIPE_READMODE_MESSAGE; - bError = SetNamedPipeHandleState(hPipe, - &dwPipeMode, - NULL, - NULL); - if (!bError) + /* Set the pipe mode */ + dwPipeMode = PIPE_READMODE_MESSAGE | PIPE_WAIT; + bError = SetNamedPipeHandleState(hPipe, &dwPipeMode, NULL, NULL); + if (!bError) { - CloseHandle(hPipe); - return(FALSE); + /* Couldn't change state, fail */ + CloseHandle(hPipe); + return FALSE; } - bError = TransactNamedPipe(hPipe, - lpInBuffer, - nInBufferSize, - lpOutBuffer, - nOutBufferSize, - lpBytesRead, - NULL); - CloseHandle(hPipe); - - return(bError); + /* Do the transact */ + bError = TransactNamedPipe(hPipe, + lpInBuffer, + nInBufferSize, + lpOutBuffer, + nOutBufferSize, + lpBytesRead, + NULL); + + /* Close the handle and return */ + CloseHandle(hPipe); + return bError; } - /* * @implemented */