ok ill do the reading,
but anyway here is my code for the adddevice routine.
////////////////////////////////////////////////////////////////////
status = IoCreateDevice(DriverObject,
DEVICE_EXTENSION_SIZE,
NULL,
FILE_DEVICE_DISK_FILE_SYSTEM,
0,
FALSE,
&filterDeviceObject);
// Type of buffering to use for the filter(device)
SET_FLAG(filterDeviceObject->Flags, DO_DIRECT_IO);
// Device Extension(generally a global storage for objs,resources,irps etc
deviceExtension = (PDEVICE_EXTENSION) filterDeviceObject->DeviceExtension;
//Fill a block of mem with zeros…ptr and num of zeros to fill
RtlZeroMemory(deviceExtension, DEVICE_EXTENSION_SIZE);
// Attaches the device object to the highest device object in the satck chain and
// return the previously highest device object, which is passed to
// IoCallDriver when pass IRPs down the device stack
deviceExtension->TargetDeviceObject =
IoAttachDeviceToDeviceStack(filterDeviceObject, PhysicalDeviceObject);
// If target device not found(does not exist)
if (deviceExtension->TargetDeviceObject == NULL) {
IoDeleteDevice(filterDeviceObject);
DebugPrint((1, “TstFilterAddDevice: Unable to attach %X to target %X\n”,
filterDeviceObject, PhysicalDeviceObject));
DbgPrint((“Unable to attach to target”));
return STATUS_NO_SUCH_DEVICE;
}
// Otherwise
// Save the filter device object in the device extension
//(storing device obj)
deviceExtension->DeviceObject = filterDeviceObject;
KeInitializeEvent(&deviceExtension->PagingPathCountEvent,
NotificationEvent, TRUE);
//
// default to DO_POWER_PAGABLE
//
SET_FLAG(filterDeviceObject->Flags, DO_POWER_PAGABLE);
////////////////////////////////////////////////////////////////////////////////////////////////////
and this is the code for attaching the filter it is a userlevel program…
///////////////////////////////////////////////////////////////////////////////////////////////////
BOOLEAN
AddUFilterDriver(
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN LPTSTR Filter
)
{
size_t length = 0; // character length
size_t size = 0; // buffer size
LPTSTR buffer = GetUpperFilters( DeviceInfoSet, DeviceInfoData );
ASSERT(DeviceInfoData != NULL);
ASSERT(Filter != NULL);
if( buffer == NULL )
{
// if there is no such value in the registry, then there are no upper
// filter drivers loaded, and we can just put one there
// make room for the string, string null terminator, and multisz null
// terminator
length = _tcslen(Filter)+2;
size = length*sizeof(_TCHAR);
buffer = malloc( size );
if( buffer == NULL )
{
printf(“in AddUpperFilterDriver(): unable to allocate memory!\n”);
return (FALSE);
}
// copy the string into the new buffer
_tcscpy(buffer, Filter);
// make the buffer a properly formed multisz
buffer[length-1]=_T(‘\0’);
}
else
{
// add the driver to the driver list
PrependSzToMultiSz(Filter, &buffer);
}
length = MultiSzLength(buffer);
size = length*sizeof(_TCHAR);
// set the new list of filters in place
if( !SetupDiSetDeviceRegistryProperty( DeviceInfoSet,
DeviceInfoData,
SPDRP_UPPERFILTERS,
(PBYTE)buffer,
size )
)
{
printf("in AddUpperFilterDriver(): "
“couldn’t set registry value! error: %u\n”, GetLastError());
free( buffer );
return (FALSE);
}
// no need for buffer anymore
free( buffer );
return (TRUE);
}
//////////////////////////////////////////////////////////////////////////////////////////
any response would help
thanks,
sachin
Ladislav Zezula wrote:
Hi
> But even though i get IRP_MJ_CREATE, i do not get
> filename. IrpSp->FileName is a 0 length string.
This means that you’ve receive a volume open
(at last in FS filter, I don’t know what you are attached to).
> how do i properly attach to the file system?
> do i need to send my code?
No offence, but I think you should study some literature
first before you will start programming. Read the docs about
IoAttachDeviceToDeviceStack, IoRegisterFsRegistrationChange,
IRP_MJ_MOUNT_VOLUME, IRP_MJ_PNP, FastIoDetachDevice
etc.
L.
—
Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@yahoo.co.in
To unsubscribe send a blank email to xxxxx@lists.osr.com
Yahoo! India Matrimony: Find your partner online.