Method for protecting specified path and file from being tampered
By building an interception layer and hierarchical data structure in the Windows operating system, the problems of adaptability, efficiency and interactivity of file protection schemes are solved, achieving efficient and flexible file protection and ensuring the stability and security of the system.
Patent Information
- Application Number
- CN202511958302.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-12-24
AI Technical Summary
Existing file protection schemes in Windows operating systems suffer from poor adaptability, low query efficiency, rigid control, poor interaction, and insufficient directory hierarchy adaptability, resulting in inadequate protection stability and execution efficiency.
By building an interception layer in the Windows file system filter driver framework, adopting a hierarchical data structure and a concurrent synchronization mechanism, an access control list is established to achieve real-time decision-making and dynamic policy updates, support multi-dimensional fine-grained policy control, and introduce an asynchronous event notification mechanism and an enhanced verification process.
It achieves continuous policy effectiveness, high path matching efficiency, strong control flexibility, and good real-time interaction, and can dynamically adapt to various application scenarios to ensure real-time perception and efficient protection of file security status.
Smart Images

Figure CN121389188A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer data security technology, specifically a method for protecting specified paths and files from being tampered with. Background Technology
[0002] In Windows operating systems, the integrity of critical files (such as core system components, security configuration files, and core business data files) directly determines system stability and data security. File corruption caused by malicious programs or accidental operations can lead to system crashes, data leaks, or even the implantation of persistent backdoors, posing serious security risks.
[0003] In Windows systems, the integrity of critical files is the core foundation for system stability and data security. File tampering caused by malicious programs or human error can lead to system crashes, malfunctions, or even the implantation of persistent backdoors, resulting in data leaks or unauthorized system control. However, existing file protection solutions have significant technical shortcomings: First, the adaptability of protection policies is insufficient, relying on device paths, which are easily affected by mount order or hardware connections, as volume identifiers, causing policies to become ineffective due to path changes. Second, policy query efficiency is low; the linear structure used to store protected paths and whitelists becomes significantly time-consuming for path matching and process verification as the number of objects increases, impacting system I / O performance. Third, the protection mechanism lacks flexibility, lacking the ability to finely control policy switching based on path, whitelist, or file type, making it difficult to adapt to diverse scenarios. Fourth, the efficiency of kernel-user interaction is insufficient; policy operations rely on multiple I / O interactions and event notification responses are delayed, failing to provide real-time feedback on interception behavior. Fifth, the data structure design fails to align with the characteristics of the Windows directory hierarchy, resulting in complex path parsing and matching logic, which is prone to misjudgments.
[0004] The essence of the above problems lies in the fact that existing solutions fail to address three major underlying technical pain points: the uniqueness of volume identifiers, the adaptability of storage structure and directory hierarchy, and the fine-grained control of policies. As a result, the protection stability, execution efficiency, and dynamic adaptability are insufficient. Summary of the Invention
[0005] The purpose of this invention is to provide a method for protecting specified paths and files from tampering, in order to solve the problems of poor adaptability, inefficient querying, rigid control, and poor interaction in the existing file protection schemes mentioned in the background art.
[0006] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows: A method for protecting specified paths and files from tampering involves making access control decisions before data is written to physical storage through the following steps: Step S1, Interception layer deployment: Register a main function code callback routine containing at least IRP_MJ_WRITE and IRP_MJ_SET_INFORMATION in the Windows file system filter driver framework, and build an interception layer loaded on the target file system driver device object to intercept I / O requests. Step S2, Policy Data Structure Construction: Construct an access control list for real-time querying in the kernel's non-paged memory, with at least the process identifier (PID) and file object path as key-value pairs; Step S3, Real-time Decision Making and Execution: Executed synchronously in the callback routine of the interception layer: Step S301: Extract the PID of the process to which the thread that initiated the current I / O request belongs and the complete device object path of the target file; Step S302: Query the access control list. First, determine whether the PID is a system process. If so, allow the process. If not, determine whether the process is in the exemption list. If so, allow the process. If not in the exemption list, determine whether the target file path is in a protected path or whether the target file extension is a protected file type. If any of the above conditions are met, set the status block IoStatus of this I / O request to STATUS_ACCESS_DENIED and complete the request, preventing data from being passed to the lower-level driver. Step S4, Dynamic Policy Update Channel: Establish a control channel based on IRP_MJ_DEVICE_CONTROL between user space and kernel space. Dynamic management of access control lists is achieved through predefined control codes, including adding, deleting, and modifying policies.
[0007] Based on the above technical solution, the construction and querying of access control lists are implemented using the following hierarchical data structure: First-level path index: A multi-branch tree rooted at the volume device object. The multi-branch tree contains node branches representing protected paths and node branches representing exempted paths, which are distinguished by the policy type attribute stored within the node; tree nodes contain a UNICODE_STRING type path name for path matching and a boolean flag for subtree protection. Second-level file type list: A linked list that stores the protected file extensions.
[0008] Specifically, shared locks are used for read operations (queries) on the policy tree, while exclusive locks are used for write operations (inserts, deletes, and updates) to ensure concurrency safety. Locking mechanisms are implemented through kernel-mode synchronization objects (such as ERESOURCE) to prevent data races or structural corruption during concurrent access by multiple threads' I / O requests.
[0009] According to the above technical solution, in step S3, the determination of the target file path supports two modes: exact path matching and subtree matching. When the policy is configured as subtree matching, if the target file path is a prefix match of the protected directory path, it is determined to be within the protection scope.
[0010] According to the above technical solution, the method also includes dynamic adaptation to volume mount events: In the InstanceSetup callback routine, the GUID of the newly mounted volume is obtained through the FltGetVolumeGuidName function. Then, the system hidden file in the root directory of the volume is opened and the original volume ID is read. The original volume ID is used to check whether there is a corresponding volume node in the current protection policy data structure. If there is, the volume ID and device path information of the node are updated.
[0011] According to the above technical solution, the control channel allows user-mode programs to independently enable or disable protection sub-policies for paths, processes, and file types; before executing the query, the kernel decision logic first checks the state of the global switch variable of the corresponding sub-policy. The switch is a Boolean variable stored in the driver device extension or global memory. In the decision process, the main switch is checked first, and if it is enabled, each sub-switch is checked in sequence.
[0012] According to the above technical solution, when step S3 determines that an interception has occurred, the method also includes an asynchronous event notification mechanism: the metadata of the current interception event is inserted into a kernel-mode first-in-first-out queue protected by a spinlock; the user-mode program asynchronously reads the interception event record from the queue through another dedicated IOCTL of the control channel.
[0013] Specifically, the queue is designed as a fixed-size circular buffer. When the queue is full, it can choose to discard the oldest event or the current event, depending on the configuration. The kernel maintains a reference count for each pending user-mode read IRP. When a user-mode process exits abnormally, the driver completes the cleanup of these IRPs and releases related resources in the device cleanup routine to prevent memory leaks.
[0014] According to the above technical solution, the access control list has persistence capability: when the system starts, the driver reads from the protected configuration file and builds the data structure in memory; when the system shuts down or the policy changes, the policy data in memory is atomically written back to the configuration file.
[0015] According to the above technical solution, it also includes a semantic conflict detection and resolution mechanism for the strategy: When a request to add or modify a policy is received through the dynamic policy update channel, the following steps are performed before updating the access control list: Parse the policy rules in the request into formal logical expressions; Formal logical expressions are Boolean expressions composed of path patterns, process identifiers, and file extensions as atomic conditions, combined using logical AND, logical OR, and logical NOT operators; the policy logic set is the set of Boolean expressions corresponding to all valid policies in the current access control list. Identify and label logical conflicts, which include at least complete coverage conflicts, partial overlap conflicts, and direct mutual exclusion conflicts. Conflict resolution suggestions are generated based on predefined priority rules. The priority rules include at least the fact that specific path strategies take precedence over wildcard path strategies. Only after verifying that the conflict has been resolved should the access control list be updated.
[0016] According to the above technical solution, an enhanced verification triggering mechanism is also included: Configure enhanced verification identifiers for specific protected targets in access control lists or their associated data structures; In the real-time decision-making and execution of step S3, after querying the access control list, if it is determined that the current I / O request should be allowed, then further check whether the target file or the initiating process is associated with an enhanced verification identifier. If an enhanced verification identifier is associated, the corresponding enhanced verification sub-process will be executed. If the verification result of the enhanced verification sub-process is not passed, the pass decision is overwritten, and the status block of this I / O request is set to STATUS_ACCESS_DENIED.
[0017] Based on the above technical solution, the enhanced verification sub-process includes file content verification: The enhanced verification identifier is the file content verification identifier; When the file content verification subprocess is triggered, the SHA-256 cryptographic hash algorithm is used to calculate the cryptographic hash value of the target file or the data to be written. The calculated hash value is compared with a pre-stored trusted hash value benchmark library; If the comparison is inconsistent, the verification result of the enhanced verification sub-process will be "fail". The file content verification identifier and trusted hash value benchmark library are configured and managed through a dynamic policy update channel.
[0018] Specifically, under secure system conditions, the trusted hash value benchmark library is injected into the kernel driver by an authorized process through a control channel, either once or incrementally. Version rollback and incremental updates of the benchmark library are supported, with the update process employing encrypted transmission and digital signature verification to ensure the integrity and trustworthiness of the benchmark library.
[0019] Compared with the prior art, the present invention has the following beneficial effects: This invention persistently stores the volume ID by creating and maintaining a system-hidden file in the root directory of the protected volume, and reads this file for policy matching when the volume is remounted. This solves the problem of policy failure caused by changes in the volume device path and ensures the continuous effectiveness of the policy.
[0020] In terms of query efficiency, this invention adopts a hierarchical data structure and a concurrent synchronization mechanism, which makes the path matching time only related to the depth of the target path and not to the total number of strategies. The strategy judgment time for a single I / O request is extremely short, and the impact on the system disk I / O performance is negligible, thus overcoming the problem of low query efficiency in traditional linear storage structures.
[0021] In terms of control flexibility, this invention supports fine-grained policy control by multiple dimensions such as path, process and file type through multi-level stacked control switches and scenario-based rule templates. It can dynamically adapt to various application scenarios such as software installation and system updates, and can complete policy switching without restarting the driver.
[0022] To achieve real-time interaction, this invention constructs a control channel based on IRP, enabling policy updates and interception event notifications to be completed within milliseconds, ensuring that administrators can perceive file security status in real time, and solving the problem of communication latency between kernel mode and user mode. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating the protection method of this invention. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] Example 1 like Figure 1 As shown, a method for protecting specified paths and files from tampering completes access control decisions before data is written to physical storage through the following steps: Step S1, Interception layer deployment: Register a main function code callback routine containing at least IRP_MJ_WRITE and IRP_MJ_SET_INFORMATION in the Windows file system filter driver framework, and build an interception layer loaded on the target file system driver device object to intercept I / O requests. Step S2, Policy Data Structure Construction: Construct an access control list for real-time querying in the kernel's non-paged memory, with at least the process identifier (PID) and file object path as key-value pairs; Step S3, Real-time Decision Making and Execution: Executed synchronously in the callback routine of the interception layer: Step S301: Extract the PID of the process to which the thread that initiated the current I / O request belongs and the complete device object path of the target file; Step S302: Query the access control list. First, determine whether the PID is a system process. If so, allow the process. If not, determine whether the process is in the exemption list. If so, allow the process. If not in the exemption list, determine whether the target file path is in a protected path or whether the target file extension is a protected file type. If any of the above conditions are met, set the status block IoStatus of this I / O request to STATUS_ACCESS_DENIED and complete the request, preventing data from being passed to the lower-level driver. Step S4, Dynamic Policy Update Channel: Establish a control channel based on IRP_MJ_DEVICE_CONTROL between user space and kernel space. Dynamic management of access control lists is achieved through predefined control codes, including adding, deleting, and modifying policies.
[0026] This invention persistently stores the volume ID by creating and maintaining a system-hidden file in the root directory of the protected volume, and reads this file for policy matching when the volume is remounted. This solves the problem of policy failure caused by changes in the volume device path and ensures the continuous effectiveness of the policy.
[0027] In terms of query efficiency, this invention adopts a hierarchical data structure and a concurrent synchronization mechanism, which makes the path matching time only related to the depth of the target path and not to the total number of strategies. The strategy judgment time for a single I / O request is extremely short, and the impact on the system disk I / O performance is negligible, thus overcoming the problem of low query efficiency in traditional linear storage structures.
[0028] In terms of control flexibility, this invention supports fine-grained policy control by multiple dimensions such as path, process and file type through multi-level stacked control switches and scenario-based rule templates. It can dynamically adapt to various application scenarios such as software installation and system updates, and can complete policy switching without restarting the driver.
[0029] To achieve real-time interaction, this invention constructs a control channel based on IRP, enabling policy updates and interception event notifications to be completed within milliseconds, ensuring that administrators can perceive file security status in real time, and solving the problem of communication latency between kernel mode and user mode.
[0030] Example 2 This embodiment is a further detailed description of Embodiment 1. This embodiment provides a file integrity protection method based on Windows kernel-mode drivers and hierarchical strategy management. The specific implementation process is as follows: Step 1: Construct a deeply integrated kernel-mode file filtering framework. In the system storage stack, a filtering driver is built on top of the file system driver based on the WindowsMinifilter framework. In the driver entry routine, the following key operations are performed sequentially: Pre-operation callback functions are registered for core I / O request packets (IRPs) such as file creation (IRP_MJ_CREATE), write operations (IRP_MJ_WRITE), and setting information (IRP_MJ_SET_INFORMATION), enabling synchronous interception of potential tampering. Simultaneously, volume mount notification callbacks (InstanceSetup) and device control dispatch routines (DriverDispatchDeviceControl) are registered. Subsequently, device objects and their corresponding user-mode accessible symbolic links are created, and the device objects are configured in DO_BUFFERED_IO mode to ensure the security and stability of data transmission between user mode and kernel mode. During the driver initialization phase, the memory required for the policy storage structure, I / O request context, and event queue is pre-allocated in the kernel non-paged pool, and synchronization objects such as spinlocks and events are initialized, laying the foundation for stable operation in high-concurrency environments.
[0031] Step Two: Design a policy storage system adapted to the hierarchical characteristics of the Windows file system. To efficiently manage protection policies, a composite storage structure consisting of a multi-way tree and a singly linked list is designed and constructed. The multi-way tree precisely maps the Windows volume-directory hierarchy, containing a root node, volume nodes, and directory nodes. It is used to uniformly manage protected paths and whitelisted paths, achieving logical differentiation through node attributes or storage in different branches of the same tree structure. The root node manages all volume node linked lists; volume nodes are associated with physical volumes, persistently storing the volume's unique GUID identifier, current device path, and a reference to the original volume ID backup file; directory nodes store the directory names of each level of a specific protected path or whitelisted path, and include recursive protection flags for subdirectories. The singly linked list is used to store the set of protected file extensions. The construction of this storage structure follows the principle of dynamic, on-demand creation: when a new protection target is added, starting from the root node, the corresponding volume nodes and directory nodes are matched or created layer by layer, forming a policy tree isomorphic to the file system directory tree. This tree structure design ensures that the path matching time is only proportional to the depth of the target path, and independent of the total number of policies, thus achieving efficient matching. Meanwhile, a node hash collision detection and periodic lazy garbage collection mechanism are introduced to ensure the robustness of the storage structure and the efficiency of memory usage.
[0032] Step 3: Implement a dynamic adaptation mechanism based on the hidden file identifier in the volume root directory. When a new volume is mounted and triggers the InstanceSetup callback, the driver obtains the volume's GUID using the FltGetVolumeGuidName function. Then, it searches for a pre-created system hidden file in the volume's root directory (this file is created when the volume is first included in protection) and reads the original volume ID stored within it. Using this original volume ID as a key index, the driver locates the corresponding volume node in the policy multi-way tree. If a match is found, the current device path and other information of the volume node are updated; if no match is found, a new volume node is created and initialized, and a new backup file of the original volume ID is written. This mechanism ensures that the protection policy can be accurately bound to the target physical storage device using the unique original volume ID.
[0033] Step 4: Deploy a refined, layered policy control switch system. To achieve protection flexibility and scenario adaptability, a four-level layered control switch system is designed, with all switch states stored in Boolean variables in the driver device extension or global memory. The first level is the global master switch, controlling the enabling and disabling of the entire driver's interception function. With the master switch enabled, the second-level path protection switch, the third-level whitelist verification switch, and the fourth-level file extension filtering switch can be independently enabled or disabled. In the I / O request processing flow, the master switch is checked first; if enabled, each sub-switch is checked sequentially, and only the policy dimensions corresponding to the enabled sub-switches are verified. For example, if only the path protection switch is enabled, only whether the target path is protected is verified, without checking the process whitelist and file extensions. User-space management tools can adjust the state of any switch in real time through dedicated device control codes (IOCTLs), achieving dynamic policy switching without restarting.
[0034] Furthermore, the method in this invention automatically restores the original policy configuration by integrating a scenario-based rule template adaptation mechanism. Specifically, the driver pre-configures multiple rule templates for typical scenarios (such as software installation and system updates). The user-mode management tool can manually or automatically enable the corresponding rule template based on current system activity characteristics (such as an active msiexec.exe process accompanied by high-frequency read / write operations to the C:\Windows\Installer directory). This template contains a set of temporarily adjusted switch states and / or temporary policy rules (such as temporarily disabling the path protection switch for the C:\Program Files\Temp directory). All temporary rules are accompanied by an expiration date tag (which can be dynamically adjusted through configuration, such as automatically expiring after 10 minutes) and an audit traceability identifier. All dynamic adjustment operations are recorded in the kernel audit log. After the scenario ends (such as the installation process exits) or the temporary policy expires, the original policy configuration is automatically restored to ensure the consistency of the protection status.
[0035] This mechanism boasts high compatibility and controllability with existing solutions. Administrators can globally disable this feature via a newly added dynamic policy enable switch; all temporary policy rules are marked as dynamically generated attributes, supporting manual intervention or deletion via user-space tools; dynamically adjusted logs are synchronized to user space through an extended auditing interface, ensuring administrators have complete operational traceability capabilities, achieving an organic combination of static rules and dynamic adaptation.
[0036] Step 5: Establish an efficient and atomic bidirectional interaction channel between the kernel and user space. Design a complete set of Device Control Code (IOCTL) interfaces to encapsulate all policy management operations. User-space management tools can complete policy addition, deletion, modification, query, or on / off control with a single I / O call through the DeviceIoControl function. Data transmission adopts a unified encapsulated buffer structure to ensure efficiency and security. For policy query requests, the kernel serializes multi-way tree and linked list structures into linear data and returns it all at once, greatly reducing context switching overhead. Simultaneously, to achieve real-time event notification, an asynchronous communication mechanism based on the IRP suspension-wake-up model is designed: the user-space thread sends an IRP to wait for events; when the kernel intercepts an illegal operation, it immediately fills the event details (timestamp, process PID / path, target file path, operation type) into the IRP's buffer and completes the operation, then the user-space thread is immediately woken up to handle the event. This mechanism avoids polling overhead and ensures millisecond-level event notification latency.
[0037] Furthermore, to address semantic conflicts under complex policy configurations, a policy integration and verification module is added between the user-space policy configuration tool and the kernel-space policy tree update operation. This module constructs a semantic conflict detection and resolution engine to ensure the inherent consistency and execution determinism of the policy set. The core function of this engine is to transform policy rules from natural language descriptions into formal logical expressions, identify potential conflicts through semantic analysis, and provide intelligent resolution solutions.
[0038] The conflict detection process employs a three-step approach: offline parsing, logical comparison, and conflict definition. First, when a user adds or modifies a policy through management tools (e.g., adding a wildcard path C:\AppData\\.conf and setting an exclusion path C:\AppData\Temp\), the engine parses the policy rule into an Abstract Syntax Tree (AST), then transforms it into an expression based on first-order predicate logic, clarifying the rule's scope, matching conditions, and execution action. Next, the new policy expression is fully compared with the logical expressions of the existing policy set, simulating rule execution results under different combinations of paths, processes, and file types. Finally, based on the comparison results, the conflict type is precisely defined, including complete overriding conflicts (the new rule completely invalidates existing rules), partial overlapping conflicts (rule scopes intersect, leading to ambiguous execution results), direct mutual exclusion conflicts (rule execution actions are opposite under the same conditions), and priority inversion conflicts (the specific rule has lower priority than the wildcard rule).
[0039] The conflict resolution mechanism follows the principle of user-led and intelligent assistance. When a conflict is detected, the engine does not directly reject policy updates, but generates a structured conflict report that clearly presents the relationships between conflicting rules, examples of conflict scenarios, and potential impacts. Simultaneously, it provides resolution suggestions based on a preset priority matrix (which can be customized). For example, specific path rules have higher priority than wildcard path rules, rejection rules have higher priority than allow rules, and post-configuration rules have higher priority than pre-configuration rules. Administrators can choose to adopt system suggestions or manually adjust rule priorities and modify rule scopes. After resolution, the engine performs a secondary verification of the adjusted policy set. Once no conflicts are confirmed, it submits the revised policy set to the kernel driver via the DeviceIoControl interface to update the multi-branch tree structure.
[0040] The integration of this engine does not change the existing interaction architecture, but only adds a verification step before policy submission. It implements conflict detection and resolution functions by extending the interface of the policy configuration tool. The kernel-mode policy storage and execution logic remain unchanged, which not only improves the efficiency of policy management in complex scenarios, but also avoids protection failure or false interception caused by policy conflicts.
[0041] Step Six: Execute multi-layered, content-aware real-time policy judgment logic. When a monitored I / O request arrives at the filter driver, the following judgment chain is executed sequentially: System process exemption: First, determine whether the initiating process is a critical system process (such as the System process with PID 4). If so, allow it directly.
[0042] Whitelist verification: If the whitelist switch is enabled, the image file path of the initiating process is obtained. The process image information is retrieved through public kernel APIs such as PsGetProcessImageFileName or IoQueryFileDosDeviceName, and a quick match is performed in the whitelist branch of the policy tree. If a match is successful, all related operations for that process are allowed.
[0043] Path protection matching: If path protection is enabled, the complete device path of the target file is resolved. After locating the corresponding volume node in the policy tree, directory-level matching is performed. If a protected directory node is matched, and its recursive protection flag is true or there are more precise child nodes matching it, path protection is triggered.
[0044] File type verification: If the file extension protection switch is enabled, the target file extension is extracted and matched against the protected extension list.
[0045] The driver will intercept the I / O request and return STATUS_ACCESS_DENIED only if the requesting process is not a system process, fails the whitelist verification, and (hit the protected path or protected file type).
[0046] Furthermore, according to the method described above, to enhance the ability to combat advanced covert threats, an enhanced verification layer can be added on top of the real-time decision-making logic. This layer can be enabled or disabled via an independent control switch and includes the following optional functions: it includes two core functions, file content fuzzy hash matching and process trust chain verification, forming a multi-layered defense system of basic verification and deep verification.
[0047] The fuzzy hash matching feature focuses on protecting the integrity of critical executable files. Administrators can enable this feature for critical file types such as .exe, .dll, and .sys via a newly added content verification switch. When such files are attempted to be modified, replaced, or created, the driver automatically triggers a content verification process after completing basic verification: For write operations, the driver reads the critical blocks of the file to be written from memory (such as the DOS header, PE header, optional header, and the first 1024 bytes of the code segment in a PE file); for creation or replacement operations, the driver reads the corresponding blocks of the target file on the disk; subsequently, a context-triggered hash algorithm (such as ssdeep or TLSH) is used to calculate the fuzzy hash value of the block. This algorithm has high sensitivity to minor file modifications and a low false positive rate for minor format adjustments. The driver quickly compares the calculated hash value with the trusted file fingerprint database maintained in kernel mode. This fingerprint database can be pre-deployed through a secure encrypted channel, or automatically learned, generated, and encrypted by the system when it is first deployed and in a secure state. If the hash value does not match, the operation will be intercepted even if the basic verification (path, process, extension) passes, and a high-priority alarm event will be generated, indicating that the content integrity is abnormal.
[0048] The process trust chain verification function is used to prevent the risk of whitelisted processes being hijacked or impersonated. When a whitelisted process initiates a sensitive operation (such as modifying core system files), if the trust chain verification switch is enabled, the enhanced verification module will initiate a process tracing process: by querying the parent process ID in the process environment block (PEB), it traverses the complete creation chain of the process to trace back to the system's trusted root processes (such as wininit.exe, services.exe, csrss.exe); at the same time, it checks whether the process has any abnormal traces such as remote thread injection or code segment memory modification. If a broken process creation chain, the presence of unknown intermediate processes, or suspicious injection traces are detected, even if the process's image path is in the whitelist, its operation will be downgraded (e.g., only read operations are allowed) or an alarm will be triggered to intercept it, ensuring that the whitelist mechanism is not maliciously exploited.
[0049] This enhanced verification mechanism integrates with existing solutions with high flexibility and scalability. The newly added content verification switch and trust chain verification switch are incorporated into the existing control switch system, supporting independent enabling or disabling. The trusted file fingerprint database is updated and maintained through an extended configuration synchronization interface, supporting incremental updates and version rollback. Overhead from hash calculations and process tracing during verification is strictly controlled to the millisecond level. By pre-caching hash values and optimizing process chain query algorithms, the impact on system performance is ensured to be no more than 2%, achieving a balance between security and performance.
[0050] Step 7: Implement a reliable kernel event queue and notification management mechanism. To handle high-concurrency interception scenarios and ensure no event loss, a fixed-capacity circular event queue protected by a spinlock is maintained in the kernel. Each time an interception occurs, the driver encapsulates the event data into a node and attempts to insert it into the queue. When the queue is full, depending on the configuration, the oldest event or the current event can be discarded to prevent memory exhaustion. After the user-mode event listening IRP is awakened and retrieves the event, the corresponding node space is released. Furthermore, a heartbeat and timeout mechanism is added to manage abnormal user-mode exits and prevent resource leaks caused by IRPs being permanently suspended.
[0051] Step 8: Integrate policy persistence and systemic fault tolerance and recovery mechanisms. At system startup, the driver loads the policy and switch states from a digitally signed, encrypted configuration file and automatically reconstructs the kernel storage structure. When the system shuts down or the driver is unloaded, the current policy is atomically synchronized back to the configuration file. Fault tolerance mechanisms are implemented throughout: in the I / O processing path, critical pointers are validated to prevent null pointer dereferences; in policy tree operations, locks are used to ensure concurrency safety, and rollback cleanup is performed after potentially failed operations (such as memory allocation); and regular consistency checks and repairs of the storage structure are performed. Additionally, driver self-monitoring and log reporting functions are provided to facilitate the diagnosis of problems in complex environments.
[0052] Example 3 This embodiment is a further refinement of Embodiment 1. This embodiment is used to protect .exe, .dll, and .sys files in the C:\Windows\System32 directory and its subdirectories of the Windows system, exempting them from modification operations by the svchost.exe process (PID=1234), and supporting administrators to dynamically add protected paths and file extensions using user-mode tools; it includes the following steps: Driver installation and initialization: Install the file filtering driver. When the driver starts, it reads the encrypted configuration file and automatically builds a multi-branch tree (creating a system disk volume node under the root node, creating a \Windows\System32 directory node under the volume node, and setting the subdirectory protection flag to enabled), a file extension list (storing .exe, .dll, and .sys), and enables the master switch, path protection switch, file extension protection switch, and whitelist switch. The process path of svchost.exe is added to the whitelist.
[0053] Volume device adaptation: When the system disk volume device changes its device path due to hardware connection adjustments, the InstanceSetup callback function is triggered. The original volume ID is read from the system hidden file in the volume root directory, matched with the volume node in the multi-way tree, and the current volume ID and device path information of the node are automatically updated, so that the protection policy continues to be effective.
[0054] Interception process: The malicious program (PID=5678) attempts to modify C:\Windows\System32\notepad.exe, triggering the IRP_MJ_WRITE callback function; the kernel obtains PID=5678 (a non-system process), and traverses the whitelist nodes without finding a match; the target file path is extracted, and the \Windows\System32 directory node in the multi-way tree is matched (subdirectory protection is enabled), which is determined to be a protected path; the file extension .exe is extracted, and the extension linked list is matched, which is determined to be a protected file type; because the path or extension match logic is satisfied, the IO request status is set to STATUS_ACCESS_DENIED, preventing file modification.
[0055] Event notification: After an event is intercepted, an event node is created in kernel mode and added to the event queue; the user-mode event listening thread is awakened, receives the event data (timestamp, PID=5678, target path C:\Windows\System32\notepad.exe, WRITE operation), and displays it to the administrator through a visual interface.
[0056] Policy Update: The administrator adds D:\Data as a protected path using a user-space tool. The tool encapsulates the path data into DD:\Data format and sends it to the kernel space via the ADD_DIRECTORY control code. The kernel space parses the data, converts it into a device path, and creates a \Data directory node under the corresponding volume node. The policy takes effect immediately without requiring a driver restart.
[0057] The technical effects of this invention are as follows: Protection stability: After the volume device path is changed, the protection policy is updated within 10ms without any protection interruption; after 96 hours of continuous operation, there are no blue screens, no memory leaks, and no loss of policy data.
[0058] Interception accuracy: 100% interception of unauthorized processes modifying target files under the protected path. Normal modification operations by the whitelisted process svchost.exe are allowed to proceed without error.
[0059] Performance impact: The time taken for policy judgment of a single IO request is ≤0.8ms, the system disk IO performance decreases by ≤3%, and it does not affect the normal operation of the system.
[0060] Real-time interactivity: Policy update operation response time ≤10ms, interception event notification delay ≤5ms, allowing administrators to monitor file security status in real time.
[0061] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "include," "contain," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.
[0062] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for protecting specified paths and files from tampering, characterized in that: Access control decisions are made before data is written to physical storage using the following steps: Step S1, Interception layer deployment: Register a main function code callback routine containing at least IRP_MJ_WRITE and IRP_MJ_SET_INFORMATION in the Windows file system filter driver framework, and build an interception layer loaded on the target file system driver device object to intercept I / O requests. Step S2, Policy Data Structure Construction: Construct an access control list for real-time querying in the kernel's non-paged memory, with at least the process identifier (PID) and file object path as key-value pairs; Step S3, Real-time Decision Making and Execution: Executed synchronously in the callback routine of the interception layer: Step S301: Extract the PID of the process to which the thread that initiated the current I / O request belongs and the complete device object path of the target file; Step S302: Query the access control list. First, determine whether the PID is a system process. If so, allow the process. If not, determine whether the process is in the exemption list. If so, allow the process. If not in the exemption list, determine whether the target file path is in a protected path or whether the target file extension is a protected file type. If any of the above conditions are met, set the status block IoStatus of this I / O request to STATUS_ACCESS_DENIED and complete the request, preventing data from being passed to the lower-level driver. Step S4, Dynamic Policy Update Channel: Establish a control channel based on IRP_MJ_DEVICE_CONTROL between user space and kernel space. Dynamic management of access control lists is achieved through predefined control codes, including adding, deleting, and modifying policies.
2. The method for protecting a specified path and file from tampering according to claim 1, characterized in that: The construction and querying of access control lists are implemented using the following hierarchical data structure: First-level path index: A multi-branch tree rooted at the volume device object. The multi-branch tree contains node branches representing protected paths and node branches representing exempted paths, which are distinguished by the policy type attribute stored within the node; tree nodes contain a UNICODE_STRING type path name for path matching and a boolean flag for subtree protection. Second-level file type list: A linked list that stores the protected file extensions.
3. The method for protecting a specified path and file from tampering according to claim 1, characterized in that: In step S3, the determination of the target file path supports two modes: exact path matching and subtree matching. When the policy is configured to subtree matching, if the target file path is a prefix match of the protected directory path, it is determined to be within the protection range.
4. The method for protecting a specified path and file from tampering according to claim 1, characterized in that: The method also includes dynamic adaptation to volume mount events: In the InstanceSetup callback routine, the GUID of the newly mounted volume is obtained through the FltGetVolumeGuidName function. Then, the system hidden file in the root directory of the volume is opened and the original volume ID is read. The original volume ID is used to check whether there is a corresponding volume node in the current protection policy data structure. If so, update the volume ID and device path information for that node.
5. A method for protecting a specified path and file from tampering according to claim 1, characterized in that: The control channel allows user-mode programs to independently enable or disable protection sub-policies for paths, processes, and file types. Before executing a query, the kernel decision logic first checks the state of the global switch variable for the corresponding sub-policy. The switch is a Boolean variable stored in the driver device extension or global memory. The decision process first checks the master switch, and if it is enabled, it checks each sub-switch in sequence.
6. A method for protecting a specified path and file from tampering according to claim 1, characterized in that: When step S3 determines that an interception has occurred, the method also includes an asynchronous event notification mechanism: inserting the metadata of this interception event into a kernel-mode first-in-first-out queue protected by a spinlock; User-space programs asynchronously read intercepted event records from this queue via another dedicated IOCTL for the control channel.
7. A method for protecting a specified path and file from tampering according to claim 1, characterized in that: Access control lists have persistence capabilities: when the system starts, the driver reads from the protected configuration file and builds the data structure in memory; when the system shuts down or the policy changes, the current policy data in memory is atomically written back to the configuration file.
8. A method for protecting a specified path and file from tampering according to claim 1, characterized in that: It also includes a semantic conflict detection and resolution mechanism for the strategy: When a request to add or modify a policy is received through the dynamic policy update channel, the following steps are performed before updating the access control list: Parse the policy rules in the request into formal logical expressions; Formal logical expressions are Boolean expressions composed of path patterns, process identifiers, and file extensions as atomic conditions, combined using logical AND, logical OR, and logical NOT operators; the policy logic set is the set of Boolean expressions corresponding to all valid policies in the current access control list. Identify and label logical conflicts, which include at least complete coverage conflicts, partial overlap conflicts, and direct mutual exclusion conflicts. Conflict resolution suggestions are generated based on predefined priority rules. The priority rules include at least the fact that specific path strategies take precedence over wildcard path strategies. Only after verifying that the conflict has been resolved should the access control list be updated.
9. A method for protecting a specified path and file from tampering according to claim 1, characterized in that: It also includes an enhanced verification triggering mechanism: Configure enhanced verification identifiers for specific protected targets in access control lists or their associated data structures; In the real-time decision-making and execution of step S3, after querying the access control list, if it is determined that the current I / O request should be allowed, then further check whether the target file or the initiating process is associated with an enhanced verification identifier. If an enhanced verification identifier is associated, the corresponding enhanced verification sub-process will be executed. If the verification result of the enhanced verification sub-process is not passed, the pass decision is overwritten, and the status block of this I / O request is set to STATUS_ACCESS_DENIED.
10. A method for protecting a specified path and file from tampering according to claim 9, characterized in that: The enhanced verification sub-process includes file content verification: The enhanced verification identifier is the file content verification identifier; When the file content verification subprocess is triggered, the cryptographic hash value of the target file or the data to be written is calculated. The calculated hash value is compared with a pre-stored trusted hash value benchmark library; If the comparison is inconsistent, the verification result of the enhanced verification sub-process will be "fail". The file content verification identifier and trusted hash value benchmark library are configured and managed through a dynamic policy update channel.
Citation Information
Patent Citations
Method and system for establishing access control
KR100577344B1
Computer protection against malware affection
US20100043072A1
Protection system and method for protecting a computer system against ransomware attacks
US20180157834A1
Efficiently authenticating an application during I / O request handling
US20210240816A1
File-system protection
WO2024184646A1
