Class: Rex::OLE::MiniFAT
Instance Method Summary collapse
- #allocate_sector ⇒ Object
-
#read ⇒ Object
low-level functions.
- #write ⇒ Object
Methods inherited from DIFAT
#+, #<<, #[], #[]=, #each, #initialize, #length, #reset, #slice!, #to_s
Constructor Details
This class inherits a constructor from Rex::OLE::DIFAT
Instance Method Details
#allocate_sector ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rex/ole/minifat.rb', line 37 def allocate_sector idx = @entries.index(SECT_FREE) if (not idx) # add a sector worth idx = @entries.length @stg.header.idx_per_sect.times { @entries << SECT_FREE } end # default mini-sectors to end of chain @entries[idx] = SECT_END idx end |
#read ⇒ Object
low-level functions
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rex/ole/minifat.rb', line 16 def read @entries = [] visited = [] sect = @stg.header._sectMiniFatStart @stg.header._csectMiniFat.times { |idx| break if sect == SECT_END if (visited.include?(sect)) raise RuntimeError, 'Sector chain loop detected (0x%08x)' % sect end visited << sect buf = @stg.read_sector(sect, @stg.header.sector_size) @stg.header.idx_per_sect.times { |idx| @entries << Util.get32(buf, (idx*4)) } sect = @stg.next_sector(sect) } end |
#write ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rex/ole/minifat.rb', line 53 def write return if (@entries.length < 1) mf_start = nil mfs_count = 0 prev_sect = nil copy = @entries.dup while (copy.length > 0) part = copy.slice!(0, @stg.header.idx_per_sect) sbuf = Util.pack32array(part) idx = @stg.write_sector(sbuf, nil, prev_sect) mfs_count += 1 mf_start ||= idx end @stg.header._sectMiniFatStart = mf_start @stg.header._csectMiniFat = mfs_count end |