vboxmrxp.cpp revision 78a072e1b56619e3230735ae073668311232ec94
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Copyright (c) 1989-1999 Microsoft Corporation
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Module Name:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This module implements the routines required for interaction with network
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo provider router interface in NT
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This module has been built and tested only in UNICODE environment
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define WNNC_DRIVER( major, minor ) ( major * 0x00010000 + minor )
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoULONG SendToMiniRdr (IN ULONG IoctlCode, IN PVOID InputDataBuf, IN ULONG InputDataLen, IN PVOID OutputDataBuf, IN PULONG pOutputDataLen)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Routine Description:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This routine sends a device ioctl to the Mini Rdr.
c1c61f44e88f4c8c155272ee56d868043146096asb Arguments:
c1c61f44e88f4c8c155272ee56d868043146096asb IoctlCode - Function code for the Mini Rdr driver
c1c61f44e88f4c8c155272ee56d868043146096asb InputDataBuf - Input buffer pointer
c1c61f44e88f4c8c155272ee56d868043146096asb InputDataLen - Lenth of the input buffer
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo OutputDataBuf - Output buffer pointer
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo pOutputDataLen - Pointer to the length of the output buffer
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Return Value:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo WN_SUCCESS if successful, otherwise the appropriate error
c1c61f44e88f4c8c155272ee56d868043146096asb // Grab a handle to the redirector device object
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo DeviceHandle = CreateFile(DD_MRX_VBOX_USERMODE_DEV_NAME_U, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, 0, (HANDLE)NULL );
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rc = DeviceIoControl(DeviceHandle, IoctlCode, InputDataBuf, InputDataLen, OutputDataBuf, *pOutputDataLen, pOutputDataLen, NULL );
if (!rc)
static int sLogged = 0;
if (!sLogged)
sLogged++;
return Status;
switch (nIndex)
case WNNC_SPEC_VERSION:
case WNNC_NET_TYPE:
case WNNC_DRIVER_VERSION:
case WNNC_CONNECTION:
rc = WNNC_CON_GETCONNECTIONS | WNNC_CON_CANCELCONNECTION | WNNC_CON_ADDCONNECTION | WNNC_CON_ADDCONNECTION3;
case WNNC_ENUMERATION:
case WNNC_START:
case WNNC_DIALOG:
case WNNC_USER:
case WNNC_ADMIN:
rc = 0;
return rc;
return WN_SUCCESS;
return WN_NOT_SUPPORTED;
NPAddConnection3 (HWND hwndOwner, LPNETRESOURCE lpNetResource, LPWSTR lpPassword, LPWSTR lpUserName, DWORD dwFlags)
return WN_BAD_NETNAME;
// LocalName[0] = (WCHAR) CharUpper( (PWCHAR) MAKELONG( (USHORT) lpNetResource->lpLocalName[0], 0 ) );
if (lstrlen (ConnectionName) + lstrlen (lpNetResource->lpRemoteName) <= sizeof (ConnectionName) / sizeof (WCHAR))
Log(("VBOXNP: NPAddConnection3: Full Connect Name Length: %d\n", ( lstrlen( ConnectionName ) + 1 ) * sizeof( WCHAR ) ));
if ( fLocalName
if ( !fLocalName
if ( fLocalName
ConnectionName ) )
return Status;
Status = SendToMiniRdr(IOCTL_MRX_VBOX_GETCONN, LocalName, sizeof(LocalName), (PVOID)RemoteName, &CopyBytes);
if (lstrlen (DD_MRX_VBOX_FS_DEVICE_NAME_U) + 2 + lstrlen (LocalName) + lstrlen (RemoteName) + 1 > sizeof (ConnectionName) / sizeof (WCHAR))
return WN_BAD_NETNAME;
CopyBytes = 0;
ConnectionName ) )
if (Verifier)
if (lstrlen (DD_MRX_VBOX_FS_DEVICE_NAME_U) + 2 + lstrlen (lpName) + 1 > sizeof (ConnectionName) / sizeof (WCHAR))
return WN_BAD_NETNAME;
CopyBytes = 0;
return Status;
Status = SendToMiniRdr(IOCTL_MRX_VBOX_GETCONN, LocalName, 3 * sizeof(WCHAR), (PVOID)RemoteName, &CopyBytes);
if (CopyBytes > 0)
if (*lpBufferSize != 0)
Log(("VBOXNP: NPGetConnection: Buffer overflow: *lpBufferSize = %d, len = %d\n", *lpBufferSize, len));
return Status;
while (*lpPrefix)
return NULL;
lpPrefix++;
lpRemoteName++;
return lpRemoteName;
int cLeadingBackslashes = 0;
lpRemoteName++;
if (!lpAfterPrefix)
return lpAfterPrefix;
return NULL;
#define NEWENUM
#ifdef NEWENUM
typedef struct _NPENUMCTX
bool fRoot;
} NPENUMCTX;
NPOpenEnum (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum)
dwUsage - the usage parameter (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER, or zero to match all the flags)
if (dwUsage == 0)
switch (dwScope)
case RESOURCE_CONTEXT: /* The interpretation of this is left to the provider. Treat this as RESOURCE_GLOBALNET. */
if (pCtx)
return (Status);
return WN_BAD_HANDLE;
return WN_BAD_VALUE;
Status = SendToMiniRdr(IOCTL_MRX_VBOX_GETCONN, LocalName, sizeof(LocalName), RemoteName, &CopyBytes);
pNetResource++;
Status = SendToMiniRdr(IOCTL_MRX_VBOX_GETGLOBALCONN, &ConnectionList[pCtx->index], sizeof(ConnectionList[pCtx->index]), RemoteName, &CopyBytes);
SpaceNeeded += 3 * sizeof(WCHAR) + sizeof(MRX_VBOX_SERVER_NAME_U) + CopyBytes; /* remote name: \\ + vboxsvr + \ + name + 0. */
pNetResource++;
return WN_BAD_HANDLE;
return Status;
if (pCtx)
return WN_SUCCESS;
NPOpenEnum (DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum)
switch (dwScope)
case RESOURCE_GLOBALNET:
case RESOURCE_CONNECTED:
lpdwEnum[0] = 0;
case RESOURCE_CONTEXT:
return (Status);
ULONG i;
return WN_NO_MORE_ENTRIES;
EntriesCopied = 0;
if (byConnectionList[i])
Status = SendToMiniRdr(IOCTL_MRX_VBOX_GETCONN, wzLocalName, 3 * sizeof(WCHAR), (PVOID)wzRemoteName, &CopyBytes);
pNetResource++;
if (byConnectionList[i])
Status = SendToMiniRdr(IOCTL_MRX_VBOX_GETGLOBALCONN, &byConnectionList[i], sizeof(byConnectionList[i]), (PVOID)wzRemoteName, &CopyBytes);
pNetResource++;
else return WN_NO_MORE_ENTRIES;
return Status;
return WN_SUCCESS;
return WN_BAD_NETNAME;
return WN_BAD_NETNAME;
if (!pParent)
return WN_OUT_OF_MEMORY;
pLastSlash--;
pLastSlash--;
*pLastSlash = 0;
if (pParent)
return Status;
NPGetResourceInformation (LPNETRESOURCE lpNetResource, LPVOID lpBuffer, LPDWORD lpBufferSize, LPWSTR *lplpSystem)
Log(("VBOXNP: NPGetResourceInformation: lpNetResource %p, lpBuffer %p, lpBufferSize %p, lplpSystem %p\n",
return WN_BAD_VALUE;
return WN_BAD_NETNAME;
return WN_BAD_DEV_TYPE;
return WN_MORE_DATA;
if (lplpSystem)
return WN_SUCCESS;
lp++;
if (*lp == 0)
SpaceNeeded += 2 * sizeof(WCHAR) + sizeof(MRX_VBOX_SERVER_NAME_U); /* \\ + server name with trailing nul */
return WN_MORE_DATA;
if (lplpSystem)
return WN_SUCCESS;
SpaceNeeded += 2 * sizeof(WCHAR) + sizeof(MRX_VBOX_SERVER_NAME_U); /* \\ + server name with trailing nul */
return WN_MORE_DATA;
*StringZone++ = 0;
if (lplpSystem)
return WN_SUCCESS;
Log(("VBOXNP: NPGetUniversalName: lpLocalPath = %ls, InfoLevel = %d, *lpBufferSize = %d\n", lpLocalPath, dwInfoLevel, *lpBufferSize));
return WN_BAD_LEVEL;
|| lpLocalPath[0] == 0
return WN_BAD_LOCALNAME;
RemoteNameLength = 0;
dwStatus = NPGetConnection (LocalDrive, RemoteNameLength? pUniversalNameInfo->lpUniversalName: NULL, &RemoteNameLength);
return dwStatus;
return WN_NO_NETWORK;
return WN_MORE_DATA;
RemoteNameLength = 0;
dwStatus = NPGetConnection (LocalDrive, RemoteNameLength? pRemoteNameInfo->lpUniversalName: NULL, &RemoteNameLength);
return dwStatus;
return WN_NO_NETWORK;
return WN_MORE_DATA;
lpDelimiter = lpString; /* Delimiter will be inserted later. For now keep the NULL terminated string. */
*lpDelimiter = 0;
return WN_SUCCESS;