首页
社区
课程
招聘
[求助][求助]关于RtlPrefixUnicodeString 的问题
发表于: 2009-4-23 10:25 6354

[求助][求助]关于RtlPrefixUnicodeString 的问题

2009-4-23 10:25
6354
我hook了ZwCreateFile,实现对特定文件夹的保护。防止在这个文件夹内所有的文件创建操作。
  得到ZwCreateFile请求的路径后,我使用RtlPrefixUnicodeString与我指定的UNICODE_STRING进行比较(\\??\\E:\\zion),但是在调用RtlPrefixUnicodeString的时候总是返回STATUC_ACCESS_VIOLATION,哪位大侠帮我看下,谢谢了
  下面是先关代码,而且总是在红色的地方出错。

__try{

  if (ObjectAttributes->RootDirectory)
  {
          Status = ObReferenceObjectByHandle(
      ObjectAttributes->RootDirectory,
      0,
      NULL,
      KernelMode,
      &Object,
      NULL);
   if (!NT_SUCCESS(Status))
  {。。。。。}
  Status = ObQueryNameString(Object,NULL,0,&PathLength);
  NameInfo2 = (POBJECT_NAME_INFORMATION)ExAllocatePool(PagedPool,PathLength);
  if (NameInfo2 == NULL) 
  {。。。。。。}
  
              Status = ObQueryNameString(  Object,NameInfo2PathLength,&PathLength);
  if (!NT_SUCCESS(Status))
  {。。。。。。}
  KdPrint(("[NewZwCreateFile]file to operate is: %S\n", NameInfo2->Name.Buffer));

  //to compare 
                if(RtlPrefixUnicodeString(&File2Protect,&NameInfo->Name,TRUE)){

         IoStatusBlock->Information = FILE_DOES_NOT_EXIST;
         Status = OldNtCreateFile(
      0,
      DesiredAccess,
      ObjectAttributes,
      IoStatusBlock,
      AllocationSize,
      FileAttributes,
      ShareAccess,
      CreateDisposition,
      CreateOptions,
      EaBuffer,
      EaLength);
  }else  goto OriginalCall;
      
  
           }__except(EXCEPTION_EXECUTE_HANDLER){ 
   Status = GetExceptionCode();
   KdPrint(("NewNtCreateFile exception occurred,%.8x\n",Status));
    goto Exit;
  }

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 225
活跃值: (10)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
2
RtlPrefixUnicodeString没用过,你试试RtlEqualUnicodeString
2009-4-23 10:48
0
雪    币: 200
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
现在不是这个问题,只要我在获得NameInfo路径后进行UNICOD_STRING相关的操作,都会给我报错。STATUS_ACCESS_VOLIATION
2009-4-23 11:04
0
雪    币: 2105
活跃值: (424)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
4
http://blog.csdn.net/misterliwei/archive/2009/01/16/3796284.aspx
2009-4-25 01:45
0
游客
登录 | 注册 方可回帖
返回
//