Module: RubySMB::Dcerpc::Ndr::TopLevelPlugin

Defined in:
lib/ruby_smb/dcerpc/ndr.rb

Defined Under Namespace

Modules: TopLevelClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(target) ⇒ Object



916
917
918
919
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 916

def self.extended(target)
  target.class.extend(TopLevelClassMethods)
  target.class.reset_pos
end

Instance Method Details

#do_write(io, is_deferred: false) ⇒ Object



926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 926

def do_write(io, is_deferred: false)
  # If for whatever reasons, the #pos value has been modified, reset it to
  # make sure the pointer ref_id will start from INITIAL_REF_ID
  self.class.reset_pos if is_top_level_ptr || @standalone_ptr
  if is_deferred
    super(io, is_deferred: is_deferred)
  else
    super(io)
  end
  # Since #pos has been incremented for each embedded pointer, let's reset
  # it to go back to its initial state
  self.class.reset_pos if is_top_level_ptr || @standalone_ptr
end

#initialize_instanceObject



921
922
923
924
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 921

def initialize_instance
  super
  @standalone_ptr = false
end

#is_top_level_ptrObject



956
957
958
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 956

def is_top_level_ptr
  !!@top_level_ptr
end

#num_bytesObject



960
961
962
963
964
965
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 960

def num_bytes
  @standalone_ptr = true
  res = super
  @standalone_ptr = false
  res
end

#set_top_level_ptrObject



947
948
949
950
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 947

def set_top_level_ptr
  @top_level_ptr = true
  #update_ref_ids
end

#to_binary_sObject



940
941
942
943
944
945
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 940

def to_binary_s
  @standalone_ptr = true
  res = super
  @standalone_ptr = false
  res
end

#unset_top_level_ptrObject



952
953
954
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 952

def unset_top_level_ptr
  @top_level_ptr = false
end