class RubySMB::SMB1::Packet::Trans2::FindFirst2Response

This class represents an SMB1 Trans2 FIND_FIRST2 Response Packet as defined in [2.2.6.2.2 Response](msdn.microsoft.com/en-us/library/ee441704.aspx)

Constants

COMMAND

Public Instance Methods

initialize_instance() click to toggle source
# File lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb, line 53
def initialize_instance
  super
  parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::FIND_FIRST2
  smb_header.flags.reply = 1
end
results(klass, unicode:) click to toggle source

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

@param klass [Class] the FileInformationClass class to read the data as @return [array<BinData::Record>] An array of structs holding the requested information @raise [RubySMB::Error::InvalidPacket] if the string buffer is not a valid File Information packet

# File lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb, line 66
def results(klass, unicode:)
  information_classes = []
  blob = data_block.trans2_data.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

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