⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 volume.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
/*
* COPYRIGHT:        See COPYING in the top level directory
* PROJECT:          ReactOS kernel
* FILE:             drivers/fs/npfs/volume.c
* PURPOSE:          Named pipe filesystem
* PROGRAMMER:       Eric Kohl
*/

/* INCLUDES *****************************************************************/

#include "npfs.h"

#define NDEBUG
#include <debug.h>

/* FUNCTIONS ****************************************************************/

static NTSTATUS
NpfsQueryFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
							 PULONG BufferLength)
{
	DPRINT("NpfsQueryFsDeviceInformation()\n");
	DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);

	if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
		return STATUS_BUFFER_OVERFLOW;

	FsDeviceInfo->DeviceType = FILE_DEVICE_NAMED_PIPE;
	FsDeviceInfo->Characteristics = 0;

	*BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);

	DPRINT("NpfsQueryFsDeviceInformation() finished.\n");

	return STATUS_SUCCESS;
}


static NTSTATUS
NpfsQueryFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
								PULONG BufferLength)
{
	DPRINT("NpfsQueryFsAttributeInformation() called.\n");
	DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);

	if (*BufferLength < sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8)
		return STATUS_BUFFER_OVERFLOW;

	FsAttributeInfo->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES;
	FsAttributeInfo->MaximumComponentNameLength = 255;
	FsAttributeInfo->FileSystemNameLength = 8;
	wcscpy(FsAttributeInfo->FileSystemName,
		L"NPFS");

	DPRINT("NpfsQueryFsAttributeInformation() finished.\n");
	*BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);

	return STATUS_SUCCESS;
}


NTSTATUS STDCALL
NpfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
						   PIRP Irp)
{
	PIO_STACK_LOCATION Stack;
	FS_INFORMATION_CLASS FsInformationClass;
	NTSTATUS Status = STATUS_SUCCESS;
	PVOID SystemBuffer;
	ULONG BufferLength;

	/* PRECONDITION */
	ASSERT(DeviceObject != NULL);
	ASSERT(Irp != NULL);

	DPRINT("NpfsQueryVolumeInformation(DeviceObject %x, Irp %x)\n",
		DeviceObject,
		Irp);

	Stack = IoGetCurrentIrpStackLocation(Irp);
	FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
	BufferLength = Stack->Parameters.QueryVolume.Length;
	SystemBuffer = Irp->AssociatedIrp.SystemBuffer;

	DPRINT("FsInformationClass %d\n", FsInformationClass);
	DPRINT("SystemBuffer %x\n", SystemBuffer);

	switch (FsInformationClass)
	{
	case FileFsDeviceInformation:
		Status = NpfsQueryFsDeviceInformation(SystemBuffer,
			&BufferLength);
		break;

	case FileFsAttributeInformation:
		Status = NpfsQueryFsAttributeInformation(SystemBuffer,
			&BufferLength);
		break;

	default:
		Status = STATUS_NOT_SUPPORTED;
	}

	Irp->IoStatus.Status = Status;
	if (NT_SUCCESS(Status))
		Irp->IoStatus.Information = Stack->Parameters.QueryVolume.Length - BufferLength;
	else
		Irp->IoStatus.Information = 0;
	IoCompleteRequest(Irp,
		IO_NO_INCREMENT);

	return Status;
}

/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -