简体   繁体   English

在Windows10中阻止文件创建

[英]Block file creation in Windows10

I need create app for Block file creation in folder, I am tried to see some of examples about minifilter, but still don't understand how to do this. 我需要在文件夹中创建用于阻止文件创建的app,我试图查看一些有关minifilter的示例,但仍然不了解如何执行此操作。 Found this piece of code that does the processing. 找到了执行处理的这段代码。 This is a link of example https://github.com/Microsoft/Windows-driver-samples/tree/master/filesys/miniFilter/minispy 这是示例https://github.com/Microsoft/Windows-driver-samples/tree/master/filesys/miniFilter/minispy的链接

CONST FLT_OPERATION_REGISTRATION Callbacks[] = 
{
{ IRP_MJ_CREATE,
  0,
  SpyPreOperationCallback,
  SpyPostOperationCallback },

{ IRP_MJ_WRITE,
  0,
  SpyPreOperationCallback,
  SpyPostOperationCallback },

{ IRP_MJ_SET_INFORMATION,
  0,
  SpyPreOperationCallback,
  SpyPostOperationCallback },

  { IRP_MJ_CLOSE,
  0,
  SpyPreOperationCallback,
  SpyPostOperationCallback },

   { IRP_MJ_OPERATION_END } };

So, in short, every sort of open or file creation ends up in the IRP_MJ_CREATE callback. 简而言之,各种打开或文件创建都以IRP_MJ_CREATE回调结束。 You can get the name of the file to be opened (or created) and the name of the folder and such (FltGetFileNameInformation) and decide whether to allow the request (return FLT_PREOP_SUCCESS_NO_CALLBACK which allows the request to continue) or set the IoStatus to something like STATUS_ACCESS_DENIED and return FLT_PREOP_COMPLETE to block the request. 您可以获取要打开(或创建)的文件的名称以及文件夹的名称(如FltGetFileNameInformation),然后决定是否允许请求(返回允许继续请求的FLT_PREOP_SUCCESS_NO_CALLBACK)或将IoStatus设置为类似STATUS_ACCESS_DENIED并返回FLT_PREOP_COMPLETE以阻止该请求。 This is, in a nutshell, what your filter should do to block creating files under specific folder. 简而言之,这是您的过滤器应执行的操作,以阻止在特定文件夹下创建文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM