Module: RubySMB::Dcerpc::Ndr::VarStringPlugin
- Defined in:
- lib/ruby_smb/dcerpc/ndr.rb
Instance Attribute Summary collapse
-
#actual_count ⇒ Object
Returns the value of attribute actual_count.
-
#offset ⇒ Object
Returns the value of attribute offset.
Instance Method Summary collapse
- #assign(val) ⇒ Object
- #do_num_bytes ⇒ Object
- #do_read(io) ⇒ Object
- #do_write(io) ⇒ Object
- #initialize_instance ⇒ Object
- #update_actual_count(val) ⇒ Object
Instance Attribute Details
#actual_count ⇒ Object
Returns the value of attribute actual_count.
566 567 568 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 566 def actual_count @actual_count end |
#offset ⇒ Object
Returns the value of attribute offset.
566 567 568 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 566 def offset @offset end |
Instance Method Details
#assign(val) ⇒ Object
589 590 591 592 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 589 def assign(val) update_actual_count(val) super end |
#do_num_bytes ⇒ Object
594 595 596 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 594 def do_num_bytes @actual_count > 0 ? (8 + super) : 8 end |
#do_read(io) ⇒ Object
583 584 585 586 587 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 583 def do_read(io) @offset = io.readbytes(4).unpack('L<').first @actual_count = io.readbytes(4).unpack('L<').first super if @actual_count > 0 end |
#do_write(io) ⇒ Object
577 578 579 580 581 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 577 def do_write(io) io.writebytes([@offset].pack('L<')) io.writebytes([@actual_count].pack('L<')) super if @actual_count > 0 end |
#initialize_instance ⇒ Object
568 569 570 571 572 573 574 575 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 568 def initialize_instance @offset = 0 @actual_count = 0 if has_parameter?(:initial_value) update_actual_count(eval_parameter(:initial_value)) end super end |
#update_actual_count(val) ⇒ Object
598 599 600 601 602 603 604 605 606 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 598 def update_actual_count(val) if is_a?(BinData::Stringz) @actual_count = val.to_s.strip.length # Only count the terminating NULL byte if the string is not empty @actual_count += 1 if @actual_count > 0 else @actual_count = val.to_s.length end end |