本文整理汇总了C++中IoCreateDevice函数的典型用法代码示例。如果您正苦于以下问题:C++ IoCreateDevice函数的具体用法?C++ IoCreateDevice怎么用?C++ IoCreateDevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoCreateDevice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: HalpDriverEntry
NTSTATUS
NTAPI
HalpDriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
NTSTATUS Status;
PDEVICE_OBJECT TargetDevice = NULL;
DPRINT("HAL: PnP Driver ENTRY!\n");
/* This is us */
HalpDriverObject = DriverObject;
/* Set up add device */
DriverObject->DriverExtension->AddDevice = HalpAddDevice;
/* Set up the callouts */
DriverObject->MajorFunction[IRP_MJ_PNP] = HalpDispatchPnp;
DriverObject->MajorFunction[IRP_MJ_POWER] = HalpDispatchPower;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HalpDispatchWmi;
/* Create the PDO */
Status = IoCreateDevice(DriverObject,
0,
NULL,
FILE_DEVICE_CONTROLLER,
0,
FALSE,
&TargetDevice);
if (!NT_SUCCESS(Status))
return Status;
TargetDevice->Flags &= ~DO_DEVICE_INITIALIZING;
/* Set up the device stack */
Status = HalpAddDevice(DriverObject, TargetDevice);
if (!NT_SUCCESS(Status))
{
IoDeleteDevice(TargetDevice);
return Status;
}
/* Tell the PnP manager about us */
Status = IoReportDetectedDevice(DriverObject,
InterfaceTypeUndefined,
-1,
-1,
NULL,
NULL,
FALSE,
&TargetDevice);
/* Return to kernel */
return Status;
}
开发者ID:Nevermore2015,项目名称:reactos,代码行数:55,代码来源:halpnpdd.c
示例2: DriverEntry
/*
* FUNCTION: Called by the system to initialize the driver
* ARGUMENTS:
* DriverObject = object describing this driver
* RegistryPath = path to our configuration entries
* RETURNS: Success or failure
*/
NTSTATUS NTAPI
DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT DeviceObject;
NTSTATUS Status;
UNICODE_STRING DeviceName;
DPRINT("MUP 0.0.1\n");
RtlInitUnicodeString(&DeviceName,
L"\\Device\\Mup");
Status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
&DeviceName,
FILE_DEVICE_MULTI_UNC_PROVIDER,
0,
FALSE,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
return Status;
}
/* Initialize driver data */
DeviceObject->Flags |= DO_DIRECT_IO;
// DriverObject->MajorFunction[IRP_MJ_CLOSE] = NtfsClose;
DriverObject->MajorFunction[IRP_MJ_CREATE] = MupCreate;
DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = MupCreate;
DriverObject->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = MupCreate;
// DriverObject->MajorFunction[IRP_MJ_READ] = NtfsRead;
// DriverObject->MajorFunction[IRP_MJ_WRITE] = NtfsWrite;
// DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
// NtfsFileSystemControl;
// DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
// NtfsDirectoryControl;
// DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
// NtfsQueryInformation;
// DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
// NtfsQueryVolumeInformation;
// DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
// NtfsSetVolumeInformation;
DriverObject->DriverUnload = NULL;
/* Initialize global data */
// DeviceExtensionNtfsGlobalData = DeviceObject->DeviceExtension;
// RtlZeroMemory(NtfsGlobalData,
// sizeof(NTFS_GLOBAL_DATA));
// NtfsGlobalData->DriverObject = DriverObject;
// NtfsGlobalData->DeviceObject = DeviceObject;
return STATUS_SUCCESS;
}
开发者ID:RareHare,项目名称:reactos,代码行数:62,代码来源:mup.c
示例3: DriverInitialize
/*
* DriverInitialize
*
* Purpose:
*
* Driver main.
*
*/
NTSTATUS DriverInitialize(
_In_ struct _DRIVER_OBJECT *DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
{
NTSTATUS status;
UNICODE_STRING SymLink, DevName;
PDEVICE_OBJECT devobj;
ULONG t;
//RegistryPath is unused
UNREFERENCED_PARAMETER(RegistryPath);
g_NotifySet = FALSE;
g_VBoxDD.Chains = NULL;
g_VBoxDD.ChainsLength = 0;
KeInitializeMutex(&g_VBoxDD.Lock, 0);
RtlInitUnicodeString(&DevName, TSUGUMI_DEV_OBJECT);
status = IoCreateDevice(DriverObject, 0, &DevName, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, TRUE, &devobj);
if (!NT_SUCCESS(status)) {
return status;
}
RtlInitUnicodeString(&SymLink, TSUGUMI_SYM_LINK);
status = IoCreateSymbolicLink(&SymLink, &DevName);
if (!NT_SUCCESS(status)) {
IoDeleteDevice(devobj);
return status;
}
devobj->Flags |= DO_BUFFERED_IO;
for (t = 0; t <= IRP_MJ_MAXIMUM_FUNCTION; t++)
DriverObject->MajorFunction[t] = &UnsupportedDispatch;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = &DevioctlDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = &CreateCloseDispatch;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = &CreateCloseDispatch;
#ifndef _SIGNED_BUILD
DriverObject->DriverUnload = NULL;
devobj->Flags &= ~DO_DEVICE_INITIALIZING;
#else
DriverObject->DriverUnload = &DriverUnload;
status = TsmiLoadParameters();
if (NT_SUCCESS(status)) {
status = PsSetLoadImageNotifyRoutine(TsmiPsImageHandler);
if (NT_SUCCESS(status)) {
g_NotifySet = TRUE;
}
}
#endif
return STATUS_SUCCESS;
}
开发者ID:CM44,项目名称:VBoxHardenedLoader,代码行数:63,代码来源:main.c
示例4: DriverEntry
NTSTATUS DriverEntry( PDRIVER_OBJECT pDriverObject,
PUNICODE_STRING pRegistryPath )
{
PDEVICE_OBJECT pdo = NULL;
NTSTATUS s = STATUS_SUCCESS;
UNICODE_STRING usDriverName, usDosDeviceName;
RtlInitUnicodeString( &usDriverName, DRIVER_NAME );
RtlInitUnicodeString( &usDosDeviceName, DEVICE_NAME );
s = IoCreateDevice( pDriverObject, 0, &usDriverName, \
FILE_DRIVER_SSDT, FILE_DEVICE_SECURE_OPEN, \
FALSE, &pdo );
if( STATUS_SUCCESS == s )
{
pDriverObject->MajorFunction[IRP_MJ_CREATE] = SSDTCreate;
pDriverObject->MajorFunction[IRP_MJ_CLOSE]=SSDTClose;
pDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] \
= SSDTDeviceIoCtl;
pDriverObject->DriverUnload = SSDTUnload;
IoCreateSymbolicLink( &usDosDeviceName, &usDriverName );
}
MUTEX_INIT(LogMutex);
// GetProcessNameOffset();
Log = ExAllocatePool(NonPagedPool,sizeof(LOG_BUF));
if(Log == NULL)
{
s = STATUS_INSUFFICIENT_RESOURCES;
}
else
{
Log->Length = 0;
Log->Next = NULL;
//pCurrentLog = Log;
NumLog = 1;
}
pSystem = PsGetCurrentProcess();
DbgPrint("pSystem %0x",pSystem);
pebAddress = GetPebAddress();
pObjectTypeProcess = *(PULONG)((ULONG)pSystem - OBJECT_HEADER_SIZE +OBJECT_TYPE_OFFSET);
MyPspTerminateThreadByPointer =GetUndocumentFunctionAdress();
GetProcessNameOffset();
DbgPrint( "SSDT: Load Success!" );
return s;
}
开发者ID:340211173,项目名称:Gold,代码行数:54,代码来源:ssdt.c
示例5: DriverEntry
NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT driverObject, PUNICODE_STRING registryPath) {
NTSTATUS status = STATUS_SUCCESS; // default status
// Debug print
DbgPrint("Hello!!\n");
DbgPrint("RegistryPath=%wZ\n", registryPath);
// Creation of the associated device
PDEVICE_OBJECT deviceObject = NULL; // represents a logical, virtual, or physical device for which a driver handles I/O requests.
UNICODE_STRING deviceName;
UNICODE_STRING dosDeviceName;// unicode string struct: USHORT Length, current length of the string
// USHORT MaximumLength, max length of the string
// PWSTR Buffer, the string /!\not even NULL terminated!
RtlInitUnicodeString(&deviceName, L"\\Device\\Example"); // Initialize a unicode string
RtlInitUnicodeString(&dosDeviceName, L"\\DosDevices\\Example");
status = IoCreateDevice(driverObject, // driver object
0, // length of device extention (extra data to pass)
&deviceName, // device name
FILE_DEVICE_UNKNOWN, // unknow because it's not a specific device
FILE_DEVICE_SECURE_OPEN,// flags: FILE_DEVICE_SECURE_OPEN,
// FILE_FLOPPY_DISKETTE,
// FILE_READ_ONLY_DEVICE,
// FILE_REMOVABLE_MEDIA,
// FILE_WRITE_ONCE_MEDIA
FALSE, // is an exclusive device?
&deviceObject); // out
if (status != STATUS_SUCCESS) {
IoDeleteDevice(deviceObject);
goto cleanup;
}
for (UINT i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {
driverObject->MajorFunction[i] = unsuported_function;
}
driverObject->MajorFunction[IRP_MJ_CLOSE] = my_close;
driverObject->MajorFunction[IRP_MJ_CREATE] = my_create;
driverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = my_io_control;
// Setting my_unload as unload function
driverObject->DriverUnload = my_unload;
deviceObject->Flags |= IO_TYPE;
deviceObject->Flags &= (~DO_DEVICE_INITIALIZING); // DO_DEVICE_INITIALIZING: tell to not send I/O request to
// the device. It is MANDATORY to clear it to use the device.
// (except in DriverEntry because it is automatic)
IoCreateSymbolicLink(&dosDeviceName, &deviceName);
cleanup:
return status;
}
开发者ID:ChibiTomo,项目名称:sandbox,代码行数:54,代码来源:driver.c
示例6: MouFilter_AddDevice
NTSTATUS
MouFilter_AddDevice(
IN PDRIVER_OBJECT Driver,
IN PDEVICE_OBJECT PDO
)
{
PDEVICE_EXTENSION devExt;
IO_ERROR_LOG_PACKET errorLogEntry;
PDEVICE_OBJECT device;
NTSTATUS status = STATUS_SUCCESS;
PAGED_CODE();
DbgPrint(("MouFilter_AddDevice() called\n"));
status = IoCreateDevice(Driver,
sizeof(DEVICE_EXTENSION),
NULL,
FILE_DEVICE_MOUSE,
0,
FALSE,
&device
);
if (!NT_SUCCESS(status)) {
return (status);
}
RtlZeroMemory(device->DeviceExtension, sizeof(DEVICE_EXTENSION));
devExt = (PDEVICE_EXTENSION) device->DeviceExtension;
devExt->TopOfStack = IoAttachDeviceToDeviceStack(device, PDO);
if (devExt->TopOfStack == NULL) {
IoDeleteDevice(device);
return STATUS_DEVICE_NOT_CONNECTED;
}
ASSERT(devExt->TopOfStack);
devExt->Self = device;
devExt->PDO = PDO;
devExt->DeviceState = PowerDeviceD0;
devExt->SurpriseRemoved = FALSE;
devExt->Removed = FALSE;
devExt->Started = FALSE;
device->Flags |= (DO_BUFFERED_IO | DO_POWER_PAGABLE);
device->Flags &= ~DO_DEVICE_INITIALIZING;
MouFilter_QueryMouseAttributes(devExt->TopOfStack);
return status;
}
开发者ID:martinb3,项目名称:windows_driver_model_tutorial,代码行数:54,代码来源:moufiltr.c
示例7: MrAddDevice
NTSTATUS MrAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT DeviceObject
)
{
struct mr_dcb *dcb;
PDEVICE_OBJECT devobj = NULL;
NTSTATUS status;
/* create filter object for target device */
status = IoCreateDevice(DriverObject,
sizeof(struct mr_dcb),
NULL,
FILE_DEVICE_MOUSE,
0,
FALSE,
&devobj
);
if (!NT_SUCCESS(status)) {
goto errorout;
}
/* initialize device extension */
dcb = (struct mr_dcb*)devobj->DeviceExtension;
memset(dcb, 0, sizeof(struct mr_dcb));
/* query device info (VID/DID ...) */
status = MrInitDcb(dcb, DeviceObject);
/* check whether this mouse is to be swapped */
if (STATUS_SUCCESS == status) {
if (MrLookupId(dcb)) {
dcb->md_state |= MR_DEV_STATE_PERSIST |
MR_DEV_STATE_ENABLED;
}
}
/* attach filter into target device stack */
dcb->md_target = IoAttachDeviceToDeviceStack(
devobj, DeviceObject);
devobj->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE;
devobj->Flags &= ~DO_DEVICE_INITIALIZING;
/* insert dcb into global list */
MrLockGlobal(TRUE);
InsertTailList(&g_core.mc_dcb_list, &dcb->md_link);
g_core.mc_dcb_count++;
MrUnlockGlobal();
errorout:
return STATUS_SUCCESS;
}
开发者ID:matt-wu,项目名称:Moure,代码行数:53,代码来源:moure.c
示例8: DriverEntry
NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS ntStatus;
UNICODE_STRING uszDriverString;
UNICODE_STRING uszDeviceString;
UNICODE_STRING uszProcessEventString;
PDEVICE_OBJECT pDeviceObject;
PDEVICE_EXTENSION extension;
RtlInitUnicodeString(&uszDriverString, DEVICE_NAME);
ntStatus = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
&uszDriverString,
FILE_DEVICE_UNKNOWN,
0,
FALSE,
&pDeviceObject);
if(ntStatus != STATUS_SUCCESS)
return ntStatus;
extension = pDeviceObject->DeviceExtension;
RtlInitUnicodeString(&uszDeviceString, DEVICE_LINK_NAME);
ntStatus = IoCreateSymbolicLink(&uszDeviceString, &uszDriverString);
if(ntStatus != STATUS_SUCCESS)
{
IoDeleteDevice(pDeviceObject);
return ntStatus;
}
g_pDeviceObject = pDeviceObject;
DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchCreateClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = Dispatch;
DriverObject->DriverUnload = UnloadDriver;
RtlInitUnicodeString(&uszProcessEventString, MONITOR_PROCESS_EVENT);
extension->ProcessEvent = IoCreateNotificationEvent (&uszProcessEventString, &extension->hProcessHandle);
KeClearEvent(extension->ProcessEvent);
ntStatus = PsSetCreateProcessNotifyRoutine(ProcessCallback, FALSE);
return ntStatus;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:53,代码来源:ProcessMonitor.c
示例9: KMix_InstallDevice
NTSTATUS
NTAPI
KMix_InstallDevice(
IN PDRIVER_OBJECT DriverObject)
{
NTSTATUS Status;
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\kmixer");
PDEVICE_OBJECT DeviceObject;
PKMIXER_DEVICE_EXT DeviceExtension;
DPRINT1("KMix_InstallDevice called\n");
/* create the device */
Status = IoCreateDevice(DriverObject,
sizeof(KMIXER_DEVICE_EXT),
&DeviceName,
FILE_DEVICE_KS,
0,
FALSE,
&DeviceObject);
/* check for success */
if (!NT_SUCCESS(Status))
{
DPRINT("Failed to create \\Device\\kmixer !\n");
return Status;
}
DeviceExtension = (PKMIXER_DEVICE_EXT)DeviceObject->DeviceExtension;
/* initialize device extension */
RtlZeroMemory(DeviceExtension, sizeof(KMIXER_DEVICE_EXT));
Status = KMixAllocateDeviceHeader(DeviceExtension);
if (!NT_SUCCESS(Status))
{
DPRINT1("KMixAllocateDeviceHeader failed with %x\n", Status);
goto cleanup;
}
/* set io flags */
DeviceObject->Flags |= DO_DIRECT_IO | DO_POWER_PAGABLE;
/* clear initializing flag */
DeviceObject->Flags &= ~ DO_DEVICE_INITIALIZING;
DPRINT("KMix_InstallDevice result %x\n", Status);
return STATUS_SUCCESS;
cleanup:
IoDeleteDevice(DeviceObject);
return Status;
}
开发者ID:RareHare,项目名称:reactos,代码行数:53,代码来源:kmixer.c
示例10: DriverEntry
NTSTATUS
NTAPI
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT DeviceObject;
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Null");
NTSTATUS Status;
PFAST_IO_DISPATCH FastIoDispatch;
PAGED_CODE();
/* Page the driver */
MmPageEntireDriver(DriverEntry);
/* Create null device */
Status = IoCreateDevice(DriverObject,
0,
&DeviceName,
FILE_DEVICE_NULL,
0,
FALSE,
&DeviceObject);
if (!NT_SUCCESS(Status)) return Status;
/* Register driver routines */
DriverObject->MajorFunction[IRP_MJ_CLOSE] = NullDispatch;
DriverObject->MajorFunction[IRP_MJ_CREATE] = NullDispatch;
DriverObject->MajorFunction[IRP_MJ_WRITE] = NullDispatch;
DriverObject->MajorFunction[IRP_MJ_READ] = NullDispatch;
DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = NullDispatch;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = NullDispatch;
/* Allocate the fast I/O dispatch table */
FastIoDispatch = ExAllocatePool(NonPagedPool, sizeof(FAST_IO_DISPATCH));
if (!FastIoDispatch)
{
/* Failed, cleanup */
IoDeleteDevice(DeviceObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* Initialize it */
RtlZeroMemory(FastIoDispatch, sizeof(FAST_IO_DISPATCH));
FastIoDispatch->SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
/* Setup our pointers */
FastIoDispatch->FastIoRead = NullRead;
FastIoDispatch->FastIoWrite = NullWrite;
DriverObject->FastIoDispatch = FastIoDispatch;
/* Return success */
return STATUS_SUCCESS;
}
开发者ID:RPG-7,项目名称:reactos,代码行数:53,代码来源:null.c
示例11: HalpReportDetectedDevices
VOID
NTAPI
HalpReportDetectedDevices(IN PDRIVER_OBJECT DriverObject,
IN PVOID Context,
IN ULONG Count)
{
PFDO_EXTENSION FdoExtension = Context;
PPDO_EXTENSION PdoExtension;
PDEVICE_OBJECT PdoDeviceObject;
PDESCRIPTION_HEADER Wdrt;
NTSTATUS Status;
/* Create the PDO */
Status = IoCreateDevice(DriverObject,
sizeof(PDO_EXTENSION),
NULL,
FILE_DEVICE_BUS_EXTENDER,
FILE_AUTOGENERATED_DEVICE_NAME,
FALSE,
&PdoDeviceObject);
if (!NT_SUCCESS(Status))
{
/* Fail */
DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status);
return;
}
/* Setup the PDO device extension */
PdoExtension = PdoDeviceObject->DeviceExtension;
PdoExtension->ExtensionType = PdoExtensionType;
PdoExtension->PhysicalDeviceObject = PdoDeviceObject;
PdoExtension->ParentFdoExtension = FdoExtension;
PdoExtension->PdoType = AcpiPdo;
/* Add the PDO to the head of the list */
PdoExtension->Next = FdoExtension->ChildPdoList;
FdoExtension->ChildPdoList = PdoExtension;
/* Initialization is finished */
PdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
/* Find the ACPI watchdog table */
Wdrt = HalAcpiGetTable(0, 'TRDW');
if (Wdrt)
{
/* FIXME: TODO */
DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
}
/* This will synchronously load the ACPI driver (needed because we're critical for boot) */
IoSynchronousInvalidateDeviceRelations(FdoExtension->PhysicalDeviceObject, BusRelations);
}
开发者ID:Nevermore2015,项目名称:reactos,代码行数:52,代码来源:halpnpdd.c
示例12: XFilter_Create
//
// 创建一个可见的设备
//
NTSTATUS
XFilter_Create(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS status = STATUS_SUCCESS;
PXPACKET_DEVICE_EXTENSION pDeviceExtension = NULL;
PDEVICE_OBJECT pFilterDeviceObject = NULL;
UNICODE_STRING usTempName;
UNICODE_STRING SymbolicLinkName;
RtlInitUnicodeString(&usTempName, XPACKET_XFILTER_DEVICE_NAME);
status = IoCreateDevice(
IN DriverObject,
IN sizeof(XPACKET_DEVICE_EXTENSION),
IN &usTempName,
IN FILE_DEVICE_XPACKET,
IN 0,
IN FALSE,
OUT &pFilterDeviceObject
);
if(status != STATUS_SUCCESS)
{
dprintf(("XFilter_Create: Couldn't create the XFilter Device Object(0x%X)\n", status));
return( status );
}
RtlInitUnicodeString(&SymbolicLinkName, XPACKET_XFILTER_DOS_DEVICE_NAME);
status = IoCreateSymbolicLink(
&SymbolicLinkName,
&usTempName);
if (!NT_SUCCESS(status))
{
dprintf(("IpFilter_Attach: Couldn't create the Ip Filter Dos Device Object(0x%X)\n", status));
IoDeleteDevice(pFilterDeviceObject);
pFilterDeviceObject = NULL;
return( status );
}
pDeviceExtension = (PXPACKET_DEVICE_EXTENSION)pFilterDeviceObject->DeviceExtension;
NdisZeroMemory(pDeviceExtension, sizeof(XPACKET_DEVICE_EXTENSION));
pDeviceExtension->ulNodeType = XPACKET_NOTE_TYPE_X_FILTER_DEVICE;
pDeviceExtension->ulNodeSize = sizeof(XPACKET_DEVICE_EXTENSION);
dprintf(("XFilter_Create: Success Create XFilter Device Object(0x%X)\n", status));
return status;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:55,代码来源:XFilter.c
示例13: VolumeFilterAddDevice
NTSTATUS VolumeFilterAddDevice (PDRIVER_OBJECT driverObject, PDEVICE_OBJECT pdo)
{
VolumeFilterExtension *Extension;
NTSTATUS status;
PDEVICE_OBJECT filterDeviceObject = NULL;
PDEVICE_OBJECT attachedDeviceObject;
Dump ("VolumeFilterAddDevice pdo=%p\n", pdo);
attachedDeviceObject = IoGetAttachedDeviceReference (pdo);
status = IoCreateDevice (driverObject, sizeof (VolumeFilterExtension), NULL, attachedDeviceObject->DeviceType, 0, FALSE, &filterDeviceObject);
ObDereferenceObject (attachedDeviceObject);
if (!NT_SUCCESS (status))
{
filterDeviceObject = NULL;
goto err;
}
Extension = (VolumeFilterExtension *) filterDeviceObject->DeviceExtension;
memset (Extension, 0, sizeof (VolumeFilterExtension));
Extension->LowerDeviceObject = IoAttachDeviceToDeviceStack (filterDeviceObject, pdo); // IoAttachDeviceToDeviceStackSafe() is not required in AddDevice routine and is also unavailable on Windows 2000 SP4
if (!Extension->LowerDeviceObject)
{
status = STATUS_DEVICE_REMOVED;
goto err;
}
Extension->IsVolumeFilterDevice = TRUE;
Extension->DeviceObject = filterDeviceObject;
Extension->Pdo = pdo;
IoInitializeRemoveLock (&Extension->Queue.RemoveLock, 'LRCT', 0, 0);
filterDeviceObject->Flags |= Extension->LowerDeviceObject->Flags & (DO_DIRECT_IO | DO_BUFFERED_IO | DO_POWER_PAGABLE);
filterDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
return status;
err:
if (filterDeviceObject)
{
if (Extension->LowerDeviceObject)
IoDetachDevice (Extension->LowerDeviceObject);
IoDeleteDevice (filterDeviceObject);
}
return status;
}
开发者ID:CSRedRat,项目名称:CipherShed,代码行数:52,代码来源:VolumeFilter.c
示例14: ulkAddDevice
NTSTATUS
ulkAddDevice(
PDRIVER_OBJECT driverObject,
PDEVICE_OBJECT pdo)
{
NTSTATUS status;
PDEVICE_OBJECT fdo = NULL;
PULK_DEV_EXT devExt;
PAGED_CODE();
#ifdef DBG
DbgPrint("[ulk] AddDevice(0x%x)\n", pdo);
#endif
__try {
status = IoCreateDevice(driverObject,
sizeof(ULK_DEV_EXT),
NULL,
pdo->DeviceType,
0,
FALSE,
&fdo);
if(!NT_SUCCESS(status)) {
DbgPrint("[ulk] ERROR ulkAddDevice:IoCreateDevice(%s)\n",
OsrNTStatusToString(status));
__leave;
}
devExt = (PULK_DEV_EXT)fdo->DeviceExtension;
RtlZeroMemory(devExt, sizeof(ULK_DEV_EXT));
IoInitializeRemoveLock(&devExt->removeLock, DEV_EXT_TAG, 0, 0);
devExt->pdo = pdo;
devExt->lowerDevice = IoAttachDeviceToDeviceStack(fdo, pdo);
if (!devExt->lowerDevice) {
DbgPrint("[ulk] ERROR ulkAddDevice:IoAttachDeviceToDeviceStack\n");
status = STATUS_INTERNAL_ERROR;
__leave;
}
fdo->Flags = pdo->Flags & (DO_BUFFERED_IO | DO_DIRECT_IO | DO_POWER_INRUSH | DO_POWER_PAGABLE);
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
} __finally {
if (!NT_SUCCESS(status)) {
if (fdo) {
ulkDeleteDevice(fdo);
}
}
}
return STATUS_SUCCESS;
}
开发者ID:Psybot,项目名称:UsbToolset,代码行数:52,代码来源:ulkDevices.c
示例15: DriverEntry
//
// This is where it all starts...
//
NTSTATUS
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
PDEVICE_OBJECT device_object;
UNICODE_STRING ctl_device_name;
UNICODE_STRING sym_link;
AWEAllocDriverObject = DriverObject;
MmPageEntireDriver((PVOID)(ULONG_PTR)DriverEntry);
// Create the control device.
RtlInitUnicodeString(&ctl_device_name, AWEALLOC_DEVICE_NAME);
status = IoCreateDevice(DriverObject,
0,
&ctl_device_name,
FILE_DEVICE_NULL,
0,
FALSE,
&device_object);
if (!NT_SUCCESS(status))
return status;
device_object->Flags |= DO_DIRECT_IO;
RtlInitUnicodeString(&sym_link, AWEALLOC_SYMLINK_NAME);
status = IoCreateUnprotectedSymbolicLink(&sym_link, &ctl_device_name);
if (!NT_SUCCESS(status))
{
IoDeleteDevice(device_object);
return status;
}
DriverObject->MajorFunction[IRP_MJ_CREATE] = AWEAllocCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = AWEAllocClose;
DriverObject->MajorFunction[IRP_MJ_READ] = AWEAllocReadWrite;
DriverObject->MajorFunction[IRP_MJ_WRITE] = AWEAllocReadWrite;
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = AWEAllocFlushBuffers;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
AWEAllocQueryInformation;
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = AWEAllocSetInformation;
DriverObject->DriverUnload = AWEAllocUnload;
KdPrint(("AWEAlloc: Initialization done. Leaving DriverEntry().\n"));
return STATUS_SUCCESS;
}
开发者ID:sundiyone,项目名称:virtual-disk,代码行数:55,代码来源:awealloc.c
示例16: CreateDevice
//初始化设备对象
NTSTATUS CreateDevice(IN PDRIVER_OBJECT pDriverObject)
{
NTSTATUS status;
PDEVICE_OBJECT pDevObj;
PDEVICE_EXTENSION pDevExt;
//创建设备名称
UNICODE_STRING szDevName;
RtlInitUnicodeString(&szDevName,L"\\Device\\ZdgDevice");
//创建设备
status=IoCreateDevice(pDriverObject,
sizeof(DEVICE_EXTENSION),
&(UNICODE_STRING)szDevName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
TRUE,
&pDevObj);
//创建不成功的话
if(!NT_SUCCESS(status))
{
DbgPrint("IoCreateDevice UnOK!\n");
return status;
}
else
DbgPrint("IoCreateDevice OK!\n");
//赋值相应参数
pDevObj->Flags|=DO_BUFFERED_IO;
pDevExt=(PDEVICE_EXTENSION)pDevObj->DeviceExtension;
pDevExt->pDevice=pDevObj;
pDevExt->ustrDeviceName=szDevName;
//创建符号链接
UNICODE_STRING symLinkName;
RtlInitUnicodeString(&symLinkName,L"\\??\\InstFilters");
pDevExt->ustrSymLinkName=symLinkName;
//创建符号链接
status=IoCreateSymbolicLink(&symLinkName,&szDevName);
if(!NT_SUCCESS(status))
{
DbgPrint("IoCreateSymbolicLink UnOK");
IoDeleteDevice(pDevObj);
return status;
}
else
DbgPrint("IoCreateSymbolicLink OK");
return STATUS_SUCCESS;
}
开发者ID:wkliuwang,项目名称:U_driver,代码行数:53,代码来源:InstFilters.cpp
示例17: DriverEntry
NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT driverObject, PUNICODE_STRING registryPath) {
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
DbgPrint("Load\n");
driverObject->DriverUnload = my_unload;
status = IoCreateDevice(driverObject,
sizeof(device_extension_t),
NULL, // Filter driver: device has no name
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&deviceObject);
if (status != STATUS_SUCCESS) {
DbgPrint("Cannot create device\n");
goto cleanup;
}
for (int i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {
// Filter driver: ignore function instead of unsupported
driverObject->MajorFunction[i] = my_ignored_function;
}
driverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = my_ioctl;
device_extension_t* device_extension = (device_extension_t*) deviceObject->DeviceExtension;
UNICODE_STRING deviceToFilter;
RtlInitUnicodeString(&deviceToFilter, DEVICE_PATH);
// Attach the filter device in the device stack
status = IoAttachDevice(deviceObject, &deviceToFilter, &device_extension->next);
if (status != STATUS_SUCCESS) {
DbgPrint("Cannot attach device\n");
goto cleanup;
}
PDEVICE_OBJECT filteredDevice = device_extension->next;
// These flags are used only for ReadFile and WriteFile.
deviceObject->Flags |= filteredDevice->Flags & (DO_BUFFERED_IO | DO_DIRECT_IO);
deviceObject->DeviceType = filteredDevice->DeviceType;
deviceObject->Characteristics = filteredDevice->Characteristics;
deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
cleanup:
if (status != STATUS_SUCCESS) {
if (deviceObject) {
IoDeleteDevice(deviceObject);
}
}
return status;
}
开发者ID:ChibiTomo,项目名称:sandbox,代码行数:52,代码来源:filter.c
示例18: DriverEntry
NTSTATUS DriverEntry(
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath
)
{
NTSTATUS status;
UNICODE_STRING deviceName;
PDEVICE_OBJECT deviceObject;
PAGED_CODE();
KphDriverObject = DriverObject;
if (!NT_SUCCESS(status = KphDynamicDataInitialization()))
return status;
KphDynamicImport();
if (!NT_SUCCESS(status = KphpReadDriverParameters(RegistryPath)))
return status;
// Create the device.
RtlInitUnicodeString(&deviceName, KPH_DEVICE_NAME);
status = IoCreateDevice(
DriverObject,
0,
&deviceName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&deviceObject
);
if (!NT_SUCCESS(status))
return status;
KphDeviceObject = deviceObject;
// Set up I/O.
DriverObject->MajorFunction[IRP_MJ_CREATE] = KphDispatchCreate;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = KphDispatchDeviceControl;
DriverObject->DriverUnload = DriverUnload;
deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
dprintf("Driver loaded\n");
return status;
}
开发者ID:john-peterson,项目名称:processhacker,代码行数:52,代码来源:main.c
示例19: DriverEntry
NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT driverObject, PUNICODE_STRING registryPath) {
NTSTATUS status = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
DbgPrint("Load\n");
driverObject->DriverUnload = my_unload;
UNICODE_STRING deviceName;
RtlInitUnicodeString(&deviceName, DEVICE_PATH);
status = IoCreateDevice(driverObject,
sizeof(device_context_t),
&deviceName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&deviceObject);
if (status != STATUS_SUCCESS) {
DbgPrint("Cannot create device\n");
goto cleanup;
}
// Initialize the context
device_context_t* context = (device_context_t*) deviceObject->DeviceExtension;
KeInitializeMutex(&(context->mutex), 0);
context->stack = NULL;
for (int i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {
driverObject->MajorFunction[i] = my_unsuported_function;
}
driverObject->MajorFunction[IRP_MJ_CREATE] = my_create;
driverObject->MajorFunction[IRP_MJ_CLOSE] = my_close;
driverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = my_ioctl;
deviceObject->Flags |= DO_BUFFERED_IO;
deviceObject->Flags &= (~DO_DEVICE_INITIALIZING);
UNICODE_STRING dosDeviceName;
RtlInitUnicodeString(&dosDeviceName, DOSDEVICE_PATH);
IoCreateSymbolicLink(&dosDeviceName, &deviceName);
cleanup:
if (status != STATUS_SUCCESS) {
if (deviceObject) {
IoDeleteDevice(deviceObject);
}
}
return status;
}
开发者ID:ChibiTomo,项目名称:sandbox,代码行数:51,代码来源:driver.c
示例20: DriverEntry
NTSTATUS DriverEntry(
IN OUT PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
PDEVICE_OBJECT pdoDeviceObj = 0;
NTSTATUS status = STATUS_UNSUCCESSFUL;
pdoGlobalDrvObj = DriverObject;
//首先初始化各种变量
if(EnviromentInitialize(DriverObject) == FALSE)
return status;
// Create the device object.
if(!NT_SUCCESS(status = IoCreateDevice(
DriverObject,
0,
&usDeviceName,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&pdoDeviceObj
)))
{
// Bail out (implicitly forces the driver to unload).
return status;
};
// Now create the respective symbolic link object
if(!NT_SUCCESS(status = IoCreateSymbolicLink(
&usSymlinkName,
&usDeviceName
)))
{
IoDeleteDevice(pdoDeviceObj);
return status;
}
// NOTE: You need not provide your own implementation for any major function that
// you do not want to handle. I have seen code using DDKWizard that left the
// *empty* dispatch routines intact. This is not necessary at all!
DriverObject->MajorFunction[IRP_MJ_CREATE] =
DriverObject->MajorFunction[IRP_MJ_CLOSE] = CRARKSYS_DispatchCreateClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CRARKSYS_DispatchDeviceControl;
DriverObject->DriverUnload = CRARKSYS_DriverUnload;
KdPrint(("CrArkSys DriverLoad.\n"));
return STATUS_SUCCESS;
}
开发者ID:yax571,项目名称:cr-ark,代码行数:51,代码来源:CrArkSys.c
注:本文中的IoCreateDevice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论