localipc-win.cpp revision 0026206ac0b641f2bd9d5b9a6cd12a313ebb5f33
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * IPRT - Local IPC, Windows Implementation Using Named Pipes.
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * Copyright (C) 2008-2013 Oracle Corporation
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * This file is part of VirtualBox Open Source Edition (OSE), as
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * available from http://www.virtualbox.org. This file is free software;
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * you can redistribute it and/or modify it under the terms of the GNU
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * General Public License (GPL) as published by the Free Software
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * Foundation, in version 2 as it comes in the "COPYING" file of the
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * The contents of this file may alternatively be used under the terms
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * of the Common Development and Distribution License Version 1.0
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * VirtualBox OSE distribution, in which case the provisions of the
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * CDDL are applicable instead of those of the GPL.
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * You may elect to license modified versions of this file under the
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * terms and conditions of either the GPL or the CDDL or both.
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest/*******************************************************************************
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest* Header Files *
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest*******************************************************************************/
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * We have to force NT 5.0 here because of
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * ConvertStringSecurityDescriptorToSecurityDescriptor. Note that because of
abd4d5547d40141d956adbbd8ac2e0efd5f025e1Andrew Forrest * FILE_FLAG_FIRST_PIPE_INSTANCE this code actually requires W2K SP2+.
#include <Windows.h>
#include <sddl.h>
#define RTLOCALIPC_WIN_SDDL \
// SDDL_ACE_BEGIN SDDL_ACCESS_ALLOWED ";CIOI;" SDDL_GENERIC_ALL ";;;" SDDL_CREATOR_OWNER SDDL_ACE_END
typedef struct RTLOCALIPCSERVERINT
bool volatile fCancelled;
typedef struct RTLOCALIPCSESSIONINT
bool fIOPending;
bool fZeroByteRead;
bool volatile fCancelled;
typedef BOOL WINAPI FNCONVERTSTRINGSECURITYDESCRIPTORTOSECURITYDESCRIPTOR(LPCTSTR, DWORD, PSECURITY_DESCRIPTOR, PULONG);
*PFNCONVERTSTRINGSECURITYDESCRIPTORTOSECURITYDESCRIPTOR; /* No, nobody fell on the keyboard, really! */
&pSecDesc,
NULL))
return rc;
static int rtLocalIpcServerWinCreatePipeInstance(PHANDLE phNmPipe, const char *pszFullPipeName, bool fFirst)
bool fSupportsFirstInstance = false;
fSupportsFirstInstance = true;
return rc;
RTDECL(int) RTLocalIpcServerCreate(PRTLOCALIPCSERVER phServer, const char *pszName, uint32_t fFlags)
AssertReturn((fFlags & RTLOCALIPC_FLAGS_MULTI_SESSION), VERR_INVALID_PARAMETER); /** @todo Implement !RTLOCALIPC_FLAGS_MULTI_SESSION */
if (!pThis)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
return rc;
return VINF_SUCCESS;
return VINF_SUCCESS;
int rc;
if ( !fRc
if ( fRc
if ( fRc
return rc;
return rc;
* @param hNmPipeSession The named pipe handle. This will be consumed by this session, meaning on failure
int rc;
if (pThis)
return VINF_SUCCESS;
return rc;
RTDECL(int) RTLocalIpcSessionConnect(PRTLOCALIPCSESSION phSession, const char *pszName, uint32_t fFlags)
if (!pThis)
return VERR_NO_MEMORY;
char *pszPipe;
return VINF_SUCCESS;
return rc;
return VINF_SUCCESS;
return VINF_SUCCESS;
RTDECL(int) RTLocalIpcSessionRead(RTLOCALIPCSESSION hSession, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)
while (cbToRead > 0)
if (pcbRead)
&& cbTotalRead
return rc;
int rc;
memmove(&pThis->pbBounceBuf[0], &pThis->pbBounceBuf[cbWritten], pThis->cbBounceBufUsed - cbWritten);
return rc;
RTDECL(int) RTLocalIpcSessionWrite(RTLOCALIPCSESSION hSession, const void *pvBuffer, size_t cbBuffer)
while (cbBuffer > 0)
if (fRc)
return rc;
return VINF_SUCCESS;
return rc;
if ( fRc
&& cbAvailable)
else if (!fRc)
if (cMillies == 0)
return rc;
if ( !fRc
return rc;
return rc;
return VERR_NOT_SUPPORTED;
return VERR_NOT_SUPPORTED;
return VERR_NOT_SUPPORTED;