class RubySMB::SMB1::Packet::Trans2::DataBlock

Extends the {RubySMB::SMB1::DataBlock} to include padding methods that all Trans2 DataBlocks will need to handle proper byte alignment.

Attributes

enable_padding[RW]

Controls whether the padding fields will be used @!attribute [rw] enable_padding

@return [Boolean]

Public Instance Methods

initialize_instance() click to toggle source
Calls superclass method
# File lib/ruby_smb/smb1/packet/trans2/data_block.rb, line 13
def initialize_instance
  super
  @enable_padding = true
end

Private Instance Methods

pad1_length() click to toggle source

Determines the correct length for the padding in front of trans2_parameters. It should always force a 4-byte alignment.

# File lib/ruby_smb/smb1/packet/trans2/data_block.rb, line 22
def pad1_length
  if enable_padding
    offset = if respond_to?(:name)
               (name.abs_offset + 1) % 4
             else
               (byte_count.abs_offset + 2) % 4
             end
    (4 - offset) % 4
  else
    0
  end
end
pad2_length() click to toggle source

Determines the correct length for the padding in front of trans2_data. It should always force a 4-byte alignment.

# File lib/ruby_smb/smb1/packet/trans2/data_block.rb, line 37
def pad2_length
  if enable_padding
    offset = (trans2_parameters.abs_offset + trans2_parameters.length) % 4
    (4 - offset) % 4
  else
    0
  end
end