Module: RubySMB::Dcerpc::Ndr::ConstructedTypePlugin

Included in:
ArrayPlugin, StructPlugin
Defined in:
lib/ruby_smb/dcerpc/ndr.rb

Overview

NDR Constructed Types #

Instance Method Summary collapse

Instance Method Details

#defer_ptr(ref) ⇒ Object



109
110
111
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 109

def defer_ptr(ref)
  @deferred_ptrs << ref
end

#do_num_bytes_ptr(struct_offset) ⇒ Object



145
146
147
148
149
150
151
152
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 145

def do_num_bytes_ptr(struct_offset)
  sum = 0
  @deferred_ptrs.each do |ptr_ref|
    sum += ptr_ref.do_num_bytes(struct_offset + sum, is_deferred: true)
  end
  @deferred_ptrs.clear
  sum
end

#get_top_level_constructed_typeObject



135
136
137
138
139
140
141
142
143
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 135

def get_top_level_constructed_type
  return self if is_a?(PointerPlugin)

  res = nil
  if parent&.is_a?(ConstructedTypePlugin)
    res = parent.get_top_level_constructed_type
  end
  return res || self
end

#has_deferred_ptrs?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 113

def has_deferred_ptrs?
  !!@deferred_ptrs&.any?
end

#initialize_instanceObject



104
105
106
107
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 104

def initialize_instance
  @deferred_ptrs = []
  super
end

#is_deferring(obj) ⇒ Object



131
132
133
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 131

def is_deferring(obj)
  @deferred_ptrs.any? { |e| e.equal?(obj) }
end

#read_ptr(io) ⇒ Object



124
125
126
127
128
129
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 124

def read_ptr(io)
  @deferred_ptrs.each do |ptr_ref|
    ptr_ref.do_read(io, is_deferred: true)
  end
  @deferred_ptrs.clear
end

#write_ptr(io) ⇒ Object



117
118
119
120
121
122
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 117

def write_ptr(io)
  @deferred_ptrs.each do |ptr_ref|
    ptr_ref.do_write(io, is_deferred: true)
  end
  @deferred_ptrs.clear
end