node/lib/metasm/samples/dasm-plugins/patch_file.rb
def reopen_rw(addr=nil, edata=nil)
	if not edata
		sections.each { |k, v| reopen_rw(k, v) }
		return true
	end

	return if not File.writable?(@program.filename)
	backup_program_file
	if not edata.data.kind_of? VirtualFile
		# section too small, loaded as real String
		# force reopen as VFile (allow hexediting in gui)
		return if not off = addr_to_fileoff(addr)
		len = edata.data.length
		edata.data = VirtualFile.read(@program.filename, 'rb+').dup(off, len)
	else
		edata.data.fd.reopen @program.filename, 'rb+'
	end
end
# create a backup and reopen the backend VirtualFile RW
create a backup and reopen the backend VirtualFile RW
create a backup and reopen the backend VirtualFile RW
def reopen_rw(addr=nil, edata=nil)
	if not edata
		sections.each { |k, v| reopen_rw(k, v) }
		return true
	end
	return if not File.writable?(@program.filename)
	backup_program_file
	if not edata.data.kind_of? VirtualFile
		return if not off = addr_to_fileoff(addr)
		len = edata.data.length
		edata.data = VirtualFile.read(@program.filename, 'rb+').dup(off, len)
	else
		edata.data.fd.reopen @program.filename, 'rb+'
	end
end
def reopen_rw ( addr = nil , edata = nil ) if not edata sections . each { | k , v | reopen_rw ( k , v ) } return true end return if not File . writable? ( @program . filename ) backup_program_file if not edata . data . kind_of? VirtualFile return if not off = addr_to_fileoff ( addr ) len = edata . data . length edata . data = VirtualFile . read ( @program . filename , 'rb+' ) . dup ( off , len ) else edata . data . fd . reopen @program . filename , 'rb+' end end
create a backup and reopen the backend VirtualFile RW
create a backup and reopen the backend VirtualFile RW
# section too small, loaded as real String # force reopen as VFile (allow hexediting in gui)
addr
edata