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



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

def defer_ptr(ref)
  @deferred_ptrs << ref
end

#do_num_bytes_ptr(struct_offset) ⇒ Object



141
142
143
144
145
146
147
148
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 141

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



131
132
133
134
135
136
137
138
139
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 131

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)


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

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

#initialize_instanceObject



100
101
102
103
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 100

def initialize_instance
  @deferred_ptrs = []
  super
end

#is_deferring(obj) ⇒ Object



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

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

#read_ptr(io) ⇒ Object



120
121
122
123
124
125
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 120

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



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

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