Class: RubySMB::Dcerpc::Ndr::NdrString

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/ruby_smb/dcerpc/ndr.rb

Overview

An NDR Conformant and Varying String representation as defined in Transfer Syntax NDR - Conformant and Varying Strings The string elements are Stringz16 (unicode)

Instance Method Summary collapse

Instance Method Details

#clearObject



47
48
49
50
51
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 47

def clear
  # Make sure #max_count and #offset are not cleared out
  self.str.clear
  self.actual_count.clear
end

#getObject



25
26
27
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 25

def get
  self.actual_count == 0 ? 0 : self.str
end

#set(v) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 29

def set(v)
  if v == 0
    self.str.clear
    self.actual_count = 0
  else
    v = v.str if v.is_a?(self.class)
    unless self.str.equal?(v)
      if v.empty?
        self.actual_count = 0
      else
        self.actual_count = v.to_s.size + 1
        self.max_count = self.actual_count
      end
    end
    self.str = v.to_s
  end
end

#to_sObject



53
54
55
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 53

def to_s
  self.str.to_s
end