Class: RubySMB::SMB2::Packet::QueryDirectoryResponse

Inherits:
GenericPacket
  • Object
show all
Defined in:
lib/ruby_smb/smb2/packet/query_directory_response.rb

Overview

An SMB2 Query Directory Response Packet as defined in 2.2.34 SMB2 QUERY_DIRECTORY Response

Constant Summary collapse

COMMAND =
RubySMB::SMB2::Commands::QUERY_DIRECTORY

Instance Method Summary collapse

Methods inherited from GenericPacket

describe, #display, fields_hashed, format_field, from_hex, #packet_smb_version, read, #status_code, #valid?, walk_fields

Instance Method Details

#initialize_instanceObject



16
17
18
19
# File 'lib/ruby_smb/smb2/packet/query_directory_response.rb', line 16

def initialize_instance
  super
  smb2_header.flags.reply = 1
end

#results(klass) ⇒ array<BinData::Record>

Returns the File Information in an array of appropriate structs for the given FileInformationClass. Pulled out of the string buffer.

Parameters:

  • klass (Class)

    the FileInformationClass class to read the data as

Returns:

  • (array<BinData::Record>)

    An array of structs holding the requested information

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ruby_smb/smb2/packet/query_directory_response.rb', line 28

def results(klass)
  information_classes = []
  blob = buffer.to_binary_s.dup
  until blob.empty?
    length = blob[0, 4].unpack('V').first

    data = if length.zero?
             blob.slice!(0, blob.length)
           else
             blob.slice!(0, length)
           end

    begin
      information_classes << klass.read(data)
    rescue IOError
      raise RubySMB::Error::InvalidPacket, "Invalid #{klass} File Information in the string buffer"
    end
  end
  information_classes
end