通过minifelters进入特定路径的障碍

发布于 2025-01-26 05:11:54 字数 986 浏览 3 评论 0原文

我正在尝试编写一个微型滤波器,以阻止对特定路径中任何文件的访问。我已经能够为C:。这就是我所做的。首先,我声明:

const wchar* internal_drives [] = {l“ c:”};

然后,在instant_setup我启动c:通过做:我可以:

        int internal_drives_length = sizeof internal_drives / sizeof * internal_drives;
        for (size_t i = 0; i < internal_drives_length; i++)
        {
            if (wcscmp(ctx->Name.Buffer, internal_drives[i]) == 0)
            {
                status = STATUS_SUCCESS;
            }
        }

我可以 :块访问C:然后通过添加功能:mini_pre_createmini_post_create

    status = STATUS_ACCESS_DENIED;
    data->IoStatus.Status = status;
    data->IoStatus.Information = 0;

有效,我可以阻止C中的任何文件的访问

这 能够指定我要阻止访问的哪个文件夹。我尝试在变量internal_drives中指定路径,但是它不起作用,我什么也没有阻止:

const wchar* internal_drives [] = {l“ d:\\ path”};

我错过了什么吗?有没有更正确的方法与miniferter进行?我是一个小型效率的完整初学者。

I am trying to write a minifilter that block access to any file within a specific path. I have been able to do it for any path in C:. This is what I´ve done. First, I declare:

const WCHAR* internal_drives[] = { L"C:" };

Then, in instant_setup I start the minifilter for C: by doing:

        int internal_drives_length = sizeof internal_drives / sizeof * internal_drives;
        for (size_t i = 0; i < internal_drives_length; i++)
        {
            if (wcscmp(ctx->Name.Buffer, internal_drives[i]) == 0)
            {
                status = STATUS_SUCCESS;
            }
        }

I can block access to C: then by adding in functions: mini_pre_create, mini_post_create:

    status = STATUS_ACCESS_DENIED;
    data->IoStatus.Status = status;
    data->IoStatus.Information = 0;

That works, I am able to block the access to any file in C:

But I´d like to be able to specify to which folder I want to block the access. I´ve trying specifying the path in the variable internal_drives but It does not work, I am blocking nothing :

const WCHAR* internal_drives[] = { L"D:\\path" };

Am I missing something? is there a more correct way to do this with minifilters? I am a complete beginner with minifilters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潜移默化 2025-02-02 05:11:54

您将设置为驱动程序,然后在特定的IRP_MJ_CREATE中过滤。为此,您必须使用fltgetFilenamamInformation和fltparsefilenamameminformation。

请注意,文件系统不适用于DOS名称驱动器字母,因此您必须将\ device \ harddiskvolumex \ folder \ file.txt转换为c:\ folder \ file.txt。您可以在设置上进行映射。

You setup to the drivers, then you filter in the specific IRP_MJ_CREATE. To do that, you have to use FltGetFileNameInformation plus FltParseFileNameInformation.

Do note that the filesystem does not work with DOS name drive letters, so you will have to transform \Device\Harddiskvolumex\folder\file.txt to c:\folder\file.txt. You can do that mapping on setup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文