class RubySMB::Dcerpc::Ndr::NdrStruct
A generic NDR structure that implements logic to read and write (to_binary_s) in case the structure contains BinData::Array or NdrPointer
fields. This class must be inherited.
Public Instance Methods
do_read(io)
click to toggle source
Calls superclass method
# File lib/ruby_smb/dcerpc/ndr.rb, line 310 def do_read(io) super(io) each_pair do |_name, field| case field when BinData::Array field.each do |element| next unless element.is_a?(NdrPointer) next if element.referent_id == 0 pad = (4 - io.offset % 4) % 4 io.seekbytes(pad) if pad > 0 element.referent.do_read(io) end when NdrPointer next if field.referent_id == 0 pad = (4 - io.offset % 4) % 4 io.seekbytes(pad) if pad > 0 field.referent.do_read(io) end end end
do_write(io)
click to toggle source
Calls superclass method
# File lib/ruby_smb/dcerpc/ndr.rb, line 331 def do_write(io) super(io) each_pair do |_name, field| case field when BinData::Array field.each do |element| next unless element.is_a?(NdrPointer) next if element.referent_id == 0 pad = (4 - io.offset % 4) % 4 io.writebytes("\x00" * pad + element.referent.to_binary_s) end when NdrPointer next if field.referent_id == 0 pad = (4 - io.offset % 4) % 4 io.writebytes("\x00" * pad + field.referent.to_binary_s) end end end