summaryrefslogtreecommitdiff
path: root/run/run.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'run/run.cpp')
-rw-r--r--run/run.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/run/run.cpp b/run/run.cpp
index 2f02a7b..b85e001 100644
--- a/run/run.cpp
+++ b/run/run.cpp
@@ -33,13 +33,21 @@ void accept_handler(boost::system::error_code const& error)
{
if(!error)
{
+ uint32_t binary_size = determine_binary_size(file);
+ BinarySizeMessage size_message {
+ .binary_size = binary_size
+ };
+ connection_socket.send(boost::asio::buffer(&size_message, sizeof size_message));
+
+ BinaryBaseOffsetMessage offset_message;
+ connection_socket.receive(boost::asio::buffer(&offset_message, sizeof offset_message));
+
std::vector<uint8_t> binary = load_binary(file);
+ relocate(file, binary, binparse::Offset32(offset_message.offset));
+
uint32_t base_address = file.object_table.entries.at(file.le_header.EIP_object).reloc_base_address;
- uint32_t binary_size = binary.size();
BinaryLoadMessage message {
- .binary_size = binary_size,
- .base_address = base_address,
- .eip = file.le_header.EIP + base_address
+ .eip = file.le_header.EIP + base_address + offset_message.offset
};
connection_socket.send(boost::asio::buffer(&message, sizeof message));