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



906
907
908
909
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 906

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

Instance Method Details

#do_write(io, is_deferred: false) ⇒ Object



916
917
918
919
920
921
922
923
924
925
926
927
928
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 916

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



911
912
913
914
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 911

def initialize_instance
  super
  @standalone_ptr = false
end

#is_top_level_ptrObject



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

def is_top_level_ptr
  !!@top_level_ptr
end

#num_bytesObject



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

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

#set_top_level_ptrObject



937
938
939
940
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 937

def set_top_level_ptr
  @top_level_ptr = true
  #update_ref_ids
end

#to_binary_sObject



930
931
932
933
934
935
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 930

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

#unset_top_level_ptrObject



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

def unset_top_level_ptr
  @top_level_ptr = false
end