Is: 

host_process = client.sys.process.open(pid.to_i, PROCESS_ALL_ACCESS)
mem = host_process.memory.allocate(pay.length + (pay.length % 1024))

Not adequate for this?