How to send a DeviceIoControl IRP to underlying NTFS file system?

My file system filter driver wants to delete a file’s reparse point
attribute by building a DeviceIoControl IRP with FSCTL_DELETE_REPARSE_POINT
control code.
Here is a piece of the code.

=======================================
Irp = IoBuildDeviceIoControlRequest(FSCTL_DELETE_REPARSE_POINT,
UnderlyDeviceObject,
ReparseBuffer,
REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
NULL, 0,
FALSE, &Event, &iosb);
if (Irp == NULL)
return STATUS_INSUFFICIENT_RESOURCES;

// Set the stack location
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->FileObject = FileObject;

// Send the request to the lower layer driver.
Status = IoCallDriver(UnderlyDeviceObject, Irp);

=======================================

The returned status of IoCallDriver is always 0xC000000D
(STATUS_INVALID_PARAMETER).
Please give me any hint about what is wrong with this code.

Thanks,

Shangwu

FSCTL_DELETE_REPARSE_POINT is not an IOCTL but file system control request.
You need to replace major function in next stack location with
IRP_MJ_FILE_SYSTEM_CONTROL and set minor function to IRP_MN_USER_FS_REQUEST.

Alexei.

“Shangwu” wrote in message news:xxxxx@ntfsd…
> My file system filter driver wants to delete a file’s reparse point
> attribute by building a DeviceIoControl IRP with
FSCTL_DELETE_REPARSE_POINT
> control code.
> Here is a piece of the code.
>
> =======================================
> Irp = IoBuildDeviceIoControlRequest(FSCTL_DELETE_REPARSE_POINT,
> UnderlyDeviceObject,
> ReparseBuffer,
> REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
> NULL, 0,
> FALSE, &Event, &iosb);
> if (Irp == NULL)
> return STATUS_INSUFFICIENT_RESOURCES;
>
> // Set the stack location
> IrpSp = IoGetNextIrpStackLocation(Irp);
> IrpSp->FileObject = FileObject;
>
> // Send the request to the lower layer driver.
> Status = IoCallDriver(UnderlyDeviceObject, Irp);
>
> =======================================
>
> The returned status of IoCallDriver is always 0xC000000D
> (STATUS_INVALID_PARAMETER).
> Please give me any hint about what is wrong with this code.
>
> Thanks,
>
> Shangwu
>
>
>

Alexei,

Thank you for the information. But it is still not working although the
major and minor function codes are changed.

Regards,

Shangwu

“Alexei Jelvis” wrote in message news:xxxxx@ntfsd…
> FSCTL_DELETE_REPARSE_POINT is not an IOCTL but file system control
request.
> You need to replace major function in next stack location with
> IRP_MJ_FILE_SYSTEM_CONTROL and set minor function to
IRP_MN_USER_FS_REQUEST.
>
> Alexei.
>
> “Shangwu” wrote in message news:xxxxx@ntfsd…
> > My file system filter driver wants to delete a file’s reparse point
> > attribute by building a DeviceIoControl IRP with
> FSCTL_DELETE_REPARSE_POINT
> > control code.
> > Here is a piece of the code.
> >
> > =======================================
> > Irp = IoBuildDeviceIoControlRequest(FSCTL_DELETE_REPARSE_POINT,
> > UnderlyDeviceObject,
> > ReparseBuffer,
> > REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
> > NULL, 0,
> > FALSE, &Event, &iosb);
> > if (Irp == NULL)
> > return STATUS_INSUFFICIENT_RESOURCES;
> >
> > // Set the stack location
> > IrpSp = IoGetNextIrpStackLocation(Irp);
> > IrpSp->FileObject = FileObject;
> >
> > // Send the request to the lower layer driver.
> > Status = IoCallDriver(UnderlyDeviceObject, Irp);
> >
> > =======================================
> >
> > The returned status of IoCallDriver is always 0xC000000D
> > (STATUS_INVALID_PARAMETER).
> > Please give me any hint about what is wrong with this code.
> >
> > Thanks,
> >
> > Shangwu
> >
> >
> >
>
>
>

I would suggest to check how you initialize ReparseBuffer. It should contain
actual tag and GUID of reparse point you are trying to delete and have
ReparseDataLenth == 0.

Alexei.

“Shangwu” wrote in message news:xxxxx@ntfsd…
> Alexei,
>
> Thank you for the information. But it is still not working although the
> major and minor function codes are changed.
>
> Regards,
>
> Shangwu
>
> “Alexei Jelvis” wrote in message
news:xxxxx@ntfsd…
> > FSCTL_DELETE_REPARSE_POINT is not an IOCTL but file system control
> request.
> > You need to replace major function in next stack location with
> > IRP_MJ_FILE_SYSTEM_CONTROL and set minor function to
> IRP_MN_USER_FS_REQUEST.
> >
> > Alexei.
> >
> > “Shangwu” wrote in message news:xxxxx@ntfsd…
> > > My file system filter driver wants to delete a file’s reparse point
> > > attribute by building a DeviceIoControl IRP with
> > FSCTL_DELETE_REPARSE_POINT
> > > control code.
> > > Here is a piece of the code.
> > >
> > > =======================================
> > > Irp = IoBuildDeviceIoControlRequest(FSCTL_DELETE_REPARSE_POINT,
> > > UnderlyDeviceObject,
> > > ReparseBuffer,
> > > REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
> > > NULL, 0,
> > > FALSE, &Event, &iosb);
> > > if (Irp == NULL)
> > > return STATUS_INSUFFICIENT_RESOURCES;
> > >
> > > // Set the stack location
> > > IrpSp = IoGetNextIrpStackLocation(Irp);
> > > IrpSp->FileObject = FileObject;
> > >
> > > // Send the request to the lower layer driver.
> > > Status = IoCallDriver(UnderlyDeviceObject, Irp);
> > >
> > > =======================================
> > >
> > > The returned status of IoCallDriver is always 0xC000000D
> > > (STATUS_INVALID_PARAMETER).
> > > Please give me any hint about what is wrong with this code.
> > >
> > > Thanks,
> > >
> > > Shangwu
> > >
> > >
> > >
> >
> >
> >
>
>
>

Yes, that is exactly what I do. The underlying driver still returns the same
error status.

Thanks,

Shangwu

“Alexei Jelvis” wrote in message news:xxxxx@ntfsd…
> I would suggest to check how you initialize ReparseBuffer. It should
contain
> actual tag and GUID of reparse point you are trying to delete and have
> ReparseDataLenth == 0.
>
> Alexei.
>
> “Shangwu” wrote in message news:xxxxx@ntfsd…
> > Alexei,
> >
> > Thank you for the information. But it is still not working although the
> > major and minor function codes are changed.
> >
> > Regards,
> >
> > Shangwu
> >
> > “Alexei Jelvis” wrote in message
> news:xxxxx@ntfsd…
> > > FSCTL_DELETE_REPARSE_POINT is not an IOCTL but file system control
> > request.
> > > You need to replace major function in next stack location with
> > > IRP_MJ_FILE_SYSTEM_CONTROL and set minor function to
> > IRP_MN_USER_FS_REQUEST.
> > >
> > > Alexei.
> > >
> > > “Shangwu” wrote in message news:xxxxx@ntfsd…
> > > > My file system filter driver wants to delete a file’s reparse point
> > > > attribute by building a DeviceIoControl IRP with
> > > FSCTL_DELETE_REPARSE_POINT
> > > > control code.
> > > > Here is a piece of the code.
> > > >
> > > > =======================================
> > > > Irp = IoBuildDeviceIoControlRequest(FSCTL_DELETE_REPARSE_POINT,
> > > > UnderlyDeviceObject,
> > > > ReparseBuffer,
> > > > REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
> > > > NULL, 0,
> > > > FALSE, &Event, &iosb);
> > > > if (Irp == NULL)
> > > > return STATUS_INSUFFICIENT_RESOURCES;
> > > >
> > > > // Set the stack location
> > > > IrpSp = IoGetNextIrpStackLocation(Irp);
> > > > IrpSp->FileObject = FileObject;
> > > >
> > > > // Send the request to the lower layer driver.
> > > > Status = IoCallDriver(UnderlyDeviceObject, Irp);
> > > >
> > > > =======================================
> > > >
> > > > The returned status of IoCallDriver is always 0xC000000D
> > > > (STATUS_INVALID_PARAMETER).
> > > > Please give me any hint about what is wrong with this code.
> > > >
> > > > Thanks,
> > > >
> > > > Shangwu
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
>
>
>