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.
564 565 566 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 564 def actual_count @actual_count end |
#offset ⇒ Object
Returns the value of attribute offset.
564 565 566 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 564 def offset @offset end |
Instance Method Details
#assign(val) ⇒ Object
587 588 589 590 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 587 def assign(val) update_actual_count(val) super end |
#do_num_bytes ⇒ Object
592 593 594 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 592 def do_num_bytes @actual_count > 0 ? (8 + super) : 8 end |
#do_read(io) ⇒ Object
581 582 583 584 585 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 581 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
575 576 577 578 579 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 575 def do_write(io) io.writebytes([@offset].pack('L<')) io.writebytes([@actual_count].pack('L<')) super if @actual_count > 0 end |
#initialize_instance ⇒ Object
566 567 568 569 570 571 572 573 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 566 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
596 597 598 599 600 601 602 603 604 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 596 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 |