ZwMakeTemporaryObject

 InitializeObjectAttributes(
        &object_attributes,
        &device_dir_name,
        OBJ_PERMANENT, //永久性的对象
        NULL,
        NULL
        );

创建一个永久性对象后,马上调用

   ZwMakeTemporaryObject(dir_handle);

把一个永久对象转化成临时对象。

注:

A temporary object has a name only as long as its handle count is greater than zero. When the handle count reaches zero, the system deletes the object name and appropriately adjusts the object's pointer count.


这就是临时对象的意义

即当对象引用变成0的时候自动删除对象

An object is permanent if it was created with the OBJ_PERMANENT object attribute specified. (For more information about object attributes, see InitializeObjectAttributes.) A permanent object is created with a reference count of 1, so it is not deleted when a driver dereferences it.

永久对象在用InitializeObjectAttributes初始化的时候会使引用计数+1

直到这个驱动释放掉的时候才会被删除

An object is temporary if it is not permanent. ZwMakeTemporaryObject turns the specified object into a temporary object. If the object is already temporary, this routine does nothing.

ZwMakeTemporaryObject 会让一个永久对象变成一个临时对象,传入临时对象的时候函数不做任何操作

另:InitializeObjectAttributes 初始化的时候必须制定 OBJ_PERMANENT 标记,才能让一个对象变成永久对象

否则对象都是临时的
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值