def get_name_info (handle):
  object_name_information = OBJECT_NAME_INFORMATION ()
  size = DWORD (sizeof (object_name_information))
  while True:
    result = signed_to_unsigned (
      ntdll.ZwQueryObject (
        handle, 1, byref (object_name_information), size, None
      )
    )
    if result == STATUS_SUCCESS:
      return object_name_information.Name.Buffer
    elif result in (STATUS_BUFFER_OVERFLOW, STATUS_BUFFER_TOO_SMALL, STATUS_INFO_LENGTH_MISMATCH):
      size = DWORD (size.value * 4)
      resize (object_name_information, size.value)
    else:
      return None
dataset/ETHPy150Open tjguk/winsys/random/file_handles.py/get_name_info/original