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



44
45
46
47
48
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 44

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

#getObject



22
23
24
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 22

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

#set(v) ⇒ Object



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

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



50
51
52
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 50

def to_s
  self.str.to_s
end