I guess using functions at least would be a good idea, the generate() function (and the windows.rb) is a little unreadable for me at this moment. I think the generate function should be something like that (just an idea):

<pre>
	#
	# Overload the generate() call to prefix our stubs
	#
	def generate(*args)
		# Call the real generator to get the payload
		buf = super(*args)
		pre = ''

		test_arch = [ *(self.arch) ]

		# Handle all x86 code here
		if test_arch.include?(ARCH_X86)
			# PrependMigrate
			if datastore['PrependMigrate'] and datastore['PrependMigrate'].to_s.downcase == 'true'
				migrate_asm = prepend_migrate(buf)
				pre << Metasm::Shellcode.assemble(Metasm::Ia32.new, migrate_asm).encode_string
			end
		# Handle all x64 code here
		elsif test_arch.include?(ARCH_X86_64) or test_arch.include?(ARCH_X64)
			# PrependMigrate
			if datastore['PrependMigrate'] and datastore['PrependMigrate'].to_s.downcase == 'true'
				migrate_asm = prepend_migrate_64(buf)
				pre << Metasm::Shellcode.assemble(Metasm::X64.new, migrate_asm).encode_string
			end
		end
		return (pre + buf)
	end

</pre>

And move the prepend assembler to functions. Not sure if there are any inconveniences atm with this. Just pointing and asking.