Add support for sending game memory changes to outside processes

This commit is contained in:
spxtr
2015-12-29 17:59:16 -08:00
parent 29ec5b065a
commit 2f50560602
8 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <atomic>
#include <map>
#include <thread>
#include <sys/socket.h>
#include <sys/un.h>
// MemoryWatcher reads a file containing in-game memory addresses and outputs
// changes to those memory addresses to a unix domain socket as the game runs.
//
// The input file is a newline-separated list of hex memory addresses
// (without the "0x"). The output to the socket is two words long, the first
// containing the address, and the second containing the data as stored in
// game memory.
class MemoryWatcher final
{
public:
MemoryWatcher();
~MemoryWatcher();
private:
bool LoadAddresses(const std::string& path);
bool OpenSocket(const std::string& path);
void WatcherThread();
std::thread m_watcher_thread;
std::atomic_bool m_running;
int m_fd;
sockaddr_un m_addr;
// Address -> last value
std::map<u32, u32> m_values;
};