CBFilter Class

Properties   Methods   Events   Config Settings   Errors  

The CBFilter class allows applications to intercept and control filesystem requests.

Syntax

class cbfsfilter.CBFilter

Remarks

The CBFilter class gives applications the ability to intercept filesystem requests, allowing them to be altered, handled, or blocked. Applications use standard filter rules to specify which requests they are interested in intercepting; and special filter rules to enforce access restrictions and redirect requests to different files.

To learn more about the class's capabilities, please refer to the product's General Information topics.

Getting Started

  1. If the class's system driver has not been installed yet, call the install method to do so. This needs to be done only once.
    • In production, the driver can be installed (or updated) ahead of time with the application's installation script using the Installer DLL. Please refer to the Driver Installation topic for more information.
  2. Call the initialize method to initialize the CBFilter class. This must be done each time the application starts.
  3. Add one or more filter rules using methods like add_filter_rule. (Rules can also be added or removed after the filter is started.)
  4. Call the start_filter method to start filtering filesystem requests.
  5. When finished, call the stop_filter method to stop filtering filesystem requests.
  6. To uninstall the class's system driver, call the uninstall method. This should not be done as part of the driver upgrade process.
    • In production, the driver can be uninstalled by the application's uninstallation script using the Installer DLL. Please refer to the Driver Installation topic for more information.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

activeThis property notes whether the class is active and processing requests.
altitudeThis property specifies the altitude the class's system driver should use .
default_rule_countThe number of records in the DefaultRule arrays.
default_rule_access_flagsThis property indicates the access restrictions enforced by the rule.
default_rule_maskThis property indicates a file mask that determines which files and directories match the rule.
file_flushing_behaviorThis property specifies the file flushing and closing behavior that the class's system driver should enforce.
filter_rule_countThe number of records in the FilterRule arrays.
filter_rule_access_flagsThis property indicates the access restrictions enforced by the rule (CBFilter only).
filter_rule_control_flagsThis property indicates which control events the rule causes the class to fire (CBFilter only).
filter_rule_ea_nameThis property indicates the name of an extended attribute that a file or directory must have to match the rule.
filter_rule_excluded_attributesThis property indicates the file attributes that a file or directory must not have to match the rule.
filter_rule_included_attributesThis property indicates the file attributes that a file or directory must have to match the rule.
filter_rule_maskThis property indicates a file mask that determines which files and directories match the rule.
filter_rule_max_sizeThis property indicates the maximum size a file can be to match the rule.
filter_rule_min_sizeThis property indicates the minimum size a file can be to match the rule.
filter_rule_notify_flagsThis property indicates which notification events the rule causes the class to fire.
fire_volume_eventsThis property specifies the events that should be fired when a filesystem volume is mounted to or unmounted from the system.
passthrough_rule_countThe number of records in the PassthroughRule arrays.
passthrough_rule_access_flagsThis property specifies the access restrictions lifted by the rule (CBFilter only).
passthrough_rule_control_flagsThis property indicates which control events the rule prevents the class from firing (CBFilter only).
passthrough_rule_ea_nameThis property indicates the name of an extended attribute that a file or directory must have to match the rule.
passthrough_rule_excluded_attributesThis property indicates the file attributes that a file or directory must not have to match the rule.
passthrough_rule_included_attributesThis property indicates the file attributes that a file or directory must have to match the rule.
passthrough_rule_maskThis property indicates a file mask that determines which files and directories match the rule.
passthrough_rule_max_sizeThis property indicates the maximum size a file can be to match the rule.
passthrough_rule_min_sizeThis property indicates the minimum size a file can be to match the rule.
passthrough_rule_notify_flagsThis property indicates which notification events the rule prevents the class from firing.
process_cached_io_requestsThis property specifies whether cached file read/write requests should be processed.
process_failed_requestsThis property specifies whether failed requests should be processed.
reparse_rule_countThe number of records in the ReparseRule arrays.
reparse_rule_maskThis property indicates a file mask that determines which files and directories match the rule.
reparse_rule_reparse_maskThis property contains a file mask that specifies where matching files and directories are redirected to.
serialize_eventsWhether events should be fired on a single worker thread, or many.
tagThis property stores application-defined data specific to a particular instance of the class.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

add_bytes_to_write_bufferThis method reserves extra space in the file data buffers used in file read/write events.
add_default_ruleThis method adds a default rule.
add_filter_ruleThis method adds a standard filter rule or access rule.
add_filter_rule_exThis method adds a standard filter rule or access rule with additional match qualifiers.
add_passthrough_ruleThis method adds a passthrough rule.
add_passthrough_rule_exThis method adds a passthrough rule with additional match qualifiers.
add_reparse_ruleThis method adds a reparse rule.
close_default_rules_snapshotThis method closes the previously created default rules snapshot.
close_reparse_rules_snapshotThis method closes the previously created reparse rules snapshot.
configSets or retrieves a configuration setting.
create_default_rules_snapshotThis method creates a snapshot of information about the default rules that have been added.
create_file_directThis method creates or opens a file or directory by passing the request directly to the filesystem.
create_file_direct_as_streamThis method creates or opens a file by passing the request directly to the filesystem.
create_reparse_rules_snapshotThis method creates a snapshot of information about the reparse rules that have been added.
create_virtual_fileThis method is under construction.
delete_all_filter_rulesThis method deletes all standard filter rules and access rules.
delete_all_passthrough_rulesThis method deletes all passthrough rules.
delete_all_reparse_rulesThis method deletes all reparse rules.
delete_default_ruleThis method deletes a particular default rule.
delete_filter_ruleThis method deletes a particular standard filter rule or access rule.
delete_passthrough_ruleThis method deletes a particular passthrough rule.
delete_reparse_ruleThis method deletes a particular reparse rule.
file_matches_maskThis method checks whether a particular file or directory name matches the specified mask.
get_driver_statusThis method retrieves the status of the class's system driver.
get_driver_versionThis method retrieves the version of the class's system driver.
get_event_filenameThis method retrieves the name of the file or directory, to which the event applies.
get_handle_creator_process_idThis method retrieves the Id of the process (PID) that opened the file handle.
get_handle_creator_process_nameThis method retrieves the name of the process that opened the file handle.
get_handle_creator_thread_idThis method retrieves the Id of the thread that opened the file handle.
get_handle_creator_tokenThis method retrieves the security token associated with the process that opened the file handle.
get_operation_timeThis method returns the time at which the request was received by the filter driver.
get_originator_process_idRetrieves the Id of the process (PID) that initiated the operation.
get_originator_process_nameRetrieves the name of the process that initiated the operation.
get_originator_thread_idRetrieves the Id of the thread that initiated the operation.
get_originator_tokenRetrieves the security token associated with the process that initiated the operation.
get_remote_access_informationThis method returns networking-related information about the operation.
get_reparse_rule_by_maskThis method retrieves the reparse rule associated with the specified file mask.
get_volume_guidThis method retrieves the volume GUID of the device targeted by a filesystem operation.
initializeThis method initializes the class.
installThis method installs (or upgrades) the class's system driver.
is_file_filteredThis method checks whether a particular file or directory is covered by any filter rules.
nt_status_to_win_32_errorThis method converts a native status code to a Win32 error code.
reset_timeoutThis method resets the timeout duration for the current event handler.
set_file_information_directThis method sets the file information of a file opened using CreateFileDirect.
set_file_size_directThis method resizes a file by passing the request directly to the filesystem.
shutdown_systemShuts down or reboots the operating system.
start_filterThis method starts filtering filesystem operations.
stop_filterThis method stops filtering filesystem operations.
suspend_default_rulesThis method suspends all default rules until the application exits.
suspend_file_eventsThis method suspends all events for a particular file or directory until all of its handles have been closed.
toggle_process_protectionThis method enables or disables termination protection for the application.
uninstallThis method uninstalls the class's system driver.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_after_can_file_be_deletedThis event fires after the OS marks a file or directory for deletion or removes such a mark.
on_after_cleanup_fileThis event fires after a file or directory handle is closed.
on_after_close_enumerationThis event fires after a directory enumeration operation finishes.
on_after_close_fileThis event fires after a file or directory is closed.
on_after_create_fileThis event fires after a file or directory is created.
on_after_create_hard_linkThis event fires after a hard link is created.
on_after_delete_fileThis event fires after a file or directory is deleted.
on_after_delete_reparse_pointThis event fires after the OS deletes a reparse point from a file or directory.
on_after_enumerate_directoryThis event fires after a directory entry is returned during directory enumeration.
on_after_filter_attach_to_volumeThis event fires after the filter attaches to a newly mounted filesystem volume.
on_after_filter_detach_from_volumeThis event fires after the filter detaches from a filesystem volume.
on_after_fsctlThis event fires after an IRP_MJ_FILE_SYSTEM_CONTROL request is processed.
on_after_get_file_securityThis event fires after a file or directory's security attributes are retrieved.
on_after_get_file_sizesThis event fires after a file's size information is retrieved.
on_after_get_reparse_pointThis event fires after a file or directory's reparse point information is retrieved.
on_after_ioctlThis event fires after an IRP_MJ_DEVICE_CONTROL request is processed.
on_after_lockThis event fires after a range of bytes in a file is locked.
on_after_open_fileThis event fires after a file or directory is opened.
on_after_query_eaThis event fires after information about extended attributes of a file is retrieved.
on_after_query_file_infoThis event fires after information about a file or directory is retrieved.
on_after_read_fileThis event fires after data are read from a file.
on_after_rename_or_move_fileThis event fires after a file or directory is renamed or moved.
on_after_set_allocation_sizeThis event fires after a file's allocation size is changed.
on_after_set_eaThis event fires after extended attributes of a file are changed.
on_after_set_file_attributesThis event fires after a file or directory's attributes or times are changed.
on_after_set_file_infoThis event fires after information about a file or directory is changed.
on_after_set_file_securityThis event fires after a file or directory's security attributes are changed.
on_after_set_file_sizeThis event fires after a file is resized.
on_after_set_reparse_pointThis event fires after the OS creates or updates a reparse point on a file or directory.
on_after_unlock_allThis event fires after all locked byte ranges in a file are unlocked.
on_after_unlock_all_by_keyThis event fires after all locked byte ranges in a file, associated with a particular key, are unlocked.
on_after_unlock_singleThis event fires after a particular locked byte range in a file is unlocked.
on_after_write_fileThis event fires after data are written to a file.
on_before_can_file_be_deletedThis event fires before the OS attempts to mark a file or directory for deletion or remove such a mark.
on_before_cleanup_fileThis event fires before a file or directory handle is closed.
on_before_close_fileThis event fires before a file or directory is closed.
on_before_create_fileThis event fires before a file or directory is created.
on_before_create_hard_linkThis event fires before a hard link is created.
on_before_delete_fileThis event fires before a file or directory is deleted.
on_before_delete_reparse_pointThis event fires when the OS wants to delete a reparse point from a file or directory.
on_before_enumerate_directoryThis event fires when an enumeration request is sent by the OS.
on_before_filter_attach_to_volumeThis event fires before the filter attaches to a newly mounted filesystem volume.
on_before_fsctlThis event fires before an IRP_MJ_FILE_SYSTEM_CONTROL request is processed.
on_before_get_file_securityThis event fires before a file or directory's security attributes are retrieved.
on_before_get_reparse_pointThis event fires when the OS wants to read a reparse point for a file or directory.
on_before_ioctlThis event fires before an IRP_MJ_DEVICE_CONTROL request is processed.
on_before_lockThis event fires before a range of bytes in a file is locked.
on_before_open_fileThis event fires before a file or directory is opened.
on_before_query_eaThis event fires before information about extended attributes of a file is retrieved.
on_before_query_file_infoThis event fires before information about a file or directory is retrieved.
on_before_read_fileThis event fires before data are read from a file.
on_before_rename_or_move_fileThis event fires before a file or directory is renamed or moved.
on_before_set_allocation_sizeThis event fires before a file's allocation size is changed.
on_before_set_eaThis event fires before extended attributes of a file are changed.
on_before_set_file_attributesThis event fires before a file or directory's attributes or times are changed.
on_before_set_file_infoThis event fires before information about a file or directory is changed.
on_before_set_file_securityThis event fires before a file or directory's security attributes are changed.
on_before_set_file_sizeThis event fires before a file is resized.
on_before_set_reparse_pointThis event fires when the OS wants to create or update a reparse point on a file or directory.
on_before_unlock_allThis event fires before all locked byte ranges in a file are unlocked.
on_before_unlock_all_by_keyThis event fires before all locked byte ranges in a file, associated with a particular key, are unlocked.
on_before_unlock_singleThis event fires before a particular locked byte range in a file is unlocked.
on_before_write_fileThis event fires before data are written to a file.
on_cleanup_contextThis event fires when the application-defined data stored in one or more contexts need to be cleaned up.
on_errorThis event fires if an unhandled error occurs during an event.
on_filter_startThis event fires once the filter has attached and filtering has started.
on_filter_stopThis event fires once filtering has stopped and the filter has detached.
on_notify_can_file_be_deletedThis event fires when the OS marks a file or directory for deletion or removes such a mark.
on_notify_cleanup_fileThis event fires when a file or directory handle has been closed.
on_notify_close_fileThis event fires when a file or directory has been closed.
on_notify_create_fileThis event fires when a file or directory has been created.
on_notify_create_hard_linkThis event fires when a hard link has been created.
on_notify_delete_fileThis event fires when a file or directory has been deleted.
on_notify_delete_reparse_pointThis event fires when a file or directory's reparse point has been deleted.
on_notify_enumerate_directoryThis event fires when a directory entry has been returned during directory enumeration.
on_notify_filter_attach_to_volumeThis event fires when the filter has been attached to a newly mounted filesystem volume.
on_notify_filter_detach_from_volumeThis event fires when the filter has been detached from a filesystem volume.
on_notify_fsctlThis event fires when an IRP_MJ_FILE_SYSTEM_CONTROL operation has occurred.
on_notify_get_file_securityThis event fires when a file or directory's security attributes have been retrieved.
on_notify_get_file_sizesThis event fires when a file's size information has been retrieved.
on_notify_get_reparse_pointThis event fires when a file or directory's reparse point information has been retrieved.
on_notify_ioctlThis event fires when an IRP_MJ_DEVICE_CONTROL operation has occurred.
on_notify_lockThis event fires when a range of bytes in a file has been locked.
on_notify_open_fileThis event fires when a file or directory has been opened.
on_notify_query_eaThis event fires when information about the extended attributes of a file has been retrieved.
on_notify_query_file_infoThis event fires when information about a file or directory has been retrieved.
on_notify_read_fileThis event fires when data have been read from a file.
on_notify_rename_or_move_fileThis event fires when a file or directory has been renamed or moved.
on_notify_set_allocation_sizeThis event fires when a file's allocation size has been changed.
on_notify_set_eaThis event fires when information about the extended attributes of a file has been changed.
on_notify_set_file_attributesThis event fires when a file or directory's attributes or times have been changed.
on_notify_set_file_infoThis event fires when information about a file or directory has been changed.
on_notify_set_file_securityThis event fires when a file or directory's security attributes have been changed.
on_notify_set_file_sizeThis event fires when a file has been resized.
on_notify_set_reparse_pointThis event fires when a file or directory's reparse point has been created or updated.
on_notify_unlock_allThis event fires when all locked byte ranges in a file have been unlocked.
on_notify_unlock_all_by_keyThis event fires when all locked byte ranges in a file, associated with a particular key, have been unlocked.
on_notify_unlock_singleThis event fires when a particular locked byte range in a file has been unlocked.
on_notify_write_fileThis event fires when data have been written to a file.
on_reparse_file_nameThis event fires to allow file access to be dynamically redirected to another location.
on_reparse_with_tagThis event fires if an open operation returns STATUS_REPARSE so that the application can respond to the reparse point.
on_worker_thread_creationFires just after a new worker thread is created.
on_worker_thread_terminationFires just before a worker thread is terminated.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

AllowFileAccessInBeforeOpenWhether file access, via the CreateFileDirect method, is allowed in during the BeforeCreateFile and BeforeOpenFile events.
AlwaysPrepareFilesWhether the driver should keep track of information for files that are already open when (i.e., were opened before) the class is initialized.
AlwaysRequestAttributesOnOpenWhether the driver should keep request existing attributes before file create/open operation.
CacheRemoteFilesLocallyWhether remote files involved in filtered operations should be cached locally rather than remotely.
DirectRequestsDownTheStackWhether requests for handles created with the CreateFileDirect method go down the filter stack and not direct to the filesystem.
FilterOwnRequestsWhether the class's system driver should filter requests made by the application itself.
ForceAdminRightsForDefaultRulesSpecifies whether default rules can be added or deleted only by administrators.
ForceAppPermissionCheckWhether the driver should require the controller process to have elevated or system privileges.
ForceSecurityChecksWhether the driver should prevent the controller process from filtering files that it would not normally have access to.
LoggingEnabledWhether extended logging is enabled.
MaxWorkerThreadCountThe maximum number of worker threads to use to fire events.
MinWorkerThreadCountThe minimum number of worker threads to use to fire events.
ModifiableReadWriteBuffersWhether the driver should duplicate read/write buffers sent to the user.
OmitEventFilenamesWhether the filename parameter should be empty in events.
PassSecurityInFileOpenEventsWhether security information, associated with the file create/open request, is passed to file creation and opening events.
PreprocessedRulesCacheSizeMaximum number of preprocessed rules to keep cached.
RecordOperationTimeEnables collection of operation time.
ResolveNtDeviceToDriveLetterWhether native device names are translated to drive letters.
SendRequestsViaDriverStackWhether internal requests to the filesystem are sent directly to the filesystem driver or through the stack of filesystem filter drivers.
SerializeAccessWhether nonintersecting operations against the same file should execute serially or in parallel.
TranslateDOSCharsInEnumMasksWhether the DOS wildcard characters should be translated during search.
WorkerInitialStackSizeThe initial stack size to create worker threads with.
BuildInfoInformation about the product's build.
LicenseInfoInformation about the current license.

active Property

This property notes whether the class is active and processing requests.

Syntax

def get_active() -> bool: ...

active = property(get_active, None)

Default Value

FALSE

Remarks

This property reflects whether the class is active and currently processing requests. It will be True after the filter has been attached successfully via a call to start_filter.

This property is read-only.

altitude Property

This property specifies the altitude the class's system driver should use .

Syntax

def get_altitude() -> str: ...
def set_altitude(value: str) -> None: ...

altitude = property(get_altitude, set_altitude)

Default Value

""

Remarks

This property specifies the altitude that the class's system driver should use . A driver's altitude determines its absolute position in the stack of filter drivers; drivers with higher altitudes are attached toward the top of the stack, closer to the user mode, which allows them to process requests earlier.

Microsoft manages and assigns filesystem minifilter driver altitudes directly, so an application-specific altitude value must be obtained from Microsoft before an application is deployed in production. Please refer to the Driver Altitudes topic for more information. During development, an appropriate arbitrary value, such as 360000 (which is not registered with Microsoft), can be used.

If this property is queried before an altitude has been set (via this property or the install method), it will return an empty string.

Note: This property cannot be changed when active is True. Additionally, the initialize method must be called before attempting to get or set this property's value, which is stored in the registry.

default_rule_count Property

The number of records in the DefaultRule arrays.

Syntax

def get_default_rule_count() -> int: ...

default_rule_count = property(get_default_rule_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at default_rule_count - 1.

This property is read-only.

default_rule_access_flags Property

This property indicates the access restrictions enforced by the rule.

Syntax

def get_default_rule_access_flags(default_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the access restrictions enforced by the rule.

This property indicates which access restrictions are enforced by the rule. Please refer to the Default Rules topic for more information. The value of this property is a combination of zero or more of the following:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The default_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the default_rule_count property.

This property is read-only.

default_rule_mask Property

This property indicates a file mask that determines which files and directories match the rule.

Syntax

def get_default_rule_mask(default_rule_index: int) -> str: ...

Default Value

""

Remarks

This property indicates a file mask that determines which files and directories match the rule.

This property reflects the file mask used to determine whether a file or directory matches the rule. In addition to being its primary match qualifier, a rule's mask also serves as its identifier; every rule in a ruleset must have a unique mask.

Note: When a rule with a drive letter is added, said drive letter is automatically converted to NT Device format. When the ResolveNtDeviceToDriveLetter configuration setting is disabled, this property's value will contain the NT Device name. When the ResolveNtDeviceToDriveLetter configuration setting is enabled, the class attempts to convert the mask back to the DOS format with a drive letter. In some situations, such backward conversion can lead to a path that was different from the original path added.

The default_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the default_rule_count property.

This property is read-only.

file_flushing_behavior Property

This property specifies the file flushing and closing behavior that the class's system driver should enforce.

Syntax

def get_file_flushing_behavior() -> int: ...
def set_file_flushing_behavior(value: int) -> None: ...

file_flushing_behavior = property(get_file_flushing_behavior, set_file_flushing_behavior)

Default Value

0

Remarks

This property specifies what file flushing and closing behaviors the class's system driver should enforce.

Applications that modify file data as it is being read or written may need to change this property's value to function correctly. For example, applications that provide on-the-fly encryption should choose the proper flags to ensure that other applications that have opened the files being encrypted cannot accidentally write nonencrypted data to the disk.

Applications that do not modify file data as it is being read or written can leave this property unchanged.

The value of this property should be constructed by ORing together zero or more of the following flags:

FS_FLUSH_FILES_ON_OPEN1Whether memory-mapped file data should be flushed to disk before files are opened.

This flag indicates that the class's system driver should flush any cached and memory-mapped file data, leftover from the last time a file was opened, before opening it again. Doing so ensures that file data are read directly from the disk rather than from the old memory mapping.

Applications that modify file data as it is being read may need to set this flag to function correctly. For example, applications that provide on-the-fly encryption should set this flag to ensure that file data are always read from the disk (and thus have a chance to get decrypted) when a file is opened.

Applications that do not modify file data as it is being read should leave this flag unset to maintain optimal performance when opening files.

FS_FLUSH_FILES_ON_CLOSE2Whether file buffers must be flushed when files are closed.

This flag indicates that the class's system driver should flush and clear the buffers of files that are opened for writing (and have had data written to them) when they are closed.

Applications that modify file data as it is being written may need to set this flag to function correctly. For example, applications that provide on-the-fly encryption should set this flag to ensure that all file data are flushed to the disk (and thus has a chance to get encrypted) when a file is closed.

Applications that do not modify file data as it is being written can unset this flag.

After a file is flushed, all in-memory buffers and memory mappings are cleared to avoid leakage of unprotected information.

FS_CLOSE_FILES_ON_STOPFILTER4Whether files opened for writing must be closed when the application stops filtering.

This flag indicates that the class's system driver should close files that are opened for writing (and have had data written to them) when the application calls stop_filter.

Applications that modify file data as it is being written (e.g., on-the-fly encryption) may need to set this flag to prevent further operations against the file data from being performed. Applications that do not modify file data as it is being written can leave this flag unset.

Note: If memory mappings of some file exist, these mappings will remain active; only the open handles to such files are closed.

When the file is closed, all in-memory buffers and memory mappings are cleared to avoid leakage of unprotected information. Applications can control whether file data are flushed before files are closed using the FS_FLUSH_FILES_ON_STOPFILTER flag; any data that are not flushed get discarded.

FS_FLUSH_FILES_ON_STOPFILTER8Whether file buffers must be flushed when the application stops filtering.

This flag indicates that the class's system driver should flush and clear the buffers of files that are opened for writing (and have had data written to them) when the application calls stop_filter.

Applications that modify file data as it is being written (e.g., on-the-fly encryption) may need to set this flag to ensure that no unprotected data are kept in memory, but rather has a chance to be encrypted and written out to disk. Applications that do not modify file data as it is being written can leave this flag unset.

If the application will not be able to perform on-the-fly data modification at the moment when stop_filter is called (e.g., because a cryptographic hardware module is unplugged), then this flag should be unset before calling stop_filter.

After a file is flushed, all in-memory buffers and memory mappings are cleared to avoid leakage of unprotected information.

FS_CLOSE_FILES_ON_CRASH16Whether files opened for writing must be closed if the application terminates unexpectedly.

This flag indicates that the class's system driver should close files that are opened for writing (and have had data written to them) if the driver detects that the application has terminated.

Applications that modify file data as it is being written (e.g., on-the-fly encryption) may need to set this flag to prevent further operations against the file data from being performed. Applications that do not modify file data as it is being written can leave this flag unset.

Note: If memory mappings of some file exist, these mappings will remain active; only the open handles to such files are closed.

When the file is closed, all in-memory buffers and memory mappings are cleared to avoid leakage of unprotected information.

FS_FLUSH_FILES_ON_CRASH32Whether file buffers must be flushed if the application terminates unexpectedly.

This flag indicates that the class's system driver should flush and clear the buffers of files that are opened for writing (and have had data written to them) if the driver detects that the application has terminated.

Applications that do not modify data as it is being written may set this flag if necessary. Applications that modify data as it is being written (e.g., on-the-fly encryption) should not set this flag, because such flushing could cause unprotected data to be written out to disk.

FS_SUPPORT_FILE_ENCRYPTION31Combination of flags suitable for on-the-fly file encryption applications.

This option includes the following flags: FS_FLUSH_FILES_ON_OPEN, FS_FLUSH_FILES_ON_CLOSE, FS_CLOSE_FILES_ON_STOPFILTER, FS_FLUSH_FILES_ON_STOPFILTER, and FS_CLOSE_FILES_ON_CRASH flags.

filter_rule_count Property

The number of records in the FilterRule arrays.

Syntax

def get_filter_rule_count() -> int: ...

filter_rule_count = property(get_filter_rule_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at filter_rule_count - 1.

This property is read-only.

filter_rule_access_flags Property

This property indicates the access restrictions enforced by the rule (CBFilter only).

Syntax

def get_filter_rule_access_flags(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the access restrictions enforced by the rule (CBFilter only).

This property indicates which access restrictions are enforced by the rule. Please refer to the Access Rules topic for more information. The value of this property is a combination of zero or more of the following:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

Note: This property is always 0 for the CBMonitor class, which does not support access rules.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_control_flags Property

This property indicates which control events the rule causes the class to fire (CBFilter only).

Syntax

def get_filter_rule_control_flags(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates which control events the rule causes the class to fire (CBFilter only).

This property indicates which filesystem operations, of those performed on matching files and directories, the class should fire Control Events for. The value of this property is a combination of zero or more of the following:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

Note: This property is always 0 for the CBMonitor class, which does not provide any Control Events for filesystem operations.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_ea_name Property

This property indicates the name of an extended attribute that a file or directory must have to match the rule.

Syntax

def get_filter_rule_ea_name(filter_rule_index: int) -> str: ...

Default Value

""

Remarks

This property indicates the name of an extended attribute that a file or directory must have to match the rule.

This property reflects the name of an extended attribute that a file or directory must have to qualify as a match for the rule. A value of an empty string indicates that the rule does not use this property as a match qualifier.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_excluded_attributes Property

This property indicates the file attributes that a file or directory must not have to match the rule.

Syntax

def get_filter_rule_excluded_attributes(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the file attributes that a file or directory must not have to match the rule.

This property indicates which file attributes a file or directory must not have to qualify as a match for the rule. A value of 0 indicates that the rule does not use this property as a match qualifier.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_included_attributes Property

This property indicates the file attributes that a file or directory must have to match the rule.

Syntax

def get_filter_rule_included_attributes(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the file attributes that a file or directory must have to match the rule.

This property indicates which file attributes a file or directory must have to qualify as a match for the rule. A value of 0 indicates that the rule does not use this property as a match qualifier.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_mask Property

This property indicates a file mask that determines which files and directories match the rule.

Syntax

def get_filter_rule_mask(filter_rule_index: int) -> str: ...

Default Value

""

Remarks

This property indicates a file mask that determines which files and directories match the rule.

This property reflects the file mask used to determine whether a file or directory matches the rule. In addition to being its primary match qualifier, a rule's mask also serves as its identifier; every rule in a ruleset must have a unique mask.

Note: When a rule with a drive letter is added, said drive letter is automatically converted to NT Device format. When the ResolveNtDeviceToDriveLetter configuration setting is disabled, this property's value will contain the NT Device name. When the ResolveNtDeviceToDriveLetter configuration setting is enabled, the class attempts to convert the mask back to the DOS format with a drive letter. In some situations, such backward conversion can lead to a path that was different from the original path added.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_max_size Property

This property indicates the maximum size a file can be to match the rule.

Syntax

def get_filter_rule_max_size(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the maximum size a file can be to match the rule.

This property indicates the maximum size, in bytes, that a file can be to qualify as a match for the rule. A value of -1 indicates that the rule does not use this property as a match qualifier.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_min_size Property

This property indicates the minimum size a file can be to match the rule.

Syntax

def get_filter_rule_min_size(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the minimum size a file can be to match the rule.

This property indicates the minimum size, in bytes, that a file can be to qualify as a match for the rule. A value of -1 indicates that the rule does not use this property as a match qualifier.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

filter_rule_notify_flags Property

This property indicates which notification events the rule causes the class to fire.

Syntax

def get_filter_rule_notify_flags(filter_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates which notification events the rule causes the class to fire.

This property indicates which filesystem operations, of those performed on matching files and directories, the class should fire Notification Events for. The value of this property is a combination of zero or more of the following:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

The filter_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the filter_rule_count property.

This property is read-only.

fire_volume_events Property

This property specifies the events that should be fired when a filesystem volume is mounted to or unmounted from the system.

Syntax

def get_fire_volume_events() -> int: ...
def set_fire_volume_events(value: int) -> None: ...

fire_volume_events = property(get_fire_volume_events, set_fire_volume_events)

Default Value

0

Remarks

This property specifies the events that the class should fire when a filesystem volume is mounted to or unmounted from the system. Possible values are as follows:

FS_MOUNT_IGNORE0Don't fire any events when volumes are mounted or unmounted.

FS_MOUNT_NOTIFY64Fire Notification Events when volumes are mounted or unmounted.

The on_notify_filter_attach_to_volume and on_notify_filter_detach_from_volume events will fire, asynchronously, as necessary.

FS_MOUNT_CONTROL128Fire Control Events when volumes are mounted or unmounted.

The on_before_filter_attach_to_volume, on_after_filter_attach_to_volume, and on_after_filter_detach_from_volume events will fire, synchronously, as necessary.

FS_MOUNT_BOTH192Fire all events when volumes are mounted or unmounted.

Note: The aforementioned events are fired only for volumes mounted/unmounted after the start_filter method is called. Typically, applications use these events to dynamically add or remove volume-specific filter rules that target removable volumes (e.g., USB drives) as well as to create virtual files on such volumes. Please refer to the File Masks topic for more information.

passthrough_rule_count Property

The number of records in the PassthroughRule arrays.

Syntax

def get_passthrough_rule_count() -> int: ...

passthrough_rule_count = property(get_passthrough_rule_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at passthrough_rule_count - 1.

This property is read-only.

passthrough_rule_access_flags Property

This property specifies the access restrictions lifted by the rule (CBFilter only).

Syntax

def get_passthrough_rule_access_flags(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property specifies the access restrictions lifted by the rule (CBFilter only).

This property indicates which access restrictions are lifted by the rule. Please refer to the Passthrough Rules topic for more information. The value of this property is a combination of zero or more of the following:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

Note: This property is always 0 for the CBMonitor class, which does not support access rules.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_control_flags Property

This property indicates which control events the rule prevents the class from firing (CBFilter only).

Syntax

def get_passthrough_rule_control_flags(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates which control events the rule prevents the class from firing (CBFilter only).

This property indicates which filesystem operations, of those performed on matching files and directories, the class should not fire Control Events for. Please refer to the Passthrough Rules topic for more information. The value of this property is a combination of zero or more of the following:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

Note: This property is always 0 for the CBMonitor class, which does not provide any Control Events for filesystem operations.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_ea_name Property

This property indicates the name of an extended attribute that a file or directory must have to match the rule.

Syntax

def get_passthrough_rule_ea_name(passthrough_rule_index: int) -> str: ...

Default Value

""

Remarks

This property indicates the name of an extended attribute that a file or directory must have to match the rule.

This property reflects the name of an extended attribute that a file or directory must have to qualify as a match for the rule. A value of an empty string indicates that the rule does not use this property as a match qualifier.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_excluded_attributes Property

This property indicates the file attributes that a file or directory must not have to match the rule.

Syntax

def get_passthrough_rule_excluded_attributes(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the file attributes that a file or directory must not have to match the rule.

This property indicates which file attributes a file or directory must not have to qualify as a match for the rule. A value of 0 indicates that the rule does not use this property as a match qualifier.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_included_attributes Property

This property indicates the file attributes that a file or directory must have to match the rule.

Syntax

def get_passthrough_rule_included_attributes(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the file attributes that a file or directory must have to match the rule.

This property indicates which file attributes a file or directory must have to qualify as a match for the rule. A value of 0 indicates that the rule does not use this property as a match qualifier.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_mask Property

This property indicates a file mask that determines which files and directories match the rule.

Syntax

def get_passthrough_rule_mask(passthrough_rule_index: int) -> str: ...

Default Value

""

Remarks

This property indicates a file mask that determines which files and directories match the rule.

This property reflects the file mask used to determine whether a file or directory matches the rule. In addition to being its primary match qualifier, a rule's mask also serves as its identifier; every rule in a ruleset must have a unique mask.

Note: When a rule with a drive letter is added, said drive letter is automatically converted to NT Device format. When the ResolveNtDeviceToDriveLetter configuration setting is disabled, this property's value will contain the NT Device name. When the ResolveNtDeviceToDriveLetter configuration setting is enabled, the class attempts to convert the mask back to the DOS format with a drive letter. In some situations, such backward conversion can lead to a path that was different from the original path added.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_max_size Property

This property indicates the maximum size a file can be to match the rule.

Syntax

def get_passthrough_rule_max_size(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the maximum size a file can be to match the rule.

This property indicates the maximum size, in bytes, that a file can be to qualify as a match for the rule. A value of -1 indicates that the rule does not use this property as a match qualifier.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_min_size Property

This property indicates the minimum size a file can be to match the rule.

Syntax

def get_passthrough_rule_min_size(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates the minimum size a file can be to match the rule.

This property indicates the minimum size, in bytes, that a file can be to qualify as a match for the rule. A value of -1 indicates that the rule does not use this property as a match qualifier.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

passthrough_rule_notify_flags Property

This property indicates which notification events the rule prevents the class from firing.

Syntax

def get_passthrough_rule_notify_flags(passthrough_rule_index: int) -> int: ...

Default Value

0

Remarks

This property indicates which notification events the rule prevents the class from firing.

This property indicates which filesystem operations, of those performed on matching files and directories, the class should not fire Notification Events for. Please refer to the Passthrough Rules topic for more information. The value of this property is a combination of zero or more of the following:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

The passthrough_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the passthrough_rule_count property.

This property is read-only.

process_cached_io_requests Property

This property specifies whether cached file read/write requests should be processed.

Syntax

def get_process_cached_io_requests() -> bool: ...
def set_process_cached_io_requests(value: bool) -> None: ...

process_cached_io_requests = property(get_process_cached_io_requests, set_process_cached_io_requests)

Default Value

FALSE

Remarks

This property specifies whether the class's system driver should process cached file read/write requests (i.e., fire *ReadFile and *WriteFile events for them). Please refer to the Cached and Non-Cached Requests topic for more information.

Note: This property cannot be changed when active is True.

process_failed_requests Property

This property specifies whether failed requests should be processed.

Syntax

def get_process_failed_requests() -> bool: ...
def set_process_failed_requests(value: bool) -> None: ...

process_failed_requests = property(get_process_failed_requests, set_process_failed_requests)

Default Value

FALSE

Remarks

This property specifies whether the class's system driver should process failed requests (i.e., fire After* or Notify* events for them).

When this property is enabled, applications can inspect the Status parameter of the aforementioned events to determine whether an operation has failed. If an operation fails, then the corresponding event's Status parameter will contain a nonzero native status code. Applications generally can use the nt_status_to_win_32_error method to convert these status codes into Win32 error codes (but keep in mind that not all native status codes have direct Win32 error code mapping).

reparse_rule_count Property

The number of records in the ReparseRule arrays.

Syntax

def get_reparse_rule_count() -> int: ...

reparse_rule_count = property(get_reparse_rule_count, None)

Default Value

0

Remarks

This property controls the size of the following arrays:

The array indices start at 0 and end at reparse_rule_count - 1.

This property is read-only.

reparse_rule_mask Property

This property indicates a file mask that determines which files and directories match the rule.

Syntax

def get_reparse_rule_mask(reparse_rule_index: int) -> str: ...

Default Value

""

Remarks

This property indicates a file mask that determines which files and directories match the rule.

This property reflects the file mask used to determine whether a file or directory matches the rule. In addition to being its primary match qualifier, a rule's mask also serves as its identifier; every rule in a ruleset must have a unique mask.

Note: When a rule with a drive letter is added, said drive letter is automatically converted to NT Device format. When the ResolveNtDeviceToDriveLetter configuration setting is disabled, this property's value will contain the NT Device name. When the ResolveNtDeviceToDriveLetter configuration setting is enabled, the class attempts to convert the mask back to the DOS format with a drive letter. In some situations, such backward conversion can lead to a path that was different from the original path added.

The reparse_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the reparse_rule_count property.

This property is read-only.

reparse_rule_reparse_mask Property

This property contains a file mask that specifies where matching files and directories are redirected to.

Syntax

def get_reparse_rule_reparse_mask(reparse_rule_index: int) -> str: ...

Default Value

""

Remarks

This property contains a file mask that specifies where matching files and directories are redirected to.

This property contains a file mask that specifies where files and directories that match reparse_rule_mask are redirected to. Please refer to the Reparse Rules topic for more information.

The reparse_rule_index parameter specifies the index of the item in the array. The size of the array is controlled by the reparse_rule_count property.

This property is read-only.

serialize_events Property

Whether events should be fired on a single worker thread, or many.

Syntax

def get_serialize_events() -> int: ...
def set_serialize_events(value: int) -> None: ...

serialize_events = property(get_serialize_events, set_serialize_events)

Default Value

0

Remarks

This property specifies whether the class should fire all events serially on a single worker thread, or concurrently on multiple worker threads. The possible values are:

0 (seOnMultipleThreads) The class fires events in the context of multiple worker threads. The MinWorkerThreadCount and MaxWorkerThreadCount configuration settings control how many worker threads are used for this.
1 (seOnOneWorkerThread) The class fires events in the context of one background worker thread.

Please refer to the Threading and Concurrency topic for more information.

Note: This property cannot be changed when active is True, and it cannot be changed within events.

tag Property

This property stores application-defined data specific to a particular instance of the class.

Syntax

def get_tag() -> int: ...
def set_tag(value: int) -> None: ...

tag = property(get_tag, set_tag)

Default Value

0

Remarks

This property can be used to store data specific to a particular instance of the class.

add_bytes_to_write_buffer Method

This method reserves extra space in the file data buffers used in file read/write events.

Syntax

def add_bytes_to_write_buffer(extra_bytes: int) -> bool: ...

Remarks

Applications that plan to add additional data when files are being read or written should call this method to specify how much extra space to reserve in the file data buffers used in the on_before_read_file, on_after_read_file, on_before_write_file, and on_after_write_file events. If successful, this method returns True; otherwise, it returns False.

The ExtraBytes parameter specifies how many bytes to reserve.

Note: The value passed for this parameter must be a multiple of 512.

Note: This method cannot be called when active is True.

add_default_rule Method

This method adds a default rule.

Syntax

def add_default_rule(mask: str, access_flags: int, product_guid: str) -> bool: ...

Remarks

This method adds a default rule for the files and directories that match the specified Mask. Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule's parameters are merged into it.

If the rule is added successfully, this method returns True; otherwise, it returns False.

Default rules, like access rules, instruct the class's system driver to apply certain access restrictions to matching files and directories. However, unlike access rules, default rules are managed by the driver directly; they are activated as soon as the driver loads at boot time, and then continue to be enforced at all times, regardless of whether the application that added them is open.

The Mask parameter must be a valid file mask according to the File Masks topic. Only the files and directories that match the specified mask will be covered by the rule.

The AccessFlags parameter specifies which access restrictions the class's system driver should apply to matching files and directories. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ProductGUID parameter identifies the application that the rule should be associated with in the registry. In most cases, the value passed for this parameter should be the same one that was used to call the initialize method.

This method requires administrative rights to execute successfully. If the user account of the process that calls this method doesn't have such rights, the call will fail with an ERROR_PRIVILEGE_NOT_HELD (0x0522) error. Please refer to the Default Rules topic for more information.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

add_filter_rule Method

This method adds a standard filter rule or access rule.

Syntax

def add_filter_rule(mask: str, access_flags: int, control_flags: int, notify_flags: int) -> bool: ...

Remarks

This method adds a standard filter rule or access rule for the files and directories that match the specified Mask. Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule's parameters are merged into it.

If the rule is added successfully, this method returns True; otherwise, it returns False.

Standard filter rules determine which filesystem operations, of those performed on matching files and directories, the class should fire its events for. Access rules instruct the class's system driver to apply certain access restrictions to matching files and directories.

The Mask parameter must be a valid file mask according to the File Masks topic. Only the files and directories that match the specified mask will be covered by the rule.

The AccessFlags parameter specifies which access restrictions the class's system driver should apply to matching files and directories. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ControlFlags parameter specifies which filesystem operations the class should fire Control Events for. For example, if the FS_CE_BEFORE_READ and FS_CE_AFTER_READ flags are present, the on_before_read_file and on_after_read_file events will fire before and after a read operation is performed on any file that matches Mask. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

The NotifyFlags parameter specifies which filesystem operations the class should fire Notification Events for. For example, if the FS_NE_READ flag is present, the on_notify_read_file event will fire after a read operation is performed on any file that matches Mask. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

add_filter_rule_ex Method

This method adds a standard filter rule or access rule with additional match qualifiers.

Syntax

def add_filter_rule_ex(mask: str, ea_name: str, access_flags: int, control_flags: int, notify_flags: int, min_size: int, max_size: int, included_attributes: int, excluded_attributes: int) -> bool: ...

Remarks

This method adds a standard filter rule or access rule for the files and directories that match the specified Mask (which must be provided), and other qualifiers (which are optional). Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule's parameters are merged into it.

If the rule is added successfully, this method returns True; otherwise, it returns False.

Standard filter rules determine which filesystem operations, of those performed on matching files and directories, the class should fire its events for. Access rules instruct the class's system driver to apply certain access restrictions to matching files and directories.

The Mask parameter must be a valid file mask according to the File Masks topic. Only the files and directories that match the specified mask will be covered by the rule.

The EaName parameter specifies the name of an extended attribute that a file or directory must have to qualify as a match; wildcards are not allowed. Pass an empty string if this parameter should not be used as a match qualifier.

The AccessFlags parameter specifies which access restrictions the class's system driver should apply to matching files and directories. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ControlFlags parameter specifies which filesystem operations the class should fire Control Events for. For example, if the FS_CE_BEFORE_READ and FS_CE_AFTER_READ flags are present, the on_before_read_file and on_after_read_file events will fire before and after a read operation is performed on any file that matches Mask. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

The NotifyFlags parameter specifies which filesystem operations the class should fire Notification Events for. For example, if the FS_NE_READ flag is present, the on_notify_read_file event will fire after a read operation is performed on any file that matches Mask. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

The MinSize and MaxSize parameters specify the minimum and maximum size, in bytes, that a file can be to qualify as a match. Pass -1 for either parameter if it should not be used as a match qualifier.

The IncludedAttributes and ExcludedAttributes parameters specify which file attributes a file or directory must have or not have to qualify as a match. Pass 0 for either parameter if it should not be used as a match qualifier.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

add_passthrough_rule Method

This method adds a passthrough rule.

Syntax

def add_passthrough_rule(mask: str, access_flags: int, control_flags: int, notify_flags: int) -> bool: ...

Remarks

This method adds a passthrough rule for the files and directories that match the specified Mask. Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule's parameters are merged into it.

If the rule is added successfully, this method returns True; otherwise, it returns False.

Passthrough rules exclude matching files and directories from being processed by other filter rules.

The Mask parameter must be a valid file mask according to the File Masks topic. Only the files and directories that match the specified mask will be covered by the rule.

The AccessFlags parameter specifies which access restrictions the class's system driver should lift from matching files and directories. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ControlFlags parameter specifies which filesystem operations the class should not fire Control Events for. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

The NotifyFlags parameter specifies which filesystem operations the class should not fire Notification Events for. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

add_passthrough_rule_ex Method

This method adds a passthrough rule with additional match qualifiers.

Syntax

def add_passthrough_rule_ex(mask: str, ea_name: str, access_flags: int, control_flags: int, notify_flags: int, min_size: int, max_size: int, included_attributes: int, excluded_attributes: int) -> bool: ...

Remarks

This method adds a passthrough rule for the files and directories that match the specified Mask (which must be provided) and other qualifiers (which are optional). Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule's parameters are merged into it.

If the rule is added successfully, this method returns True; otherwise, it returns False.

Passthrough rules exclude matching files and directories from being processed by other filter rules.

The Mask parameter must be a valid file mask according to the File Masks topic. Only the files and directories that match the specified mask will be covered by the rule.

The EaName parameter specifies the name of an extended attribute that a file or directory must have to qualify as a match; wildcards are not allowed. Pass an empty string if this parameter should not be used as a match qualifier.

The AccessFlags parameter specifies which access restrictions the class's system driver should lift from matching files and directories. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ControlFlags parameter specifies which filesystem operations the class should not fire Control Events for. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

The NotifyFlags parameter specifies which filesystem operations the class should not fire Notification Events for. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

The MinSize and MaxSize parameters specify the minimum and maximum size, in bytes, that a file can be to qualify as a match. Pass -1 for either parameter if it should not be used as a match qualifier.

The IncludedAttributes and ExcludedAttributes parameters specify which file attributes a file or directory must have or not have to qualify as a match. Pass 0 for either parameter if it should not be used as a match qualifier.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

add_reparse_rule Method

This method adds a reparse rule.

Syntax

def add_reparse_rule(mask: str, reparse_mask: str, product_guid: str, flags: int) -> bool: ...

Remarks

This method adds a reparse rule for the files and directories that match the specified Mask. Each rule in a ruleset is uniquely identified by its mask; if a rule with the specified mask already exists, the new rule replaces it.

If the rule is added successfully, this method returns True; otherwise, it returns False.

Reparse rules are used to redirect access from a file or directory covered by Mask to another location in the filesystem, specified by ReparseMask.

The Mask and ReparseMask parameters must be valid file masks according to the File Masks topic. Only the files and directories that match Mask will be covered by the rule (i.e., redirected to the path specified by ReparseMask). For example, passing *.txt for Mask and *_1.txt for ReparseMask would cause, for example, test.txt to be redirected to test_1.txt.

More generally, for each wildcard (* or ?) present in Mask, there must be a corresponding wildcard (of the same type) in ReparseMask; and the wildcards in ReparseMask must appear in the same order as they do in Mask. For example, if Mask is 20??_Budget.*, then 20??_Budget_Report.* would be a legal value for ReparseMask; but 20??_Budget_Report.xls would not be, nor would 20*_Budget_Report.*.

The ProductGUID parameter identifies the application that the rule should be associated with in the registry. In most cases, the value passed for this parameter should be the same one that was used to call the initialize method.

The Flags parameter specifies how, exactly, the redirection should be performed. Possible values are as follows:

FS_REPARSE_CHANGE_PATH0Perform redirection by modifying the path directly using the CBFilter system driver.

FS_REPARSE_USE_REPARSE_POINT1Perform redirection by having the CBFilter system driver emulate real reparse point behavior.

This option will cause the driver to report that a file or directory's parent directory is a reparse point of the SYMLINK variety. Redirection performed in this manner is more consistent with Windows' behavior; however, some software may fail to correctly handle paths that cross such symbolic links.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

close_default_rules_snapshot Method

This method closes the previously created default rules snapshot.

Syntax

def close_default_rules_snapshot() -> None: ...

Remarks

This method closes the default rules snapshot previously created by create_default_rules_snapshot, releasing the memory associated with it. Please refer to that method's documentation for more information.

Note: This method cannot be called within events.

The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

close_reparse_rules_snapshot Method

This method closes the previously created reparse rules snapshot.

Syntax

def close_reparse_rules_snapshot() -> None: ...

Remarks

This method closes the reparse rules snapshot previously created by create_reparse_rules_snapshot, releasing the memory associated with it. Please refer to that method's documentation for more information.

Note: This method cannot be called within events.

The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

config Method

Sets or retrieves a configuration setting.

Syntax

def config(configuration_string: str) -> str: ...

Remarks

config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

create_default_rules_snapshot Method

This method creates a snapshot of information about the default rules that have been added.

Syntax

def create_default_rules_snapshot(product_guid: str) -> None: ...

Remarks

This method creates a snapshot of information about all default rules that have been added by the application identified by ProductGUID. This information is then used to populate the DefaultRule* properties.

When the application is finished working with the default rules snapshot, it must close it by calling the close_default_rules_snapshot method to release the associated memory. If this method is called again before an existing snapshot is closed, the class will attempt to close it before creating a new one.

Note: This method cannot be called within events.

The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

create_file_direct Method

This method creates or opens a file or directory by passing the request directly to the filesystem.

Syntax

def create_file_direct(file_name: str, synchronize: bool, desired_access: int, share_mode: int, creation_disposition: int, flags_and_attributes: int, close_immediately: bool) -> int: ...

Remarks

This method should be used instead of the Windows API's CreateFile function to create or open a file or directory when an application needs to access it without sending requests through the filesystem filter driver stack.

The parameters of this method correspond to the parameters of the CreateFile function. The ShareMode parameter should be set by ORing together zero or more of the following flags:

FILESYS_SHARE_NONE0x00000000Prevents any process from opening a file or device if it requests delete, read, or write access.

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CBFILTER_IGNORE_SHARE_ACCESS_CHECK0x10000000Specifies that the driver should pass IO_IGNORE_SHARE_ACCESS_CHECK flag to the system functions.

Use this flag to bypass sharing checks performed by the I/O manager when opening local files.

Note: The filesystem still may perform these checks. Also, the internal structures are not updated with the share mode values, passed in this call. This means that subsequent file open operations will not know about the previous share mode and may succeed where they would have to fail.

If the file or directory is created or opened successfully, this method returns a file handle for it; otherwise, it returns INVALID_HANDLE_VALUE. The returned handle, if valid, must be closed using the Windows API's CloseHandle function when the application is finished with it.

If CloseImmediately is True, this method will create or open the specified file or directory and then immediately close the resulting handle. In this case, the handle will still be returned to indicate the success of the operation, but it will not be usable in any file operations.

Because all requests against the returned file handle are routed directly to the filesystem (bypassing all filter drivers, including the class's), applications can use it to call the Windows File API functions (ReadFile, WriteFile) within filesystem-related events without causing a system deadlock. However, pay special attention to the Synchronize parameter's documentation, which is given below.

The returned handle can be used with some of the Windows API functions that accept a file handle as a parameter. Support may vary depending on the internal implementation of each function. The following Windows API functions have been tested and proven to work:

Other functions may work as well but have not been tested.

Note: When calling the GetFileInformationByHandleEx function, only the following information classes are currently supported:

  • FileAttributeTagInfo
  • FileBasicInfo
  • FileStandardInfo
  • FileStreamInfo
  • FileIdInfo
Support for other information classes depends on the class and OS capabilities.

The FileName, DesiredAccess, CreationDisposition, and FlagsAndAttributes parameters correspond to the lpFileName, dwDesiredAccess, dwCreationDisposition, and dwFlagsAndAttributes parameters of the Windows API's CreateFile function (respectively). Please refer to Microsoft's documentation for more information about how to set these parameters appropriately.

The file is opened with a sharing mode that allows other processes to open the file for any kind of operation.

The Synchronize parameter specifies whether this method and operations with the resulting handle should be synchronized with the thread that originated the underlying filesystem request associated with the current event (i.e., the event that this method was called from).

The parameter is applicable only when a caller uses it to open the file, for which the event was fired. Also, the parameter should not be set to True when this method is called from the on_after_close_file event; when the event is fired, no file is open to synchronize operations with.

If Synchronize is True, this method and all operations with the resulting handle will be execute in the context of the external thread that originated the underlying filesystem request associated with the current event (which is important for on-the-fly file data modification like encryption), and the following restrictions will apply:

  • The method may be called from any event handlers with the exception of on_after_close_file and on_cleanup_context. Note: To be able to call the method from the on_before_create_file and on_before_open_file event handlers, set the AllowFileAccessInBeforeOpen configuration setting to True.
  • The method should be called only for the file or directory that the event fired for.
  • A file will be opened without buffering, which means that applications must comply with all restrictions imposed by the FILE_FLAG_NO_BUFFERING flag when reading and writing file data. Please refer to Microsoft's File Buffering article for more information.
There also exists a limitation in how the method works in the following scenario: if the method is called from a on_before_create_file or on_before_open_file event handler and the file doesn't exist and the method is used to create this file, then writing to this file from the same event handler will not work. The reason is that the file didn't exist at the moment when the event was fired, so the driver cannot synchronize the operations properly. The solution is to move the file writing step to the on_after_create_file and on_after_open_file event handler respectively. There, an application may use the handle obtained in on_before_create_file or on_before_open_file and write data to that file.

If Synchronize is False, this method and operations with the resulting handle are executed in the context of the thread in which the corresponding call is made, and the restrictions described above do not apply. This provides applications with greater flexibility because the returned file handle can be used in any event (as long as its handler complies with the general restrictions described by the Avoiding Deadlocks and Recursive Calls topics).

In both cases, the class must be active - that is, it must be started using a call to the start_filter method.

create_file_direct_as_stream Method

This method creates or opens a file by passing the request directly to the filesystem.

Syntax

def create_file_direct_as_stream(file_name: str, synchronize: bool, desired_access: int, share_mode: int, creation_disposition: int, flags_and_attributes: int, handle: List[int]) -> CBFSFilterStream: ...

Remarks

This method should be used instead of the Windows API's CreateFile function to create or open a file when an application needs to access it without sending requests through the filesystem filter driver stack.

The parameters of this method correspond to the parameters of the CreateFile function. The ShareMode parameter should be set by ORing together zero or more of the following flags:

FILESYS_SHARE_NONE0x00000000Prevents any process from opening a file or device if it requests delete, read, or write access.

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CBFILTER_IGNORE_SHARE_ACCESS_CHECK0x10000000Specifies that the driver should pass IO_IGNORE_SHARE_ACCESS_CHECK flag to the system functions.

Use this flag to bypass sharing checks performed by the I/O manager when opening local files.

Note: The filesystem still may perform these checks. Also, the internal structures are not updated with the share mode values, passed in this call. This means that subsequent file open operations will not know about the previous share mode and may succeed where they would have to fail.

If the file is created or opened successfully, this method returns a stream object that provides access to its data; otherwise, it returns None. Upon success, the Handle parameter is populated with the handle value, which can be used to call set_file_size_direct or set_file_information_direct if needed.

Because all requests against the file are routed directly to the filesystem (bypassing all filter drivers, including the class's), applications can use the returned stream within filesystem-related events without causing a system deadlock. However, pay special attention to the Synchronize parameter's documentation, which is given below.

The FileName, DesiredAccess, CreationDisposition, and FlagsAndAttributes parameters correspond to the lpFileName, dwDesiredAccess, dwCreationDisposition, and dwFlagsAndAttributes parameters of the Windows API's CreateFile function (respectively). Please refer to Microsoft's documentation for more information about how to set these parameters appropriately.

The file is opened with a sharing mode that allows other processes to open the file for any kind of operation.

The Synchronize parameter specifies whether this method and operations with the resulting handle should be synchronized with the thread that originated the underlying filesystem request associated with the current event (i.e., the event that this method was called from).

The parameter is applicable only when a caller uses it to open the file, for which the event was fired. Also, the parameter should not be set to True when this method is called from the on_after_close_file event; when the event is fired, no file is open to synchronize operations with.

If Synchronize is True, this method and all operations with the resulting handle will be execute in the context of the external thread that originated the underlying filesystem request associated with the current event (which is important for on-the-fly file data modification like encryption), and the following restrictions will apply:

  • The method may be called from any event handlers with the exception of on_after_close_file and on_cleanup_context. Note: To be able to call the method from the on_before_create_file and on_before_open_file event handlers, set the AllowFileAccessInBeforeOpen configuration setting to True.
  • The method should be called only for the file or directory that the event fired for.
  • A file will be opened without buffering, which means that applications must comply with all restrictions imposed by the FILE_FLAG_NO_BUFFERING flag when reading and writing file data. Please refer to Microsoft's File Buffering article for more information.
There also exists a limitation in how the method works in the following scenario: if the method is called from a on_before_create_file or on_before_open_file event handler and the file doesn't exist and the method is used to create this file, then writing to this file from the same event handler will not work. The reason is that the file didn't exist at the moment when the event was fired, so the driver cannot synchronize the operations properly. The solution is to move the file writing step to the on_after_create_file and on_after_open_file event handler respectively. There, an application may use the handle obtained in on_before_create_file or on_before_open_file and write data to that file.

If Synchronize is False, this method and operations with the resulting handle are executed in the context of the thread in which the corresponding call is made, and the restrictions described above do not apply. This provides applications with greater flexibility because the returned file handle can be used in any event (as long as its handler complies with the general restrictions described by the Avoiding Deadlocks and Recursive Calls topics).

In both cases, the class must be active - that is, it must be started using a call to the start_filter method.

create_reparse_rules_snapshot Method

This method creates a snapshot of information about the reparse rules that have been added.

Syntax

def create_reparse_rules_snapshot(product_guid: str) -> None: ...

Remarks

This method creates a snapshot of information about all reparse rules that have been added by the application identified by ProductGUID. This information is then used to populate the ReparseRule* properties.

When the application is finished working with the reparse rules snapshot, it must close it by calling the close_reparse_rules_snapshot method to release the associated memory. If this method is called again before an existing snapshot is closed, the class will attempt to close it before creating a new one.

Note: This method cannot be called within events.

The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

create_virtual_file Method

This method is under construction.

Syntax

def create_virtual_file(file_name: str, desired_access: int, share_mode: int, creation_disposition: int, flags_and_attributes: int) -> int: ...

Remarks

This method is under construction.

delete_all_filter_rules Method

This method deletes all standard filter rules and access rules.

Syntax

def delete_all_filter_rules() -> bool: ...

Remarks

This method deletes all standard filter rules and access rules that are currently present.

If the rules are deleted successfully, this method returns True; otherwise, it returns False.

To delete standard filter rules or access rules individually, use the delete_filter_rule method instead.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

delete_all_passthrough_rules Method

This method deletes all passthrough rules.

Syntax

def delete_all_passthrough_rules() -> bool: ...

Remarks

This method deletes all passthrough rules that are currently present.

If the rules are deleted successfully, this method returns True; otherwise, it returns False.

To delete passthrough rules individually, use the delete_passthrough_rule method instead.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

delete_all_reparse_rules Method

This method deletes all reparse rules.

Syntax

def delete_all_reparse_rules(product_guid: str) -> bool: ...

Remarks

This method deletes all reparse rules associated with the application identified by ProductGUID.

If the rules are deleted successfully, this method returns True; otherwise, it returns False.

In most cases, the value passed for the ProductGUID parameter should be the same one that was used to call the initialize method. Please refer to the add_reparse_rule method's documentation for more information.

To delete reparse rules individually, use the delete_reparse_rule method instead.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

delete_default_rule Method

This method deletes a particular default rule.

Syntax

def delete_default_rule(mask: str, access_flags: int, product_guid: str) -> bool: ...

Remarks

This method deletes the specified AccessFlags from the default rule identified by Mask and associated with the application identified by ProductGUID. If AccessFlags includes all flags currently present in the rule, then the entire rule is deleted; otherwise, the flags specified by AccessFlags are simply removed from the rule.

If the flags or this rule are deleted successfully, this method returns True; otherwise, it returns False.

The Mask parameter must be the file mask of an existing rule. If a rule with the specified mask cannot be found, this method will fail.

The AccessFlags parameter specifies which access restrictions should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

In most cases, the value passed for the ProductGUID parameter should be the same one that was used to call the initialize method. Please refer to the add_default_rule method's documentation for more information.

This method requires administrative rights to execute successfully. If the user account of the process that calls this method doesn't have such rights, the call will fail with an ERROR_PRIVILEGE_NOT_HELD (0x0522) error. Please refer to the Default Rules topic for more information.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

delete_filter_rule Method

This method deletes a particular standard filter rule or access rule.

Syntax

def delete_filter_rule(mask: str, access_flags: int, control_flags: int, notify_flags: int) -> bool: ...

Remarks

This method deletes the specified AccessFlags, ControlFlags, and/or NotifyFlags from the standard filter rule and/or access rule identified by Mask. If the aforementioned parameters include all flags currently present in the rule, then the entire rule is deleted; otherwise, the specified flags are simply removed from the rule.

If the flags or this rule are deleted successfully, this method returns True; otherwise, it returns False.

The Mask parameter must be the file mask of an existing rule. If a rule with the specified mask cannot be found, this method will fail.

The AccessFlags parameter specifies which access restrictions should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ControlFlags parameter specifies which Control Event flags should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

The NotifyFlags parameter specifies which Notification Event flags should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

To delete all standard filter rules and access rules, use the delete_all_filter_rules method instead.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

delete_passthrough_rule Method

This method deletes a particular passthrough rule.

Syntax

def delete_passthrough_rule(mask: str, access_flags: int, control_flags: int, notify_flags: int) -> bool: ...

Remarks

This method deletes the specified AccessFlags, ControlFlags, and/or NotifyFlags from the passthrough rule identified by Mask. If the aforementioned parameters include all flags currently present in the rule, then the entire rule is deleted; otherwise, the specified flags are simply removed from the rule.

If the flags or this rule are deleted successfully, this method returns True; otherwise, it returns False.

The Mask parameter must be the file mask of an existing rule. If a rule with the specified mask cannot be found, this method will fail.

The AccessFlags parameter specifies which access restrictions should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

ACCESS_NONE0x00No access restrictions.

ACCESS_READ_ONLY0x01Read-only access; writing and deleting are prohibited.

ACCESS_WRITE_ONLY0x02Write-only access; reading and deleting are prohibited.

ACCESS_DELETE_PROTECT0x04Deleting and renaming are prohibited.

ACCESS_EXECUTE_PROTECT0x08Execution is prohibited.

ACCESS_NO_CHANGE_DAC0x10Change of security attributes is prohibited.

ACCESS_NO_CHANGE_OWNER0x20Change of owner is prohibited.

ACCESS_RENAME_PROTECT0x40Renaming is prohibited.

ACCESS_DELETE_ONLY_PROTECT0x80Deleting is prohibited (renaming is not affected).

ACCESS_REMOTE_ACCESS_PROTECT0x100Access from other systems is prohibited.

ACCESS_DENY_ALL0x200All access is denied.

ACCESS_ALL_FLAGS-1Used to denote all currently set access restriction flags.

The ControlFlags parameter specifies which Control Event flags should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_CE_NONE0Don't fire for any filesystem operations.

Control Events will not fire for any filesystem operations.

FS_CE_BEFORE_CREATE0x000000000001LFire before file creation operations.

The on_before_create_file event will fire anytime the OS attempts to create a file or directory. In some cases, this event can cause the on_before_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_CREATE0x000000000002LFire after file creation operations.

The on_after_create_file event will fire after a file or directory creation request has been processed, before the response is returned. In some cases, this event can cause the on_after_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_OPEN0x000000000004LFire before file open operations.

The on_before_open_file event will fire anytime the OS attempts to open a file or directory. In some cases, this event can cause the on_before_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_AFTER_OPEN0x000000000008LFire after file open operations.

The on_after_open_file event will fire after a file or directory open request has been processed, before the response is returned. In some cases, this event can cause the on_after_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_CE_BEFORE_READ0x000000000010LFire before read operations.

The on_before_read_file event will fire anytime the OS attempts to read data from a file.

FS_CE_AFTER_READ0x000000000020LFire after read operations.

The on_after_read_file event will fire after a read request has been processed, before the response is returned.

FS_CE_BEFORE_WRITE0x000000000040LFire before write operations.

The on_before_write_file event will fire anytime the OS attempts to write data to a file.

FS_CE_AFTER_WRITE0x000000000080LFire after write operations.

The on_after_read_file event will fire after a write request has been processed, before the response is returned.

FS_CE_BEFORE_LOCK_CONTROL0x000000000100LFire before lock and unlock operations.

The on_before_lock, on_before_unlock_all, on_before_unlock_all_by_key, and on_before_unlock_single events will fire, as applicable, before the OS attempts to lock or unlock a range of bytes in a file.

FS_CE_AFTER_LOCK_CONTROL0x000000000200LFire before and after lock and unlock operations.

The on_after_lock, on_after_unlock_all, on_after_unlock_all_by_key, and on_after_unlock_single, events will fire, as applicable, after a lock or unlock request has been processed, before the response is returned.

FS_CE_BEFORE_CLEANUP0x000000000400LFire before file handle cleanup operations.

The on_before_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_CE_AFTER_CLEANUP0x000000000800LFire after file handle cleanup operations.

The on_after_cleanup_file event will fire after a file handle cleanup request has been processed, before the response is returned.

FS_CE_BEFORE_CLOSE0x000000001000LFire before file close operations.

The on_before_close_file event will fire anytime the OS closes a file or directory. Also, the on_after_close_enumeration event will fire anytime the OS closes a directory enumeration (which typically occurs immediately before the directory is closed).

FS_CE_AFTER_CLOSE0x000000002000LFire after file close operations.

The on_after_close_file event will fire after a file/directory close request has been processed, before the response is returned.

FS_CE_BEFORE_CAN_DELETE0x000000004000LFire before 'can be deleted' operations.

The on_before_can_file_be_deleted event will fire anytime the OS checks whether a file or directory can be deleted.

FS_CE_AFTER_CAN_DELETE0x000000008000LFire after 'can be deleted' operations.

The on_after_can_file_be_deleted event will fire after a can be deleted request has been processed, before the response is returned.

FS_CE_BEFORE_DELETE0x000000010000LFire before delete operations

The on_before_delete_file event will fire anytime the OS attempts to delete a file or directory.

FS_CE_AFTER_DELETE0x000000020000LFire after delete operations.

The on_after_delete_file event will fire after a delete request has been processed, before the response is returned.

FS_CE_BEFORE_RENAME0x000000040000LFire before rename/move operations.

The on_before_rename_or_move_file event will fire anytime the OS attempts to rename or move a file or directory.

FS_CE_AFTER_RENAME0x000000080000LFire after rename/move operations.

The on_after_rename_or_move_file event will fire after a rename or move request has been processed, before the response is returned.

FS_CE_BEFORE_GET_SECURITY0x000000100000LFire before get security operations.

The on_before_get_file_security event will fire before the OS queries the security attributes of a file or directory.

FS_CE_AFTER_GET_SECURITY0x000000200000LFire after get security operations.

The on_after_get_file_security events will fire after a get security operation has been processed, before the response is returned.

FS_CE_BEFORE_ENUMERATE_DIRECTORY0x000000400000LFire before directory enumeration operations.

The on_before_enumerate_directory event will fire anytime the OS needs to read information about directory entries.

FS_CE_AFTER_ENUMERATE_DIRECTORY0x000000800000LFire after directory enumeration operations.

The on_after_enumerate_directory event will fire after information about a directory entry has been retrieved during directory enumeration, before the response is returned.

FS_CE_BEFORE_QUERY_FILE_INFO0x000001000000LFire before 'query file information' operations.

The on_before_query_file_info event will fire anytime the OS needs to retrieve information about a file or directory.

FS_CE_AFTER_QUERY_FILE_INFO0x000002000000LFire after 'query file information' operations.

The on_after_query_file_info event will fire after a file or directory information query request has been processed, before the response is returned.

FS_CE_AFTER_GET_SIZES0x000008000000LFire after get size operations.

The on_after_get_file_sizes event will fire after a file's size information is retrieved, before the response is returned.

FS_CE_BEFORE_SET_SECURITY0x000010000000LFire before set security operations.

The on_before_set_file_security event will fire anytime the OS needs to change the security attributes of a file or directory.

FS_CE_AFTER_SET_SECURITY0x000020000000LFire after set security operations.

The on_after_set_file_security event will fire after a security attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_ATTRIBUTES0x000040000000LFire before file attribute update operations.

The on_before_set_file_attributes event will fire anytime the OS attempts to change the attributes of a file or directory.

FS_CE_AFTER_SET_ATTRIBUTES0x000080000000LFire after file attribute update operations.

The on_after_set_file_attributes event will fire after a file attribute change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_SIZES0x000100000000LFire before file resize operations.

The on_before_set_file_size event will fire anytime the OS attempts to resize a file, and the on_before_set_allocation_size event will fire anytime the OS attempts to change a file's allocation size.

FS_CE_AFTER_SET_SIZES0x000200000000LFire after file resize operations.

The on_after_set_file_size event will fire after a file resize request has been processed, and the on_after_set_allocation_size event will fire after a file allocation size change request has been processed, before the response is returned.

FS_CE_BEFORE_CREATE_HARD_LINK0x000400000000LFire before hard link creation operations.

The on_before_create_hard_link event will fire anytime the OS attempts to create a hard link.

FS_CE_AFTER_CREATE_HARD_LINK0x000800000000LFire after hard link creation operations.

The on_after_create_hard_link events will fire after a hard link creation request has been processed, before the response is returned.

FS_CE_BEFORE_FSCTL0x001000000000LFire before FSCTL operations.

The on_before_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL request occurs.

FS_CE_AFTER_FSCTL0x002000000000LFire after FSCTL operations.

The on_after_fsctl event will fire after an IRP_MJ_FILE_SYSTEM_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_IOCTL0x004000000000LFire before IOCTL operations.

The on_before_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL request occurs.

FS_CE_AFTER_IOCTL0x008000000000LFire after IOCTL operations.

The on_after_ioctl event will fire after an IRP_MJ_DEVICE_CONTROL request has been processed, before the response is returned.

FS_CE_BEFORE_SET_FILE_INFO0x010000000000LFire before 'set file information' operations.

The on_before_set_file_info event will fire anytime the OS needs to change information about a file or directory.

FS_CE_AFTER_SET_FILE_INFO0x020000000000LFire after 'set file information' operations.

The on_after_set_file_info event will fire after a file or directory information change request has been processed, before the response is returned.

FS_CE_BEFORE_SET_EA0x040000000000LFire before Set Extended Attributes operations.

The on_before_set_ea event will fire anytime the OS needs to set extended attributes of a file.

FS_CE_AFTER_SET_EA0x080000000000LFire after Set Extended Attributes operations.

The on_after_set_ea event will fire after the OS request to set extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_QUERY_EA0x100000000000LFire before Query Extended Attributes operations.

The on_before_query_ea event will fire anytime the OS needs to retrieve extended attributes of a file.

FS_CE_AFTER_QUERY_EA0x200000000000LFire after Query Extended Attributes operations.

The on_after_query_ea event will fire after the OS request to retrieve extended attributes of a file has been processed, before the response is returned.

FS_CE_BEFORE_GET_REPARSE_POINT0x400000000000LFire before Get Reparse Point operations.

The on_before_get_reparse_point event will fire anytime the OS needs to read a reparse point of a file or directory.

FS_CE_AFTER_GET_REPARSE_POINT0x800000000000LFire after Get Reparse Point operations.

The on_after_get_reparse_point event will fire after the OS request to read a reparse point of a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_SET_REPARSE_POINT0x1000000000000LFire before Set Reparse Point operations.

The on_before_set_reparse_point event will fire anytime the OS needs to set or update a reparse point for a file or directory.

FS_CE_AFTER_SET_REPARSE_POINT0x2000000000000LFire after Set Reparse Point operations.

The on_after_set_reparse_point event will fire after the OS request to set or update a reparse point for a file or directory has been processed, before the response is returned.

FS_CE_BEFORE_DELETE_REPARSE_POINT0x4000000000000LFire before Delete Reparse Point operations.

The on_before_delete_reparse_point event will fire anytime the OS needs to remove reparse point information from a file or directory.

FS_CE_AFTER_DELETE_REPARSE_POINT0x8000000000000LFire after Delete Reparse Point operations.

The on_after_delete_reparse_point event will fire after the OS request to remove reparse point information from a file or directory has been processed, before the response is returned.

FS_CE_REPARSE_FILENAME0x40000000000000LFire before various operations for the purpose of file redirection.

The on_reparse_file_name event will fire before any operation that includes a file or directory name, giving the application a chance to redirect it. This event is typically used when an application requires more advanced redirection logic than Reparse Rules can provide; please refer to that topic for more information.

FS_CE_REPARSE_TAG0x80000000000000LFire for reparse operations.

The on_reparse_with_tag event will fire anytime a file/directory open operation returns a STATUS_REPARSE result, allowing the application to handle the reparse point. Please refer to Microsoft's Reparse Points article for more information.

FS_CE_ALL-1Fire for all filesystem operations.

Control Events will fire for all filesystem operations that the class tracks.

The NotifyFlags parameter specifies which Notification Event flags should be removed from the rule. The value passed for this parameter should be constructed by ORing together zero or more of the following flags:

FS_NE_NONE0Don't fire for any filesystem operations.

Notification Events will not fire for any filesystem operations.

FS_NE_CREATE0x00000001LFire for file creation operations.

The on_notify_create_file event will fire anytime the OS creates a file or directory. In some cases, this event can cause the on_notify_open_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_OPEN0x00000002LFire for file open operations.

The on_notify_open_file event will fire anytime the OS opens a file or directory. In some cases, this event can cause the on_notify_create_file event to fire; refer to the File Create/Open Events topic for more information.

FS_NE_READ0x00000004LFire for read operations.

The on_notify_read_file event will fire anytime the OS reads data from a file.

FS_NE_WRITE0x00000008LFire for write operations.

The on_notify_write_file event will fire anytime the OS writes data to a file.

FS_NE_LOCK_CONTROL0x00000010LFire for lock and unlock operations.

The on_notify_lock, on_notify_unlock_all, on_notify_unlock_all_by_key, and on_notify_unlock_single events will fire, as applicable, anytime the OS locks or unlocks a range of bytes in a file.

FS_NE_CLEANUP0x00000020LFire for file handle cleanup operations.

The on_notify_cleanup_file event will fire anytime a process closes a file or directory handle.

FS_NE_CLOSE0x00000040LFire for file close operations.

The on_notify_close_file event will fire anytime the OS closes a file or directory.

FS_NE_CAN_DELETE0x00000080LFire for 'can be deleted' operations.

The on_notify_can_file_be_deleted event will fire anytime the OS checks whether or not a file or directory can be deleted.

FS_NE_DELETE0x00000100LFire for delete operations.

The on_notify_delete_file event will fire anytime the OS deletes a file or directory.

FS_NE_RENAME0x00000200LFire for rename/move operations.

The on_notify_rename_or_move_file event will fire anytime the OS renames or moves a file or directory.

FS_NE_GET_SECURITY0x00000400LFire for get security operations.

The on_notify_get_file_security event will fire anytime the OS queries the security attributes of a file or directory.

FS_NE_ENUMERATE_DIRECTORY0x00000800LFire for directory enumeration operations.

The on_notify_enumerate_directory event will fire anytime the OS retrieves a directory entry during directory enumeration.

FS_NE_QUERY_FILE_INFO0x00001000LFire for QueryFileInformation operations.

The on_notify_query_file_info event will fire anytime the OS retrieves information about a file or directory.

FS_NE_GET_SIZES0x00002000LFire for get size operations.

The on_notify_get_file_sizes event will fire anytime the OS retrieves a file's size information.

FS_NE_SET_SECURITY0x00004000LFire for set security operations.

The on_notify_set_file_security event will fire anytime the OS changes the security attributes of a file or directory.

FS_NE_SET_ATTRIBUTES0x00008000LFire for file attribute update operations.

The on_notify_set_file_attributes event will fire anytime the OS changes the attributes of a file or directory.

FS_NE_SET_SIZES0x00010000LFire for file resize operations.

The on_notify_set_file_size event will fire anytime the OS resizes a file, and the on_notify_set_allocation_size event will fire anytime the OS changes a file's allocation size.

FS_NE_CREATE_HARD_LINK0x00020000LFire for hard link creation operations.

The on_notify_create_hard_link event will fire anytime the OS creates a hard link.

FS_NE_FSCTL0x00040000LFire for FSCTL operations.

The on_notify_fsctl event will fire anytime an IRP_MJ_FILE_SYSTEM_CONTROL operation occurs.

FS_NE_IOCTL0x00080000LFire for IOCTL operations.

The on_notify_ioctl event will fire anytime an IRP_MJ_DEVICE_CONTROL operation occurs.

FS_NE_SET_FILE_INFO0x00100000LFire for SetFileInformation operations.

The on_notify_set_file_info event will fire anytime the OS changes information about a file or directory.

FS_NE_SET_EA0x00200000LFire for Set Extended Attributes operations.

The on_notify_set_ea event will fire anytime the OS sets extended attributes of a file.

FS_NE_QUERY_EA0x00400000LFire for Query Extended Attributes operations.

The on_notify_query_ea event will fire anytime the OS retrieves extended attributes of a file.

FS_NE_GET_REPARSE_POINT0x00800000LFire for Get Reparse Point operations.

The on_notify_get_reparse_point event will fire anytime the OS reads reparse point information of a file or directory.

FS_NE_SET_REPARSE_POINT0x01000000LFire for Set Reparse Point operations.

The on_notify_set_reparse_point event will fire anytime the OS sets or updates reparse point information for a file or directory.

FS_NE_DELETE_REPARSE_POINT0x02000000LFire for Delete Reparse Point operations.

The on_notify_delete_reparse_point event will fire anytime the OS deletes reparse point information from a file or directory.

FS_NE_ALL-1Fire for all filesystem operations.

Notification Events will fire for all filesystem operations that the class tracks.

To delete all passthrough rules, use the delete_all_passthrough_rules method instead.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

delete_reparse_rule Method

This method deletes a particular reparse rule.

Syntax

def delete_reparse_rule(mask: str, product_guid: str) -> bool: ...

Remarks

This method deletes the ReparseRules identified by Mask and associated with the application identified by ProductGUID.

If the flags or this rule are deleted successfully, this method returns True; otherwise, it returns False.

The Mask parameter must be the file mask of an existing rule. If a rule with the specified mask cannot be found, this method will fail.

In most cases, the value passed for the ProductGUID parameter should be the same one that was used to call the initialize method. Please refer to the add_reparse_rule method's documentation for more information.

To delete all reparse rules, use the delete_all_reparse_rules method instead.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

file_matches_mask Method

This method checks whether a particular file or directory name matches the specified mask.

Syntax

def file_matches_mask(mask: str, file_name: str, case_sensitive: bool) -> bool: ...

Remarks

This method checks whether the file or directory name specified by FileName matches Mask; if it does, this method returns True. The CaseSensitive parameter controls whether a case-sensitive match should be performed.

Note: This method does not handle so-called DOS_* wildcards (DOS_STAR, DOS_QM, DOS_DOT). The explanation about the characters can be found in the MSDN article. If you have a mask that includes one of those characters on Windows, you can use the RtlIsNameInExpression function of Windows API.

Note: As the explanation states, "When you do a case-insensitive search and do not provide a translation table, the name is converted to uppercase."

get_driver_status Method

This method retrieves the status of the class's system driver.

Syntax

def get_driver_status(product_guid: str) -> int: ...

Remarks

This method retrieves the status of the class's system driver. This status can then be used to verify whether it has been properly installed and is ready for use.

The value returned by the method corresponds to the dwCurrentState field of the SERVICE_STATUS structure from the Windows API. It will be one of the following:

MODULE_STATUS_NOT_PRESENT0x00000000The specified module is not present on the system.

MODULE_STATUS_STOPPED0x00000001The specified module is in the Stopped state.

MODULE_STATUS_RUNNING0x00000004The specified module is loaded and running.

ProductGUID is used to distinguish among driver installations performed by different applications. Such information is necessary to guard against unexpected situations, such as the driver being uninstalled by one application despite other applications still needing it.

Therefore, to ensure proper operation, it is critical that each individual application have its own unique ProductGUID value, and that applications (and their installation scripts) use that value when calling any of the following methods:

This method is available in both the class API and the Installer DLL included with the product; please refer to the Driver Installation topic for more information about the latter.

Note: This method cannot be called within events.

get_driver_version Method

This method retrieves the version of the class's system driver.

Syntax

def get_driver_version(product_guid: str) -> int: ...

Remarks

This method retrieves the version of the class's system driver. The value is returned as a 64-bit integer composed of four 16-bit words that each correspond to a piece of the overall module version. For example, a version of 2.32.6.28 would cause the value 0x000200200006001C to be returned.

If the class's system driver is not installed, this method returns 0.

ProductGUID is used to distinguish among driver installations performed by different applications. Such information is necessary to guard against unexpected situations, such as the driver being uninstalled by one application despite other applications still needing it.

Therefore, to ensure proper operation, it is critical that each individual application have its own unique ProductGUID value, and that applications (and their installation scripts) use that value when calling any of the following methods:

This method is available in both the class API and the Installer DLL included with the product; please refer to the Driver Installation topic for more information about the latter.

Note: This method cannot be called within events.

get_event_filename Method

This method retrieves the name of the file or directory, to which the event applies.

Syntax

def get_event_filename() -> str: ...

Remarks

This method can be called within event handlers of events, related to the file or directory operations, to retrieve the name of the file or directory, to which the operation applies. If the query fails or an event does not have an associated filename, this method returns an empty string.

get_handle_creator_process_id Method

This method retrieves the Id of the process (PID) that opened the file handle.

Syntax

def get_handle_creator_process_id() -> int: ...

Remarks

This method can be called within certain events to retrieve the Id of the process (PID) that opened the file handle. If the query fails, this method returns 0.

Note: PIDs are not unique and may be reused by different processes over time (although in practice, this is uncommon).

Applications cannot use this method to retrieve information about remote processes accessing drives shared on the network. Windows does not provide such information due to the nature of remote access.

Note: This method can be called only within the on_after_create_file and on_after_open_file events, and must be called in the same thread that the event was originally fired on. Applications that need the information that this method returns during other events can do the following:

  1. Call this method within the on_after_create_file or on_after_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information through the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: This method cannot be used from on_cleanup_context event handlers.

get_handle_creator_process_name Method

This method retrieves the name of the process that opened the file handle.

Syntax

def get_handle_creator_process_name() -> str: ...

Remarks

This method can be called within certain events to retrieve the name of the process that opened the file handle. If the query fails, this method returns an empty string.

Applications cannot use this method to retrieve information about remote processes accessing drives shared on the network. Windows does not provide such information due to the nature of remote access.

Note: This method can be called only within the on_after_create_file and on_after_open_file events, and must be called in the same thread that the event was originally fired on. Applications that need the information that this method returns during other events can do the following:

  1. Call this method within the on_after_create_file or on_after_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information through the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: This method cannot be used from on_cleanup_context event handlers.

get_handle_creator_thread_id Method

This method retrieves the Id of the thread that opened the file handle.

Syntax

def get_handle_creator_thread_id() -> int: ...

Remarks

This method can be called within certain events to retrieve the Id of the thread that opened the file handle. If the query fails, this method returns 0.

Notes: Thread Ids are not unique and may be reused by different threads over time.

Note: This method can be called only within the on_after_create_file and on_after_open_file events, and must be called in the same thread that the event was originally fired on. Applications that need the information that this method returns during other events can do the following:

  1. Call this method within the on_after_create_file or on_after_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information through the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: This method cannot be used from on_cleanup_context event handlers.

get_handle_creator_token Method

This method retrieves the security token associated with the process that opened the file handle.

Syntax

def get_handle_creator_token() -> int: ...

Remarks

This method can be called within certain events to retrieve the security token associated with the process that opened the file handle. If the query fails, this method returns INVALID_HANDLE_VALUE.

The security token returned by this method can be passed to the Windows API's GetTokenInformation function to obtain more information about the process.

Note: When applications are finished using the returned security token, they must close it using the Windows API's CloseHandle function.

Network Access Notes

Applications monitoring a drive shared on the network may wish to obtain information about the network users accessing it (e.g., account names). Drives can be shared in several modes in Windows, which can affect the information retrievable via the security token this method returns:

  • Authenticated mode, in which case the network redirector (which, in general, is responsible for relaying remote drive requests to and from the system driver) will impersonate the network user, allowing that account's actual information to be retrieved.
  • Guest mode, in which case the retrievable information is for the system's GUEST account.
  • Administrative shares (those which exist by default and whose names end with '$'; e.g., C$, ADMIN$, etc.), in which case the retrievable information is for the LOCAL_SYSTEM account.

Note: This method can be called only within the on_after_create_file and on_after_open_file events, and must be called in the same thread that the event was originally fired on. Applications that need the information that this method returns during other events can do the following:

  1. Call this method within the on_after_create_file or on_after_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information through the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: This method cannot be used from on_cleanup_context event handlers.

get_operation_time Method

This method returns the time at which the request was received by the filter driver.

Syntax

def get_operation_time() -> datetime.datetime: ...

Remarks

This method can be called within operation-related events to retrieve the time at which the filter driver received the request. The time is recorded before an event is fired but only when the RecordOperationTime configuration setting is enabled.

The timestamps returned by this method are specified in UTC.

get_originator_process_id Method

Retrieves the Id of the process (PID) that initiated the operation.

Syntax

def get_originator_process_id() -> int: ...

Remarks

This method can be called within events fired for filesystem operations to retrieve the Id of the process (PID) that initiated the operation. If the query fails, this method returns 0.

Please note that PIDs are not unique, and may be reused by different processes over time (though in practice, this is uncommon).

Applications cannot use this method to retrieve information about remote processes accessing drives shared on the network. Windows does not provide such information due to the nature of remote access.

Note: This method can be called only within events, and it must be called in the same thread that the event was originally fired on. However, it must not be called within events that work with opened files since such events can be initiated by system components (e.g., the cache manager, memory manager, etc.). If applications need the information this method returns during such events, they may do the following:

  1. Call this method within the on_create_file or on_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information via the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: Renaming and deletion of files is performed after the file is opened. Thus, access checks should be performed during file opening as described above.

Note: This method cannot be used from on_cleanup_context event handlers.

get_originator_process_name Method

Retrieves the name of the process that initiated the operation.

Syntax

def get_originator_process_name() -> str: ...

Remarks

This method can be called within events fired for filesystem operations to retrieve the name of the process that initiated the operation. If the query fails, this method returns empty string.

Applications cannot use this method to retrieve information about remote processes accessing drives shared on the network. Windows does not provide such information due to the nature of remote access.

Note: This method can be called only within events, and it must be called in the same thread that the event was originally fired on. However, it must not be called within events that work with opened files since such events can be initiated by system components (e.g., the cache manager, memory manager, etc.). If applications need the information this method returns during such events, they may do the following:

  1. Call this method within the on_create_file or on_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information via the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: Renaming and deletion of files is performed after the file is opened. Thus, access checks should be performed during file opening as described above.

Note: This method cannot be used from on_cleanup_context event handlers.

get_originator_thread_id Method

Retrieves the Id of the thread that initiated the operation.

Syntax

def get_originator_thread_id() -> int: ...

Remarks

This method can be called within events fired for filesystem operations to retrieve the Id of the thread that initiated the operation. If the query fails, this method returns 0.

Please note that thread Ids are not unique, and may be reused by different threads over time.

Note: This method can be called only within events, and it must be called in the same thread that the event was originally fired on. However, it must not be called within events that work with opened files since such events can be initiated by system components (e.g., the cache manager, memory manager, etc.). If applications need the information this method returns during such events, they may do the following:

  1. Call this method within the on_create_file or on_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information via the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: Renaming and deletion of files is performed after the file is opened. Thus, access checks should be performed during file opening as described above.

Note: This method cannot be used from on_cleanup_context event handlers.

get_originator_token Method

Retrieves the security token associated with the process that initiated the operation.

Syntax

def get_originator_token() -> int: ...

Remarks

This method can be called within synchronous, i.e., Before* and After* events fired for filesystem operations to retrieve the security token associated with the process that initiated the operation. If the query fails, this method returns INVALID_HANDLE_VALUE. Note: This method will not work properly when called from Notify* event handlers because security tokens are not kept for possible later use. If you need to obtain security information about a request, use corresponding After* events.

The security token returned by this method can be passed to the Windows API's GetTokenInformation function to obtain more information about the process.

Important: When applications are finished using the returned security token, they must close it using the Windows API's CloseHandle function.

Network Access Notes

Applications monitoring a drive shared on the network may wish to obtain information about the network users accessing it (e.g., account names). Drives can be shared in several modes in Windows, which can affect the information retrievable via the security token this method returns:

  • Authenticated mode, in which case the network redirector (which, in general, is responsible for relaying remote drive requests to and from the system driver) will impersonate the network user, allowing that account's actual information to be retrieved.
  • Guest mode, in which case the retrievable information is for the system's GUEST account.
  • Administrative shares (those which exist by default and whose names end with '$'; e.g., C$, ADMIN$, etc.), in which case the retrievable information is for the LOCAL_SYSTEM account.

Note: This method can be called only within events, and it must be called in the same thread that the event was originally fired on. However, it must not be called within events that work with opened files since such events can be initiated by system components (e.g., the cache manager, memory manager, etc.). If applications need the information this method returns during such events, they may do the following:

  1. Call this method within the on_create_file or on_open_file event.
  2. Store the information somewhere, and store a reference to it in the event's HandleContext parameter.
  3. In a later event, access the information via the reference stored in HandleContext.
Please refer to the Contexts topic for more information on how to use events' context parameters.

Note: Renaming and deletion of files is performed after the file is opened. Thus, access checks should be performed during file opening as described above.

Note: This method cannot be used from on_cleanup_context event handlers.

get_remote_access_information Method

This method returns networking-related information about the operation.

Syntax

def get_remote_access_information(share_name: List[str], client_socket_address_buffer: int, client_socket_address_buffer_size: List[int]) -> None: ...

Remarks

Call this method from *CreateFile/*OpenFile events to retrieve the collected networking details information related to the filesystem operation performed across the network.

Note: The information will be available only when the CollectRemoteOpenInformation configuration setting is enabled.

This method returns the contents of one of two structures, SRV_OPEN_ECP_CONTEXT or NFS_OPEN_ECP_CONTEXT. These structures contain various networking information that differs depending on the remote access type. Please refer to MSDN for additional information.

Depending on the type of remote access, the information is extracted from one of those structures. When the method returns, ShareName will contain the value of either ShareName or ExportAlias field of the corresponding structure. ClientSocketAddressBuffer will contain the value of the SocketAddress or ClientSocketAddress field of the corresponding structure. This field is a structure of the SOCKADDR_STORAGE_NFS type.

When calling the method, an application needs to prepare the buffer of the required size and specify this size of the ClientSocketAddressBuffer buffer in the ClientSocketAddressBufferSize argument.

get_reparse_rule_by_mask Method

This method retrieves the reparse rule associated with the specified file mask.

Syntax

def get_reparse_rule_by_mask(mask: str, product_guid: str) -> str: ...

Remarks

This method retrieves the reparse rule identified by Mask and associated with the application identified by ProductGUID. If such a reparse rule is found, this method returns its reparse mask (see add_reparse_rule); otherwise, it returns empty string.

The Mask parameter must be the file mask of an existing rule.

In most cases, the value passed for the ProductGUID parameter should be the same one that was used to call the initialize method.

Note: The methods and properties related to rule management are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads (e.g., during the on_after_filter_attach_to_volume and on_after_filter_detach_from_volume events) are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of the rule lists both occur in a thread-safe manner.

get_volume_guid Method

This method retrieves the volume GUID of the device targeted by a filesystem operation.

Syntax

def get_volume_guid() -> str: ...

Remarks

This method can be called within events fired for filesystem operations to retrieve the volume GUID of the device targeted by the operation, returned in the Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} format. If the query fails, this method returns an empty string.

Volume GUIDs can be used to enumerate the mounting points of a device using the Windows API's GetVolumePathNamesForVolumeName function.

Note: This method can be called only within events.

initialize Method

This method initializes the class.

Syntax

def initialize(product_guid: str) -> None: ...

Remarks

This method initializes the class and must be called each time the application starts before attempting to call any of the class's other methods with the exception of installation-related methods.

ProductGUID is used to distinguish among driver installations performed by different applications. Such information is necessary to guard against unexpected situations, such as the driver being uninstalled by one application despite other applications still needing it.

Therefore, to ensure proper operation, it is critical that each individual application have its own unique ProductGUID value, and that applications (and their installation scripts) use that value when calling any of the following methods:

If the required driver was not installed using the install method with the same value of ProductGUID, initialize will return a ERROR_FILE_NOT_FOUND error (Win32 error code 2).

If the loaded kernel-mode driver is older than the user-mode API, initialize will return a ERROR_INVALID_KERNEL_INFO_VERSION error (Win32 error code 340). In this situation, an update of the driver using the install method is required before the class can be used.

install Method

This method installs (or upgrades) the class's system driver.

Syntax

def install(cab_file_name: str, product_guid: str, path_to_install: str, altitude: str, flags: int) -> bool: ...

Remarks

This method is used to install or upgrade the class's system driver. If the system must be rebooted to complete the installation process, this method returns True; otherwise, it returns False.

Important: To upgrade the class's driver, use only the install method. Previously installed versions of the driver should not be uninstalled first. Calling the install method will upgrade the previously installed version.

Please refer to the Driver Installation topic for more information.

CabFileName must be the path of the cbfilter.cab file containing the class's system driver.

Note: This .cab file must remain on the target system (or be available in some other way) after installation, as it is required to uninstall the driver from the system.

ProductGUID is used to distinguish among driver installations performed by different applications. Such information is necessary to guard against unexpected situations, such as the driver being uninstalled by one application despite other applications still needing it.

Therefore, to ensure proper operation, it is critical that each individual application have its own unique ProductGUID value, and that applications (and their installation scripts) use that value when calling any of the following methods:

PathToInstall controls where the driver is installed. Pass empty string (highly recommended) to automatically install them to the appropriate Windows system directory.

Altitude specifies the driver altitude to use . During development, you can use any acceptable altitude value. For deployment, an altitude value must be assigned by Microsoft before deploying a filesystem minifilter in production. After installation, the altitude can be changed at any time using the altitude property. Please refer to the Driver Altitudes topic for more information.

Flags specifies various installation options. It should contain zero or more of the following flags, ORed together:

INSTALL_REMOVE_OLD_VERSIONS0x00000001Uninstall drivers from previous class versions (e.g., 2017).

INSTALL_KEEP_START_TYPE0x00000002Keep the driver's current start type setting in the registry.

If this flag is not set (default), the installation logic will reset the driver's start type setting in the Windows registry to the default value. Setting this flag causes the installation logic to preserve the current value, which may be necessary if the user (or the application) set it previously.

INSTALL_REQUESTS_VIA_DRIVER_STACK0x00000004Whether internal requests to the filesystem are sent directly to the filesystem driver or through the stack of filesystem filter drivers.

This flag is applicable only for CBFilter and CBMonitor.

After installation, the effects of this flag can be changed using the SendRequestsViaDriverStack configuration setting.

INSTALL_ALWAYS_PREPARE_FILES0x00010000Whether the driver should keep track of information for files that are already open when (i.e., were opened before) the class is initialized.

This flag is applicable only for CBFilter and CBMonitor.

If this flag is set, the driver will prepare information about each file as it is opened, regardless of whether a CBFilter/CBMonitor-based application is actually running at the time. This information then allows applications to receive events for any files that are already open when the CBFilter/CBMonitor class is initialized.

Note: These preparations will slow down all file open operations; do not enable this feature unless it is actually necessary.

After installation, the effects of this flag can be changed using the AlwaysPrepareFiles configuration setting.

INSTALL_FORCE_APP_PERMISSION_CHECK0x00020000Whether the driver should require the controller process to have elevated or system privileges.

This flag is not applicable for CBProcess.

If this flag is set, the driver will verify that the controller process is a system service (or is executing with elevated privileges) anytime a file is opened. If the controller process does not meet these requirements, the file will be skipped (i.e., not filtered in any way).

Note: This additional verification will slow down all file open operations.

After installation, the effects of this flag can be changed using the ForceAppPermissionCheck configuration setting.

INSTALL_FORCE_SECURITY_CHECKS0x00040000Whether the driver should prevent the controller process from filtering files that it would not normally have access to.

This flag is not applicable for CBProcess.

If this flag is set, the driver will check the security permissions of the controller process anytime a file is opened to verify that the process has access to the file. If the controller process does not have access to the file, the file will be skipped (i.e., not filtered in any way). For example, if this flag is set and the controller process is running with limited privileges, then the driver will not allow it to filter files that require greater privileges to access.

Note: This additional verification will slow down all file open operations.

After installation, the effects of this flag can be changed using the ForceSecurityChecks configuration setting.

Note: Enabling the AlwaysPrepareFiles and/or SendRequestsViaDriverStack configuration settings before calling this method will cause the corresponding flags to be added automatically. These configuration settings can also be used to toggle the corresponding options at any time after installation.

This method is available in both the class API and the Installer DLL included with the product; please refer to the Driver Installation topic for more information about the latter.

This method requires administrative rights to execute successfully. If the user account of the process that calls this method doesn't have such rights, the call will fail with an ERROR_PRIVILEGE_NOT_HELD (0x0522) error.

Note: This method cannot be called within events.

is_file_filtered Method

This method checks whether a particular file or directory is covered by any filter rules.

Syntax

def is_file_filtered(file_name: str) -> bool: ...

Remarks

This method checks whether the file or directory specified by FileName is covered by any of the standard filter rules active currently (i.e., whether the class would fire its events for one or more kinds of filesystem operations performed on it). If the specified file or directory matches any of the active standard filter rules, this method returns True; otherwise, it returns False.

Applications should use this method anytime they want to create/open some file or directory from within an event handler. If this method returns True, then the file or directory must be created/opened using the class's create_file_direct method rather than the Windows API's CreateFile function, because the latter could trigger recursion and cause a system deadlock.

nt_status_to_win_32_error Method

This method converts a native status code to a Win32 error code.

Syntax

def nt_status_to_win_32_error(status: int) -> int: ...

Remarks

This method converts the native status code specified by Status to a Win32 error code. If the specified native status code does not map directly to a Win32 error code, this method returns ERROR_MR_MID_NOT_FOUND (317).

reset_timeout Method

This method resets the timeout duration for the current event handler.

Syntax

def reset_timeout(timeout: int) -> bool: ...

Remarks

When event timeouts are being enforced, this method can be called within an event handler to inform the class that request processing is taking longer than expected.

If called successfully, this method returns True, and the current event handler's timeout timer is immediately reset to 0; when it reaches the number of milliseconds specified by Timeout, the driver will either "release" the underlying request and pass it onwards, or cancel it by reporting an error; whichever is most appropriate for the event in question. Please refer to the Timeouts topic for more information.

Passing 0 for Timeout disables the timeout timer for the current event handler, allowing it to take as long as it needs to complete.

Note: When several events are fired for the same file concurrently (if the SerializeAccess configuration setting is disabled), and reset_timeout is called from one of the handlers of these events, this method will reset the timer for all currently executed event handlers.

Note: This method can be called only within events.

set_file_information_direct Method

This method sets the file information of a file opened using CreateFileDirect.

Syntax

def set_file_information_direct(file_handle: int, information_class: int, file_information: bytes) -> None: ...

Remarks

Applications may call this method to change various kinds of information about a file that was opened using the create_file_direct method.

The FileHBut Iandle parameter specifies the file that should be updated. The value passed for this parameter must be a file handle obtained from the create_file_direct method; please refer to its documentation for more information.

The InformationClass parameter specifies the class of information to be set. For the list of supported classes, please refer to the documentation of the Windows API's FltSetInformationFile function.

Note: Only a limited subset of classes comparing to similar functions like NtSetInformationFile or NtQueryInformationFile is supported by this function.

FileInformation is a buffer that must contain the information to be set. The exact size and format of the information depend on InformationClass and are described in the FltSetInformationFile help topic.

set_file_size_direct Method

This method resizes a file by passing the request directly to the filesystem.

Syntax

def set_file_size_direct(file_handle: int, size: int) -> bool: ...

Remarks

Applications can call this method in filesystem-related event handlers to resize a file without sending the request through the filesystem filter driver stack. If the file is resized successfully, this method returns True; otherwise, it returns False.

The FileHandle parameter specifies the file that should be resized. The value passed for this parameter must be a file handle obtained from the create_file_direct method; please refer to its documentation for more information.

The Size parameter specifies the new file size, in bytes.

To set file allocation size or valid file length, you may use the set_file_information_direct method.

Note: This method can be called only within events.

shutdown_system Method

Shuts down or reboots the operating system.

Syntax

def shutdown_system(shutdown_prompt: str, timeout: int, force_close_apps: bool, reboot: bool) -> bool: ...

Remarks

This method shuts down or (if Reboot is True) reboots the operating system. If the appropriate privileges cannot be obtained, or if the InitiateSystemShutdown system call returns False, then this method will return False; otherwise, it returns True. This method can be used if the installation or uninstallation function requires the system to be rebooted in order to complete.

ShutdownPrompt, if non-empty, specifies a message that the OS should display to the user for Timeout seconds. If empty string is passed for ShutdownPrompt, no message is displayed and the Timeout parameter's value is ignored.

ForceCloseApps specifies whether the OS should forcefully close all applications. Please keep in mind that forceful closing of applications with unsaved data can lead to data loss.

Reboot specifies whether the OS should reboot (True) or just shut down (False).

This method is available in both the class API and the Installer DLL included with the product; please refer to the Driver Installation topic for more information about the latter.

Note: This method cannot be called within events.

start_filter Method

This method starts filtering filesystem operations.

Syntax

def start_filter(timeout: int) -> None: ...

Remarks

This method attaches the filter, causing the class's system driver to start filtering filesystem operations according to the filter rules currently present. Rules can be added and removed both before and after this method is called, so long as the initialize method is called before doing anything else.

The Timeout parameter specifies how many milliseconds the driver should wait for events to execute before releasing or cancelling the underlying OS requests; please refer to the Timeouts topic for more information. Valid values are 0, which disables event timeouts, and values greater than or equal to 3000. When event timeouts are in effect, event handlers can call reset_timeout to reset the timer if they require additional time to complete.

This method can fail for a number of reasons, including (but not limited to) the following:

  • If the class's system driver has not been properly installed, or is awaiting a system reboot (as indicated by the return value of install), this method fails with an ERROR_FILE_NOT_FOUND (2) error code.
  • If the initialize method has not been called yet, this method fails with an ERROR_NOT_READY (21) error code.
  • If the filter is already active, this method fails with an ERROR_CONNECTION_ACTIVE (1230) error code.
  • If an invalid value is passed for Timeout, this method fails with an ERROR_IMPLEMENTATION_LIMIT (1292) error code.

stop_filter Method

This method stops filtering filesystem operations.

Syntax

def stop_filter(reserved: bool) -> None: ...

Remarks

This method detaches the filter, causing the class's system driver to stop filtering filesystem operations. This method will block until all pending requests have been completed and the filter has been detached.

The Reserved parameter is obsolete.

suspend_default_rules Method

This method suspends all default rules until the application exits.

Syntax

def suspend_default_rules(product_guid: str) -> bool: ...

Remarks

This method suspends (i.e., deactivates) all default rules associated with the application identified by ProductGUID until the application exits. If the rules are suspended successfully, this method returns True; otherwise, it returns False.

In most cases, the value passed for the ProductGUID parameter should be the same one that was used to call the initialize method.

When the application exits, the class's system driver will reactivate the suspended rules and start enforcing them once again.

suspend_file_events Method

This method suspends all events for a particular file or directory until all of its handles have been closed.

Syntax

def suspend_file_events() -> None: ...

Remarks

Applications can call this method from an on_after_create_file or on_after_open_file event to suspend all further events for the file or directory that the event fired for. The suspension will remain in effect until all handles to said file or directory have been closed, at which point the class will once again fire events for it (if it is accessed again).

Typically, this method should be used only as a "last resort"; that is, when the application cannot achieve the same outcome through the use of more granular standard filter rules. Said another way, it is almost always more efficient for an application to exclude files or directories implicitly using standard filter rules, if possible, than it is to exclude them explicitly using this method.

Note: This method can be called only within the on_after_create_file and on_after_open_file events.

toggle_process_protection Method

This method enables or disables termination protection for the application.

Syntax

def toggle_process_protection(enabled: bool) -> bool: ...

Remarks

This method controls the termination protection mechanism, which applications can enable to prevent their process and threads from being terminated. If successful, this method returns True; otherwise, it returns False.

The Enabled parameter specifies whether termination protection should be enabled (True) or disabled (False); it is disabled by default. If termination protection is enabled, an application must disable it before attempting to exit.

Note: When developing a GUI-based application, please keep in mind that the termination protection mechanism does not intercept Windows' notifications like WM_CLOSE or WM_QUIT; applications must intercept and handle such messages themselves if they wish to protect their UI. Please refer to Microsoft's Window Notifications articles for more information.

uninstall Method

This method uninstalls the class's system driver.

Syntax

def uninstall(cab_file_name: str, product_guid: str, installed_path: str, flags: int) -> bool: ...

Remarks

This method is used to uninstall the class's system driver. If the system must be rebooted to complete the uninstallation process, this method returns True; otherwise, it returns False.

Important: To upgrade the class's driver, use only the install method. Previously installed versions of the driver should not be uninstalled first. Calling the install method will upgrade the previously installed version.

Please refer to the Driver Installation topic for more information.

The same values must be passed for the CabFileName, ProductGUID, and InstalledPath parameters as were passed when install was called; please refer to its documentation for more information.

Flags specifies which versions of the class's system driver should be uninstalled and which should be set by ORing together one or more of the following values:

UNINSTALL_VERSION_PREVIOUS0x00000001Uninstall modules from previous product versions.

UNINSTALL_VERSION_CURRENT0x00000002Uninstall modules from the current product version.

UNINSTALL_VERSION_ALL0x00000003Uninstall modules from all product versions.

This method is available in both the class API and the Installer DLL included with the product; please refer to the Driver Installation topic for more information about the latter.

This method requires administrative rights to execute successfully. If the user account of the process that calls this method doesn't have such rights, the call will fail with an ERROR_PRIVILEGE_NOT_HELD (0x0522) error.

Note: This method cannot be called within events.

on_after_can_file_be_deleted Event

This event fires after the OS marks a file or directory for deletion or removes such a mark.

Syntax

class CBFilterAfterCanFileBeDeletedEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def request_type() -> int: ...

  @property
  def can_delete() -> bool: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_can_file_be_deleted() -> Callable[[CBFilterAfterCanFileBeDeletedEventParams], None]: ...
@on_after_can_file_be_deleted.setter
def on_after_can_file_be_deleted(event_hook: Callable[[CBFilterAfterCanFileBeDeletedEventParams], None]) -> None: ...

Remarks

This event fires after the OS marks the file or directory specified by FileName for deletion or removes such a mark.

If the file or directory is marked for deletion, they will not be removed immediately but will actually be removed when the last handle is closed. Moreover, it is possible that a future call to a system function will remove the mark, so this event is not a final indicator that the file or directory will be deleted.

Files and directories can be deleted in two ways: (1) a file or directory can be opened with the FILE_FLAG_DELETE_ON_CLOSE flag, or (2) some process may call Windows API's NtSetInformationFile function with FILE_DISPOSITION_INFORMATION or FILE_DISPOSITION_INFORMATION_EX structure as a parameter.

If the file or directory is created or opened with the FILE_FLAG_DELETE_ON_CLOSE flag, this event is fired shortly after the on_after_create_file or on_after_open_file event.

The RequestType indicates which kind of system request resulted in firing this event. It can be one of the following:

DEL_REQ_OPEN_FLAG0x1The file or directory is opened with the FILE_FLAG_DELETE_ON_CLOSE flag

DEL_REQ_SET_DISPOSITION0x2The system has sent the IRP_MJ_SET_INFORMATION request with SetFileDisposition structure as a parameter.

This request usually is sent using the NtSetInformationFile() Windows native API function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_CAN_DELETE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The CanDelete parameter reflects whether the file or directory will be deleted.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_cleanup_file Event

This event fires after a file or directory handle is closed.

Syntax

class CBFilterAfterCleanupFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_cleanup_file() -> Callable[[CBFilterAfterCleanupFileEventParams], None]: ...
@on_after_cleanup_file.setter
def on_after_cleanup_file(event_hook: Callable[[CBFilterAfterCleanupFileEventParams], None]) -> None: ...

Remarks

This event fires after a handle to the file or directory specified by FileName is closed. This event differs from on_after_close_file in that on_after_cleanup_file fires immediately after an open handle to the specified file or directory is closed by a process, whereas on_after_close_file may be fired much later when the OS decides that the file or directory can be formally closed.

Other events may fire for the file or directory in the time between when this event fires and when the on_after_close_file event fires. For example, system components, such as the memory manager or cache manager, may cause the on_after_read_file and on_after_write_file events to fire.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_CLEANUP flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_close_enumeration Event

This event fires after a directory enumeration operation finishes.

Syntax

class CBFilterAfterCloseEnumerationEventParams(object):
  @property
  def directory_name() -> str: ...

  @property
  def directory_context() -> int: ...

  @property
  def handle_context() -> int: ...

  @property
  def enumeration_context() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_close_enumeration() -> Callable[[CBFilterAfterCloseEnumerationEventParams], None]: ...
@on_after_close_enumeration.setter
def on_after_close_enumeration(event_hook: Callable[[CBFilterAfterCloseEnumerationEventParams], None]) -> None: ...

Remarks

This event fires after enumeration of the directory specified by DirectoryName finishes.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_CLOSE flag (directory enumerations are typically closed immediately before a directory is closed).

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The EnumerationContext parameter is a placeholder for application-defined data associated with the enumeration. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_close_file Event

This event fires after a file or directory is closed.

Syntax

class CBFilterAfterCloseFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_close_file() -> Callable[[CBFilterAfterCloseFileEventParams], None]: ...
@on_after_close_file.setter
def on_after_close_file(event_hook: Callable[[CBFilterAfterCloseFileEventParams], None]) -> None: ...

Remarks

This event fires after the file or directory specified by FileName is closed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_CLOSE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

If the file or directory was marked for deletion earlier, the on_after_delete_file will fire shortly before this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_create_file Event

This event fires after a file or directory is created.

Syntax

class CBFilterAfterCreateFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def existing_attributes() -> int: ...

  @property
  def isolate() -> bool: ...

  @property
  def backend_file_name() -> str: ...

  @property
  def desired_access() -> int: ...

  @property
  def attributes() -> int: ...

  @property
  def share_mode() -> int: ...

  @property
  def options() -> int: ...

  @property
  def create_disposition() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_create_file() -> Callable[[CBFilterAfterCreateFileEventParams], None]: ...
@on_after_create_file.setter
def on_after_create_file(event_hook: Callable[[CBFilterAfterCreateFileEventParams], None]) -> None: ...

Remarks

This event fires after the file or directory specified by FileName is created. Please refer to the File Create/Open Events topic for more information about how the class determines whether to fire this event or on_after_open_file.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_CREATE flag.

Note: Applications must have the FilterOwnRequests configuration setting enabled if they wish to filter their own file/directory creation requests.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

When extended rules are used or the AlwaysRequestAttributesOnOpen configuration setting is enabled, the driver requests attributes of the entity from the filesystem and passes them to ExistingAttributes. If the attributes are not requested, this parameter contains 0.

Isolation-related functionality is under construction.

The DesiredAccess, Attributes, ShareMode, and CreateDisposition parameters reflect the values that were passed for the similarly named parameters of the Windows API's CreateFile function (or, more accurately, the values carried by the IRP_MJ_CREATE IRP).

DesiredAccess may contain one or more of the following access flags:

DESIRED_ACCESS_FILE_LIST_DIRECTORY0x00000001For a directory, the right to list the contents of the directory.

DESIRED_ACCESS_FILE_READ_DATA0x00000001For a file object, the right to read the corresponding file data.

For a directory object, the right to read the corresponding directory data.

DESIRED_ACCESS_FILE_ADD_FILE0x00000002For a directory, the right to create a file in the directory.

DESIRED_ACCESS_FILE_WRITE_DATA0x00000002For a file object, the right to write data to the file.

For a directory object, the right to create a file in the directory

DESIRED_ACCESS_FILE_ADD_SUBDIRECTORY0x00000004For a directory, the right to create a subdirectory.

DESIRED_ACCESS_FILE_APPEND_DATA0x00000004For a file object, the right to append data to the file.

(For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) For a directory object, the right to create a subdirectory (FILE_ADD_SUBDIRECTORY).

DESIRED_ACCESS_FILE_READ_EA0x00000008The right to read extended file attributes.

DESIRED_ACCESS_FILE_WRITE_EA0x00000010The right to write extended file attributes.

DESIRED_ACCESS_FILE_EXECUTE0x00000020For a native code file, the right to execute the file.

This access right given to scripts may cause the script to be executable, depending on the script interpreter.

DESIRED_ACCESS_FILE_DELETE_CHILD0x00000040For a directory, the right to delete a directory and all the files it contains, including read-only files.

DESIRED_ACCESS_FILE_READ_ATTRIBUTES0x00000080The right to read file attributes.

DESIRED_ACCESS_FILE_WRITE_ATTRIBUTES0x00000100The right to write file attributes.

DESIRED_ACCESS_READ_CONTROL0x00020000The right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_READ0x00020000Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_WRITE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_STANDARD_RIGHTS_EXECUTE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_SYNCHRONIZE0x00100000The right to use the object for synchronization.

This enables a thread to wait until the object is in the signaled state. Some object types do not support this access right.

DESIRED_ACCESS_FILE_ALL_ACCESS0x001F01FFAll possible access rights for a file.

DESIRED_ACCESS_FILE_GENERIC_READ0x00120089A combinarion of flags that allow reading of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_WRITE0x00120116A combinarion of flags that allow modifications to the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_EXECUTE0x001200A0A combinarion of flags that allow execution of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

Attributes may contain one or more of the following attributes:

FILE_SYS_ATTR_READ_ONLY0x00000001The file is read-only.

Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.

FILE_SYS_ATTR_HIDDEN0x00000002The file or directory is hidden.

The file is not included in an ordinary directory listing.

FILE_SYS_ATTR_SYSTEM0x00000004A file or directory that the operating system uses a part of, or uses exclusively.

FILE_SYS_ATTR_DIRECTORY0x00000010The entry is a directory.

FILE_SYS_ATTR_ARCHIVE0x00000020The entry is an archive file or directory.

Applications typically use this attribute to mark files for backup or removal.

FILE_SYS_ATTR_NORMAL0x00000080A file doesn't have other attributes set.

This attribute is valid only when used alone.

FILE_SYS_ATTR_TEMPORARY0x00000100A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data are written after the handle is closed.

FILE_SYS_ATTR_SPARSE_FILE0x00000200A file that is a sparse file.

FILE_SYS_ATTR_REPARSE_POINT0x00000400A file that is a reparse point or a symbolic link.

FILE_SYS_ATTR_COMPRESSED0x00000800A file or directory that is compressed.

For a file, all of the data in the file are compressed. For a directory, compression is the default for newly created files and subdirectories. A filesystem implementation can make use of this attribute by setting the support_compressed_attribute property to True and then properly handling the on_get_file_info, on_enumerate_directory, and on_set_file_attributes events.

FILE_SYS_ATTR_OFFLINE0x00001000The data of a file are not available immediately.

This attribute indicates that the file data are physically moved to offline storage.

FILE_SYS_ATTR_NOT_CONTENT_INDEXED0x00002000The file or directory is not to be indexed by the content indexing service.

FILE_SYS_ATTR_ENCRYPTED0x00004000A file or directory that is encrypted.

For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.

Note: This flag is used by NTFS and the OS sends undocumented requests to the filesystem based on this flag. The flag should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_VIRTUAL0x00010000Reserved.

Note: This flag is reserved by the OS and should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_RECALL_ON_OPEN0x00040000The file or directory has no physical representation on the local system; the item is virtual.

Opening the item will be more expensive than normal (e.g., it will cause at least some of it to be fetched from a remote store). This flag is reported by filesystems during directory enumerations.

ShareMode may contain zero or more of the following share mode flags:

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CreateDisposition may contain one of the following values:

FILE_DISPOSITION_CREATE_NEW0x00000001Creates a new file, only if it does not already exist.

If the specified file exists, the operation fails with an "already exists" error.

FILE_DISPOSITION_CREATE_ALWAYS0x00000002Creates a new file, always.

If the specified file exists and is writable, the system overwrites the file. If the specified file does not exist and is a valid path, a new file is created.

FILE_DISPOSITION_OPEN_EXISTING0x00000003Opens a file, only if it exists

If the specified file does not exist, opening fails.

FILE_DISPOSITION_OPEN_ALWAYS0x00000004Opens a file, always.

If the specified file exists, the operation succeeds. If the specified file does not exist and is a valid path to a writable location, the a file is created.

FILE_DISPOSITION_TRUNCATE_EXISTING0x00000005Opens a file and truncates it so that its size is zero bytes, only if it exists.

If the specified file does not exist, the operation fails with a "file not found" error.

Options contains the flags that are described in the CreateOptions parameter of the native API's ZwCreateFile function. Most of those flags correspond to flags passed in the FlagsAndAttributes parameter of the Windows API's CreateFile function, but some flags are specific to the native API. If you need those flags, check both functions' descriptions.

Please refer to Microsoft's documentation for detailed information about these constants.

To determine whether the request was for a file or a directory, compare Attributes against the FILE_SYS_ATTR_DIRECTORY constant, as follows: // Check whether the request is for a file or a directory. bool isDirectory = Attributes & FILE_SYS_ATTR_DIRECTORY == FILE_SYS_ATTR_DIRECTORY; FILE_SYS_ATTR_DIRECTORY will be present if it was specified by the calling process or if the existing filesystem entry is a directory.

To determine whether a file will be deleted when its last handle is closed, compare Options against the Windows API's FILE_FLAG_DELETE_ON_CLOSE constant, as follows: // Check whether the file will be deleted on close. bool deleteOnClose = Options & FILE_FLAG_DELETE_ON_CLOSE == FILE_FLAG_DELETE_ON_CLOSE; Note: Because files can be deleted in different ways, do not use this check to take actions related to tracking file deletion operations. Instead, use the events related to file deletion.

When a file or directory is created using the CreateFile() Windows API function, a caller can specify the security descriptor with the security information. This security information should be applied to a newly created file or directory. The class passes this security information in the SecurityInformation and SecurityDescriptor parameters, when the PassSecurityInFileOpenEvents configuration setting is enabled. If this configuration setting is omitted, the corresponding parameters are empty.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, are valid and should have been applied. Please refer to Microsoft's SECURITY_INFORMATION data type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

If the Options contains the FILE_FLAG_DELETE_ON_CLOSE flag, the on_after_can_file_be_deleted event will fire after this event.

If the file is created with Extended Attributes passed in the request, the on_after_set_ea event will fire after this event.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

When the process_failed_requests property is enabled, this event may fire even if the specified file or directory has not been created or opened, in which case the Status parameter will be non-zero. When this occurs, applications must not alter the FileContext and HandleContext parameters.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_create_hard_link Event

This event fires after a hard link is created.

Syntax

class CBFilterAfterCreateHardLinkEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def link_name() -> str: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_create_hard_link() -> Callable[[CBFilterAfterCreateHardLinkEventParams], None]: ...
@on_after_create_hard_link.setter
def on_after_create_hard_link(event_hook: Callable[[CBFilterAfterCreateHardLinkEventParams], None]) -> None: ...

Remarks

This event fires after a hard link to the file specified by FileName is created. Please refer to Microsoft's Hard Links article for more information about hard links.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_CREATE_HARD_LINK flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The LinkName parameter reflects the name of the created hard link.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_delete_file Event

This event fires after a file or directory is deleted.

Syntax

class CBFilterAfterDeleteFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def request_type() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_delete_file() -> Callable[[CBFilterAfterDeleteFileEventParams], None]: ...
@on_after_delete_file.setter
def on_after_delete_file(event_hook: Callable[[CBFilterAfterDeleteFileEventParams], None]) -> None: ...

Remarks

This event fires after the file or directory specified by FileName is deleted. More specifically, this event is fired after the final IRP_MJ_CLOSE IRP is processed by the filesystem (i.e., after the last handle to the file or directory is closed and the file or directory is gone) and before on_after_close_file fires.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_DELETE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The RequestType indicates which kind of system request resulted in firing this event. It can be one of the following:

DEL_REQ_OPEN_FLAG0x1The file or directory is opened with the FILE_FLAG_DELETE_ON_CLOSE flag

DEL_REQ_SET_DISPOSITION0x2The system has sent the IRP_MJ_SET_INFORMATION request with SetFileDisposition structure as a parameter.

This request usually is sent using the NtSetInformationFile() Windows native API function.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_delete_reparse_point Event

This event fires after the OS deletes a reparse point from a file or directory.

Syntax

class CBFilterAfterDeleteReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_delete_reparse_point() -> Callable[[CBFilterAfterDeleteReparsePointEventParams], None]: ...
@on_after_delete_reparse_point.setter
def on_after_delete_reparse_point(event_hook: Callable[[CBFilterAfterDeleteReparsePointEventParams], None]) -> None: ...

Remarks

This event fires after the OS deletes a reparse point from a file or directory specified by FileName.

Note: The file or directory is not deleted, only a reparse point is.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_DELETE_REPARSE_POINT flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The ReparseBuffer parameter points to a memory buffer that specifies the known reparse point information. This information is provided for convenience. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Please refer to the Reparse Points topic for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_enumerate_directory Event

This event fires after a directory entry is returned during directory enumeration.

Syntax

class CBFilterAfterEnumerateDirectoryEventParams(object):
  @property
  def directory_name() -> str: ...

  @property
  def flags() -> int: ...

  @property
  def index() -> int: ...

  @property
  def file_name() -> str: ...
  @file_name.setter
  def file_name(value) -> None: ...

  @property
  def creation_time() -> datetime.datetime: ...
  @creation_time.setter
  def creation_time(value) -> None: ...

  @property
  def last_access_time() -> datetime.datetime: ...
  @last_access_time.setter
  def last_access_time(value) -> None: ...

  @property
  def last_write_time() -> datetime.datetime: ...
  @last_write_time.setter
  def last_write_time(value) -> None: ...

  @property
  def change_time() -> datetime.datetime: ...
  @change_time.setter
  def change_time(value) -> None: ...

  @property
  def size() -> int: ...
  @size.setter
  def size(value) -> None: ...

  @property
  def allocation_size() -> int: ...
  @allocation_size.setter
  def allocation_size(value) -> None: ...

  @property
  def file_id() -> int: ...
  @file_id.setter
  def file_id(value) -> None: ...

  @property
  def attributes() -> int: ...
  @attributes.setter
  def attributes(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def directory_context() -> int: ...
  @directory_context.setter
  def directory_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def enumeration_context() -> int: ...
  @enumeration_context.setter
  def enumeration_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_enumerate_directory() -> Callable[[CBFilterAfterEnumerateDirectoryEventParams], None]: ...
@on_after_enumerate_directory.setter
def on_after_enumerate_directory(event_hook: Callable[[CBFilterAfterEnumerateDirectoryEventParams], None]) -> None: ...

Remarks

This event fires after a directory entry (i.e., a file or subdirectory) is returned during enumeration of the directory specified by DirectoryName.

Applications may use this event to modify the entry's metadata before it gets reported to the requestor or even to prevent the entry from being reported in the first place.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_ENUMERATE_DIRECTORY flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Flags parameter specifies supplementary information about enumeration. It is a combination of zero or more values:

FS_ENUM_RESTART_SCAN1The requestor specified that directory enumeration must be restarted.

FS_ENUM_RETURN_SINGLE_ENTRY2One entry should be returned.

FS_ENUM_INDEX_SPECIFIED4The requestor specified the index to start enumeration from.

If the Flags parameter contains FS_ENUM_INDEX_SPECIFIED, the Index parameter contains the index as provided by the OS.

The FileName parameter reflects the name of the directory entry. .

The CreationTime, LastAccessTime, LastWriteTime, and ChangeTime parameters specify the entry's time values, specified in UTC.

The Size parameter specifies the size of the file, in bytes; it must always be 0 for subdirectories.

The AllocationSize parameter specifies the amount of space allocated for the file, in bytes; it must always be 0 for subdirectories.

The FileId parameter specifies the unique Id of the entry, as reported by the filesystem (or, for virtual files, by the application itself). This Id is used by the network redirector, and some third-party applications, to open files and directories by Id instead of by name. The root directory always uses the predefined Id 0x7FFFFFFFFFFFFFFF.

The Attributes parameter specifies the entry's attributes; please refer to Microsoft's File Attribute Constants article for attribute descriptions.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The DirectoryContext, HandleContext, and EnumerationContext parameters are placeholders for application-defined data associated with the directory, specific handle, and enumeration, respectively. (For general-purpose events, the DirectoryContext is called FileContext instead.) DirectoryContext corresponds to the FileContext in the file/directory creation, opening, and closing events. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the directory entry should actually be reported to the requestor; it is True by default. Setting this parameter to False will "hide" the directory entry (i.e., prevent it from being reported).

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_filter_attach_to_volume Event

This event fires after the filter attaches to a newly mounted filesystem volume.

Syntax

class CBFilterAfterFilterAttachToVolumeEventParams(object):
  @property
  def volume_name() -> str: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_filter_attach_to_volume() -> Callable[[CBFilterAfterFilterAttachToVolumeEventParams], None]: ...
@on_after_filter_attach_to_volume.setter
def on_after_filter_attach_to_volume(event_hook: Callable[[CBFilterAfterFilterAttachToVolumeEventParams], None]) -> None: ...

Remarks

This event fires after the filter attaches to the newly mounted filesystem volume specified by VolumeName. Please refer to the fire_volume_events property for more information.

Applications need to handle this event only if the fire_volume_events property includes the FS_MOUNT_CONTROL flag.

Note: This event won't fire for any volumes skipped during the on_before_filter_attach_to_volume event; please refer to its documentation for more information.

Applications can use this event to add volume-specific rules for the volume that has been mounted (keeping in mind that this event does not fire for volumes that are already present when start_filter is called). Applications that intend to do so must ensure that proper thread synchronization techniques are used when manipulating or enumerating the rule lists, because this event's handler will always execute in the context of some worker thread.

Applications must be aware that this event fires as a direct response to a filesystem state change (mount or unmount). Various system components or third-party actors can perform supplementary filesystem mounting and unmounting during main unmount operations (e.g., Volume Service is one such component). This can cause seemingly excessive events to be fired, and sometimes they can be fired out of order (such as two *Attach or *Detach events fired in a row).

The format of the VolumeName parameter's value depends on whether the ResolveNtDeviceToDriveLetter configuration setting is enabled; please refer to its documentation for more information. Applications can obtain additional information about a volume by retrieving its GUID using the get_volume_guid method, and then using that GUID to call various Windows API functions.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_filter_detach_from_volume Event

This event fires after the filter detaches from a filesystem volume.

Syntax

class CBFilterAfterFilterDetachFromVolumeEventParams(object):
  @property
  def volume_name() -> str: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_filter_detach_from_volume() -> Callable[[CBFilterAfterFilterDetachFromVolumeEventParams], None]: ...
@on_after_filter_detach_from_volume.setter
def on_after_filter_detach_from_volume(event_hook: Callable[[CBFilterAfterFilterDetachFromVolumeEventParams], None]) -> None: ...

Remarks

This event fires after the filter detaches from the filesystem volume specified by VolumeName, typically because of the volume being unmounted. Please refer to the fire_volume_events property for more information.

Applications need to handle this event only if the fire_volume_events property includes the FS_MOUNT_CONTROL flag.

Note: This event won't fire for any volumes skipped during the on_before_filter_attach_to_volume event; please refer to its documentation for more information.

Applications should use this event to remove volume-specific rules for the volume that has been unmounted. Applications that intend to do so must ensure that proper thread synchronization techniques are used when manipulating or enumerating the rule lists, because this event's handler will always execute in the context of some worker thread.

Applications must be aware that this event fires as a direct response to a filesystem state change (mount or unmount). Various system components or third-party actors can perform supplementary filesystem mounting and unmounting during main unmount operations (e.g., Volume Service is one such component). This can cause seemingly excessive events to be fired, and sometimes they can be fired out of order (such as two *Attach or *Detach events fired in a row).

The format of the VolumeName parameter's value depends on whether the ResolveNtDeviceToDriveLetter configuration setting is enabled; please refer to its documentation for more information. Applications can obtain additional information about a volume by retrieving its GUID using the get_volume_guid method, and then using that GUID to call various Windows API functions.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_fsctl Event

This event fires after an IRP_MJ_FILE_SYSTEM_CONTROL request is processed.

Syntax

class CBFilterAfterFsctlEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def fs_control_code() -> int: ...

  @property
  def in_buffer() -> c_void_p: ...

  @property
  def in_buffer_length() -> int: ...

  @property
  def in_buffer_valid_bytes() -> int: ...

  @property
  def out_buffer() -> c_void_p: ...

  @property
  def out_buffer_length() -> int: ...

  @property
  def out_buffer_valid_bytes() -> int: ...
  @out_buffer_valid_bytes.setter
  def out_buffer_valid_bytes(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_fsctl() -> Callable[[CBFilterAfterFsctlEventParams], None]: ...
@on_after_fsctl.setter
def on_after_fsctl(event_hook: Callable[[CBFilterAfterFsctlEventParams], None]) -> None: ...

Remarks

This event fires after an IRP_MJ_FILE_SYSTEM_CONTROL (FSCTL) request is processed. Such requests are sent using the Windows API's DeviceIoControl function (user mode), or ZwFsControlFile function (kernel mode); please refer to Microsoft's documentation for more information.

Applications may use this event to modify the output data (if there are any) before the response is returned to the requestor. Applications that choose to do this must:

  1. copy no more than OutBufferLength bytes into OutBuffer; and
  2. update the OutBufferValidBytes parameter's value afterward so that it correctly reflects the amount of data in OutBuffer.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_FSCTL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileName parameter reflects the file, directory, or volume targeted by the request.

The FsControlCode parameter reflects the requested filesystem control code (FSCTL).

The InBuffer parameter points to a memory buffer that contains the data required to perform the operation. The InBufferLength and InBufferValidBytes parameters reflect the capacity of InBuffer and the length of the data it contains (respectively), in bytes; InBufferValidBytes may be less than InBufferLength (unless the request did not include data, in which case both will be 0).

The OutBuffer parameter points to a memory buffer that contains the data returned by the operation. The OutBufferLength and OutBufferValidBytes parameters reflect the capacity of OutBuffer and the length of the data it contains (respectively), in bytes; OutBufferValidBytes may be less than OutBufferLength (unless the operation did not return data, in which case both will be 0).

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_get_file_security Event

This event fires after a file or directory's security attributes are retrieved.

Syntax

class CBFilterAfterGetFileSecurityEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def security_information() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def length_needed() -> int: ...
  @length_needed.setter
  def length_needed(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_get_file_security() -> Callable[[CBFilterAfterGetFileSecurityEventParams], None]: ...
@on_after_get_file_security.setter
def on_after_get_file_security(event_hook: Callable[[CBFilterAfterGetFileSecurityEventParams], None]) -> None: ...

Remarks

This event fires after security attributes are retrieved for the file or directory specified by FileName.

Note: This event will not fire every time a file or directory is accessed. To check file security upon each access to a file or directory, implement the file create and open events and perform the necessary checks there instead.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_GET_SECURITY flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The SecurityInformation parameter indicates which pieces of security information were requested. Please refer to Microsoft's SECURITY_INFORMATION data-type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that, if the request was successful, contains the requested security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

Applications that wish to modify the security information may do so by replacing the data in the SecurityDescriptor buffer. If the current Length is too small to accommodate the new security information, set LengthNeeded to the number of bytes necessary to hold the data and return the ERROR_INSUFFICIENT_BUFFER error code via ResultCode.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_get_file_sizes Event

This event fires after a file's size information is retrieved.

Syntax

class CBFilterAfterGetFileSizesEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def size() -> int: ...
  @size.setter
  def size(value) -> None: ...

  @property
  def allocation_size() -> int: ...
  @allocation_size.setter
  def allocation_size(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_get_file_sizes() -> Callable[[CBFilterAfterGetFileSizesEventParams], None]: ...
@on_after_get_file_sizes.setter
def on_after_get_file_sizes(event_hook: Callable[[CBFilterAfterGetFileSizesEventParams], None]) -> None: ...

Remarks

This event fires after size information is retrieved for the file specified by FileName.

Applications that intend to modify a file's contents should use this event to modify the file's actual size or allocation size as necessary. Applications that make use of virtual files should use this event to report the size of the virtual files.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_GET_SIZES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Size parameter specifies the actual size of the file, in bytes.

The AllocationSize parameter specifies the amount of space allocated for the file, in bytes.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_get_reparse_point Event

This event fires after a file or directory's reparse point information is retrieved.

Syntax

class CBFilterAfterGetReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def data_length() -> int: ...
  @data_length.setter
  def data_length(value) -> None: ...

  @property
  def length_needed() -> int: ...
  @length_needed.setter
  def length_needed(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_get_reparse_point() -> Callable[[CBFilterAfterGetReparsePointEventParams], None]: ...
@on_after_get_reparse_point.setter
def on_after_get_reparse_point(event_hook: Callable[[CBFilterAfterGetReparsePointEventParams], None]) -> None: ...

Remarks

This event fires after reparse point information is retrieved for the file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_GET_REPARSE_POINT flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The ReparseBuffer parameter points to a memory buffer that, if the request was successful, contains the requested reparse point information. The DataLength parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Please refer to the Reparse Points topic for more information.

Applications that wish to modify the reparse point information may do so by replacing the data in the ReparseBuffer buffer. If the current BufferLength is too small to accommodate the new information, the application should write as much data as possible, set LengthNeeded appropriately, and return the STATUS_BUFFER_OVERFLOW status code via Status.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

Depending on how the request originator accessed the specified file or directory, it may or may not currently be open. The FileContext and HandleContext parameters will be absent if it is not open, in which case they will be None.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_ioctl Event

This event fires after an IRP_MJ_DEVICE_CONTROL request is processed.

Syntax

class CBFilterAfterIoctlEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def io_control_code() -> int: ...

  @property
  def in_buffer() -> c_void_p: ...

  @property
  def in_buffer_length() -> int: ...

  @property
  def in_buffer_valid_bytes() -> int: ...

  @property
  def out_buffer() -> c_void_p: ...

  @property
  def out_buffer_length() -> int: ...

  @property
  def out_buffer_valid_bytes() -> int: ...
  @out_buffer_valid_bytes.setter
  def out_buffer_valid_bytes(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_ioctl() -> Callable[[CBFilterAfterIoctlEventParams], None]: ...
@on_after_ioctl.setter
def on_after_ioctl(event_hook: Callable[[CBFilterAfterIoctlEventParams], None]) -> None: ...

Remarks

This event fires after an IRP_MJ_DEVICE_CONTROL (IOCTL) request is processed. Such requests are sent using the Windows API's DeviceIoControl function (user mode), or ZwDeviceIoControlFile function (kernel mode). Please refer to Microsoft's documentation for more information.

Applications may use this event to modify the output data (if there are any) before the response is returned to the requestor. Applications that choose to do this must:

  1. copy no more than OutBufferLength bytes into OutBuffer; and
  2. update the OutBufferValidBytes parameter's value afterward so that it correctly reflects the amount of data in OutBuffer.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_IOCTL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileName parameter reflects the file, directory, or volume targeted by the request.

The IoControlCode parameter reflects the requested I/O control code (IOCTL).

The InBuffer parameter points to a memory buffer that contains the data required to perform the operation. The InBufferLength and InBufferValidBytes parameters reflect the capacity of InBuffer and the length of the data it contains (respectively), in bytes; InBufferValidBytes may be less than InBufferLength (unless the request did not include data, in which case both will be 0).

The OutBuffer parameter points to a memory buffer that contains the data returned by the operation. The OutBufferLength and OutBufferValidBytes parameters reflect the capacity of OutBuffer and the length of the data it contains (respectively), in bytes; OutBufferValidBytes may be less than OutBufferLength (unless the operation did not return data, in which case both will be 0).

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_lock Event

This event fires after a range of bytes in a file is locked.

Syntax

class CBFilterAfterLockEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def offset() -> int: ...

  @property
  def length() -> int: ...

  @property
  def key() -> int: ...

  @property
  def fail_immediately() -> bool: ...

  @property
  def exclusive_lock() -> bool: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_lock() -> Callable[[CBFilterAfterLockEventParams], None]: ...
@on_after_lock.setter
def on_after_lock(event_hook: Callable[[CBFilterAfterLockEventParams], None]) -> None: ...

Remarks

This event fires after a range of bytes in the file specified by FileName is locked; This request is made either by the OS, or on behalf of a user mode application that called the Windows API's LockFile or LockFileEx function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Offset parameter reflects the byte offset where the byte range lock starts.

The Length parameter reflects the length of the byte range lock.

The Key parameter reflects the key that the byte range lock is associated with. This key is used to identify the byte range lock in later unlock-by-key requests.

The FailImmediately parameter indicates whether the request was to fail if the lock could not be granted immediately.

The ExclusiveLock parameter indicates whether the byte range lock was to be exclusive (True) or shared (False).

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_open_file Event

This event fires after a file or directory is opened.

Syntax

class CBFilterAfterOpenFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def existing_attributes() -> int: ...

  @property
  def isolate() -> bool: ...

  @property
  def backend_file_name() -> str: ...

  @property
  def desired_access() -> int: ...

  @property
  def attributes() -> int: ...

  @property
  def share_mode() -> int: ...

  @property
  def options() -> int: ...

  @property
  def create_disposition() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_open_file() -> Callable[[CBFilterAfterOpenFileEventParams], None]: ...
@on_after_open_file.setter
def on_after_open_file(event_hook: Callable[[CBFilterAfterOpenFileEventParams], None]) -> None: ...

Remarks

This event fires after the file or directory specified by FileName is opened. Please refer to the File Create/Open Events topic for more information about how the class determines whether to fire this event or on_after_create_file.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_OPEN flag.

Note: Applications must have the FilterOwnRequests configuration setting enabled if they wish to filter their own file/directory open requests.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

When extended rules are used or the AlwaysRequestAttributesOnOpen configuration setting is enabled, the driver requests attributes of the entity from the filesystem and passes them to ExistingAttributes. If the attributes are not requested, this parameter contains 0.

Isolation-related functionality is under construction.

The DesiredAccess, Attributes, ShareMode, and CreateDisposition parameters reflect the values that were passed for the similarly named parameters of the Windows API's CreateFile function (or, more accurately, the values carried by the IRP_MJ_CREATE IRP).

DesiredAccess may contain one or more of the following access flags:

DESIRED_ACCESS_FILE_LIST_DIRECTORY0x00000001For a directory, the right to list the contents of the directory.

DESIRED_ACCESS_FILE_READ_DATA0x00000001For a file object, the right to read the corresponding file data.

For a directory object, the right to read the corresponding directory data.

DESIRED_ACCESS_FILE_ADD_FILE0x00000002For a directory, the right to create a file in the directory.

DESIRED_ACCESS_FILE_WRITE_DATA0x00000002For a file object, the right to write data to the file.

For a directory object, the right to create a file in the directory

DESIRED_ACCESS_FILE_ADD_SUBDIRECTORY0x00000004For a directory, the right to create a subdirectory.

DESIRED_ACCESS_FILE_APPEND_DATA0x00000004For a file object, the right to append data to the file.

(For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) For a directory object, the right to create a subdirectory (FILE_ADD_SUBDIRECTORY).

DESIRED_ACCESS_FILE_READ_EA0x00000008The right to read extended file attributes.

DESIRED_ACCESS_FILE_WRITE_EA0x00000010The right to write extended file attributes.

DESIRED_ACCESS_FILE_EXECUTE0x00000020For a native code file, the right to execute the file.

This access right given to scripts may cause the script to be executable, depending on the script interpreter.

DESIRED_ACCESS_FILE_DELETE_CHILD0x00000040For a directory, the right to delete a directory and all the files it contains, including read-only files.

DESIRED_ACCESS_FILE_READ_ATTRIBUTES0x00000080The right to read file attributes.

DESIRED_ACCESS_FILE_WRITE_ATTRIBUTES0x00000100The right to write file attributes.

DESIRED_ACCESS_READ_CONTROL0x00020000The right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_READ0x00020000Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_WRITE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_STANDARD_RIGHTS_EXECUTE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_SYNCHRONIZE0x00100000The right to use the object for synchronization.

This enables a thread to wait until the object is in the signaled state. Some object types do not support this access right.

DESIRED_ACCESS_FILE_ALL_ACCESS0x001F01FFAll possible access rights for a file.

DESIRED_ACCESS_FILE_GENERIC_READ0x00120089A combinarion of flags that allow reading of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_WRITE0x00120116A combinarion of flags that allow modifications to the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_EXECUTE0x001200A0A combinarion of flags that allow execution of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

Attributes may contain one or more of the following attributes:

FILE_SYS_ATTR_READ_ONLY0x00000001The file is read-only.

Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.

FILE_SYS_ATTR_HIDDEN0x00000002The file or directory is hidden.

The file is not included in an ordinary directory listing.

FILE_SYS_ATTR_SYSTEM0x00000004A file or directory that the operating system uses a part of, or uses exclusively.

FILE_SYS_ATTR_DIRECTORY0x00000010The entry is a directory.

FILE_SYS_ATTR_ARCHIVE0x00000020The entry is an archive file or directory.

Applications typically use this attribute to mark files for backup or removal.

FILE_SYS_ATTR_NORMAL0x00000080A file doesn't have other attributes set.

This attribute is valid only when used alone.

FILE_SYS_ATTR_TEMPORARY0x00000100A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data are written after the handle is closed.

FILE_SYS_ATTR_SPARSE_FILE0x00000200A file that is a sparse file.

FILE_SYS_ATTR_REPARSE_POINT0x00000400A file that is a reparse point or a symbolic link.

FILE_SYS_ATTR_COMPRESSED0x00000800A file or directory that is compressed.

For a file, all of the data in the file are compressed. For a directory, compression is the default for newly created files and subdirectories. A filesystem implementation can make use of this attribute by setting the support_compressed_attribute property to True and then properly handling the on_get_file_info, on_enumerate_directory, and on_set_file_attributes events.

FILE_SYS_ATTR_OFFLINE0x00001000The data of a file are not available immediately.

This attribute indicates that the file data are physically moved to offline storage.

FILE_SYS_ATTR_NOT_CONTENT_INDEXED0x00002000The file or directory is not to be indexed by the content indexing service.

FILE_SYS_ATTR_ENCRYPTED0x00004000A file or directory that is encrypted.

For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.

Note: This flag is used by NTFS and the OS sends undocumented requests to the filesystem based on this flag. The flag should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_VIRTUAL0x00010000Reserved.

Note: This flag is reserved by the OS and should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_RECALL_ON_OPEN0x00040000The file or directory has no physical representation on the local system; the item is virtual.

Opening the item will be more expensive than normal (e.g., it will cause at least some of it to be fetched from a remote store). This flag is reported by filesystems during directory enumerations.

ShareMode may contain zero or more of the following share mode flags:

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CreateDisposition may contain one of the following values:

FILE_DISPOSITION_CREATE_NEW0x00000001Creates a new file, only if it does not already exist.

If the specified file exists, the operation fails with an "already exists" error.

FILE_DISPOSITION_CREATE_ALWAYS0x00000002Creates a new file, always.

If the specified file exists and is writable, the system overwrites the file. If the specified file does not exist and is a valid path, a new file is created.

FILE_DISPOSITION_OPEN_EXISTING0x00000003Opens a file, only if it exists

If the specified file does not exist, opening fails.

FILE_DISPOSITION_OPEN_ALWAYS0x00000004Opens a file, always.

If the specified file exists, the operation succeeds. If the specified file does not exist and is a valid path to a writable location, the a file is created.

FILE_DISPOSITION_TRUNCATE_EXISTING0x00000005Opens a file and truncates it so that its size is zero bytes, only if it exists.

If the specified file does not exist, the operation fails with a "file not found" error.

Options contains the flags that are described in the CreateOptions parameter of the native API's ZwCreateFile function. Most of those flags correspond to flags passed in the FlagsAndAttributes parameter of the Windows API's CreateFile function, but some flags are specific to the native API. If you need those flags, check both functions' descriptions.

Please refer to Microsoft's documentation for detailed information about these constants.

To determine whether the request was for a file or a directory, compare Attributes against the FILE_SYS_ATTR_DIRECTORY constant, as follows: // Check whether the request is for a file or a directory. bool isDirectory = Attributes & FILE_SYS_ATTR_DIRECTORY == FILE_SYS_ATTR_DIRECTORY; FILE_SYS_ATTR_DIRECTORY will be present if it was specified by the calling process or if the existing filesystem entry is a directory.

To determine whether a file will be deleted when its last handle is closed, compare Options against the Windows API's FILE_FLAG_DELETE_ON_CLOSE constant, as follows: // Check whether the file will be deleted on close. bool deleteOnClose = Options & FILE_FLAG_DELETE_ON_CLOSE == FILE_FLAG_DELETE_ON_CLOSE; Note: Because files can be deleted in different ways, do not use this check to take actions related to tracking file deletion operations. Instead, use the events related to file deletion.

When a file or directory is created using the CreateFile() Windows API function, a caller can specify the security descriptor with the security information. This security information should be applied to a newly created file or directory. The class passes this security information in the SecurityInformation and SecurityDescriptor parameters, when the PassSecurityInFileOpenEvents configuration setting is enabled. If this configuration setting is omitted, the corresponding parameters are empty.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, are valid and should have been applied. Please refer to Microsoft's SECURITY_INFORMATION data type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

If the Options contains the FILE_FLAG_DELETE_ON_CLOSE flag, the on_after_can_file_be_deleted event will fire after this event.

If the file is opened with extended attributes passed in the request, the on_after_set_ea event will fire after this event.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

When the process_failed_requests property is enabled, this event may fire even if the specified file or directory has not been created or opened, in which case the Status parameter will be non-zero. When this occurs, applications must not alter the FileContext and HandleContext parameters.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_query_ea Event

This event fires after information about extended attributes of a file is retrieved.

Syntax

class CBFilterAfterQueryEaEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def return_single_entry() -> bool: ...

  @property
  def ea_list() -> c_void_p: ...

  @property
  def ea_list_length() -> int: ...

  @property
  def ea_index() -> int: ...

  @property
  def restart_scan() -> bool: ...

  @property
  def length_returned() -> int: ...
  @length_returned.setter
  def length_returned(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_query_ea() -> Callable[[CBFilterAfterQueryEaEventParams], None]: ...
@on_after_query_ea.setter
def on_after_query_ea(event_hook: Callable[[CBFilterAfterQueryEaEventParams], None]) -> None: ...

Remarks

This event fires after information about extended attributes of the file specified by FileName is retrieved using the FltQueryEaFile function of the system API.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_QUERY_EA flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the requested information. The data in the buffer are formatted as a FILE_FULL_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information. The Length parameter reflects the length of this buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

ReturnSingleEntry specifies that the filesystem had to return only the first entry it has found.

EaList is an optional parameter that points to a caller-supplied memory buffer specifying the extended attributes to be queried. The data in the buffer are formatted as a FILE_GET_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information. The EaListLength parameter reflects the length of this data, in bytes. If the caller of the FltQueryEaFile function did not specify any value, it will contain 0.

EaIndex is an optional parameter that specifies the starting index of the attribute, information about which was requested. This parameter is ignored by the filesystem if EaList points to a nonempty list. If the caller of the FltQueryEaFile function did not specify any value, the parameter will contain -1.

The RestartScan parameter instructs the filesystem to restart enumeration of extended attributes from the first entry. If the parameter is False, retrieval of the extended attributes is resumed by the filesystem after a previous request.

LengthReturned is an optional parameter that contains the size, in bytes, of the information, returned in the Buffer.

A handler may modify the contents of the Buffer given that the size of the modified data does not exceed the length of the buffer. When modifying the data, a handler should update LengthReturned accordingly.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_query_file_info Event

This event fires after information about a file or directory is retrieved.

Syntax

class CBFilterAfterQueryFileInfoEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_information_class() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def valid_bytes() -> int: ...
  @valid_bytes.setter
  def valid_bytes(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_query_file_info() -> Callable[[CBFilterAfterQueryFileInfoEventParams], None]: ...
@on_after_query_file_info.setter
def on_after_query_file_info(event_hook: Callable[[CBFilterAfterQueryFileInfoEventParams], None]) -> None: ...

Remarks

This event fires after information about the file or directory specified by FileName is retrieved; This event typically fires in response to the Windows API's NtQueryInformationFile function.

Applications may use this event to modify the output data before the response is returned to the requestor. Applications that choose to do this must:

  1. copy no more than BufferLength bytes into Buffer; and
  2. update the ValidBytes parameter's value afterward so that it correctly reflects the amount of data in Buffer.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_QUERY_FILE_INFO flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileInformationClass parameter indicates what kind of file information was requested. Please refer to the NtQueryInformationFile function's documentation for more information about possible values.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the requested file information. The BufferLength and ValidBytes parameters reflect the capacity of Buffer and the length of the data it contains (respectively), in bytes; ValidBytes may be less than BufferLength. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The format of the data is determined by the specified FileInformationClass; please refer to the NtQueryInformationFile function's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_read_file Event

This event fires after data are read from a file.

Syntax

class CBFilterAfterReadFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def position() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def bytes_to_read() -> int: ...

  @property
  def reserved() -> int: ...

  @property
  def direction() -> int: ...

  @property
  def bytes_read() -> int: ...
  @bytes_read.setter
  def bytes_read(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_read_file() -> Callable[[CBFilterAfterReadFileEventParams], None]: ...
@on_after_read_file.setter
def on_after_read_file(event_hook: Callable[[CBFilterAfterReadFileEventParams], None]) -> None: ...

Remarks

This event fires after data are read from the file specified by FileName.

Applications may use this event to modify the data that were read from the file before it is returned to the requestor. Applications that choose to do this must:

  1. enable the ModifiableReadWriteBuffers configuration setting (i.e., before this event fires);
  2. copy no more than BytesToRead bytes into Buffer; and
  3. update the BytesRead parameter's value afterward so that it correctly reflects the amount of data in Buffer.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_READ flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Position parameter reflects the byte offset in the file at which reading started.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the data that were read from the file. The BufferLength parameter reflects the capacity of Buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The BytesToRead parameter reflects how many bytes were to be read from the file (i.e., how many bytes the requestor expects will be read).

The Direction parameter indicates the request direction; please refer to the Cached and Non-Cached Requests topic for more information. Possible values are as follows:

FS_REQUEST_DIR_USER_NONCACHED0Operations performed in the user mode application <--> filesystem direction.
FS_REQUEST_DIR_USER_CACHED1Operations performed in the user mode application <--> system cache direction.
FS_REQUEST_DIR_SYSTEM_NONCACHED2Operations performed in the system cache <--> filesystem direction.
FS_REQUEST_DIR_SYSTEM_CACHED3Operations performed in the system component <--> system cache direction.

The BytesRead parameter specifies how many bytes were actually read from the file, and thus the length of the data in Buffer. This parameter's value must not exceed BufferLength (and should not exceed BytesToRead; please refer to on_before_read_file for more information).

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_rename_or_move_file Event

This event fires after a file or directory is renamed or moved.

Syntax

class CBFilterAfterRenameOrMoveFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def new_file_name() -> str: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_rename_or_move_file() -> Callable[[CBFilterAfterRenameOrMoveFileEventParams], None]: ...
@on_after_rename_or_move_file.setter
def on_after_rename_or_move_file(event_hook: Callable[[CBFilterAfterRenameOrMoveFileEventParams], None]) -> None: ...

Remarks

This event fires after the file or directory specified by FileName is renamed or moved to NewFileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_RENAME flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

A rule's mask is matched against both previous and new filenames, and the event will fire when either of the names matches the mask.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_allocation_size Event

This event fires after a file's allocation size is changed.

Syntax

class CBFilterAfterSetAllocationSizeEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def allocation_size() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_allocation_size() -> Callable[[CBFilterAfterSetAllocationSizeEventParams], None]: ...
@on_after_set_allocation_size.setter
def on_after_set_allocation_size(event_hook: Callable[[CBFilterAfterSetAllocationSizeEventParams], None]) -> None: ...

Remarks

This event fires after the allocation size of the file specified by FileName is changed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_SIZES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The AllocationSize parameter reflects the new allocation size, in bytes. A file's allocation size is typically larger than its actual size because filesystem operations often reserve space on disk before writing additional data to a file.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_ea Event

This event fires after extended attributes of a file are changed.

Syntax

class CBFilterAfterSetEaEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_ea() -> Callable[[CBFilterAfterSetEaEventParams], None]: ...
@on_after_set_ea.setter
def on_after_set_ea(event_hook: Callable[[CBFilterAfterSetEaEventParams], None]) -> None: ...

Remarks

This event fires after extended attributes are changed for the file specified by FileName.

If the file is created or opened with extended attributes passed in the request, this event will fire shortly after the on_after_create_file or on_after_open_file event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_EA flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Buffer parameter points to a memory buffer that specifies the extended attribute information. The Length parameter reflects the length of this buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a FILE_FULL_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_file_attributes Event

This event fires after a file or directory's attributes or times are changed.

Syntax

class CBFilterAfterSetFileAttributesEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def creation_time() -> datetime.datetime: ...

  @property
  def last_access_time() -> datetime.datetime: ...

  @property
  def last_write_time() -> datetime.datetime: ...

  @property
  def change_time() -> datetime.datetime: ...

  @property
  def attributes() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_file_attributes() -> Callable[[CBFilterAfterSetFileAttributesEventParams], None]: ...
@on_after_set_file_attributes.setter
def on_after_set_file_attributes(event_hook: Callable[[CBFilterAfterSetFileAttributesEventParams], None]) -> None: ...

Remarks

This event fires after the attributes or times of the file or directory specified by FileName are changed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_ATTRIBUTES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The CreationTime, LastAccessTime, LastWriteTime, and ChangeTime parameters reflect the new time values, specified in UTC. A value of January 1, 1601 00:00:00 UTC indicates that the corresponding time value was not included in the request.

The Attributes parameter reflects the new attributes; please refer to Microsoft's File Attribute Constants article for attribute descriptions.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_file_info Event

This event fires after information about a file or directory is changed.

Syntax

class CBFilterAfterSetFileInfoEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_information_class() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def valid_bytes() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_file_info() -> Callable[[CBFilterAfterSetFileInfoEventParams], None]: ...
@on_after_set_file_info.setter
def on_after_set_file_info(event_hook: Callable[[CBFilterAfterSetFileInfoEventParams], None]) -> None: ...

Remarks

This event fires after information about the file or directory specified by FileName is changed; This event typically fires in response to the Windows API's NtSetInformationFile function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_FILE_INFO flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileInformationClass parameter indicates what kind of file information was set. Please refer to the NtSetInformationFile function's documentation for more information about possible values.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the new file information. The BufferLength and ValidBytes parameters reflect the capacity of Buffer and the length of the data it contains (respectively), in bytes; ValidBytes may be less than BufferLength. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The format of the data is determined by the specified FileInformationClass; please refer to the NtSetInformationFile function's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_file_security Event

This event fires after a file or directory's security attributes are changed.

Syntax

class CBFilterAfterSetFileSecurityEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def security_information() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_file_security() -> Callable[[CBFilterAfterSetFileSecurityEventParams], None]: ...
@on_after_set_file_security.setter
def on_after_set_file_security(event_hook: Callable[[CBFilterAfterSetFileSecurityEventParams], None]) -> None: ...

Remarks

This event fires after security attributes are changed for the file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_SECURITY flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, were to be set. Please refer to Microsoft's SECURITY_INFORMATION data-type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the new security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_file_size Event

This event fires after a file is resized.

Syntax

class CBFilterAfterSetFileSizeEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def size() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_file_size() -> Callable[[CBFilterAfterSetFileSizeEventParams], None]: ...
@on_after_set_file_size.setter
def on_after_set_file_size(event_hook: Callable[[CBFilterAfterSetFileSizeEventParams], None]) -> None: ...

Remarks

This event fires after the file specified by FileName is resized, whether explicitly (e.g., truncation) or implicitly (i.e., as data are appended).

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_SIZES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Size parameter reflects the new file size, in bytes.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_set_reparse_point Event

This event fires after the OS creates or updates a reparse point on a file or directory.

Syntax

class CBFilterAfterSetReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_tag() -> int: ...

  @property
  def reparse_buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def data_length() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_set_reparse_point() -> Callable[[CBFilterAfterSetReparsePointEventParams], None]: ...
@on_after_set_reparse_point.setter
def on_after_set_reparse_point(event_hook: Callable[[CBFilterAfterSetReparsePointEventParams], None]) -> None: ...

Remarks

This event fires after the OS creates or updates a reparse point on a file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_SET_REPARSE_POINT flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The ReparseTag parameter contains the reparse tag, which is the value the system uses to identify the format of the reparse point data. This value is also present in the ReparseBuffer data; the class extracts it and provides it separately for convenience.

The ReparseBuffer parameter points to a memory buffer that specifies the new reparse point information. The DataLength parameter reflects the length of the data contained in the buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Please refer to the Reparse Points topic for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_unlock_all Event

This event fires after all locked byte ranges in a file are unlocked.

Syntax

class CBFilterAfterUnlockAllEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_unlock_all() -> Callable[[CBFilterAfterUnlockAllEventParams], None]: ...
@on_after_unlock_all.setter
def on_after_unlock_all(event_hook: Callable[[CBFilterAfterUnlockAllEventParams], None]) -> None: ...

Remarks

This event fires after all locked byte ranges in the file specified by FileName are unlocked.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_unlock_all_by_key Event

This event fires after all locked byte ranges in a file, associated with a particular key, are unlocked.

Syntax

class CBFilterAfterUnlockAllByKeyEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def key() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_unlock_all_by_key() -> Callable[[CBFilterAfterUnlockAllByKeyEventParams], None]: ...
@on_after_unlock_all_by_key.setter
def on_after_unlock_all_by_key(event_hook: Callable[[CBFilterAfterUnlockAllByKeyEventParams], None]) -> None: ...

Remarks

This event fires after all locked byte ranges in the file specified by FileName, and associated with the specified Key, are unlocked.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Key parameter contains the key value specified when the byte ranges were locked. Please refer to the on_after_lock event's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_unlock_single Event

This event fires after a particular locked byte range in a file is unlocked.

Syntax

class CBFilterAfterUnlockSingleEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def offset() -> int: ...

  @property
  def length() -> int: ...

  @property
  def key() -> int: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_unlock_single() -> Callable[[CBFilterAfterUnlockSingleEventParams], None]: ...
@on_after_unlock_single.setter
def on_after_unlock_single(event_hook: Callable[[CBFilterAfterUnlockSingleEventParams], None]) -> None: ...

Remarks

This event fires after a particular locked byte range in the file specified by FileName is unlocked.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Offset, Length, and Key parameters contain the starting byte offset, length, and key values (respectively) specified when the byte range was locked. Please refer to the on_after_lock event's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_after_write_file Event

This event fires after data are written to a file.

Syntax

class CBFilterAfterWriteFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def position() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def bytes_to_write() -> int: ...

  @property
  def direction() -> int: ...

  @property
  def bytes_written() -> int: ...
  @bytes_written.setter
  def bytes_written(value) -> None: ...

  @property
  def status() -> int: ...
  @status.setter
  def status(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_after_write_file() -> Callable[[CBFilterAfterWriteFileEventParams], None]: ...
@on_after_write_file.setter
def on_after_write_file(event_hook: Callable[[CBFilterAfterWriteFileEventParams], None]) -> None: ...

Remarks

This event fires after data are written to the file specified by FileName.

Applications may use this event to inspect the data that were written to the file, but must not attempt to alter said data. If, during on_before_write_file, an application causes less data than requested to be written to the file, it should use this event to set BytesWritten back to the expected value (i.e., BytesToWrite) to prevent the requestor from behaving unexpectedly.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_AFTER_WRITE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Position parameter reflects the byte offset in the file at which writing started. A value of -1 means "append to the end of the file".

The Buffer parameter points to a memory buffer that contains the data that, if the request was successful, were written to the file. The BufferLength parameter reflects the capacity of Buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The BytesToWrite parameter reflects how many bytes were to be written to the file (i.e., how many bytes the requestor expects will be written).

The Direction parameter indicates the request direction; please refer to the Cached and Non-Cached Requests topic for more information. Possible values are as follows:

FS_REQUEST_DIR_USER_NONCACHED0Operations performed in the user mode application <--> filesystem direction.
FS_REQUEST_DIR_USER_CACHED1Operations performed in the user mode application <--> system cache direction.
FS_REQUEST_DIR_SYSTEM_NONCACHED2Operations performed in the system cache <--> filesystem direction.
FS_REQUEST_DIR_SYSTEM_CACHED3Operations performed in the system component <--> system cache direction.

The BytesWritten parameter specifies how many bytes were actually written to the file. This parameter's value must not exceed BufferLength (and should not exceed BytesToWrite; please refer to on_before_write_file for more information).

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_can_file_be_deleted Event

This event fires before the OS attempts to mark a file or directory for deletion or remove such a mark.

Syntax

class CBFilterBeforeCanFileBeDeletedEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def request_type() -> int: ...

  @property
  def can_delete() -> bool: ...
  @can_delete.setter
  def can_delete(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_can_file_be_deleted() -> Callable[[CBFilterBeforeCanFileBeDeletedEventParams], None]: ...
@on_before_can_file_be_deleted.setter
def on_before_can_file_be_deleted(event_hook: Callable[[CBFilterBeforeCanFileBeDeletedEventParams], None]) -> None: ...

Remarks

This event fires before the OS marks the file or directory specified by FileName for deletion or removes such a mark.

Files and directories can be deleted in two ways: (1) a file or directory can be opened with the FILE_FLAG_DELETE_ON_CLOSE flag, or (2) some process may call Windows API's NtSetInformationFile function with FILE_DISPOSITION_INFORMATION or FILE_DISPOSITION_INFORMATION_EX structure as a parameter.

If the file or directory is created or opened with the FILE_FLAG_DELETE_ON_CLOSE flag, this event is fired shortly before the on_before_create_file or on_before_open_file event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_CAN_DELETE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The RequestType indicates which kind of system request resulted in firing this event. It can be one of the following:

DEL_REQ_OPEN_FLAG0x1The file or directory is opened with the FILE_FLAG_DELETE_ON_CLOSE flag

DEL_REQ_SET_DISPOSITION0x2The system has sent the IRP_MJ_SET_INFORMATION request with SetFileDisposition structure as a parameter.

This request usually is sent using the NtSetInformationFile() Windows native API function.

The CanDelete parameter specifies whether the file or directory will be deleted. This parameter can be True or False depending on which request the OS has sent. Applications may prevent deletion of the file or directory by setting CanDelete to False. Changing CanDelete from False to True may or may not have the effect on the file being deleted later, so such a change should be avoided.

Note: If the file is opened with FILE_FLAG_DELETE_ON_CLOSE flag set and the event handler permits file deletion, such flag cannot be removed later (even with the call to NtSetInformationFile() API function).

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The effect of ProcessRequest depends on what operation caused the event to fire:

  • If the event fires during the file open operation where the FILE_FLAG_DELETE_ON_CLOSE flag is set,
    • setting CanDelete to False and ProcessRequest to True causes the FILE_FLAG_DELETE_ON_CLOSE flag to be removed and the file open request to be passed further to the filesystem; and
    • setting CanDelete to False and ProcessRequest to False causes the file open request to fail with ACCESS_DENIED error.
  • If the event fires in the context of the call to NtSetInformationFile Windows API function, setting CanDelete to False causes the DeleteFlag parameter to be set to False and the request to be passed further to the filesystem. This combination effectively resets the file deletion state, known to the filesystem, to the False ("do not delete") value. The value of ProcessRequest in this case does not matter as the new value must reach the filesystem.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the specified file or directory was not opened before the request, both contexts will be absent, in which case these parameters will be None.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_cleanup_file Event

This event fires before a file or directory handle is closed.

Syntax

class CBFilterBeforeCleanupFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_cleanup_file() -> Callable[[CBFilterBeforeCleanupFileEventParams], None]: ...
@on_before_cleanup_file.setter
def on_before_cleanup_file(event_hook: Callable[[CBFilterBeforeCleanupFileEventParams], None]) -> None: ...

Remarks

This event fires before a handle to the file or directory specified by FileName is closed. This event differs from on_before_close_file in that on_before_cleanup_file fires immediately before an open handle to the specified file or directory is closed by a process, whereas on_before_close_file may be fired much later when the OS itself decides that the file or directory can be formally closed.

Other events may fire for the file or directory in the time between when this event fires and when the on_before_close_file event fires. For example, system components such as the memory manager or cache manager may cause the on_before_read_file and on_before_write_file events to fire.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_CLEANUP flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_close_file Event

This event fires before a file or directory is closed.

Syntax

class CBFilterBeforeCloseFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_close_file() -> Callable[[CBFilterBeforeCloseFileEventParams], None]: ...
@on_before_close_file.setter
def on_before_close_file(event_hook: Callable[[CBFilterBeforeCloseFileEventParams], None]) -> None: ...

Remarks

This event fires before the file or directory specified by FileName is closed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_CLOSE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

If the file or directory was marked for deletion earlier, the on_before_delete_file will fire shortly before this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_create_file Event

This event fires before a file or directory is created.

Syntax

class CBFilterBeforeCreateFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def existing_attributes() -> int: ...

  @property
  def isolate() -> bool: ...
  @isolate.setter
  def isolate(value) -> None: ...

  @property
  def backend_file_name() -> str: ...
  @backend_file_name.setter
  def backend_file_name(value) -> None: ...

  @property
  def desired_access() -> int: ...
  @desired_access.setter
  def desired_access(value) -> None: ...

  @property
  def attributes() -> int: ...
  @attributes.setter
  def attributes(value) -> None: ...

  @property
  def share_mode() -> int: ...
  @share_mode.setter
  def share_mode(value) -> None: ...

  @property
  def options() -> int: ...
  @options.setter
  def options(value) -> None: ...

  @property
  def create_disposition() -> int: ...
  @create_disposition.setter
  def create_disposition(value) -> None: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_create_file() -> Callable[[CBFilterBeforeCreateFileEventParams], None]: ...
@on_before_create_file.setter
def on_before_create_file(event_hook: Callable[[CBFilterBeforeCreateFileEventParams], None]) -> None: ...

Remarks

This event fires before the file or directory specified by FileName is created. Please refer to the File Create/Open Events topic for more information about how the class determines whether to fire this event or on_before_open_file.

Applications may use this event to modify the request's parameters, or to block the request entirely. To do the latter, set ProcessRequest to False; this has the same effect as returning ACCESS_DENIED.

To redirect a request to another file or directory, use the on_reparse_file_name event, which is fired shortly after this event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_CREATE flag.

Note: Applications must have the FilterOwnRequests configuration setting enabled if they wish to filter their own file/directory creation requests.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

When extended rules are used or the AlwaysRequestAttributesOnOpen configuration setting is enabled, the driver requests attributes of the entity from the filesystem and passes them to ExistingAttributes. If the attributes are not requested, this parameter contains 0.

Isolation-related functionality is under construction.

The initial values of DesiredAccess, Attributes, ShareMode, and CreateDisposition parameters reflect the values that were passed for the similarly named parameters of the Windows API's CreateFile function (or, more accurately, the values carried by the IRP_MJ_CREATE Internet Relay Programming).

DesiredAccess may contain one or more of the following access flags:

DESIRED_ACCESS_FILE_LIST_DIRECTORY0x00000001For a directory, the right to list the contents of the directory.

DESIRED_ACCESS_FILE_READ_DATA0x00000001For a file object, the right to read the corresponding file data.

For a directory object, the right to read the corresponding directory data.

DESIRED_ACCESS_FILE_ADD_FILE0x00000002For a directory, the right to create a file in the directory.

DESIRED_ACCESS_FILE_WRITE_DATA0x00000002For a file object, the right to write data to the file.

For a directory object, the right to create a file in the directory

DESIRED_ACCESS_FILE_ADD_SUBDIRECTORY0x00000004For a directory, the right to create a subdirectory.

DESIRED_ACCESS_FILE_APPEND_DATA0x00000004For a file object, the right to append data to the file.

(For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) For a directory object, the right to create a subdirectory (FILE_ADD_SUBDIRECTORY).

DESIRED_ACCESS_FILE_READ_EA0x00000008The right to read extended file attributes.

DESIRED_ACCESS_FILE_WRITE_EA0x00000010The right to write extended file attributes.

DESIRED_ACCESS_FILE_EXECUTE0x00000020For a native code file, the right to execute the file.

This access right given to scripts may cause the script to be executable, depending on the script interpreter.

DESIRED_ACCESS_FILE_DELETE_CHILD0x00000040For a directory, the right to delete a directory and all the files it contains, including read-only files.

DESIRED_ACCESS_FILE_READ_ATTRIBUTES0x00000080The right to read file attributes.

DESIRED_ACCESS_FILE_WRITE_ATTRIBUTES0x00000100The right to write file attributes.

DESIRED_ACCESS_READ_CONTROL0x00020000The right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_READ0x00020000Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_WRITE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_STANDARD_RIGHTS_EXECUTE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_SYNCHRONIZE0x00100000The right to use the object for synchronization.

This enables a thread to wait until the object is in the signaled state. Some object types do not support this access right.

DESIRED_ACCESS_FILE_ALL_ACCESS0x001F01FFAll possible access rights for a file.

DESIRED_ACCESS_FILE_GENERIC_READ0x00120089A combinarion of flags that allow reading of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_WRITE0x00120116A combinarion of flags that allow modifications to the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_EXECUTE0x001200A0A combinarion of flags that allow execution of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

Attributes may contain one or more of the following attributes:

FILE_SYS_ATTR_READ_ONLY0x00000001The file is read-only.

Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.

FILE_SYS_ATTR_HIDDEN0x00000002The file or directory is hidden.

The file is not included in an ordinary directory listing.

FILE_SYS_ATTR_SYSTEM0x00000004A file or directory that the operating system uses a part of, or uses exclusively.

FILE_SYS_ATTR_DIRECTORY0x00000010The entry is a directory.

FILE_SYS_ATTR_ARCHIVE0x00000020The entry is an archive file or directory.

Applications typically use this attribute to mark files for backup or removal.

FILE_SYS_ATTR_NORMAL0x00000080A file doesn't have other attributes set.

This attribute is valid only when used alone.

FILE_SYS_ATTR_TEMPORARY0x00000100A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data are written after the handle is closed.

FILE_SYS_ATTR_SPARSE_FILE0x00000200A file that is a sparse file.

FILE_SYS_ATTR_REPARSE_POINT0x00000400A file that is a reparse point or a symbolic link.

FILE_SYS_ATTR_COMPRESSED0x00000800A file or directory that is compressed.

For a file, all of the data in the file are compressed. For a directory, compression is the default for newly created files and subdirectories. A filesystem implementation can make use of this attribute by setting the support_compressed_attribute property to True and then properly handling the on_get_file_info, on_enumerate_directory, and on_set_file_attributes events.

FILE_SYS_ATTR_OFFLINE0x00001000The data of a file are not available immediately.

This attribute indicates that the file data are physically moved to offline storage.

FILE_SYS_ATTR_NOT_CONTENT_INDEXED0x00002000The file or directory is not to be indexed by the content indexing service.

FILE_SYS_ATTR_ENCRYPTED0x00004000A file or directory that is encrypted.

For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.

Note: This flag is used by NTFS and the OS sends undocumented requests to the filesystem based on this flag. The flag should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_VIRTUAL0x00010000Reserved.

Note: This flag is reserved by the OS and should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_RECALL_ON_OPEN0x00040000The file or directory has no physical representation on the local system; the item is virtual.

Opening the item will be more expensive than normal (e.g., it will cause at least some of it to be fetched from a remote store). This flag is reported by filesystems during directory enumerations.

ShareMode may contain zero or more of the following share mode flags:

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CreateDisposition may contain one of the following values:

FILE_DISPOSITION_CREATE_NEW0x00000001Creates a new file, only if it does not already exist.

If the specified file exists, the operation fails with an "already exists" error.

FILE_DISPOSITION_CREATE_ALWAYS0x00000002Creates a new file, always.

If the specified file exists and is writable, the system overwrites the file. If the specified file does not exist and is a valid path, a new file is created.

FILE_DISPOSITION_OPEN_EXISTING0x00000003Opens a file, only if it exists

If the specified file does not exist, opening fails.

FILE_DISPOSITION_OPEN_ALWAYS0x00000004Opens a file, always.

If the specified file exists, the operation succeeds. If the specified file does not exist and is a valid path to a writable location, the a file is created.

FILE_DISPOSITION_TRUNCATE_EXISTING0x00000005Opens a file and truncates it so that its size is zero bytes, only if it exists.

If the specified file does not exist, the operation fails with a "file not found" error.

Options contains the flags that are described in the CreateOptions parameter of the Native API's ZwCreateFile function. Most of those flags correspond to flags passed in the FlagsAndAttributes parameter of the Windows API's CreateFile function, but some flags are specific to Native API. If you need those flags, check both functions' descriptions.

Please refer to Microsoft's documentation for detailed information about these constants.

To determine whether the request is for a file or a directory, compare Attributes against the FILE_SYS_ATTR_DIRECTORY constant, as follows: // Check whether the request is for a file or a directory. bool isDirectory = Attributes & FILE_SYS_ATTR_DIRECTORY == FILE_SYS_ATTR_DIRECTORY; FILE_SYS_ATTR_DIRECTORY will be present only if it was specified by the calling process; its presence or absence does not indicate the real presence of the attribute on the file or directory on disk.

To determine whether a file will be deleted when its last handle is closed, compare Options against the Windows API's FILE_FLAG_DELETE_ON_CLOSE constant, as follows: // Check whether the file will be deleted on close. bool deleteOnClose = Options & FILE_FLAG_DELETE_ON_CLOSE == FILE_FLAG_DELETE_ON_CLOSE;

Note: Files can be deleted in different ways, so do not use this check to take actions related to tracking file deletion operations. Instead, use the events related to file deletion.

To prevent a file or directory from being opened, set the ResultCode parameter to a non-zero value (typically ERROR_ACCESS_DENIED (5)).

When a file or directory is created using the CreateFile() Windows API function, a caller can specify the security descriptor with the security information. This security information should be applied to a newly created file or directory. The class passes this security information in the SecurityInformation and SecurityDescriptor parameters, when the PassSecurityInFileOpenEvents configuration setting is enabled. If this configuration setting is omitted, the corresponding parameters are empty.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, are valid and should have been applied. Please refer to Microsoft's SECURITY_INFORMATION data type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

If an application needs to alter the security information, it can do this by placing up to Length bytes of information into the SecurityDescriptor buffer.

Note: Changing the security data is possible only when the PassSecurityInFileOpenEvents configuration setting is enabled.

If the capacity reflected by the Length parameter is not enough to accommodate the security information, set LengthNeeded to the number of bytes necessary to hold the data, and return the ERROR_INSUFFICIENT_BUFFER error code via ResultCode.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

If the Options contains the FILE_FLAG_DELETE_ON_CLOSE flag, the on_before_can_file_be_deleted event will fire before this event.

If the file is opened with extended attributes passed in the request, the on_before_set_ea event will fire after this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_create_hard_link Event

This event fires before a hard link is created.

Syntax

class CBFilterBeforeCreateHardLinkEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def link_name() -> str: ...

  @property
  def replace_if_exists() -> bool: ...
  @replace_if_exists.setter
  def replace_if_exists(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_create_hard_link() -> Callable[[CBFilterBeforeCreateHardLinkEventParams], None]: ...
@on_before_create_hard_link.setter
def on_before_create_hard_link(event_hook: Callable[[CBFilterBeforeCreateHardLinkEventParams], None]) -> None: ...

Remarks

This event fires before a hard link to the file specified by FileName is created. Please refer to Microsoft's Hard Links article for more information about hard links.

Applications may use this event to modify the request's parameters, or to block the request entirely. To do the latter, set ProcessRequest to False.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_CREATE_HARD_LINK flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The LinkName parameter reflects the name of the new hard link.

The ReplaceIfExists parameter specifies what to do if a hard link with the specified LinkName already exists. If this parameter is True, the new hard link will replace the existing hard link; if this parameter is False, the operation will fail.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_delete_file Event

This event fires before a file or directory is deleted.

Syntax

class CBFilterBeforeDeleteFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def request_type() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_delete_file() -> Callable[[CBFilterBeforeDeleteFileEventParams], None]: ...
@on_before_delete_file.setter
def on_before_delete_file(event_hook: Callable[[CBFilterBeforeDeleteFileEventParams], None]) -> None: ...

Remarks

This event fires before the file or directory specified by FileName is deleted. More specifically, this event is fired before the final IRM_MJ_CLOSE Internet Relay Programming (IRP) is processed by the filesystem and before on_before_close_file fires.

Applications may use this event to obtain information about the specified file or directory, which still exists at the time this event fires. This event cannot be used to prevent a deletion; use the on_before_can_file_be_deleted event instead.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_DELETE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The RequestType indicates which kind of system request resulted in firing this event. It can be one of the following:

DEL_REQ_OPEN_FLAG0x1The file or directory is opened with the FILE_FLAG_DELETE_ON_CLOSE flag

DEL_REQ_SET_DISPOSITION0x2The system has sent the IRP_MJ_SET_INFORMATION request with SetFileDisposition structure as a parameter.

This request usually is sent using the NtSetInformationFile() Windows native API function.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_delete_reparse_point Event

This event fires when the OS wants to delete a reparse point from a file or directory.

Syntax

class CBFilterBeforeDeleteReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_delete_reparse_point() -> Callable[[CBFilterBeforeDeleteReparsePointEventParams], None]: ...
@on_before_delete_reparse_point.setter
def on_before_delete_reparse_point(event_hook: Callable[[CBFilterBeforeDeleteReparsePointEventParams], None]) -> None: ...

Remarks

This event fires before the OS deletes a reparse point from a file or directory specified by FileName.

Note: The file or directory is not deleted, only the reparse point is.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_DELETE_REPARSE_POINT flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The ReparseBuffer parameter points to a memory buffer that specifies the known reparse point information. This information is provided for convenience. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Please refer to the Reparse Points topic for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_enumerate_directory Event

This event fires when an enumeration request is sent by the OS.

Syntax

class CBFilterBeforeEnumerateDirectoryEventParams(object):
  @property
  def directory_name() -> str: ...

  @property
  def flags() -> int: ...

  @property
  def mask() -> str: ...

  @property
  def index() -> int: ...

  @property
  def directory_context() -> int: ...
  @directory_context.setter
  def directory_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def enumeration_context() -> int: ...
  @enumeration_context.setter
  def enumeration_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_enumerate_directory() -> Callable[[CBFilterBeforeEnumerateDirectoryEventParams], None]: ...
@on_before_enumerate_directory.setter
def on_before_enumerate_directory(event_hook: Callable[[CBFilterBeforeEnumerateDirectoryEventParams], None]) -> None: ...

Remarks

This event fires when the OS sends a request for reading one or more entries of the directory specified by DirectoryName.

Applications may use this event to record the request and optionally block it.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_ENUMERATE_DIRECTORY flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Flags parameter specifies supplementary information about enumeration. It is a combination of zero or more values:

FS_ENUM_RESTART_SCAN1The requestor specified that directory enumeration must be restarted.

FS_ENUM_RETURN_SINGLE_ENTRY2One entry should be returned.

FS_ENUM_INDEX_SPECIFIED4The requestor specified the index to start enumeration from.

If the Flags parameter contains FS_ENUM_INDEX_SPECIFIED, the Index parameter contains the index as provided by the OS.

The Mask parameter contains the mask for the enumeration. This value may contain any combination of valid filename characters and wildcards (the * and ? characters). Alternatively, it may be an exact filename (i.e., a value without any wildcards), as some applications query file information by specifying an exact filename in an enumeration. When TranslateDOSCharsInEnumMasks is False, this parameter may contain a so-called DOS wildcard (please, refer to the description of this setting for more information). The mask can also be empty in rare cases: this happens when the OS request is a continuation of a previous enumeration with a valid non-zero Index.

The DirectoryContext, HandleContext, and EnumerationContext parameters are placeholders for application-defined data associated with the directory, specific handle, and enumeration, respectively. (For general-purpose events, the DirectoryContext is called FileContext instead.) DirectoryContext corresponds to the FileContext in the file/directory creation, opening, and closing events. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_filter_attach_to_volume Event

This event fires before the filter attaches to a newly mounted filesystem volume.

Syntax

class CBFilterBeforeFilterAttachToVolumeEventParams(object):
  @property
  def volume_name() -> str: ...

  @property
  def skip_volume() -> bool: ...
  @skip_volume.setter
  def skip_volume(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_filter_attach_to_volume() -> Callable[[CBFilterBeforeFilterAttachToVolumeEventParams], None]: ...
@on_before_filter_attach_to_volume.setter
def on_before_filter_attach_to_volume(event_hook: Callable[[CBFilterBeforeFilterAttachToVolumeEventParams], None]) -> None: ...

Remarks

This event fires before the filter attaches to the newly mounted filesystem volume specified by VolumeName. Please refer to the fire_volume_events property for more information.

Applications need to handle this event only if the fire_volume_events property includes the FS_MOUNT_CONTROL flag.

The VolumeName parameter's value is always an NT native format in this event (unlike the other volume-related events, listed below, where its format depends on the ResolveNtDeviceToDriveLetter configuration setting). It is therefore recommended that applications add volume-specific rules, if desired, during the on_after_filter_attach_to_volume event rather than this one. Applications can obtain additional information about a volume by retrieving its GUID using the get_volume_guid method, and then using that GUID to call various Windows API functions.

The SkipVolume parameter specifies whether the class's system driver should skip the specified volume (i.e., not attach the filter to it). Setting this parameter to True will cause all filesystem operations that target to volume to be completely ignored by the class's system driver. It also will prevent any of the following events from firing for the volume:

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

Applications must be aware that this event fires as a direct response to a filesystem state change (mount or unmount). Various system components or third-party actors can perform supplementary filesystem mounting and unmounting during main unmount operations (e.g., Volume Service is one such component). This can cause seemingly excessive events to be fired, and sometimes they can be fired out of order (such as two *Attach or *Detach events fired in a row).

on_before_fsctl Event

This event fires before an IRP_MJ_FILE_SYSTEM_CONTROL request is processed.

Syntax

class CBFilterBeforeFsctlEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def fs_control_code() -> int: ...

  @property
  def in_buffer() -> c_void_p: ...

  @property
  def in_buffer_length() -> int: ...

  @property
  def in_buffer_valid_bytes() -> int: ...
  @in_buffer_valid_bytes.setter
  def in_buffer_valid_bytes(value) -> None: ...

  @property
  def out_buffer() -> c_void_p: ...

  @property
  def out_buffer_length() -> int: ...

  @property
  def out_buffer_valid_bytes() -> int: ...
  @out_buffer_valid_bytes.setter
  def out_buffer_valid_bytes(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_fsctl() -> Callable[[CBFilterBeforeFsctlEventParams], None]: ...
@on_before_fsctl.setter
def on_before_fsctl(event_hook: Callable[[CBFilterBeforeFsctlEventParams], None]) -> None: ...

Remarks

This event fires before an IRP_MJ_FILE_SYSTEM_CONTROL (FSCTL) request is processed. Such requests are sent using the Windows API's DeviceIoControl function (user mode), or ZwFsControlFile function (kernel mode); please refer to Microsoft's documentation for more information.

Applications may use this event to modify the input data (if there are any) before the request continues onward. Applications that choose to do this must do the following:

  1. Copy no more than InBufferLength bytes into InBuffer.
  2. Update the InBufferValidBytes parameter's value afterward so that it correctly reflects the amount of data in InBuffer.

Alternatively, applications may use this event to handle the request (preventing it from continuing onward), in which case they must do the following:

  1. Copy no more than OutBufferLength bytes into OutBuffer.
  2. Update the OutBufferValidBytes parameter's value afterward so that it correctly reflects the amount of data in OutBuffer.
  3. Set ProcessRequest to False to indicate that the request has been handled and should not continue onward.
(The first two steps are not applicable if the requested operation is not expected to return data.)

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_FSCTL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileName parameter reflects the file, directory, or volume targeted by the request.

The FsControlCode parameter reflects the requested filesystem control code (FSCTL).

The InBuffer parameter points to a memory buffer that contains the data required to perform the operation. The InBufferLength and InBufferValidBytes parameters reflect the capacity of InBuffer and the length of the data it contains (respectively), in bytes; InBufferValidBytes may be less than InBufferLength (unless the request did not include data, in which case both will be 0).

The OutBuffer parameter points to a memory buffer that receives the data returned by the operation. The OutBufferLength and OutBufferValidBytes parameters reflect the capacity of OutBuffer and the length of the data it contains (respectively), in bytes; OutBufferValidBytes may be less than OutBufferLength (unless the operation is not expected to return data, in which case both will be 0).

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_get_file_security Event

This event fires before a file or directory's security attributes are retrieved.

Syntax

class CBFilterBeforeGetFileSecurityEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def security_information() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def length_needed() -> int: ...
  @length_needed.setter
  def length_needed(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_get_file_security() -> Callable[[CBFilterBeforeGetFileSecurityEventParams], None]: ...
@on_before_get_file_security.setter
def on_before_get_file_security(event_hook: Callable[[CBFilterBeforeGetFileSecurityEventParams], None]) -> None: ...

Remarks

This event fires before security attributes are retrieved for the file or directory specified by FileName.

Note: This event will not fire every time a file or directory is accessed. To check file security upon each access to a file or directory, implement the file create and open events and perform the necessary checks there instead.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_GET_SECURITY flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The SecurityInformation parameter indicates which pieces of security information are requested. Please refer to Microsoft's SECURITY_INFORMATION data-type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that receives the requested security information. The buffer referenced by the SecurityDescriptor parameter may be modified by the event handler if the operation is completed without passing it further to other filters and the filesystem driver. The Length parameter reflects the capacity of the SecurityDescriptor buffer, in bytes.

If the capacity reflected by the Length parameter is not sufficient to accommodate the security information, set LengthNeeded to the number of bytes necessary to hold the data, and return the ERROR_INSUFFICIENT_BUFFER error code via ResultCode.

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The returned data will be formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_get_reparse_point Event

This event fires when the OS wants to read a reparse point for a file or directory.

Syntax

class CBFilterBeforeGetReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_buffer() -> c_void_p: ...

  @property
  def reparse_buffer_length() -> int: ...
  @reparse_buffer_length.setter
  def reparse_buffer_length(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_get_reparse_point() -> Callable[[CBFilterBeforeGetReparsePointEventParams], None]: ...
@on_before_get_reparse_point.setter
def on_before_get_reparse_point(event_hook: Callable[[CBFilterBeforeGetReparsePointEventParams], None]) -> None: ...

Remarks

This event fires when the OS wants to read a reparse point for the file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_GET_REPARSE_POINT flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

If an application desires to handle the event and does not pass the request further, it needs to fill ReparseBuffer with the reparse point data associated with the specified file or directory and set ReparseBufferLength to the number of bytes written. The ReparseBufferLength parameter's initial value reflects the capacity of the memory buffer pointed to by ReparseBuffer. If the buffer is too small to hold all of the reparse point data, then the application should write as much data to it as possible, set ReparseBufferLength appropriately, and return the ERROR_MORE_DATA error code via ResultCode.

Please refer to the Reparse Points topic for more information.

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

Depending on how the request originator accessed the specified file or directory, it may or may not currently be open. The FileContext and HandleContext parameters will be absent if it is not open, in which case they will be None.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_ioctl Event

This event fires before an IRP_MJ_DEVICE_CONTROL request is processed.

Syntax

class CBFilterBeforeIoctlEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def io_control_code() -> int: ...

  @property
  def in_buffer() -> c_void_p: ...

  @property
  def in_buffer_length() -> int: ...

  @property
  def in_buffer_valid_bytes() -> int: ...
  @in_buffer_valid_bytes.setter
  def in_buffer_valid_bytes(value) -> None: ...

  @property
  def out_buffer() -> c_void_p: ...

  @property
  def out_buffer_length() -> int: ...

  @property
  def out_buffer_valid_bytes() -> int: ...
  @out_buffer_valid_bytes.setter
  def out_buffer_valid_bytes(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_ioctl() -> Callable[[CBFilterBeforeIoctlEventParams], None]: ...
@on_before_ioctl.setter
def on_before_ioctl(event_hook: Callable[[CBFilterBeforeIoctlEventParams], None]) -> None: ...

Remarks

This event fires before an IRP_MJ_DEVICE_CONTROL (IOCTL) request is processed. Such requests are sent using the Windows API's DeviceIoControl function (user mode), or ZwDeviceIoControlFile function (kernel mode). Please refer to Microsoft's documentation for more information.

Applications may use this event to modify the input data (if there are any) before the request continues onward. Applications that choose to do this must do the following:

  1. Copy no more than InBufferLength bytes into InBuffer.
  2. Update the InBufferValidBytes parameter's value afterward so that it correctly reflects the amount of data in InBuffer.

Alternatively, applications may use this event to handle the request (preventing it from continuing onward), in which case they must do the following:

  1. Copy no more than OutBufferLength bytes into OutBuffer.
  2. Update the OutBufferValidBytes parameter's value afterward so that it correctly reflects the amount of data in OutBuffer.
  3. Set ProcessRequest to False to indicate that the request has been handled and should not continue onward.
(The first two steps are not applicable if the requested operation is not expected to return data.)

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_IOCTL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileName parameter reflects the file, directory, or volume targeted by the request.

The IoControlCode parameter reflects the requested I/O control code (IOCTL).

The InBuffer parameter points to a memory buffer that contains the data required to perform the operation. The InBufferLength and InBufferValidBytes parameters reflect the capacity of InBuffer and the length of the data it contains (respectively), in bytes; InBufferValidBytes may be less than InBufferLength (unless the request did not include data, in which case both will be 0).

The OutBuffer parameter points to a memory buffer that receives the data returned by the operation. The OutBufferLength and OutBufferValidBytes parameters reflect the capacity of OutBuffer and the length of the data it contains (respectively), in bytes; OutBufferValidBytes may be less than OutBufferLength (unless the operation is not expected to return data, in which case both will be 0).

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_lock Event

This event fires before a range of bytes in a file is locked.

Syntax

class CBFilterBeforeLockEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def offset() -> int: ...
  @offset.setter
  def offset(value) -> None: ...

  @property
  def length() -> int: ...
  @length.setter
  def length(value) -> None: ...

  @property
  def key() -> int: ...

  @property
  def fail_immediately() -> bool: ...
  @fail_immediately.setter
  def fail_immediately(value) -> None: ...

  @property
  def exclusive_lock() -> bool: ...
  @exclusive_lock.setter
  def exclusive_lock(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_lock() -> Callable[[CBFilterBeforeLockEventParams], None]: ...
@on_before_lock.setter
def on_before_lock(event_hook: Callable[[CBFilterBeforeLockEventParams], None]) -> None: ...

Remarks

This event fires before a range of bytes in the file specified by FileName is locked; This request is made either by the OS, or on behalf of a user mode application that called the Windows API's LockFile or LockFileEx function.

Applications may use this event to modify the request's parameters.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Offset parameter specifies the byte offset where the byte range lock should start.

The Length parameter specifies the length of the byte range lock.

The Key parameter reflects the key that the byte range lock will be associated with. This key is used to identify the byte range lock in later unlock-by-key requests.

The FailImmediately parameter specifies whether the request should fail if the lock cannot be granted immediately.

The ExclusiveLock parameter specifies whether the byte range lock should be exclusive (True) or shared (False).

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_open_file Event

This event fires before a file or directory is opened.

Syntax

class CBFilterBeforeOpenFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def existing_attributes() -> int: ...

  @property
  def isolate() -> bool: ...
  @isolate.setter
  def isolate(value) -> None: ...

  @property
  def backend_file_name() -> str: ...
  @backend_file_name.setter
  def backend_file_name(value) -> None: ...

  @property
  def desired_access() -> int: ...
  @desired_access.setter
  def desired_access(value) -> None: ...

  @property
  def attributes() -> int: ...
  @attributes.setter
  def attributes(value) -> None: ...

  @property
  def share_mode() -> int: ...
  @share_mode.setter
  def share_mode(value) -> None: ...

  @property
  def options() -> int: ...
  @options.setter
  def options(value) -> None: ...

  @property
  def create_disposition() -> int: ...
  @create_disposition.setter
  def create_disposition(value) -> None: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_open_file() -> Callable[[CBFilterBeforeOpenFileEventParams], None]: ...
@on_before_open_file.setter
def on_before_open_file(event_hook: Callable[[CBFilterBeforeOpenFileEventParams], None]) -> None: ...

Remarks

This event fires before the file or directory specified by FileName is opened. Please refer to the File Create/Open Events topic for more information about how the class determines whether to fire this event or on_before_create_file.

Applications may use this event to modify the request's parameters, or to block the request entirely. To do the latter, set ProcessRequest to False; this has the same effect as returning ACCESS_DENIED.

To redirect a request to another file or directory, use the on_reparse_file_name event, which is fired shortly after this event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_OPEN flag.

Note: Applications must have the FilterOwnRequests configuration setting enabled if they wish to filter their own file/directory open requests.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

When extended rules are used or the AlwaysRequestAttributesOnOpen configuration setting is enabled, the driver requests attributes of the entity from the filesystem and passes them to ExistingAttributes. If the attributes are not requested, this parameter contains 0.

Isolation-related functionality is under construction.

The initial values of DesiredAccess, Attributes, ShareMode, and CreateDisposition parameters reflect the values that were passed for the similarly named parameters of the Windows API's CreateFile function (or, more accurately, the values carried by the IRP_MJ_CREATE Internet Relay Programming).

DesiredAccess may contain one or more of the following access flags:

DESIRED_ACCESS_FILE_LIST_DIRECTORY0x00000001For a directory, the right to list the contents of the directory.

DESIRED_ACCESS_FILE_READ_DATA0x00000001For a file object, the right to read the corresponding file data.

For a directory object, the right to read the corresponding directory data.

DESIRED_ACCESS_FILE_ADD_FILE0x00000002For a directory, the right to create a file in the directory.

DESIRED_ACCESS_FILE_WRITE_DATA0x00000002For a file object, the right to write data to the file.

For a directory object, the right to create a file in the directory

DESIRED_ACCESS_FILE_ADD_SUBDIRECTORY0x00000004For a directory, the right to create a subdirectory.

DESIRED_ACCESS_FILE_APPEND_DATA0x00000004For a file object, the right to append data to the file.

(For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) For a directory object, the right to create a subdirectory (FILE_ADD_SUBDIRECTORY).

DESIRED_ACCESS_FILE_READ_EA0x00000008The right to read extended file attributes.

DESIRED_ACCESS_FILE_WRITE_EA0x00000010The right to write extended file attributes.

DESIRED_ACCESS_FILE_EXECUTE0x00000020For a native code file, the right to execute the file.

This access right given to scripts may cause the script to be executable, depending on the script interpreter.

DESIRED_ACCESS_FILE_DELETE_CHILD0x00000040For a directory, the right to delete a directory and all the files it contains, including read-only files.

DESIRED_ACCESS_FILE_READ_ATTRIBUTES0x00000080The right to read file attributes.

DESIRED_ACCESS_FILE_WRITE_ATTRIBUTES0x00000100The right to write file attributes.

DESIRED_ACCESS_READ_CONTROL0x00020000The right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_READ0x00020000Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_WRITE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_STANDARD_RIGHTS_EXECUTE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_SYNCHRONIZE0x00100000The right to use the object for synchronization.

This enables a thread to wait until the object is in the signaled state. Some object types do not support this access right.

DESIRED_ACCESS_FILE_ALL_ACCESS0x001F01FFAll possible access rights for a file.

DESIRED_ACCESS_FILE_GENERIC_READ0x00120089A combinarion of flags that allow reading of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_WRITE0x00120116A combinarion of flags that allow modifications to the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_EXECUTE0x001200A0A combinarion of flags that allow execution of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

Attributes may contain one or more of the following attributes:

FILE_SYS_ATTR_READ_ONLY0x00000001The file is read-only.

Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.

FILE_SYS_ATTR_HIDDEN0x00000002The file or directory is hidden.

The file is not included in an ordinary directory listing.

FILE_SYS_ATTR_SYSTEM0x00000004A file or directory that the operating system uses a part of, or uses exclusively.

FILE_SYS_ATTR_DIRECTORY0x00000010The entry is a directory.

FILE_SYS_ATTR_ARCHIVE0x00000020The entry is an archive file or directory.

Applications typically use this attribute to mark files for backup or removal.

FILE_SYS_ATTR_NORMAL0x00000080A file doesn't have other attributes set.

This attribute is valid only when used alone.

FILE_SYS_ATTR_TEMPORARY0x00000100A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data are written after the handle is closed.

FILE_SYS_ATTR_SPARSE_FILE0x00000200A file that is a sparse file.

FILE_SYS_ATTR_REPARSE_POINT0x00000400A file that is a reparse point or a symbolic link.

FILE_SYS_ATTR_COMPRESSED0x00000800A file or directory that is compressed.

For a file, all of the data in the file are compressed. For a directory, compression is the default for newly created files and subdirectories. A filesystem implementation can make use of this attribute by setting the support_compressed_attribute property to True and then properly handling the on_get_file_info, on_enumerate_directory, and on_set_file_attributes events.

FILE_SYS_ATTR_OFFLINE0x00001000The data of a file are not available immediately.

This attribute indicates that the file data are physically moved to offline storage.

FILE_SYS_ATTR_NOT_CONTENT_INDEXED0x00002000The file or directory is not to be indexed by the content indexing service.

FILE_SYS_ATTR_ENCRYPTED0x00004000A file or directory that is encrypted.

For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.

Note: This flag is used by NTFS and the OS sends undocumented requests to the filesystem based on this flag. The flag should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_VIRTUAL0x00010000Reserved.

Note: This flag is reserved by the OS and should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_RECALL_ON_OPEN0x00040000The file or directory has no physical representation on the local system; the item is virtual.

Opening the item will be more expensive than normal (e.g., it will cause at least some of it to be fetched from a remote store). This flag is reported by filesystems during directory enumerations.

ShareMode may contain zero or more of the following share mode flags:

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CreateDisposition may contain one of the following values:

FILE_DISPOSITION_CREATE_NEW0x00000001Creates a new file, only if it does not already exist.

If the specified file exists, the operation fails with an "already exists" error.

FILE_DISPOSITION_CREATE_ALWAYS0x00000002Creates a new file, always.

If the specified file exists and is writable, the system overwrites the file. If the specified file does not exist and is a valid path, a new file is created.

FILE_DISPOSITION_OPEN_EXISTING0x00000003Opens a file, only if it exists

If the specified file does not exist, opening fails.

FILE_DISPOSITION_OPEN_ALWAYS0x00000004Opens a file, always.

If the specified file exists, the operation succeeds. If the specified file does not exist and is a valid path to a writable location, the a file is created.

FILE_DISPOSITION_TRUNCATE_EXISTING0x00000005Opens a file and truncates it so that its size is zero bytes, only if it exists.

If the specified file does not exist, the operation fails with a "file not found" error.

Options contains the flags that are described in the CreateOptions parameter of the Native API's ZwCreateFile function. Most of those flags correspond to flags passed in the FlagsAndAttributes parameter of the Windows API's CreateFile function, but some flags are specific to Native API. If you need those flags, check both functions' descriptions.

Please refer to Microsoft's documentation for detailed information about these constants.

To determine whether the request is for a file or a directory, compare Attributes against the FILE_SYS_ATTR_DIRECTORY constant, as follows: // Check whether the request is for a file or a directory. bool isDirectory = Attributes & FILE_SYS_ATTR_DIRECTORY == FILE_SYS_ATTR_DIRECTORY; FILE_SYS_ATTR_DIRECTORY will be present only if it was specified by the calling process; its presence or absence does not indicate the real presence of the attribute on the file or directory on disk.

To determine whether a file will be deleted when its last handle is closed, compare Options against the Windows API's FILE_FLAG_DELETE_ON_CLOSE constant, as follows: // Check whether the file will be deleted on close. bool deleteOnClose = Options & FILE_FLAG_DELETE_ON_CLOSE == FILE_FLAG_DELETE_ON_CLOSE;

Note: Files can be deleted in different ways, so do not use this check to take actions related to tracking file deletion operations. Instead, use the events related to file deletion.

To prevent a file or directory from being opened, set the ResultCode parameter to a non-zero value (typically ERROR_ACCESS_DENIED (5)).

When a file or directory is created using the CreateFile() Windows API function, a caller can specify the security descriptor with the security information. This security information should be applied to a newly created file or directory. The class passes this security information in the SecurityInformation and SecurityDescriptor parameters, when the PassSecurityInFileOpenEvents configuration setting is enabled. If this configuration setting is omitted, the corresponding parameters are empty.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, are valid and should have been applied. Please refer to Microsoft's SECURITY_INFORMATION data type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

If an application needs to alter the security information, it can do this by placing up to Length bytes of information into the SecurityDescriptor buffer.

Note: Changing the security data is possible only when the PassSecurityInFileOpenEvents configuration setting is enabled.

If the capacity reflected by the Length parameter is not enough to accommodate the security information, set LengthNeeded to the number of bytes necessary to hold the data, and return the ERROR_INSUFFICIENT_BUFFER error code via ResultCode.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

If the Options contains the FILE_FLAG_DELETE_ON_CLOSE flag, the on_before_can_file_be_deleted event will fire before this event.

If the file is opened with extended attributes passed in the request, the on_before_set_ea event will fire after this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_query_ea Event

This event fires before information about extended attributes of a file is retrieved.

Syntax

class CBFilterBeforeQueryEaEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def return_single_entry() -> bool: ...
  @return_single_entry.setter
  def return_single_entry(value) -> None: ...

  @property
  def ea_list() -> c_void_p: ...

  @property
  def ea_list_length() -> int: ...
  @ea_list_length.setter
  def ea_list_length(value) -> None: ...

  @property
  def ea_index() -> int: ...
  @ea_index.setter
  def ea_index(value) -> None: ...

  @property
  def restart_scan() -> bool: ...
  @restart_scan.setter
  def restart_scan(value) -> None: ...

  @property
  def length_returned() -> int: ...
  @length_returned.setter
  def length_returned(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_query_ea() -> Callable[[CBFilterBeforeQueryEaEventParams], None]: ...
@on_before_query_ea.setter
def on_before_query_ea(event_hook: Callable[[CBFilterBeforeQueryEaEventParams], None]) -> None: ...

Remarks

This event fires before information about extended attributes of the file specified by FileName is retrieved using the FltQueryEaFile function of the system API.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_QUERY_EA flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Buffer parameter points to a memory buffer, into which, if the request is successful, the filesystem will place the requested information. The data in the buffer are formatted as a FILE_FULL_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information. The Length parameter reflects the length of this buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

ReturnSingleEntry specifies that the filesystem had to return only the first entry it has found.

EaList is an optional parameter that points to a caller-supplied memory buffer specifying the extended attributes to be queried. The data in the buffer are formatted as a FILE_GET_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information. The EaListLength parameter reflects the length of this data, in bytes. If the caller of the FltQueryEaFile function did not specify any value, it will contain 0. The list may be modified by an event handler, if needed, provided that the size of the new or modified data does not exceed the value of the EaListLength parameter.

EaIndex is an optional parameter that specifies the starting index of the attribute, information about which is requested. This parameter is ignored by the filesystem if EaList points to a nonempty list. If the caller of the FltQueryEaFile function did not specify any value, the parameter will contain -1.

The RestartScan parameter instructs the filesystem to restart enumeration of extended attributes from the first entry. If the parameter is False, retrieval of the extended attributes is resumed by the filesystem after a previous request. The parameter may be modified by an event handler if needed.

LengthReturned is an optional parameter that contains the size, in bytes, of the information, returned in the Buffer.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

Applications may use this event to modify the request's data before it continues onward, or to handle the request entirely (preventing it from continuing onward). In these cases, applications must do the following:

  1. Copy no more than BufferLength bytes into Buffer.
  2. Update the LengthReturned parameter's value afterward so that it correctly reflects the amount of data in Buffer.
  3. If the request has been handled and should not continue onward, set ProcessRequest to False.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_query_file_info Event

This event fires before information about a file or directory is retrieved.

Syntax

class CBFilterBeforeQueryFileInfoEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_information_class() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def valid_bytes() -> int: ...
  @valid_bytes.setter
  def valid_bytes(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_query_file_info() -> Callable[[CBFilterBeforeQueryFileInfoEventParams], None]: ...
@on_before_query_file_info.setter
def on_before_query_file_info(event_hook: Callable[[CBFilterBeforeQueryFileInfoEventParams], None]) -> None: ...

Remarks

This event fires before information about the file or directory specified by FileName is retrieved; This event typically fires in response to the Windows API's NtQueryInformationFile function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_QUERY_FILE_INFO flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileInformationClass parameter indicates what kind of file information is requested. Please refer to the NtQueryInformationFile function's documentation for more information about possible values.

The Buffer parameter points to a memory buffer that receives the requested file information. The BufferLength and ValidBytes parameters reflect the capacity of Buffer and the length of the data it contains (respectively), in bytes; ValidBytes may be less than BufferLength. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The format of the data is determined by the specified FileInformationClass; please refer to the NtQueryInformationFile function's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

Applications may use this event to modify the request's data before it continues onward, or to handle the request entirely (preventing it from continuing onward). In these cases, applications must do the following:

  1. Copy no more than BufferLength bytes into Buffer.
  2. Update the ValidBytes parameter's value afterward so that it correctly reflects the amount of data in Buffer.
  3. If the request has been handled and should not continue onward, set ProcessRequest to False.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_read_file Event

This event fires before data are read from a file.

Syntax

class CBFilterBeforeReadFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def position() -> int: ...
  @position.setter
  def position(value) -> None: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def bytes_to_read() -> int: ...
  @bytes_to_read.setter
  def bytes_to_read(value) -> None: ...

  @property
  def reserved() -> int: ...
  @reserved.setter
  def reserved(value) -> None: ...

  @property
  def direction() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_read_file() -> Callable[[CBFilterBeforeReadFileEventParams], None]: ...
@on_before_read_file.setter
def on_before_read_file(event_hook: Callable[[CBFilterBeforeReadFileEventParams], None]) -> None: ...

Remarks

This event fires before data are read from the file specified by FileName.

Applications that intend to modify a file's data after it is read may use this event to modify the request's parameters, if necessary (e.g., to ensure that the correct data are read from the file and made available for postprocessing during the on_after_read_file event). Applications may also use this event to block the request entirely by returning an appropriate error code (e.g., ACCESS_DENIED) via ResultCode.

Alternatively, applications may use this event to handle the underlying request, in which case they must do the following:

  1. Enable the ModifiableReadWriteBuffers configuration setting (i.e., before this event fires).
  2. Copy no more than BufferLength bytes into Buffer.
  3. Update the BytesToRead parameter's value afterward so that it correctly reflects the amount of data in Buffer.
  4. Set ProcessRequest to False to indicate that the request has been handled and should not continue onward.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_READ flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Position parameter specifies the byte offset in the file at which reading should start.

The Buffer parameter points to a memory buffer that receives the data read from the file. The BufferLength parameter reflects the capacity of Buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The BytesToRead parameter's initial value reflects how many bytes should be read from the file (i.e., how many bytes the requestor expects will be read). This parameter's value may be changed (for either of the reasons discussed above), but it must not exceed BufferLength.

Note: However, reading more or less data than requested is not expected behavior and likely will cause the requestor to misbehave. Applications that change BytesToRead, for any reason, should use the on_after_read_file event to "cover up" such behavior; please refer to its documentation for more information.

The Direction parameter indicates the request direction; please refer to the Cached and Non-Cached Requests topic for more information. Possible values are as follows:

FS_REQUEST_DIR_USER_NONCACHED0Operations performed in the user mode application <--> filesystem direction.
FS_REQUEST_DIR_USER_CACHED1Operations performed in the user mode application <--> system cache direction.
FS_REQUEST_DIR_SYSTEM_NONCACHED2Operations performed in the system cache <--> filesystem direction.
FS_REQUEST_DIR_SYSTEM_CACHED3Operations performed in the system component <--> system cache direction.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_rename_or_move_file Event

This event fires before a file or directory is renamed or moved.

Syntax

class CBFilterBeforeRenameOrMoveFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def new_file_name() -> str: ...

  @property
  def replace_if_exists() -> bool: ...
  @replace_if_exists.setter
  def replace_if_exists(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_rename_or_move_file() -> Callable[[CBFilterBeforeRenameOrMoveFileEventParams], None]: ...
@on_before_rename_or_move_file.setter
def on_before_rename_or_move_file(event_hook: Callable[[CBFilterBeforeRenameOrMoveFileEventParams], None]) -> None: ...

Remarks

This event fires before the file or directory specified by FileName is renamed or moved to NewFileName.

Applications may use this event to modify the request's parameters, or to block the request entirely. To do the latter, set ProcessRequest to False.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_RENAME flag. A rule's mask is matched against both previous and new filenames, and the event will fire when either of the names matches the mask.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The ReplaceIfExists parameter specifies what to do if a file with the specified NewFileName already exists. If this parameter is True, the existing file will be overwritten by the file being renamed/moved; if this parameter is False, the operation will fail.

Note: Windows only allows files to be overwritten; if the destination is an existing directory, the request will be denied regardless of this parameter's value.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_allocation_size Event

This event fires before a file's allocation size is changed.

Syntax

class CBFilterBeforeSetAllocationSizeEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def allocation_size() -> int: ...
  @allocation_size.setter
  def allocation_size(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_allocation_size() -> Callable[[CBFilterBeforeSetAllocationSizeEventParams], None]: ...
@on_before_set_allocation_size.setter
def on_before_set_allocation_size(event_hook: Callable[[CBFilterBeforeSetAllocationSizeEventParams], None]) -> None: ...

Remarks

This event fires before the allocation size of the file specified by FileName is changed.

Applications may use this event to modify the request's parameters.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_SIZES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The AllocationSize parameter specifies the new allocation size, in bytes. A file's allocation size is typically larger than its actual size because filesystem operations often reserve space on disk before writing additional data to a file. Applications may track such situations and avoid reallocating disk space where possible to improve performance.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_ea Event

This event fires before extended attributes of a file are changed.

Syntax

class CBFilterBeforeSetEaEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_ea() -> Callable[[CBFilterBeforeSetEaEventParams], None]: ...
@on_before_set_ea.setter
def on_before_set_ea(event_hook: Callable[[CBFilterBeforeSetEaEventParams], None]) -> None: ...

Remarks

This event fires before extended attributes are changed for the file specified by FileName.

If the file is created or opened with extended attributes passed in the request, this event will fire shortly after the on_before_create_file or on_before_open_file event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_EA flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Buffer parameter points to a memory buffer that specifies the extended attribute information. The buffer referenced by the Buffer parameter may be modified when needed if the request is to be passed further to other filters and the filesystem driver. The Length parameter reflects the length of this buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a FILE_FULL_EA_INFORMATION structure; please refer to Microsoft's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_file_attributes Event

This event fires before a file or directory's attributes or times are changed.

Syntax

class CBFilterBeforeSetFileAttributesEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def creation_time() -> datetime.datetime: ...
  @creation_time.setter
  def creation_time(value) -> None: ...

  @property
  def last_access_time() -> datetime.datetime: ...
  @last_access_time.setter
  def last_access_time(value) -> None: ...

  @property
  def last_write_time() -> datetime.datetime: ...
  @last_write_time.setter
  def last_write_time(value) -> None: ...

  @property
  def change_time() -> datetime.datetime: ...
  @change_time.setter
  def change_time(value) -> None: ...

  @property
  def attributes() -> int: ...
  @attributes.setter
  def attributes(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_file_attributes() -> Callable[[CBFilterBeforeSetFileAttributesEventParams], None]: ...
@on_before_set_file_attributes.setter
def on_before_set_file_attributes(event_hook: Callable[[CBFilterBeforeSetFileAttributesEventParams], None]) -> None: ...

Remarks

This event fires before the attributes or times of a file or directory specified by FileName are changed.

Applications may use this event to modify the request's parameters.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_ATTRIBUTES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The CreationTime, LastAccessTime, LastWriteTime, and ChangeTime parameters specify the new time values, specified in UTC. A value of January 1, 1601 00:00:00 UTC indicates that the corresponding time value is not included in the request.

The Attributes parameter specifies the new attributes; please refer to Microsoft's File Attribute Constants article for attribute descriptions.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_file_info Event

This event fires before information about a file or directory is changed.

Syntax

class CBFilterBeforeSetFileInfoEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_information_class() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def valid_bytes() -> int: ...
  @valid_bytes.setter
  def valid_bytes(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_file_info() -> Callable[[CBFilterBeforeSetFileInfoEventParams], None]: ...
@on_before_set_file_info.setter
def on_before_set_file_info(event_hook: Callable[[CBFilterBeforeSetFileInfoEventParams], None]) -> None: ...

Remarks

This event fires before information about the file or directory specified by FileName is changed; This event typically fires in response to the Windows API's NtSetInformationFile function.

Applications may use this event to modify the request's data before it continues onward, in which case they must do the following:

  1. Copy no more than BufferLength bytes into Buffer.
  2. Update the ValidBytes parameter's value afterward so that it correctly reflects the amount of data in Buffer.

Alternatively, applications may use this event to handle the underlying request, preventing it from continuing onward, by setting ProcessRequest to False.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_FILE_INFO flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileInformationClass parameter indicates what kind of file information is to be changed. Please refer to the NtSetInformationFile function's documentation for more information about possible values.

The Buffer parameter points to a memory buffer that specifies the new file information. The BufferLength and ValidBytes parameters reflect the capacity of Buffer and the length of the data it contains, respectively, in bytes; ValidBytes may be less than BufferLength. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The format of the data is determined by the specified FileInformationClass; please refer to the NtSetInformationFile function's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_file_security Event

This event fires before a file or directory's security attributes are changed.

Syntax

class CBFilterBeforeSetFileSecurityEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def security_information() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_file_security() -> Callable[[CBFilterBeforeSetFileSecurityEventParams], None]: ...
@on_before_set_file_security.setter
def on_before_set_file_security(event_hook: Callable[[CBFilterBeforeSetFileSecurityEventParams], None]) -> None: ...

Remarks

This event fires before security attributes are changed for the file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_SECURITY flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, will be set. Please refer to Microsoft's SECURITY_INFORMATION data-type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that specifies the new security information. The buffer referenced by the SecurityDescriptor parameter may be modified when needed if the request is to be passed further to other filters and the filesystem driver. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_file_size Event

This event fires before a file is resized.

Syntax

class CBFilterBeforeSetFileSizeEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def size() -> int: ...
  @size.setter
  def size(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_file_size() -> Callable[[CBFilterBeforeSetFileSizeEventParams], None]: ...
@on_before_set_file_size.setter
def on_before_set_file_size(event_hook: Callable[[CBFilterBeforeSetFileSizeEventParams], None]) -> None: ...

Remarks

This event fires before the file specified by FileName is resized, whether explicitly (e.g., truncation) or implicitly (i.e., as data are appended).

Applications may use this event to modify the request's parameters.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_SIZES flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Size parameter specifies the new file size, in bytes.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_set_reparse_point Event

This event fires when the OS wants to create or update a reparse point on a file or directory.

Syntax

class CBFilterBeforeSetReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_tag() -> int: ...

  @property
  def reparse_buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def data_length() -> int: ...
  @data_length.setter
  def data_length(value) -> None: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_set_reparse_point() -> Callable[[CBFilterBeforeSetReparsePointEventParams], None]: ...
@on_before_set_reparse_point.setter
def on_before_set_reparse_point(event_hook: Callable[[CBFilterBeforeSetReparsePointEventParams], None]) -> None: ...

Remarks

This event fires before the OS creates or updates a reparse point on a file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_SET_REPARSE_POINT flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The ReparseTag is the reparse tag, which is the value the system uses to identify the format of the reparse point data. This value is also present in the ReparseBuffer data; for convenience, the class extracts it and provides it separately. If the event handler needs to change the reparse tag, it may do so in ReparseBuffer.

The ReparseBuffer parameter points to a memory buffer that specifies the new reparse point information. The buffer referenced by the ReparseBuffer parameter may be modified when needed if the request is to be passed further to other filters and the filesystem driver. The DataLength parameter initially reflects the length of the data contained in the buffer, in bytes. If the event handler updates the data in the ReparseBuffer, it should adjust DataLength to the size of the new data, placed to the buffer. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Please refer to the Reparse Points topic for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_unlock_all Event

This event fires before all locked byte ranges in a file are unlocked.

Syntax

class CBFilterBeforeUnlockAllEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_unlock_all() -> Callable[[CBFilterBeforeUnlockAllEventParams], None]: ...
@on_before_unlock_all.setter
def on_before_unlock_all(event_hook: Callable[[CBFilterBeforeUnlockAllEventParams], None]) -> None: ...

Remarks

This event fires before all locked byte ranges in the file specified by FileName are unlocked.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_unlock_all_by_key Event

This event fires before all locked byte ranges in a file, associated with a particular key, are unlocked.

Syntax

class CBFilterBeforeUnlockAllByKeyEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def key() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_unlock_all_by_key() -> Callable[[CBFilterBeforeUnlockAllByKeyEventParams], None]: ...
@on_before_unlock_all_by_key.setter
def on_before_unlock_all_by_key(event_hook: Callable[[CBFilterBeforeUnlockAllByKeyEventParams], None]) -> None: ...

Remarks

This event fires before all locked byte ranges in the file specified by FileName, and associated with the specified Key, are unlocked.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Key parameter contains the key value specified when the byte ranges were locked. Please refer to the on_before_lock event's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_unlock_single Event

This event fires before a particular locked byte range in a file is unlocked.

Syntax

class CBFilterBeforeUnlockSingleEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def offset() -> int: ...
  @offset.setter
  def offset(value) -> None: ...

  @property
  def length() -> int: ...
  @length.setter
  def length(value) -> None: ...

  @property
  def key() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_unlock_single() -> Callable[[CBFilterBeforeUnlockSingleEventParams], None]: ...
@on_before_unlock_single.setter
def on_before_unlock_single(event_hook: Callable[[CBFilterBeforeUnlockSingleEventParams], None]) -> None: ...

Remarks

This event fires before a particular locked byte range in the file specified by FileName is unlocked.

Applications may use this event to modify the request's parameters.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_LOCK_CONTROL flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Offset, Length, and Key parameters contain the starting byte offset, length, and key values, respectively, specified when the byte range was locked. Please refer to the on_before_lock event's documentation for more information.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_before_write_file Event

This event fires before data are written to a file.

Syntax

class CBFilterBeforeWriteFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def position() -> int: ...
  @position.setter
  def position(value) -> None: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def bytes_to_write() -> int: ...
  @bytes_to_write.setter
  def bytes_to_write(value) -> None: ...

  @property
  def reserved() -> int: ...
  @reserved.setter
  def reserved(value) -> None: ...

  @property
  def direction() -> int: ...

  @property
  def file_context() -> int: ...
  @file_context.setter
  def file_context(value) -> None: ...

  @property
  def handle_context() -> int: ...
  @handle_context.setter
  def handle_context(value) -> None: ...

  @property
  def process_request() -> bool: ...
  @process_request.setter
  def process_request(value) -> None: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_before_write_file() -> Callable[[CBFilterBeforeWriteFileEventParams], None]: ...
@on_before_write_file.setter
def on_before_write_file(event_hook: Callable[[CBFilterBeforeWriteFileEventParams], None]) -> None: ...

Remarks

This event fires before data are written to the file specified by FileName.

Applications may use this event to modify the request's parameters or data. Applications that choose to modify the request's data must do the following:

  1. Enable the ModifiableReadWriteBuffers configuration setting (i.e., before this event fires).
  2. Copy no more than BufferLength bytes into Buffer.
  3. Update the BytesToWrite parameter's value afterward so that it correctly reflects the amount of data in Buffer.

Applications may also use this event to block the request entirely by returning an appropriate error code (e.g., ACCESS_DENIED) via ResultCode.

Alternatively, applications may use this event to handle the underlying request, in which case they must do the following:

  1. Write the data pointed to by Buffer to the desired location (after preprocessing it, if necessary).
  2. Update the BytesToWrite parameter's value afterward so that it correctly reflects the amount of data that were written.
  3. Set ProcessRequest to False to indicate that the request has been handled and should not continue onward.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_CE_BEFORE_WRITE flag.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

The Position parameter specifies the byte offset in the file at which writing should start. A value of -1 means "append to the end of the file".

The Buffer parameter points to a memory buffer that contains the data to write to the file. The BufferLength parameter reflects the capacity of Buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The BytesToWrite parameter's initial value reflects how many bytes should be written to the file (i.e., how many bytes the requestor expects will be written). This parameter's value may be changed (for either of the reasons discussed above), but it must not exceed BufferLength.

Note: However, writing more or less data than requested is not expected behavior and likely will cause the requestor to misbehave. Applications that change BytesToWrite, for any reason, should use the on_after_write_file event to "cover up" such behavior; please refer to its documentation for more information.

The Direction parameter indicates the request direction; please refer to the Cached and Non-Cached Requests topic for more information. Possible values are as follows:

FS_REQUEST_DIR_USER_NONCACHED0Operations performed in the user mode application <--> filesystem direction.
FS_REQUEST_DIR_USER_CACHED1Operations performed in the user mode application <--> system cache direction.
FS_REQUEST_DIR_SYSTEM_NONCACHED2Operations performed in the system cache <--> filesystem direction.
FS_REQUEST_DIR_SYSTEM_CACHED3Operations performed in the system component <--> system cache direction.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be None.)

The ProcessRequest parameter controls whether the request is sent onward for further processing by subsequent filter drivers and the filesystem; it is True by default.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_cleanup_context Event

This event fires when the application-defined data stored in one or more contexts need to be cleaned up.

Syntax

class CBFilterCleanupContextEventParams(object):
  @property
  def file_context() -> int: ...

  @property
  def handle_context() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_cleanup_context() -> Callable[[CBFilterCleanupContextEventParams], None]: ...
@on_cleanup_context.setter
def on_cleanup_context(event_hook: Callable[[CBFilterCleanupContextEventParams], None]) -> None: ...

Remarks

This event fires after a file or directory is closed, just before any contexts related to it are discarded, giving applications a chance to clean up any information stored in them.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information.

When a handle to some file or directory is closed, this event will fire if the HandleContext associated with that handle is not None. When the last handle to the file or directory is closed, this event will fire if the HandleContext associated with that handle or the FileContext associated with that file or directory is not None. After this event fires, the applicable contexts are set back to None automatically.

Applications that need to know the name of the file or directory this event is firing for should store a copy of that name in the context during an earlier event.

This event is optional; it will fire regardless of whether any filter rules are present, but only if FileContext, HandleContext, or both, are not already None. Applications that clean up their contexts (and set them back to None) when a file is being closed, or earlier, do not need to handle this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_error Event

This event fires if an unhandled error occurs during an event.

Syntax

class CBFilterErrorEventParams(object):
  @property
  def error_code() -> int: ...

  @property
  def description() -> str: ...

# In class CBFilter:
@property
def on_error() -> Callable[[CBFilterErrorEventParams], None]: ...
@on_error.setter
def on_error(event_hook: Callable[[CBFilterErrorEventParams], None]) -> None: ...

Remarks

This event fires if an unhandled error occurs during another event. Developers can use this information to track down unhandled errors in an application's event handlers.

Note: Not everything is possible or allowed in the event handlers. For details, see the Recursive Calls topic.

on_filter_start Event

This event fires once the filter has attached and filtering has started.

Syntax

class CBFilterFilterStartEventParams(object):
  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_filter_start() -> Callable[[CBFilterFilterStartEventParams], None]: ...
@on_filter_start.setter
def on_filter_start(event_hook: Callable[[CBFilterFilterStartEventParams], None]) -> None: ...

Remarks

This event fires once the filter has attached and filtering has started; please refer to the start_filter method for more information.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available or security checks failed), set it to a nonzero value to report an appropriate error. Please see the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_filter_stop Event

This event fires once filtering has stopped and the filter has detached.

Syntax

class CBFilterFilterStopEventParams(object):
  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_filter_stop() -> Callable[[CBFilterFilterStopEventParams], None]: ...
@on_filter_stop.setter
def on_filter_stop(event_hook: Callable[[CBFilterFilterStopEventParams], None]) -> None: ...

Remarks

This event fires once filtering has stopped and the filter has detached.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

on_notify_can_file_be_deleted Event

This event fires when the OS marks a file or directory for deletion or removes such a mark.

Syntax

class CBFilterNotifyCanFileBeDeletedEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def request_type() -> int: ...

  @property
  def can_delete() -> bool: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_can_file_be_deleted() -> Callable[[CBFilterNotifyCanFileBeDeletedEventParams], None]: ...
@on_notify_can_file_be_deleted.setter
def on_notify_can_file_be_deleted(event_hook: Callable[[CBFilterNotifyCanFileBeDeletedEventParams], None]) -> None: ...

Remarks

This event fires when the OS marks the file or directory specified by FileName for deletion or removes such a mark.

Files and directories can be deleted in two ways: (1) a file or directory can be opened with the FILE_FLAG_DELETE_ON_CLOSE flag, or (2) some process may call Windows API's NtSetInformationFile function with FILE_DISPOSITION_INFORMATION or FILE_DISPOSITION_INFORMATION_EX structure as a parameter.

If the file or directory is created or opened with the FILE_FLAG_DELETE_ON_CLOSE flag, this event is fired shortly after the on_notify_create_file or on_notify_open_file event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_CAN_DELETE flag.

The RequestType indicates which kind of system request resulted in firing this event. It can be one of the following:

DEL_REQ_OPEN_FLAG0x1The file or directory is opened with the FILE_FLAG_DELETE_ON_CLOSE flag

DEL_REQ_SET_DISPOSITION0x2The system has sent the IRP_MJ_SET_INFORMATION request with SetFileDisposition structure as a parameter.

This request usually is sent using the NtSetInformationFile() Windows native API function.

The CanDelete parameter reflects whether or not the file or directory can be deleted.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_cleanup_file Event

This event fires when a file or directory handle has been closed.

Syntax

class CBFilterNotifyCleanupFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_cleanup_file() -> Callable[[CBFilterNotifyCleanupFileEventParams], None]: ...
@on_notify_cleanup_file.setter
def on_notify_cleanup_file(event_hook: Callable[[CBFilterNotifyCleanupFileEventParams], None]) -> None: ...

Remarks

This event fires when a handle to the file or directory specified by FileName has been closed. This event differs from on_notify_close_file in that on_notify_cleanup_file fires when an open handle to the specified file or directory is closed by a process, whereas on_notify_close_file may be fired much later when the OS itself decides that the file or directory can be formally closed.

Other events may fire for the file or directory in the time between when this event fires and when the on_notify_close_file event fires. For example, system components, such as the memory manager or cache manager, may cause the on_notify_read_file and on_notify_write_file events to fire.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_CLEANUP flag.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_close_file Event

This event fires when a file or directory has been closed.

Syntax

class CBFilterNotifyCloseFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_close_file() -> Callable[[CBFilterNotifyCloseFileEventParams], None]: ...
@on_notify_close_file.setter
def on_notify_close_file(event_hook: Callable[[CBFilterNotifyCloseFileEventParams], None]) -> None: ...

Remarks

This event fires when the file or directory specified by FileName has been closed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_CLOSE flag.

If the file or directory was marked for deletion earlier, the on_notify_delete_file will fire shortly before this event.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_create_file Event

This event fires when a file or directory has been created.

Syntax

class CBFilterNotifyCreateFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def existing_attributes() -> int: ...

  @property
  def desired_access() -> int: ...

  @property
  def attributes() -> int: ...

  @property
  def share_mode() -> int: ...

  @property
  def options() -> int: ...

  @property
  def create_disposition() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_create_file() -> Callable[[CBFilterNotifyCreateFileEventParams], None]: ...
@on_notify_create_file.setter
def on_notify_create_file(event_hook: Callable[[CBFilterNotifyCreateFileEventParams], None]) -> None: ...

Remarks

This event fires when the file or directory specified by FileName has been created. Please refer to the File Create/Open Events topic for more information about how the class determines whether to fire this event or on_notify_open_file.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_CREATE flag.

Note: Applications must have the FilterOwnRequests configuration setting enabled if they wish to filter their own file/directory creation requests.

When extended rules are used or the AlwaysRequestAttributesOnOpen configuration setting is enabled, the driver requests attributes of the entity from the filesystem and passes them to ExistingAttributes. If the attributes are not requested, this parameter contains 0.

The DesiredAccess, Attributes, ShareMode, and CreateDisposition parameters reflect the values that were passed for the similarly named parameters of the Windows API's CreateFile function (or, more accurately, the values carried by the IRP_MJ_CREATE IRP).

DesiredAccess may contain one or more of the following access flags:

DESIRED_ACCESS_FILE_LIST_DIRECTORY0x00000001For a directory, the right to list the contents of the directory.

DESIRED_ACCESS_FILE_READ_DATA0x00000001For a file object, the right to read the corresponding file data.

For a directory object, the right to read the corresponding directory data.

DESIRED_ACCESS_FILE_ADD_FILE0x00000002For a directory, the right to create a file in the directory.

DESIRED_ACCESS_FILE_WRITE_DATA0x00000002For a file object, the right to write data to the file.

For a directory object, the right to create a file in the directory

DESIRED_ACCESS_FILE_ADD_SUBDIRECTORY0x00000004For a directory, the right to create a subdirectory.

DESIRED_ACCESS_FILE_APPEND_DATA0x00000004For a file object, the right to append data to the file.

(For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) For a directory object, the right to create a subdirectory (FILE_ADD_SUBDIRECTORY).

DESIRED_ACCESS_FILE_READ_EA0x00000008The right to read extended file attributes.

DESIRED_ACCESS_FILE_WRITE_EA0x00000010The right to write extended file attributes.

DESIRED_ACCESS_FILE_EXECUTE0x00000020For a native code file, the right to execute the file.

This access right given to scripts may cause the script to be executable, depending on the script interpreter.

DESIRED_ACCESS_FILE_DELETE_CHILD0x00000040For a directory, the right to delete a directory and all the files it contains, including read-only files.

DESIRED_ACCESS_FILE_READ_ATTRIBUTES0x00000080The right to read file attributes.

DESIRED_ACCESS_FILE_WRITE_ATTRIBUTES0x00000100The right to write file attributes.

DESIRED_ACCESS_READ_CONTROL0x00020000The right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_READ0x00020000Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_WRITE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_STANDARD_RIGHTS_EXECUTE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_SYNCHRONIZE0x00100000The right to use the object for synchronization.

This enables a thread to wait until the object is in the signaled state. Some object types do not support this access right.

DESIRED_ACCESS_FILE_ALL_ACCESS0x001F01FFAll possible access rights for a file.

DESIRED_ACCESS_FILE_GENERIC_READ0x00120089A combinarion of flags that allow reading of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_WRITE0x00120116A combinarion of flags that allow modifications to the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_EXECUTE0x001200A0A combinarion of flags that allow execution of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

Attributes may contain one or more of the following attributes:

FILE_SYS_ATTR_READ_ONLY0x00000001The file is read-only.

Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.

FILE_SYS_ATTR_HIDDEN0x00000002The file or directory is hidden.

The file is not included in an ordinary directory listing.

FILE_SYS_ATTR_SYSTEM0x00000004A file or directory that the operating system uses a part of, or uses exclusively.

FILE_SYS_ATTR_DIRECTORY0x00000010The entry is a directory.

FILE_SYS_ATTR_ARCHIVE0x00000020The entry is an archive file or directory.

Applications typically use this attribute to mark files for backup or removal.

FILE_SYS_ATTR_NORMAL0x00000080A file doesn't have other attributes set.

This attribute is valid only when used alone.

FILE_SYS_ATTR_TEMPORARY0x00000100A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data are written after the handle is closed.

FILE_SYS_ATTR_SPARSE_FILE0x00000200A file that is a sparse file.

FILE_SYS_ATTR_REPARSE_POINT0x00000400A file that is a reparse point or a symbolic link.

FILE_SYS_ATTR_COMPRESSED0x00000800A file or directory that is compressed.

For a file, all of the data in the file are compressed. For a directory, compression is the default for newly created files and subdirectories. A filesystem implementation can make use of this attribute by setting the support_compressed_attribute property to True and then properly handling the on_get_file_info, on_enumerate_directory, and on_set_file_attributes events.

FILE_SYS_ATTR_OFFLINE0x00001000The data of a file are not available immediately.

This attribute indicates that the file data are physically moved to offline storage.

FILE_SYS_ATTR_NOT_CONTENT_INDEXED0x00002000The file or directory is not to be indexed by the content indexing service.

FILE_SYS_ATTR_ENCRYPTED0x00004000A file or directory that is encrypted.

For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.

Note: This flag is used by NTFS and the OS sends undocumented requests to the filesystem based on this flag. The flag should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_VIRTUAL0x00010000Reserved.

Note: This flag is reserved by the OS and should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_RECALL_ON_OPEN0x00040000The file or directory has no physical representation on the local system; the item is virtual.

Opening the item will be more expensive than normal (e.g., it will cause at least some of it to be fetched from a remote store). This flag is reported by filesystems during directory enumerations.

ShareMode may contain zero or more of the following share mode flags:

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CreateDisposition may contain one of the following values:

FILE_DISPOSITION_CREATE_NEW0x00000001Creates a new file, only if it does not already exist.

If the specified file exists, the operation fails with an "already exists" error.

FILE_DISPOSITION_CREATE_ALWAYS0x00000002Creates a new file, always.

If the specified file exists and is writable, the system overwrites the file. If the specified file does not exist and is a valid path, a new file is created.

FILE_DISPOSITION_OPEN_EXISTING0x00000003Opens a file, only if it exists

If the specified file does not exist, opening fails.

FILE_DISPOSITION_OPEN_ALWAYS0x00000004Opens a file, always.

If the specified file exists, the operation succeeds. If the specified file does not exist and is a valid path to a writable location, the a file is created.

FILE_DISPOSITION_TRUNCATE_EXISTING0x00000005Opens a file and truncates it so that its size is zero bytes, only if it exists.

If the specified file does not exist, the operation fails with a "file not found" error.

Options contains the flags that are described in the CreateOptions parameter of the native API's ZwCreateFile function. Most of those flags correspond to flags passed in the FlagsAndAttributes parameter of the Windows API's CreateFile function, but some flags are specific to the native API. If you need those flags, check both functions' descriptions.

Please refer to Microsoft's documentation for detailed information about these constants.

To determine whether the request was for a file or a directory, compare Attributes against the FILE_SYS_ATTR_DIRECTORY constant, as follows: // Check whether the request is for a file or a directory. bool isDirectory = Attributes & FILE_SYS_ATTR_DIRECTORY == FILE_SYS_ATTR_DIRECTORY; FILE_SYS_ATTR_DIRECTORY will be present if it was specified by the calling process or if the existing filesystem entry is a directory.

To determine whether a file will be deleted when its last handle is closed, compare Options against the Windows API's FILE_FLAG_DELETE_ON_CLOSE constant, as follows: // Check whether the file will be deleted on close. bool deleteOnClose = Options & FILE_FLAG_DELETE_ON_CLOSE == FILE_FLAG_DELETE_ON_CLOSE; Note: Because files can be deleted in different ways, do not use this check to take actions related to tracking file deletion operations. Instead, use the events related to file deletion.

When a file or directory is created using the CreateFile() Windows API function, a caller can specify the security descriptor with the security information. This security information should be applied to a newly created file or directory. The class passes this security information in the SecurityInformation and SecurityDescriptor parameters, when the PassSecurityInFileOpenEvents configuration setting is enabled. If this configuration setting is omitted, the corresponding parameters are empty.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, are valid and should have been applied. Please refer to Microsoft's SECURITY_INFORMATION data type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

If the Options contains the FILE_FLAG_DELETE_ON_CLOSE flag, the on_notify_can_file_be_deleted event will fire after this event.

If the file is created with extended attributes passed in the request, the on_notify_set_ea event will fire after this event.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_create_hard_link Event

This event fires when a hard link has been created.

Syntax

class CBFilterNotifyCreateHardLinkEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def link_name() -> str: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_create_hard_link() -> Callable[[CBFilterNotifyCreateHardLinkEventParams], None]: ...
@on_notify_create_hard_link.setter
def on_notify_create_hard_link(event_hook: Callable[[CBFilterNotifyCreateHardLinkEventParams], None]) -> None: ...

Remarks

This event fires when a hard link to the file specified by FileName has been created. Please refer to Microsoft's Hard Links article for more information about hard links.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_CREATE_HARD_LINK flag.

The LinkName parameter reflects the name of the created hard link.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_delete_file Event

This event fires when a file or directory has been deleted.

Syntax

class CBFilterNotifyDeleteFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def request_type() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_delete_file() -> Callable[[CBFilterNotifyDeleteFileEventParams], None]: ...
@on_notify_delete_file.setter
def on_notify_delete_file(event_hook: Callable[[CBFilterNotifyDeleteFileEventParams], None]) -> None: ...

Remarks

This event fires when the file or directory specified by FileName has been deleted. More specifically, this event is queued for delivery after the final IRP_MJ_CLOSE I/O request packet (IRP) has been processed by the filesystem (i.e., after the last handle to the file or directory is closed and the file or directory is gone) and before on_notify_close_file is queued.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_DELETE flag.

The RequestType indicates which kind of system request resulted in firing this event. It can be one of the following:

DEL_REQ_OPEN_FLAG0x1The file or directory is opened with the FILE_FLAG_DELETE_ON_CLOSE flag

DEL_REQ_SET_DISPOSITION0x2The system has sent the IRP_MJ_SET_INFORMATION request with SetFileDisposition structure as a parameter.

This request usually is sent using the NtSetInformationFile() Windows native API function.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_delete_reparse_point Event

This event fires when a file or directory's reparse point has been deleted.

Syntax

class CBFilterNotifyDeleteReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_delete_reparse_point() -> Callable[[CBFilterNotifyDeleteReparsePointEventParams], None]: ...
@on_notify_delete_reparse_point.setter
def on_notify_delete_reparse_point(event_hook: Callable[[CBFilterNotifyDeleteReparsePointEventParams], None]) -> None: ...

Remarks

This event fires when a reparse point has been deleted from the file or directory specified by FileName.

Note: The file or directory was not deleted, only a reparse point was.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_DELETE_REPARSE_POINT flag.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_enumerate_directory Event

This event fires when a directory entry has been returned during directory enumeration.

Syntax

class CBFilterNotifyEnumerateDirectoryEventParams(object):
  @property
  def directory_name() -> str: ...

  @property
  def flags() -> int: ...

  @property
  def index() -> int: ...

  @property
  def file_name() -> str: ...

  @property
  def creation_time() -> datetime.datetime: ...

  @property
  def last_access_time() -> datetime.datetime: ...

  @property
  def last_write_time() -> datetime.datetime: ...

  @property
  def change_time() -> datetime.datetime: ...

  @property
  def size() -> int: ...

  @property
  def allocation_size() -> int: ...

  @property
  def file_id() -> int: ...

  @property
  def attributes() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_enumerate_directory() -> Callable[[CBFilterNotifyEnumerateDirectoryEventParams], None]: ...
@on_notify_enumerate_directory.setter
def on_notify_enumerate_directory(event_hook: Callable[[CBFilterNotifyEnumerateDirectoryEventParams], None]) -> None: ...

Remarks

This event fires when a directory entry (i.e., file or subdirectory) has been returned during enumeration of the directory specified by DirectoryName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_ENUMERATE_DIRECTORY flag.

The Flags parameter specifies supplementary information about enumeration. It is a combination of zero or more values:

FS_ENUM_RESTART_SCAN1The requestor specified that directory enumeration must be restarted.

FS_ENUM_RETURN_SINGLE_ENTRY2One entry should be returned.

FS_ENUM_INDEX_SPECIFIED4The requestor specified the index to start enumeration from.

If the Flags parameter contains FS_ENUM_INDEX_SPECIFIED, the Index parameter contains the index as provided by the OS.

The FileName parameter reflects the name of the directory entry.

The CreationTime, LastAccessTime, LastWriteTime, and ChangeTime parameters reflect the entry's time values, specified in UTC.

The Size parameter reflects the size of the file, in bytes; it is always 0 for subdirectories.

The AllocationSize parameter reflects the amount of space allocated for the file, in bytes; it is always 0 for subdirectories.

The FileId parameter reflects the unique Id of the entry, as reported by the filesystem. This Id is used by the network redirector, and some third-party applications, to open files and directories by Id instead of by name. The root directory always uses the predefined Id 0x7FFFFFFFFFFFFFFF.

The Attributes parameter reflects the entry's attributes; please refer to Microsoft's File Attribute Constants article for attribute descriptions.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_filter_attach_to_volume Event

This event fires when the filter has been attached to a newly mounted filesystem volume.

Syntax

class CBFilterNotifyFilterAttachToVolumeEventParams(object):
  @property
  def volume_name() -> str: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_filter_attach_to_volume() -> Callable[[CBFilterNotifyFilterAttachToVolumeEventParams], None]: ...
@on_notify_filter_attach_to_volume.setter
def on_notify_filter_attach_to_volume(event_hook: Callable[[CBFilterNotifyFilterAttachToVolumeEventParams], None]) -> None: ...

Remarks

This event fires when the filter has been attached to the newly mounted filesystem volume specified by VolumeName. Please refer to the fire_volume_events property for more information.

Applications need to handle this event only if the fire_volume_events property includes the FS_MOUNT_NOTIFY flag.

Note: This event won't fire for any volumes skipped during the on_before_filter_attach_to_volume event; please refer to its documentation for more information.

Applications that use volume-specific rules should typically add such rules during the on_after_filter_attach_to_volume event, which is fired synchronously, rather than this one.

The format of the VolumeName parameter's value depends on whether the ResolveNtDeviceToDriveLetter configuration setting is enabled; please refer to its documentation for more information. Applications can obtain additional information about a volume by retrieving its GUID using the get_volume_guid method, and then using that GUID to call various Windows API functions.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

Applications must be aware that this event fires as a direct response to a filesystem state change (mount or unmount). Various system components or third-party actors can perform supplementary filesystem mounting and unmounting during main unmount operations (e.g., Volume Service is one such component). This can cause seemingly excessive events to be fired, and sometimes they can be fired out of order (such as two *Attach or *Detach events fired in a row).

on_notify_filter_detach_from_volume Event

This event fires when the filter has been detached from a filesystem volume.

Syntax

class CBFilterNotifyFilterDetachFromVolumeEventParams(object):
  @property
  def volume_name() -> str: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_filter_detach_from_volume() -> Callable[[CBFilterNotifyFilterDetachFromVolumeEventParams], None]: ...
@on_notify_filter_detach_from_volume.setter
def on_notify_filter_detach_from_volume(event_hook: Callable[[CBFilterNotifyFilterDetachFromVolumeEventParams], None]) -> None: ...

Remarks

This event fires when the filter has been detached from the filesystem volume specified by VolumeName, typically as a result of the volume being unmounted. Please refer to the fire_volume_events property for more information.

Applications need to handle this event only if the fire_volume_events property includes the FS_MOUNT_NOTIFY flag.

Note: This event won't fire for any volumes skipped during the on_before_filter_attach_to_volume event; please refer to its documentation for more information.

Applications that use volume-specific rules typically should remove such rules during the on_after_filter_detach_from_volume event, which is fired synchronously, rather than this one.

The format of the VolumeName parameter's value depends on whether the ResolveNtDeviceToDriveLetter configuration setting is enabled; please refer to its documentation for more information. Applications can obtain additional information about a volume by retrieving its GUID using the get_volume_guid method, and then using that GUID to call various Windows API functions.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

Applications must be aware that this event fires as a direct response to a filesystem state change (mount or unmount). Various system components or third-party actors can perform supplementary filesystem mounting and unmounting during main unmount operations (e.g., Volume Service is one such component). This can cause seemingly excessive events to be fired, and sometimes they can be fired out of order (such as two *Attach or *Detach events fired in a row).

on_notify_fsctl Event

This event fires when an IRP_MJ_FILE_SYSTEM_CONTROL operation has occurred.

Syntax

class CBFilterNotifyFsctlEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def fs_control_code() -> int: ...

  @property
  def in_buffer() -> c_void_p: ...

  @property
  def in_buffer_length() -> int: ...

  @property
  def in_buffer_valid_bytes() -> int: ...

  @property
  def out_buffer() -> c_void_p: ...

  @property
  def out_buffer_length() -> int: ...

  @property
  def out_buffer_valid_bytes() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_fsctl() -> Callable[[CBFilterNotifyFsctlEventParams], None]: ...
@on_notify_fsctl.setter
def on_notify_fsctl(event_hook: Callable[[CBFilterNotifyFsctlEventParams], None]) -> None: ...

Remarks

This event fires when an IRP_MJ_FILE_SYSTEM_CONTROL (FSCTL) operation has occurred. Such requests are sent using the Windows API's DeviceIoControl function (user mode), or ZwFsControlFile function (kernel mode); please refer to Microsoft's documentation for more information.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_FSCTL flag.

The FileName parameter reflects the file, directory, or volume targeted by the request.

The FsControlCode parameter reflects the requested filesystem control code (FSCTL).

The InBuffer parameter points to a memory buffer that contains the data required to perform the operation. The InBufferLength and InBufferValidBytes parameters reflect the capacity of InBuffer and the length of the data it contains (respectively), in bytes; InBufferValidBytes may be less than InBufferLength (unless the request did not include data, in which case both will be 0).

The OutBuffer parameter points to a memory buffer that contains the data returned by the operation. The OutBufferLength and OutBufferValidBytes parameters reflect the capacity of OutBuffer and the length of the data it contains (respectively), in bytes; OutBufferValidBytes may be less than OutBufferLength (unless the operation did not return data, in which case both will be 0).

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_get_file_security Event

This event fires when a file or directory's security attributes have been retrieved.

Syntax

class CBFilterNotifyGetFileSecurityEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def security_information() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_get_file_security() -> Callable[[CBFilterNotifyGetFileSecurityEventParams], None]: ...
@on_notify_get_file_security.setter
def on_notify_get_file_security(event_hook: Callable[[CBFilterNotifyGetFileSecurityEventParams], None]) -> None: ...

Remarks

This event fires when security attributes have been retrieved for the file or directory specified by FileName.

Note: This event will not fire every time a file or directory is accessed. To check file security upon each access to a file or directory, implement the file create and open events and perform the necessary checks there instead.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_GET_SECURITY flag.

The SecurityInformation parameter indicates which pieces of security information were requested. Please refer to Microsoft's SECURITY_INFORMATION data-type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that, if the request was successful, contains the requested security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_get_file_sizes Event

This event fires when a file's size information has been retrieved.

Syntax

class CBFilterNotifyGetFileSizesEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def size() -> int: ...

  @property
  def allocation_size() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_get_file_sizes() -> Callable[[CBFilterNotifyGetFileSizesEventParams], None]: ...
@on_notify_get_file_sizes.setter
def on_notify_get_file_sizes(event_hook: Callable[[CBFilterNotifyGetFileSizesEventParams], None]) -> None: ...

Remarks

This event fires when size information has been retrieved for the file specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_GET_SIZES flag.

The Size parameter reflects the actual size of the file, in bytes.

The AllocationSize parameter reflects the amount of space allocated for the file, in bytes.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_get_reparse_point Event

This event fires when a file or directory's reparse point information has been retrieved.

Syntax

class CBFilterNotifyGetReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_get_reparse_point() -> Callable[[CBFilterNotifyGetReparsePointEventParams], None]: ...
@on_notify_get_reparse_point.setter
def on_notify_get_reparse_point(event_hook: Callable[[CBFilterNotifyGetReparsePointEventParams], None]) -> None: ...

Remarks

This event fires when reparse point information has been retrieved for the file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_GET_REPARSE_POINT flag.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_ioctl Event

This event fires when an IRP_MJ_DEVICE_CONTROL operation has occurred.

Syntax

class CBFilterNotifyIoctlEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def io_control_code() -> int: ...

  @property
  def in_buffer() -> c_void_p: ...

  @property
  def in_buffer_length() -> int: ...

  @property
  def in_buffer_valid_bytes() -> int: ...

  @property
  def out_buffer() -> c_void_p: ...

  @property
  def out_buffer_length() -> int: ...

  @property
  def out_buffer_valid_bytes() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_ioctl() -> Callable[[CBFilterNotifyIoctlEventParams], None]: ...
@on_notify_ioctl.setter
def on_notify_ioctl(event_hook: Callable[[CBFilterNotifyIoctlEventParams], None]) -> None: ...

Remarks

This event fires when an IRP_MJ_DEVICE_CONTROL (IOCTL) operation has occurred. Such requests are sent using the Windows API's DeviceIoControl function (user mode), or ZwDeviceIoControlFile function (kernel mode). Please refer to Microsoft's documentation for more information.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_IOCTL flag.

The FileName parameter reflects the file, directory, or volume targeted by the request.

The IoControlCode parameter reflects the requested I/O control code (IOCTL).

The InBuffer parameter points to a memory buffer that contains the data required to perform the operation. The InBufferLength and InBufferValidBytes parameters reflect the capacity of InBuffer and the length of the data it contains (respectively), in bytes; InBufferValidBytes may be less than InBufferLength (unless the request did not include data, in which case both will be 0).

The OutBuffer parameter points to a memory buffer that contains the data returned by the operation. The OutBufferLength and OutBufferValidBytes parameters reflect the capacity of OutBuffer and the length of the data it contains (respectively), in bytes; OutBufferValidBytes may be less than OutBufferLength (unless the operation did not return data, in which case both will be 0).

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_lock Event

This event fires when a range of bytes in a file has been locked.

Syntax

class CBFilterNotifyLockEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def offset() -> int: ...

  @property
  def length() -> int: ...

  @property
  def key() -> int: ...

  @property
  def fail_immediately() -> bool: ...

  @property
  def exclusive_lock() -> bool: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_lock() -> Callable[[CBFilterNotifyLockEventParams], None]: ...
@on_notify_lock.setter
def on_notify_lock(event_hook: Callable[[CBFilterNotifyLockEventParams], None]) -> None: ...

Remarks

This event fires when a range of bytes in the file specified by FileName has been locked; This request is made either by the OS, or on behalf of a user mode application that called the Windows API's LockFile or LockFileEx function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_LOCK_CONTROL flag.

The Offset parameter reflects the byte offset where the byte range lock starts.

The Length parameter reflects the length of the byte range lock.

The Key parameter reflects the key that the byte range lock is associated with. This key is used to identify the byte range lock in later unlock-by-key requests.

The FailImmediately parameter indicates whether the request was to fail if the lock could not be granted immediately.

The ExclusiveLock parameter indicates whether the byte range lock was to be exclusive (True) or shared (False).

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_open_file Event

This event fires when a file or directory has been opened.

Syntax

class CBFilterNotifyOpenFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def existing_attributes() -> int: ...

  @property
  def desired_access() -> int: ...

  @property
  def attributes() -> int: ...

  @property
  def share_mode() -> int: ...

  @property
  def options() -> int: ...

  @property
  def create_disposition() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_open_file() -> Callable[[CBFilterNotifyOpenFileEventParams], None]: ...
@on_notify_open_file.setter
def on_notify_open_file(event_hook: Callable[[CBFilterNotifyOpenFileEventParams], None]) -> None: ...

Remarks

This event fires when the file or directory specified by FileName has been opened. Please refer to the File Create/Open Events topic for more information about how the class determines whether to fire this event or on_notify_create_file.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_OPEN flag.

Note: Applications must have the FilterOwnRequests configuration setting enabled if they wish to filter their own file/directory open requests.

When extended rules are used or the AlwaysRequestAttributesOnOpen configuration setting is enabled, the driver requests attributes of the entity from the filesystem and passes them to ExistingAttributes. If the attributes are not requested, this parameter contains 0.

The DesiredAccess, Attributes, ShareMode, and CreateDisposition parameters reflect the values that were passed for the similarly named parameters of the Windows API's CreateFile function (or, more accurately, the values carried by the IRP_MJ_CREATE IRP).

DesiredAccess may contain one or more of the following access flags:

DESIRED_ACCESS_FILE_LIST_DIRECTORY0x00000001For a directory, the right to list the contents of the directory.

DESIRED_ACCESS_FILE_READ_DATA0x00000001For a file object, the right to read the corresponding file data.

For a directory object, the right to read the corresponding directory data.

DESIRED_ACCESS_FILE_ADD_FILE0x00000002For a directory, the right to create a file in the directory.

DESIRED_ACCESS_FILE_WRITE_DATA0x00000002For a file object, the right to write data to the file.

For a directory object, the right to create a file in the directory

DESIRED_ACCESS_FILE_ADD_SUBDIRECTORY0x00000004For a directory, the right to create a subdirectory.

DESIRED_ACCESS_FILE_APPEND_DATA0x00000004For a file object, the right to append data to the file.

(For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) For a directory object, the right to create a subdirectory (FILE_ADD_SUBDIRECTORY).

DESIRED_ACCESS_FILE_READ_EA0x00000008The right to read extended file attributes.

DESIRED_ACCESS_FILE_WRITE_EA0x00000010The right to write extended file attributes.

DESIRED_ACCESS_FILE_EXECUTE0x00000020For a native code file, the right to execute the file.

This access right given to scripts may cause the script to be executable, depending on the script interpreter.

DESIRED_ACCESS_FILE_DELETE_CHILD0x00000040For a directory, the right to delete a directory and all the files it contains, including read-only files.

DESIRED_ACCESS_FILE_READ_ATTRIBUTES0x00000080The right to read file attributes.

DESIRED_ACCESS_FILE_WRITE_ATTRIBUTES0x00000100The right to write file attributes.

DESIRED_ACCESS_READ_CONTROL0x00020000The right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_READ0x00020000Includes READ_CONTROL, which is the right to read the information in the file or directory object's security descriptor.

This does not include the information in the SACL.

DESIRED_ACCESS_STANDARD_RIGHTS_WRITE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_STANDARD_RIGHTS_EXECUTE0x00020000Same as STANDARD_RIGHTS_READ

DESIRED_ACCESS_SYNCHRONIZE0x00100000The right to use the object for synchronization.

This enables a thread to wait until the object is in the signaled state. Some object types do not support this access right.

DESIRED_ACCESS_FILE_ALL_ACCESS0x001F01FFAll possible access rights for a file.

DESIRED_ACCESS_FILE_GENERIC_READ0x00120089A combinarion of flags that allow reading of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_WRITE0x00120116A combinarion of flags that allow modifications to the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

DESIRED_ACCESS_FILE_GENERIC_EXECUTE0x001200A0A combinarion of flags that allow execution of the file.

Note: Don't match received values against this flag. Instead, use flags that specify the rights that you want to verify or add/remove.

Attributes may contain one or more of the following attributes:

FILE_SYS_ATTR_READ_ONLY0x00000001The file is read-only.

Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories.

FILE_SYS_ATTR_HIDDEN0x00000002The file or directory is hidden.

The file is not included in an ordinary directory listing.

FILE_SYS_ATTR_SYSTEM0x00000004A file or directory that the operating system uses a part of, or uses exclusively.

FILE_SYS_ATTR_DIRECTORY0x00000010The entry is a directory.

FILE_SYS_ATTR_ARCHIVE0x00000020The entry is an archive file or directory.

Applications typically use this attribute to mark files for backup or removal.

FILE_SYS_ATTR_NORMAL0x00000080A file doesn't have other attributes set.

This attribute is valid only when used alone.

FILE_SYS_ATTR_TEMPORARY0x00000100A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data are written after the handle is closed.

FILE_SYS_ATTR_SPARSE_FILE0x00000200A file that is a sparse file.

FILE_SYS_ATTR_REPARSE_POINT0x00000400A file that is a reparse point or a symbolic link.

FILE_SYS_ATTR_COMPRESSED0x00000800A file or directory that is compressed.

For a file, all of the data in the file are compressed. For a directory, compression is the default for newly created files and subdirectories. A filesystem implementation can make use of this attribute by setting the support_compressed_attribute property to True and then properly handling the on_get_file_info, on_enumerate_directory, and on_set_file_attributes events.

FILE_SYS_ATTR_OFFLINE0x00001000The data of a file are not available immediately.

This attribute indicates that the file data are physically moved to offline storage.

FILE_SYS_ATTR_NOT_CONTENT_INDEXED0x00002000The file or directory is not to be indexed by the content indexing service.

FILE_SYS_ATTR_ENCRYPTED0x00004000A file or directory that is encrypted.

For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.

Note: This flag is used by NTFS and the OS sends undocumented requests to the filesystem based on this flag. The flag should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_VIRTUAL0x00010000Reserved.

Note: This flag is reserved by the OS and should not be used for files in custom filesystem implementations.

FILE_SYS_ATTR_RECALL_ON_OPEN0x00040000The file or directory has no physical representation on the local system; the item is virtual.

Opening the item will be more expensive than normal (e.g., it will cause at least some of it to be fetched from a remote store). This flag is reported by filesystems during directory enumerations.

ShareMode may contain zero or more of the following share mode flags:

FILESYS_SHARE_READ0x00000001Enables subsequent open operations on a file or device to request read access.

Enables subsequent open operations to request read access; otherwise, no process can open the file or device if it requests read access. If this flag is not specified, but the file or device has been opened for read access, the function fails.

FILESYS_SHARE_WRITE0x00000002Enables subsequent open operations on a file or device to request write access.

Enables subsequent open operations to request write access; otherwise, no process can open the file or device if it requests write access. If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the function fails.

FILESYS_SHARE_DELETE0x00000004Enables subsequent open operations on a file or device to request delete access.

Enables subsequent open operations to request delete access; otherwise, no process can open the file or device if it requests delete access. If this flag is not specified, but the file or device has been opened for delete access, the function fails.

Note: Delete access allows both delete and rename operations.

CreateDisposition may contain one of the following values:

FILE_DISPOSITION_CREATE_NEW0x00000001Creates a new file, only if it does not already exist.

If the specified file exists, the operation fails with an "already exists" error.

FILE_DISPOSITION_CREATE_ALWAYS0x00000002Creates a new file, always.

If the specified file exists and is writable, the system overwrites the file. If the specified file does not exist and is a valid path, a new file is created.

FILE_DISPOSITION_OPEN_EXISTING0x00000003Opens a file, only if it exists

If the specified file does not exist, opening fails.

FILE_DISPOSITION_OPEN_ALWAYS0x00000004Opens a file, always.

If the specified file exists, the operation succeeds. If the specified file does not exist and is a valid path to a writable location, the a file is created.

FILE_DISPOSITION_TRUNCATE_EXISTING0x00000005Opens a file and truncates it so that its size is zero bytes, only if it exists.

If the specified file does not exist, the operation fails with a "file not found" error.

Options contains the flags that are described in the CreateOptions parameter of the native API's ZwCreateFile function. Most of those flags correspond to flags passed in the FlagsAndAttributes parameter of the Windows API's CreateFile function, but some flags are specific to the native API. If you need those flags, check both functions' descriptions.

Please refer to Microsoft's documentation for detailed information about these constants.

To determine whether the request was for a file or a directory, compare Attributes against the FILE_SYS_ATTR_DIRECTORY constant, as follows: // Check whether the request is for a file or a directory. bool isDirectory = Attributes & FILE_SYS_ATTR_DIRECTORY == FILE_SYS_ATTR_DIRECTORY; FILE_SYS_ATTR_DIRECTORY will be present if it was specified by the calling process or if the existing filesystem entry is a directory.

To determine whether a file will be deleted when its last handle is closed, compare Options against the Windows API's FILE_FLAG_DELETE_ON_CLOSE constant, as follows: // Check whether the file will be deleted on close. bool deleteOnClose = Options & FILE_FLAG_DELETE_ON_CLOSE == FILE_FLAG_DELETE_ON_CLOSE; Note: Because files can be deleted in different ways, do not use this check to take actions related to tracking file deletion operations. Instead, use the events related to file deletion.

When a file or directory is created using the CreateFile() Windows API function, a caller can specify the security descriptor with the security information. This security information should be applied to a newly created file or directory. The class passes this security information in the SecurityInformation and SecurityDescriptor parameters, when the PassSecurityInFileOpenEvents configuration setting is enabled. If this configuration setting is omitted, the corresponding parameters are empty.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, are valid and should have been applied. Please refer to Microsoft's SECURITY_INFORMATION data type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

If the Options contains the FILE_FLAG_DELETE_ON_CLOSE flag, the on_notify_can_file_be_deleted event will fire after this event.

If the file is opened with extended attributes passed in the request, the on_notify_set_ea event will fire after this event.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_query_ea Event

This event fires when information about the extended attributes of a file has been retrieved.

Syntax

class CBFilterNotifyQueryEaEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def return_single_entry() -> bool: ...

  @property
  def ea_list() -> c_void_p: ...

  @property
  def ea_list_length() -> int: ...

  @property
  def ea_index() -> int: ...

  @property
  def restart_scan() -> bool: ...

  @property
  def length_returned() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_query_ea() -> Callable[[CBFilterNotifyQueryEaEventParams], None]: ...
@on_notify_query_ea.setter
def on_notify_query_ea(event_hook: Callable[[CBFilterNotifyQueryEaEventParams], None]) -> None: ...

Remarks

This event fires when information about the extended attributes of a file specified by FileName has been retrieved.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_QUERY_EA flag.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the requested information. The data in the buffer are formatted as a FILE_FULL_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information. The Length parameter reflects the length of this buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

ReturnSingleEntry specifies that the filesystem had to return only the first entry it has found.

EaList is an optional parameter that points to a caller-supplied memory buffer specifying the extended attributes to be queried. The data in the buffer are formatted as a FILE_GET_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information. The EaListLength parameter reflects the length of this data, in bytes. If the caller of the FltQueryEaFile function did not specify any value, it will contain 0.

EaIndex is an optional parameter that specifies the starting index of the attribute, information about which was requested. This parameter is ignored by the filesystem if EaList points to a nonempty list. If the caller of the FltQueryEaFile function did not specify any value, the parameter will contain -1.

The RestartScan parameter instructs the filesystem to restart enumeration of extended attributes from the first entry. If the parameter is False, retrieval of the extended attributes is resumed by the filesystem after a previous request.

LengthReturned is an optional parameter that contains the size, in bytes, of the information, returned in the Buffer.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_query_file_info Event

This event fires when information about a file or directory has been retrieved.

Syntax

class CBFilterNotifyQueryFileInfoEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_information_class() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def valid_bytes() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_query_file_info() -> Callable[[CBFilterNotifyQueryFileInfoEventParams], None]: ...
@on_notify_query_file_info.setter
def on_notify_query_file_info(event_hook: Callable[[CBFilterNotifyQueryFileInfoEventParams], None]) -> None: ...

Remarks

This event fires when information about a file or directory specified by FileName has been retrieved; This event typically fires in response to the Windows API's NtQueryInformationFile function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_QUERY_FILE_INFO flag.

The FileInformationClass parameter indicates what kind of file information was requested. Please refer to the NtQueryInformationFile function's documentation for more information about possible values.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the requested file information. The BufferLength and ValidBytes parameters reflect the capacity of Buffer and the length of the data it contains (respectively), in bytes; ValidBytes may be less than BufferLength. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The format of the data is determined by the specified FileInformationClass; please refer to the NtQueryInformationFile function's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_read_file Event

This event fires when data have been read from a file.

Syntax

class CBFilterNotifyReadFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def position() -> int: ...

  @property
  def bytes_to_read() -> int: ...

  @property
  def direction() -> int: ...

  @property
  def bytes_read() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_read_file() -> Callable[[CBFilterNotifyReadFileEventParams], None]: ...
@on_notify_read_file.setter
def on_notify_read_file(event_hook: Callable[[CBFilterNotifyReadFileEventParams], None]) -> None: ...

Remarks

This event fires when data have been read from a file specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_READ flag.

The Position parameter reflects the byte offset in the file at which reading started.

The BytesToRead parameter reflects how many bytes were to be read from the file.

The Direction parameter indicates the request direction; please refer to the Cached and Non-Cached Requests topic for more information. Possible values are as follows:

FS_REQUEST_DIR_USER_NONCACHED0Operations performed in the user mode application <--> filesystem direction.
FS_REQUEST_DIR_USER_CACHED1Operations performed in the user mode application <--> system cache direction.
FS_REQUEST_DIR_SYSTEM_NONCACHED2Operations performed in the system cache <--> filesystem direction.
FS_REQUEST_DIR_SYSTEM_CACHED3Operations performed in the system component <--> system cache direction.

The BytesRead parameter reflects how many bytes were actually read from the file.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_rename_or_move_file Event

This event fires when a file or directory has been renamed or moved.

Syntax

class CBFilterNotifyRenameOrMoveFileEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def new_file_name() -> str: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_rename_or_move_file() -> Callable[[CBFilterNotifyRenameOrMoveFileEventParams], None]: ...
@on_notify_rename_or_move_file.setter
def on_notify_rename_or_move_file(event_hook: Callable[[CBFilterNotifyRenameOrMoveFileEventParams], None]) -> None: ...

Remarks

This event fires when a file or directory specified by FileName has been renamed or moved to NewFileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_RENAME flag. A rule's mask is matched against both previous and new filenames, and the event will fire when either of the names matches the mask.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_allocation_size Event

This event fires when a file's allocation size has been changed.

Syntax

class CBFilterNotifySetAllocationSizeEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def allocation_size() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_allocation_size() -> Callable[[CBFilterNotifySetAllocationSizeEventParams], None]: ...
@on_notify_set_allocation_size.setter
def on_notify_set_allocation_size(event_hook: Callable[[CBFilterNotifySetAllocationSizeEventParams], None]) -> None: ...

Remarks

This event fires when the allocation size of the file specified by FileName has been changed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_SET_SIZES flag.

The AllocationSize parameter reflects the new allocation size, in bytes. A file's allocation size is typically larger than its actual size because filesystem operations often reserve space on disk before writing additional data to a file.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_ea Event

This event fires when information about the extended attributes of a file has been changed.

Syntax

class CBFilterNotifySetEaEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_ea() -> Callable[[CBFilterNotifySetEaEventParams], None]: ...
@on_notify_set_ea.setter
def on_notify_set_ea(event_hook: Callable[[CBFilterNotifySetEaEventParams], None]) -> None: ...

Remarks

This event fires when information about the extended attributes of a file specified by FileName has been changed.

If the file is created or opened with extended attributes passed in the request, this event will fire shortly after the on_notify_create_file or on_notify_open_file event.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_SET_EA flag.

The Buffer parameter points to a memory buffer that specifies the extended attribute information. The Length parameter reflects the length of this buffer, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a FILE_FULL_EA_INFORMATION structure; please refer to the Microsoft's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_file_attributes Event

This event fires when a file or directory's attributes or times have been changed.

Syntax

class CBFilterNotifySetFileAttributesEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def creation_time() -> datetime.datetime: ...

  @property
  def last_access_time() -> datetime.datetime: ...

  @property
  def last_write_time() -> datetime.datetime: ...

  @property
  def change_time() -> datetime.datetime: ...

  @property
  def attributes() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_file_attributes() -> Callable[[CBFilterNotifySetFileAttributesEventParams], None]: ...
@on_notify_set_file_attributes.setter
def on_notify_set_file_attributes(event_hook: Callable[[CBFilterNotifySetFileAttributesEventParams], None]) -> None: ...

Remarks

This event fires when the attributes or times of the file or directory specified by FileName have been changed.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_SET_ATTRIBUTES flag.

The CreationTime, LastAccessTime, LastWriteTime, and ChangeTime parameters reflect the new time values, specified in UTC. A value of January 1, 1601 00:00:00 UTC indicates that the corresponding time value was not included in the request.

The Attributes parameter reflects the new attributes; please refer to Microsoft's File Attribute Constants article for attribute descriptions.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_file_info Event

This event fires when information about a file or directory has been changed.

Syntax

class CBFilterNotifySetFileInfoEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def file_information_class() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def buffer_length() -> int: ...

  @property
  def valid_bytes() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_file_info() -> Callable[[CBFilterNotifySetFileInfoEventParams], None]: ...
@on_notify_set_file_info.setter
def on_notify_set_file_info(event_hook: Callable[[CBFilterNotifySetFileInfoEventParams], None]) -> None: ...

Remarks

This event fires when information about a file or directory specified by FileName has been changed; This event typically fires in response to the Windows API's NtSetInformationFile function.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_QUERY_FILE_INFO flag.

The FileInformationClass parameter indicates what kind of file information was set. Please refer to the NtSetInformationFile function's documentation for more information about possible values.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the new file information. The BufferLength and ValidBytes parameters reflect the capacity of Buffer and the length of the data it contains (respectively), in bytes; ValidBytes may be less than BufferLength. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The format of the data is determined by the specified FileInformationClass; please refer to the NtSetInformationFile function's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_file_security Event

This event fires when a file or directory's security attributes have been changed.

Syntax

class CBFilterNotifySetFileSecurityEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def security_information() -> int: ...

  @property
  def security_descriptor() -> c_void_p: ...

  @property
  def length() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_file_security() -> Callable[[CBFilterNotifySetFileSecurityEventParams], None]: ...
@on_notify_set_file_security.setter
def on_notify_set_file_security(event_hook: Callable[[CBFilterNotifySetFileSecurityEventParams], None]) -> None: ...

Remarks

This event fires when security attributes have been changed for a file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_SET_SECURITY flag.

The SecurityInformation parameter reflects which pieces of security information, of those present in SecurityDescriptor, were to be set. Please refer to Microsoft's SECURITY_INFORMATION data-type documentation for more information about possible values.

The SecurityDescriptor parameter points to a memory buffer that contains the new security information. The Length parameter reflects the length of this data, in bytes. Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The data are formatted as a SECURITY_DESCRIPTOR structure in self-relative format; please refer to the Microsoft's documentation for more information.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_file_size Event

This event fires when a file has been resized.

Syntax

class CBFilterNotifySetFileSizeEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def size() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_file_size() -> Callable[[CBFilterNotifySetFileSizeEventParams], None]: ...
@on_notify_set_file_size.setter
def on_notify_set_file_size(event_hook: Callable[[CBFilterNotifySetFileSizeEventParams], None]) -> None: ...

Remarks

This event fires when the file specified by FileName has been resized, whether explicitly (e.g., truncation) or implicitly (i.e., as data are appended).

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_SET_SIZES flag.

The Size parameter reflects the new file size, in bytes.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_set_reparse_point Event

This event fires when a file or directory's reparse point has been created or updated.

Syntax

class CBFilterNotifySetReparsePointEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def reparse_tag() -> int: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_set_reparse_point() -> Callable[[CBFilterNotifySetReparsePointEventParams], None]: ...
@on_notify_set_reparse_point.setter
def on_notify_set_reparse_point(event_hook: Callable[[CBFilterNotifySetReparsePointEventParams], None]) -> None: ...

Remarks

This event fires when a reparse point has been created or updated for a file or directory specified by FileName.

Applications need to handle this event only if they have added a standard filter rule that includes [the TBD]. FS_NE_SET_REPARSE_POINT flag.

The ReparseTag parameter contains the reparse tag, which is the value the system uses to identify the format of the reparse point data.

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the nt_status_to_win_32_error method.

Note: This event will not fire for failed requests unless the process_failed_requests property is enabled.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason, set it to a non-zero value to report an appropriate error.

Note: This event fires after the operation has already completed, so reporting an error will not actually affect the operation itself. Please refer to the Error Reporting and Handling topic for more information.

This event is fired asynchronously; please refer to the Event Types topic for more information.

on_notify_unlock_all Event

This event fires when all locked byte ranges in a file have been unlocked.

Syntax

class CBFilterNotifyUnlockAllEventParams(object):
  @property
  def file_name() -> str: ...

  @property
  def status() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBFilter:
@property
def on_notify_unlock_all() -> Callable[[CBFilterNotifyUnlockAllEventParams], Non