netroot.c revision 78a072e1b56619e3230735ae073668311232ec94
/*++
Copyright (c) 1989 - 1999 Microsoft Corporation
Module Name:
Abstract:
This module implements the routines for creating the net root.
--*/
#include "precomp.h"
#pragma hdrstop
//
// Forward declarations ...
//
/*++
Routine Description:
This routine updates the mini redirector state associated with a net root.
Arguments:
pNetRoot - the net root instance.
Return Value:
NTSTATUS - The return status for the operation
Notes:
By diffrentiating the mini redirector state from the net root condition it is possible
to permit a variety of reconnect strategies. It is conceivable that the RDBSS considers
a net root to be good while the underlying mini redirector might mark it as invalid
and reconnect on the fly.
--*/
{
Log(("VBOXSF: VBoxMRxUpdateNetRootState: Called.\n"));
return (Status);
}
/*++
Routine Description:
This routine initializes a new net root.
It also validates rootnames. Eg: attempts to create a
file in a root that has not been created will fail.
Arguments:
pNetRoot - the net root
Return Value:
NTSTATUS - The return status for the operation
Notes:
--*/
{
Log(("VBOXSF: VBoxMRxInitializeNetRootEntry: Called.\n"));
return Status;
}
/*++
Routine Description:
This routine initializes the wrapper data structure corresponding to a
given net root entry.
Arguments:
pNetRootEntry - the server entry
Return Value:
STATUS_SUCCESS if successful
--*/
{
PAGED_CODE();
{
case NET_ROOT_DISK:
break;
case NET_ROOT_PIPE:
break;
case NET_ROOT_COMM:
break;
case NET_ROOT_PRINT:
break;
case NET_ROOT_MAILSLOT:
break;
case NET_ROOT_WILD:
/* We get this type when for example Windows Media player opens an MP3 file.
* This NetRoot has the same remote path (\\vboxsrv\dir) as other NetRoots,
* which were created earlier and which were NET_ROOT_DISK.
*
* In the beginning of the function (UpdateNetRoot) the DDK sample sets
* pNetRoot->Type of newly created NetRoots using a value previously
* pstored in a NetRootExtension. One NetRootExtensions is used for a single
* remote path and reused by a few NetRoots, if they point to the same path.
*
* To simplify things we just set the type to DISK here (we do not support
* anything else anyway), and update the DeviceType correspondingly.
*/
break;
default:
AssertMsgFailed(("VBOXSF: VBoxUpdateNetRoot: Invalid net root type! Type = 0x%x\n", pNetRoot->Type));
break;
}
return STATUS_SUCCESS;
}
/*++
Routine Description:
This routine patches the RDBSS created net root instance with the information required
by the mini redirector.
Arguments:
pVNetRoot - the virtual net root instance.
pCreateNetRootContext - the net root context for calling back
Return Value:
NTSTATUS - The return status for the operation
Notes:
--*/
{
Log(("VBOXSF: VBoxMRxCreateVNetRoot: pNetRoot = %p, fTreeConnectOpen = %d\n", pNetRoot, pRxContext->Create.ThisIsATreeConnectOpen));
/* IMPORTANT:
*
* This function must always call 'pCreateNetRootContext->Callback(pCreateNetRootContext)' before
* returning and then return STATUS_PENDING. Otherwise Win64 will hang.
*/
{
/* DDK sample returns this status code. And our driver does get such NetRoots. */
Log(("VBOXSF: VBoxMRxCreateVNetRoot: Mailslot or Pipe open (%d) not supported!\n", pNetRoot->Type));
goto l_Exit;
}
// The V_NET_ROOT is associated with a NET_ROOT. The two cases of interest are as
// follows
// 1) the V_NET_ROOT and the associated NET_ROOT are being newly created.
// 2) a new V_NET_ROOT associated with an existing NET_ROOT is being created.
//
// These two cases can be distinguished by checking if the context associated with
// NET_ROOT is NULL. Since the construction of NET_ROOT's/V_NET_ROOT's are serialized
// by the wrapper this is a safe check.
// ( The wrapper cannot have more then one thread tryingto initialize the same
// NET_ROOT).
//
// The above is not really true in our case. Since we have asked the wrapper,
// to manage our netroot extension, the netroot context will always be non-NULL.
// We will distinguish the cases by checking our root state in the context...
//
{
}
else
{
/* Detect an already initialized NetRoot.
* pNetRootExtension is actually the pNetRoot->Context and it is not null.
*/
}
Assert((NodeType(pNetRoot) == RDBSS_NTC_NETROOT) && (NodeType(pNetRoot->pSrvCall) == RDBSS_NTC_SRVCALL));
// update the net root state to be good.
if (fInitializeNetRoot)
{
int vboxRC;
PSHFLSTRING ParsedPath = 0;
// validate the fixed netroot name
if (!RootNameLength)
{
/* Refuse a netroot path with an empty shared folder name */
Log(("VBOXSF: VBoxMRxCreateVNetRoot: Invalid shared folder name! (length=0)\n"));
goto l_Exit;
}
pRootName = (PWCHAR)(pNetRoot->pNetRootName->Buffer + (pSrvCall->pSrvCallName->Length / sizeof(WCHAR)));
pRootName++; /* remove leading backslash */
{
Log(("VBOXSF: VBoxMRxCreateVNetRoot: Initialize netroot length = %d, name = %.*ls\n", RootNameLength, RootNameLength / sizeof(WCHAR), pRootName));
/* Calculate length required for parsed path.
*/
if (!ParsedPath)
{
goto l_Exit;
}
if (vboxRC != VINF_SUCCESS)
{
}
else
{
}
}
}
else Log(("VBOXSF: VBoxMRxCreateVNetRoot: Creating V_NET_ROOT on existing NET_ROOT!\n"));
{
//
// A new NET_ROOT and associated V_NET_ROOT are being created !
//
Log(("VBOXSF: VBoxMRxCreateVNetRoot: NulMRXInitializeNetRootEntry called, Status = 0x%lx\n", Status));
}
if (Status != STATUS_PENDING)
{
if (fInitializeNetRoot)
// Callback the RDBSS for resumption.
// Map the error code to STATUS_PENDING since this triggers
// the synchronization mechanism in the RDBSS.
}
Log(("VBOXSF: VBoxMRxCreateVNetRoot: Returned STATUS_PENDING\n"));
return Status;
}
/*++
Routine Description:
Arguments:
pVNetRoot - the virtual net root
ForceDisconnect - disconnect is forced
Return Value:
NTSTATUS - The return status for the operation
--*/
{
int vboxRC;
if (pNetRootExtension->phgcmClient)
{
if (vboxRC != VINF_SUCCESS)
{
}
}
//
// This is called when all outstanding handles on this
// root have been cleaned up ! We can now zap the netroot
// extension...
//
return Status;
}
/*++
Routine Description:
Arguments:
pVirtualNetRoot - the virtual net root
ForceDisconnect - disconnect is forced
Return Value:
NTSTATUS - The return status for the operation
--*/
{
Log(("VBOXSF: VBoxMRxFinalizeNetRoot: Called.\n"));
//
// This is called when all outstanding handles on this
// root have been cleaned up ! We can now zap the netroot
// extension...
//
return (Status);
}
VOID VBoxMRxExtractNetRootName (IN PUNICODE_STRING FilePathName, IN PMRX_SRV_CALL SrvCall, OUT PUNICODE_STRING NetRootName, OUT PUNICODE_STRING RestOfName OPTIONAL
)
/*++
Routine Description:
This routine parses the input name into srv, netroot, and the
rest.
Arguments:
--*/
{
Log(("VBOXSF: VBoxMRxExtractNetRootName: Called.\n"));
for (;;)
{
if (w >= wlimit)
break;
if ((*w == OBJ_NAME_PATH_SEPARATOR) && (w != wlow))
{
break;
}
w++;
}
//w = FilePathName->Buffer;
//NetRootName->Buffer = w++;
if (!RestOfName)
RestOfName->Buffer = w;
Log(("VBOXSF: VBoxMRxExtractNetRootName: FilePath = %.*ls\n", FilePathName->Length / sizeof(WCHAR), FilePathName->Buffer));
Log(("VBOXSF: VBoxMRxExtractNetRootName: Srv = %.*ls, Root = %.*ls, Rest = %.*ls\n", SrvCall->pSrvCallName->Length / sizeof(WCHAR), SrvCall->pSrvCallName->Buffer, NetRootName->Length
return;
}