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 标记,才能让一个对象变成永久对象
否则对象都是临时的