Ejemplo n.º 1
0
static VOID DokanControl(PDOKAN_CONTROL Control)
{
	PMOUNT_ENTRY	mountEntry;

	Control->Status = DOKAN_CONTROL_FAIL;

	switch (Control->Type)
	{
	case DOKAN_CONTROL_MOUNT:

		DbgPrintW(L"DokanControl Mount\n");

		if (DokanControlMount(Control->MountPoint, Control->DeviceName)) {
			Control->Status = DOKAN_CONTROL_SUCCESS;
			InsertMountEntry(Control);
		} else {
			Control->Status = DOKAN_CONTROL_FAIL;
		}
		break;

	case DOKAN_CONTROL_UNMOUNT:

		DbgPrintW(L"DokanControl Unmount\n");

		mountEntry = FindMountEntry(Control);
		if (mountEntry == NULL) {
			if (!wcslen(Control->MountPoint))
				FindMountPoint(Control);
			DbgPrintW(L"DokanControl MountEntry not found. Try unmount '%s' force: %d\n", Control->MountPoint, Control->Option);
			if (Control->Option == DOKAN_CONTROL_OPTION_FORCE_UNMOUNT &&
				DokanControlUnmount(Control->MountPoint)) {
				Control->Status = DOKAN_CONTROL_SUCCESS;
				break;
			}
			Control->Status = DOKAN_CONTROL_FAIL;
			break;	
		}

		if (DokanControlUnmount(mountEntry->MountControl.MountPoint)) {
			Control->Status = DOKAN_CONTROL_SUCCESS;
			if (Control->DeviceName[0] == L'\0') {
				wcscpy_s(Control->DeviceName, sizeof(Control->DeviceName) / sizeof(WCHAR),
						mountEntry->MountControl.DeviceName);
			}
			RemoveMountEntry(mountEntry);
		} else {
			mountEntry->MountControl.Status = DOKAN_CONTROL_FAIL;
			Control->Status = DOKAN_CONTROL_FAIL;
		}

		break;

	case DOKAN_CONTROL_CHECK:
		{
			DbgPrint("DokanControl Check\n");
			Control->Status = 0;
		}
		break;

	case DOKAN_CONTROL_FIND:
		{
			DbgPrintW(L"DokanControl Find\n");
			DokanControlFind(Control);
		}
		break;

	case DOKAN_CONTROL_LIST:
		{
			DbgPrintW(L"DokanControl List\n");
			DokanControlList(Control);
		}
		break;

	default:
		DbgPrintW(L"DokanControl UnknownType %u\n", Control->Type);
	}

	return;
}
Ejemplo n.º 2
0
Archivo: mounter.c Proyecto: ulteo/ovd
static VOID DokanControl(PDOKAN_CONTROL Control)
{
	PMOUNT_ENTRY	mountEntry;
	ULONG	index = 0;
	DWORD written = 0;

	Control->Status = DOKAN_CONTROL_FAIL;

	switch (Control->Type)
	{
	case DOKAN_CONTROL_MOUNT:

		DbgPrintW(L"DokanControl Mount\n");

//		if (DokanControlMount(Control->MountPoint, Control->DeviceName)) {
			Control->Status = DOKAN_CONTROL_SUCCESS;
			InsertMountEntry(Control);
			DbgPrintW(L"DriveLetter: %c, DeviceName %s\n", Control->MountPoint[0], Control->DeviceName);

//		} else {
//			Control->Status = DOKAN_CONTROL_FAIL;
//		}
		break;

	case DOKAN_CONTROL_UNMOUNT:

		DbgPrintW(L"DokanControl Unmount\n");

		mountEntry = FindMountEntry(Control);
		if (mountEntry == NULL) {
			if (Control->Option == DOKAN_CONTROL_OPTION_FORCE_UNMOUNT ) {
				Control->Status = DOKAN_CONTROL_SUCCESS;
				break;
			}
			Control->Status = DOKAN_CONTROL_FAIL;
			break;	
		}

//		if (DokanControlUnmount(mountEntry->MountControl.MountPoint)) {
			Control->Status = DOKAN_CONTROL_SUCCESS;
			if (wcslen(Control->DeviceName) == 0) {
				wcscpy_s(Control->DeviceName, sizeof(Control->DeviceName) / sizeof(WCHAR),
						mountEntry->MountControl.DeviceName);
			}
			RemoveMountEntry(mountEntry);
//		} else {
//			mountEntry->MountControl.Status = DOKAN_CONTROL_FAIL;
//			Control->Status = DOKAN_CONTROL_FAIL;
//		}

		break;

	case DOKAN_CONTROL_CHECK:
		{
			DbgPrint("DokanControl Check\n");
			Control->Status = 0;
		}
		break;

	case DOKAN_CONTROL_FIND:
		{
			DbgPrintW(L"DokanControl Find\n");
			DokanControlFind(Control);
		}
		break;

	case DOKAN_CONTROL_LIST:
		{
			DbgPrintW(L"DokanControl List\n");
			DokanControlList(Control);
		}
		break;

	default:
		DbgPrintW(L"DokanControl UnknownType %u\n", Control->Type);
	}

	return;
}