lib/twib/interfaces/ITwibDebugger.rb in twib-0.1.2 vs lib/twib/interfaces/ITwibDebugger.rb in twib-0.1.3

- old
+ new

@@ -39,19 +39,21 @@ # Reads from process memory at the given address. # @param addr [Integer] Address to read from # @param size [Integer] How many bytes to read # @return [String] def read_memory(addr, size) - send(Command::READ_MEMORY, [addr, size].pack("Q<Q<")).wait_ok.payload + response = send(Command::READ_MEMORY, [addr, size].pack("Q<Q<")).wait_ok.payload + length = response.unpack("Q<")[0] + return response[8, length] end # Writes to process memory at the given address. # @param addr [Integer] Address to write to # @param string [String] Data to write # @return [String] def write_memory(addr, string) - send(Command::WRITE_MEMORY, [addr].pack("Q<") + string).wait_ok + send(Command::WRITE_MEMORY, [addr, string.bytesize].pack("Q<Q<") + string).wait_ok string end # Lists threads in the target process. # @return [self] @@ -85,10 +87,10 @@ # Continues the target process. # @param flags [Integer] See http://www.switchbrew.org/index.php?title=SVC#ContinueDebugFlagsOld # @return [self] def continue_debug_event(flags, thread_ids=[]) - send(Command::CONTINUE_DEBUG_EVENT, ([flags] + thread_ids).pack("L<Q<*")).wait_ok + send(Command::CONTINUE_DEBUG_EVENT, ([flags, thread_ids.length] + thread_ids).pack("L<Q<Q<*")).wait_ok self end # Sets a thread's context. # @return [self]