def _query_handle(self, handle, klass, object_info_type):
"""Gets the object handle info.
Parameters
----------
handle: HANDLE
handle object
klass: int
the class of information to query
object_info_type: Structure
structure type which holds the handle info
"""
buff = malloc(self._object_buff_size)
rlen = ULONG()
status = nt_query_object(handle,
klass,
buff,
self._object_buff_size,
byref(rlen))
if status >= 0:
info = cast(buff, POINTER(object_info_type))
self._buffers.append(buff)
return info
else:
# reallocate the buffer size
# and try again
buff = realloc(buff, rlen.value)
status = nt_query_object(handle,
klass,
buff,
self._object_buff_size,
None)
if status >= 0:
info = cast(buff, POINTER(object_info_type))
self._buffers.append(buff)
return info
else:
free(buff)
return None
评论列表
文章目录