FLT_CREATEFILE_TARGET_ECP_CONTEXT 구조체(fltkernel.h)
FLT_CREATEFILE_TARGET_ECP_CONTEXT 구조체는 재구매 대상 정보를 FltCreateFileEx2호출자에게 반환하는 데 사용되는 ECP(추가 만들기 매개 변수)입니다.
통사론
typedef struct _FLT_CREATEFILE_TARGET_ECP_CONTEXT {
PFLT_INSTANCE Instance;
PFLT_VOLUME Volume;
PFLT_FILE_NAME_INFORMATION FileNameInformation;
FLT_CREATEFILE_TARGET_FLAGS Flags;
} FLT_CREATEFILE_TARGET_ECP_CONTEXT, *PFLT_CREATEFILE_TARGET_ECP_CONTEXT;
회원
Instance
조정된 대상에 연결된 필터 인스턴스입니다.
Volume
조정된 대상 볼륨입니다.
FileNameInformation
조정된 대상에 대한 파일 정보입니다.
Flags
재 분석 작업을 제어하는 플래그입니다. 이 값은 0 또는 다음 중 하나일 수 있습니다.
값 | 의미 |
---|---|
|
원래 파일 정보와 함께 대상을 찾을 수 없는 경우 FltCreateFileEx2 재문 분석 작업을 시도해도 되도록 요청합니다. |
발언
FltCreateFileEx2 호출자가 볼륨 대상에 대한 재구매를 사용하도록 설정하려는 경우 FLT_CREATEFILE_TARGET_ECP_CONTEXTDriverContext 매개 변수의 ECP 목록에 대한 ECP로 포함될 수 있습니다. 이 ECP가 있는 경우 FltCreateFileEx2 만들기 작업에 대한 대상 디바이스를 조정하고 지정된 파일 정보에 적합한 볼륨의 필터링된 인스턴스를 찾으려고 시도합니다. 필터 관리자가 대상 볼륨에서 호출자에 대한 해당 인스턴스를 찾지 못하면 볼륨 설정되고 새 대상에 대한 FLT_CREATEFILE_TARGET_ECP_CONTEXT 멤버의 FileNameInformation 멤버를. 그런 다음 호출자는 이 정보를 사용하여 진행하는 최선의 방법을 결정할 수 있습니다.
FltCreateFileEx2 호출자가 재구매 작업 자체를 처리하려는 경우 Flags 멤버에서 FLTTCFL_AUTO_REPARSE 플래그가 지워집니다. 이 경우 FltCreateFileEx2 초기 대상 조정 정보를 ECP에 배치한 다음 반환하여 파일 만들기 시도를 종료합니다.
인스턴스, 볼륨또는 FileNameInformation 값이 승인된 ECP에 설정된 경우 참조되는 개체입니다. FltCreateFileEx2 호출자는 인스턴스 및 볼륨대한 FltObjectDereference 호출하고 FileNameInformation대해 FltReleaseFileNameNameInformation 호출합니다.
다음 예제 루틴은 파일 대상을 찾는 데 필요한 경우 미니 필터가 FLT_CREATEFILE_TARGET_ECP_CONTEXTFltCreateFileEx2 호출하여 다른 볼륨에 대한 재처리를 처리하는 방법을 보여 줍니다.
NTSTATUS
CrossVolumeCreate(
_In_ PUNICODE_STRING FileName,
_In_ PFLT_FILTER Filter,
_In_ PFLT_INSTANCE Instance,
_Inout_ PIO_STATUS_BLOCK IoStatus,
_Out_ PHANDLE Handle,
_Outptr_ PFILE_OBJECT *FileObject
)
/*++
Routine Description:
Issues a targeted create and handles cross volume reparse.
Arguments:
FileName - The name of the file to open
Filter – The filter issuing the create
Instance - The filter instance for the targeted create
IoStatus - Receives the operation status
Handle - Receives the file handle
FileObject - Receives the file object
Return Value:
status of the operation
--*/
{
PFLT_CREATEFILE_TARGET_ECP_CONTEXT ecpContext;
PECP_LIST ecpList;
PFLT_FILE_NAME_INFORMATION fileNameInformation;
IO_DRIVER_CREATE_CONTEXT myCreateContext;
OBJECT_ATTRIBUTES objAttr;
NTSTATUS status;
ecpContext = NULL;
ecpList = NULL;
fileNameInformation = NULL;
status = STATUS_SUCCESS;
InitializeObjectAttributes( &objAttr,
FileName,
OBJ_KERNEL_HANDLE,
NULL,
NULL );
//
// First we optimistically send a targeted create that is not
// setup to handle cross-volume reparse.
//
status = FltCreateFileEx2( Filter,
Instance,
Handle,
FileObject,
FILE_READ_DATA|FILE_WRITE_DATA,
&objAttr,
IoStatus,
NULL,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0,
IO_IGNORE_SHARE_ACCESS_CHECK,
NULL );
if (!NT_SUCCESS(status)) {
if ((status != STATUS_INVALID_DEVICE_OBJECT_PARAMETER) &&
(status != STATUS_MOUNT_POINT_NOT_RESOLVED)) {
goto CrossVolumeCreateExit;
}
} else {
//
// The create succeeded. There must not have been a cross-volume
// reparse.
//
goto CrossVolumeCreateExit;
}
//
// The create failed traversing a cross-volume link.
// Issue another create with a targeting ECP so that
// we can handle cross-volume reparse.
//
status = FltAllocateExtraCreateParameterList( Filter,
0,
&ecpList );
if (!NT_SUCCESS( status )) {
goto CrossVolumeCreateExit;
}
status = FltAllocateExtraCreateParameter( Filter,
&GUID_ECP_FLT_CREATEFILE_TARGET,
sizeof(FLT_CREATEFILE_TARGET_ECP_CONTEXT),
0,
NULL,
POOL_TAG,
&ecpContext );
if (!NT_SUCCESS( status )) {
goto CrossVolumeCreateExit;
}
//
// Initialize the ECP with the FLTTCFL_AUTO_REPARSE flag which
// tells filter manager to handle the cross-volume reparse
// internally when possible (when it can find our instance
// on the target volume). If this flag is not set, the filter will
// be responsible for calling FltCreateFileEx2 with appropriate
// Instance parameter.
//
ecpContext->Flags = FLTTCFL_AUTO_REPARSE;
ecpContext->Instance = NULL;
ecpContext->Volume = NULL;
ecpContext->FileNameInformation = NULL;
status = FltInsertExtraCreateParameter( Filter,
ecpList,
ecpContext );
if (!NT_SUCCESS( status )) {
goto CrossVolumeCreateExit;
}
IoInitializeDriverCreateContext( &myCreateContext );
myCreateContext.ExtraCreateParameter = ecpList;
InitializeObjectAttributes( &objAttr,
FileName,
OBJ_KERNEL_HANDLE,
NULL,
NULL );
status = FltCreateFileEx2( Filter,
Instance,
Handle,
FileObject,
FILE_READ_DATA|FILE_WRITE_DATA,
&objAttr,
IoStatus,
NULL,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0,
IO_IGNORE_SHARE_ACCESS_CHECK,
&myCreateContext );
if (!NT_SUCCESS(status)) {
if ((status != STATUS_INVALID_DEVICE_OBJECT_PARAMETER) &&
(status != STATUS_MOUNT_POINT_NOT_RESOLVED)) {
goto CrossVolumeCreateExit;
}
} else {
goto CrossVolumeCreateExit;
}
//
// Filter manager should have acknowledged the ECP. If it
// is not acknowledged, it does not contain any cross-volume
// targeting information.
//
if (!FltIsEcpAcknowledged( Filter, ecpContext)) {
goto CrossVolumeCreateExit;
}
//
// Filter manager could not automatically handle the
// cross-volume traversal. We choose to send the create
// to the top of the stack on the target volume indicated
// in the targeting ECP.
//
//
// The ECP may contain pointers to referenced objects. We
// need to deal with those references before reusing the
// ECP.
//
if (ecpContext->Volume != NULL) {
FltObjectDereference( ecpContext->Volume );
ecpContext->Volume = NULL;
}
//
// Note: since we flagged the ECP to automatically handle
// cross-volume reparse, the create should have failed after
// we traversed a mountpoint only if our filter did not have
// an instance on the target volume. In that case we would
// expect the Instance field in the ECP to be NULL. We still
// demonstrate derefing the instance for the general case.
//
if (ecpContext->Instance != NULL) {
FltObjectDereference( ecpContext->Instance );
ecpContext->Instance = NULL;
}
fileNameInformation = ecpContext->FileNameInformation;
ecpContext->FileNameInformation = NULL;
//
// Tell filter manager to not handle the cross-volume
// reparse itself. Presumably a filter would do this if it
// did not want the create automatically targeted at its
// instance on another volume.
//
ecpContext->Flags = 0;
//
// Reinitialize the targeting ECP to it can be reused.
//
FltPrepareToReuseEcp( Filter, ecpContext );
IoInitializeDriverCreateContext( &myCreateContext );
myCreateContext.ExtraCreateParameter = ecpList;
InitializeObjectAttributes( &objAttr,
&fileNameInformation->Name,
OBJ_KERNEL_HANDLE,
NULL,
NULL );
status = FltCreateFileEx2( Filter,
NULL,
Handle,
FileObject,
FILE_READ_DATA|FILE_WRITE_DATA,
&objAttr,
IoStatus,
NULL,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN_IF,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0,
IO_IGNORE_SHARE_ACCESS_CHECK,
&myCreateContext );
if (!NT_SUCCESS(status)) {
if ((status != STATUS_INVALID_DEVICE_OBJECT_PARAMETER) &&
(status != STATUS_MOUNT_POINT_NOT_RESOLVED)) {
goto CrossVolumeCreateExit;
}
//
// We hit another cross-volume link. For the purposes of
// this example we are just giving up. An actual filter
// would determine the next target instance based on the
// information provided in the targeting ECP. Some of the
// possibilities are:
// 1) If the Instance field in the ECP is available, target
// the create to this instance.
// 2) If the Instance field is NULL, attempt to attach
// an instance based on the Volume parameter in the ECP
// and then target that new instance.
// 3) Use the FileNameInformation provided in the ECP and a
// NULL instance to target the top of the other
// volume's stack.
//
} else {
goto CrossVolumeCreateExit;
}
CrossVolumeCreateExit:
if (ecpContext != NULL &&
FltIsEcpAcknowledged( Filter, ecpContext)) {
FltRemoveExtraCreateParameter( Filter,
ecpList,
&GUID_ECP_FLT_CREATEFILE_TARGET,
&ecpContext,
NULL );
if (ecpContext->Instance != NULL) {
FltObjectDereference( ecpContext->Instance );
}
if (ecpContext->Volume != NULL) {
FltObjectDereference( ecpContext->Volume );
}
if (ecpContext->FileNameInformation != NULL) {
FltReleaseFileNameInformation( ecpContext->FileNameInformation );
}
FltFreeExtraCreateParameter( Filter, ecpContext );
}
if (ecpList != NULL) {
FltFreeExtraCreateParameterList( Filter, ecpList );
}
if (fileNameInformation != NULL) {
FltReleaseFileNameInformation( fileNameInformation );
}
return status;
}
요구 사항
요구 | 값 |
---|---|
지원되는 최소 클라이언트 | 이 구조는 Windows 8부터 사용할 수 있습니다. |
헤더 | fltkernel.h(FltKernel.h 포함) |