Hi,
I minimized my export code.
I want manage a virtual file system in network UNC \teste.
I do not know what it says on MSDN, but its not working at all!.
DeviceType = FILE_DEVICE_NETWORK_FILE_SYSTEM;
DWORD charact=FILE_DEVICE_IS_MOUNTED;
if (devicetype==FILE_DEVICE_NETWORK_FILE_SYSTEM)
charact|=FILE_REMOTE_DEVICE;
status=IoCreateDevice(DriverObject,
sizeof (TPARAMVDF),
&dn,
devicetype,
charact,
FALSE,
&gvd);
…
…
…
…
//Dcb->_namedriver is equal to dn variable
RtlInitUnicodeString(&cs,Dcb->_namedriver);
KdPrintfd2((“Register NetWork driver (%ws)\n”,cs.Buffer));
status = FsRtlRegisterUncProvider(&(Dcb->MupHandle), &cs, FALSE);
…
…
…
In the thread of the driver what receives the function IOCTL_REDIR_QUERY_PATH i allocate mdl, and return STATUS_PENDING and my thread which manage virtual disk file system take the irp returned STATUS_PENDING and
finish by IoCompleteRequest
Thread DrvDispatch driver what receives the function IOCTL_REDIR_QUERY_PATH
NTSTATUS
AllocateMdl(
__in PIRP Irp,
__in ULONG Length
)
{
if (Irp->MdlAddress == NULL) {
PMDL mdl = IoAllocateMdl(Irp->UserBuffer, Length, FALSE, FALSE, Irp);
if (mdl == NULL) {
KdPrintf((" IoAllocateMdl returned NULL\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}
__try {
MmProbeAndLockPages(Irp->MdlAddress, Irp->RequestorMode, IoWriteAccess);
} __except (EXCEPTION_EXECUTE_HANDLER) {
KdPrintf((" MmProveAndLockPages error\n"));
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = NULL;
return STATUS_INSUFFICIENT_RESOURCES;
}
}
return STATUS_SUCCESS;
}
NTSTATUS
DrvDispatch (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
PIO_STACK_LOCATION irps;
NTSTATUS status=STATUS_NOT_IMPLEMENTED;
KdPrintf((“[VFUM] control\n”));
irps = IoGetCurrentIrpStackLocation(Irp);
…
…
…
if ((irps->MajorFunction==IRP_MJ_DEVICE_CONTROL))
{
ULONG Length;
PMDL mdl;
if (irps->Parameters.DeviceIoControl.IoControlCode==IOCTL_REDIR_QUERY_PATH)
{
Length = irps->Parameters.Read.Length;
KdPrintfd2((“Int IRP_MJ_DEVICE_CONTROL Offset %x Length %x\n”,irps->Parameters.Read.ByteOffset.LowPart,Length));
if (Irp->MdlAddress==NULL)
{
KdPrintfd2((“Int IRP_MJ_DEVICE_CONTROL Irp->MdlAddress==NULL\n”));
status=AllocateMdl(Irp,sizeof (QUERY_PATH_RESPONSE));
if (!NT_SUCCESS(status))
goto trierrorop;
}
}
}
…
…
…
//PushListHead //push irp in the list head
//IoMarkIrpPending
return STATUS_PENDING;
}
My Thread kernel what manages the virtual disk file system receives the IOCTL function IOCTL_REDIR_QUERY_PATH from IRP taked, it returns STATUS_SUCCESS if it is the string \teste
…
…
case IRP_MJ_DEVICE_CONTROL:
KdPrintfd2((“IRP_MJ_DEVICE_CONTROL irp:%x irps:%x\n”,irp,irps));
status=FatDiskControl(hProcess,DeviceObject,irp,irps);
//status= STATUS_NOT_IMPLEMENTED;
break;
…
…
IoCompleteRequest
…
…
NTSTATUS FatDiskControl(HANDLE hProcess,PDEVICE_OBJECT DeviceObject,PIRP irp,PIO_STACK_LOCATION irps)
{
…
…
switch (irps->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_REDIR_QUERY_PATH:
{
PQUERY_PATH_REQUEST p;
KdPrintfd2((“query_path_network\n”));
{
int len;
WCHAR *path;
p=irps->Parameters.DeviceIoControl.Type3InputBuffer;
KdPrintfd2((“Path (%ws)\n”,p->FilePathName));
len=wcslen(p->FilePathName)<<1;
path=p->FilePathName;
…
status=ischaintest(path);
//compare path if \teste
…
return status;
}
}
break;
…
…
}
PVOID
FatMapUserBuffer (
IN OUT PIRP Irp
)
{
PAGED_CODE();
//
// If there is no Mdl, then we must be in the Fsd, and we can simply
// return the UserBuffer field from the Irp.
//
if (Irp->MdlAddress == NULL) {
return Irp->UserBuffer;
} else {
PVOID Address = MmGetSystemAddressForMdlSafe( Irp->MdlAddress, NormalPagePriority );
if (Address == NULL) {
ExRaiseStatus( STATUS_INSUFFICIENT_RESOURCES );
}
return Address;
}
}
So far it works.
Problem:
The MUP controller instead of the list myself of my virtual file, it will try to open the file \teste\pipe\wkssvc with function IRP_MJ_CREATE
and read with the function IRP_MJ_READ! the SMB controller.
The MUP controller don’t call the function (it does not call any of the function): IRP_MJ_DIRECTORY_CONTROL -> IRP_MN_QUERY_DIRECTORY.
Conclusion: obviously the browser (explorer.exe) returns an error can not access it.
Also :
I also had a random blue screen on the controller MUP :
BugCheck 50, {e2242000, 0, 804db20d, 1}
MODULE_NAME: Mup
FAULTING_MODULE: 804d7000 nt
DEBUG_FLR_IMAGE_TIMESTAMP: 41107ef8
READ_ADDRESS: unable to get nt!MmSpecialPoolStart
unable to get nt!MmSpecialPoolEnd
unable to get nt!MmPoolCodeStart
unable to get nt!MmPoolCodeEnd
e2242000
FAULTING_IP:
nt!memmove+33
804db20d f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
MM_INTERNAL_CODE: 1
DEFAULT_BUCKET_ID: DRIVER_FAULT
BUGCHECK_STR: 0x50
LAST_CONTROL_TRANSFER: from 805296be to 80537832
STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
b203883c 805296be 00000050 e2242000 00000000 nt!KeBugCheckEx+0x1b
b203888c 804e0f07 00000000 e2242000 00000000 nt!KePulseEvent+0xd123
b20388c4 80552146 81e34c10 00000080 b2030000 nt!Kei386EoiHelper+0x274d
b2038920 f82b3fcc e24e0de8 e2241f90 00000080 nt!ExAllocatePoolWithTag+0x141
b2038940 f82b468d b2038cc0 00000080 e10c5af0 Mup+0x5fcc
b2038974 f82b4471 81bb7e80 b2038cc0 00000000 Mup+0x668d
b20389b8 f82b3b19 81bb7e80 b2038cc0 b2038a50 Mup+0x6471
b2038a14 804e19ee 81eaad70 81bb7e80 81bb7e80 Mup+0x5b19
b2038b04 8056e063 81eaad70 00000000 81dc0008 nt!IofCallDriver+0x32
b2038b7c 805715e8 00000000 b2038bbc 00000040 nt!SeDeleteAccessState+0x573
b2038bd0 8057c0cd 00000000 00000000 e1a9c901 nt!ObOpenObjectByName+0xda
b2038d54 804ddf0f 0006a258 0006a230 0006a284 nt!NtSetInformationProcess+0x304
b2038e0c 80570593 b2038a78 000005c9 00000000 nt!KiDeliverApc+0xbbb
b2038e50 804da591 00000000 00000000 00000001 nt!KeUserModeCallback+0x87
b2038ed0 bf9077d5 bf9076be 00050007 00000038 nt!ExAcquireResourceExclusiveLite+0x4a
b2038ed4 bf9076be 00050007 00000038 e0090001 win32k!EngAlphaBlend+0x42d0
b2038ed8 00050007 00000038 e0090001 746a08b6 win32k!EngAlphaBlend+0x41b9
b2038edc 00000000 e0090001 746a08b6 77d26df4 0x50007
Is necessary i call the function IoFreeMdl after the end of the function IOCTL_REDIR_QUERY_PATH ? I do not know.
I did what was said in MSDN for see my virtual files of my UNC path \teste, and it’s don’t all work !.
What should I do?
Thank you.