Thank you Guys for your responses!
I do understand that writing a mini filter is much better than this legacy one. However, we may not be able to afford writing a mini filter from scratch. So we better would like to continue with the legacy one for the time being.
This is how we are calling in our driver as well. However, the IOCallDriver returns invalid parameter for shared files in Windows 8/server 2012. We would like to know the answer for this.
It would be great , if anyone can let me the reason behind that. The same code is working fine in Windows 7 for IRP_MJ_SETINFORMATION.
// initialize the synchronization event
KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
// allocate the irp to pass to the next driver
pIrp = IoAllocateIrp(pDeviceObject->StackSize, FALSE);
// build the irp
pIrp->AssociatedIrp.SystemBuffer = pInformation;
pIrp->UserEvent = &Event;
pIrp->UserIosb = &IoSb;
pIrp->Tail.Overlay.Thread = PsGetCurrentThread();
pIrp->Tail.Overlay.OriginalFileObject = pFileObject;
pIrp->RequestorMode = KernelMode;
pIrp->Flags = 0;
// get the next stack location and build it
pIrpStack = IoGetNextIrpStackLocation(pIrp);
pIrpStack->MajorFunction = IRP_MJ_QUERY_INFORMATION;
pIrpStack->DeviceObject = pDeviceObject;
pIrpStack->FileObject = pFileObject;
pIrpStack->Parameters.QueryFile.Length = sizeof(FILE_NETWORK_OPEN_INFORMATION);
pIrpStack->Parameters.QueryFile.FileInformationClass = FileNetworkOpenInformation;
// set the completion routine and call the next driver
// wait for the synchronization event to be set before
// proceeding to implement synchronous behaviour
IoSetCompletionRoutine(pIrp, IrpCompletion, 0, TRUE, TRUE, TRUE);
IoCallDriver(pDeviceObject, pIrp);
KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0);