Module: RubySMB::Dcerpc::Ndr::ConfStringPlugin
- Defined in:
- lib/ruby_smb/dcerpc/ndr.rb
Instance Attribute Summary collapse
-
#max_count ⇒ Object
Returns the value of attribute max_count.
Instance Method Summary collapse
- #assign(val) ⇒ Object
- #do_num_bytes ⇒ Object
- #do_read(io) ⇒ Object
- #do_write(io) ⇒ Object
- #get_max_count(val) ⇒ Object
- #initialize_instance ⇒ Object
- #set_max_count(val) ⇒ Object
- #should_process_max_count? ⇒ Boolean
Instance Attribute Details
#max_count ⇒ Object
Returns the value of attribute max_count.
499 500 501 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 499 def max_count @max_count end |
Instance Method Details
#assign(val) ⇒ Object
529 530 531 532 533 534 535 536 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 529 def assign(val) if val.is_a?(ConfStringPlugin) @max_count = val.max_count else set_max_count(get_max_count(val)) end super end |
#do_num_bytes ⇒ Object
538 539 540 541 542 543 544 545 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 538 def do_num_bytes sum = 0 if should_process_max_count? # add max_count size sum += 4 end sum + super end |
#do_read(io) ⇒ Object
522 523 524 525 526 527 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 522 def do_read(io) if should_process_max_count? set_max_count(io.readbytes(4).unpack('L<').first) end super end |
#do_write(io) ⇒ Object
515 516 517 518 519 520 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 515 def do_write(io) if should_process_max_count? io.writebytes([@max_count].pack('L<')) end super end |
#get_max_count(val) ⇒ Object
547 548 549 550 551 552 553 554 555 556 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 547 def get_max_count(val) if is_a?(BinData::Stringz) max_count = val.to_s.strip.length # Only count the terminating NULL byte if the string is not empty max_count += 1 if max_count > 0 return max_count else return val.to_s.length end end |
#initialize_instance ⇒ Object
501 502 503 504 505 506 507 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 501 def initialize_instance @max_count = 0 if has_parameter?(:initial_value) set_max_count(get_max_count(eval_parameter(:initial_value))) end super end |
#set_max_count(val) ⇒ Object
558 559 560 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 558 def set_max_count(val) @max_count = val end |
#should_process_max_count? ⇒ Boolean
509 510 511 512 513 |
# File 'lib/ruby_smb/dcerpc/ndr.rb', line 509 def should_process_max_count? # :max_count has already been processed if the parent structure is an # NdrStruct, but this is not the case if we are dealing with a pointer !parent.is_a?(NdrStruct) || self.is_a?(PointerPlugin) end |