ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

BOOL WINAPI WaitNamedPipeW ( LPCWSTR  lpNamedPipeName,
DWORD  nTimeOut 
)

Definition at line 568 of file npipe.c.

Referenced by CallNamedPipeW(), DhcpCApiInitialize(), RPC_GetLocalClassObject(), ScConnectControlPipe(), and WaitNamedPipeA().

{
    UNICODE_STRING NamedPipeName;
    NTSTATUS Status;
    OBJECT_ATTRIBUTES ObjectAttributes;
    FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
    HANDLE FileHandle;
    IO_STATUS_BLOCK Iosb;

    if (RtlDosPathNameToNtPathName_U(lpNamedPipeName,
                                     &NamedPipeName,
                                     NULL,
                                     NULL) == FALSE)
    {
        return FALSE;
    }

    InitializeObjectAttributes(&ObjectAttributes,
                               &NamedPipeName,
                               OBJ_CASE_INSENSITIVE,
                               NULL,
                               NULL);
    Status = NtOpenFile(&FileHandle,
                        FILE_READ_ATTRIBUTES | SYNCHRONIZE,
                        &ObjectAttributes,
                        &Iosb,
                        FILE_SHARE_READ | FILE_SHARE_WRITE,
                        FILE_SYNCHRONOUS_IO_NONALERT);
    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        RtlFreeUnicodeString(&NamedPipeName);
        return FALSE;
    }

    /* Check what timeout we got */
    if (nTimeOut == NMPWAIT_WAIT_FOREVER)
    {
        /* Don't use a timeout */
        WaitPipe.TimeoutSpecified = FALSE;
    }
    else
    {
        /* Check if default */
        if (nTimeOut == NMPWAIT_USE_DEFAULT_WAIT)
        {
            /* Set it to 0 */
            WaitPipe.Timeout.LowPart = 0;
            WaitPipe.Timeout.HighPart = 0;
        }
        else
        {
            /* Convert to NT format */
            WaitPipe.Timeout.QuadPart = UInt32x32To64(-10000, nTimeOut);
        }

        /* In both cases, we do have a timeout */
        WaitPipe.TimeoutSpecified = TRUE;
    }

    Status = NtFsControlFile(FileHandle,
                             NULL,
                             NULL,
                             NULL,
                             &Iosb,
                             FSCTL_PIPE_WAIT,
                             &WaitPipe,
                             sizeof(WaitPipe),
                             NULL,
                             0);
    NtClose(FileHandle);
    if (!NT_SUCCESS(Status))
    {
        BaseSetLastNTError(Status);
        RtlFreeUnicodeString(&NamedPipeName);
        return FALSE;
    }

    RtlFreeUnicodeString(&NamedPipeName);
    return TRUE;
}

Generated on Mon May 28 2012 05:11:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.