Skip to content

Commit

Permalink
FsRtlRegisterUncProvider in system thread
Browse files Browse the repository at this point in the history
git-svn-id: http://dokan.googlecode.com/svn/trunk@133 53ea604a-054e-0410-8546-456bafaea6b0
  • Loading branch information
asakaw committed Apr 3, 2010
1 parent a0c94fe commit c764cf9
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions sys/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@ DokanCreateGlobalDiskDevice(
}


VOID
DokanRegisterUncProvider(
__in PDokanDCB Dcb)
{
NTSTATUS status;
status = FsRtlRegisterUncProvider(&(Dcb->MupHandle), Dcb->FileSystemDeviceName, FALSE);
if (NT_SUCCESS(status)) {
DDbgPrint(" FsRtlRegisterUncProvider success\n");
} else {
DDbgPrint(" FsRtlRegisterUncProvider failed: 0x%x\n", status);
Dcb->MupHandle = 0;
}
PsTerminateSystemThread(STATUS_SUCCESS);
}


PUNICODE_STRING
AllocateUnicodeString(
__in PCWSTR String)
Expand Down Expand Up @@ -580,12 +596,23 @@ DokanCreateDiskDevice(
IoRegisterFileSystem(fsDeviceObject);

if (DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) {
status = FsRtlRegisterUncProvider(&(dcb->MupHandle), dcb->FileSystemDeviceName, FALSE);
if (NT_SUCCESS(status)) {
DDbgPrint(" FsRtlRegisterUncProvider success\n");
// Run FsRtlRegisterUncProvider in System thread.
HANDLE handle;
PKTHREAD thread;
OBJECT_ATTRIBUTES objectAttribs;

InitializeObjectAttributes(
&objectAttribs, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
status = PsCreateSystemThread(&handle, THREAD_ALL_ACCESS,
&objectAttribs, NULL, NULL, (PKSTART_ROUTINE)DokanRegisterUncProvider, dcb);
if (!NT_SUCCESS(status)) {
DDbgPrint("PsCreateSystemThread failed: 0x%X\n", status);
} else {
DDbgPrint(" FsRtlRegisterUncProvider failed: 0x%x\n", status);
dcb->MupHandle = 0;
ObReferenceObjectByHandle(handle, THREAD_ALL_ACCESS, NULL,
KernelMode, &thread, NULL);
ZwClose(handle);
KeWaitForSingleObject(thread, Executive, KernelMode, FALSE, NULL);
ObDereferenceObject(thread);
}
}
//DokanRegisterMountedDeviceInterface(diskDeviceObject, dcb);
Expand Down

0 comments on commit c764cf9

Please sign in to comment.