NetworkCaptureLogger: Move SSL logging
This commit is contained in:
parent
3e66db2fd7
commit
289637f92f
|
@ -406,6 +406,8 @@ add_library(core
|
||||||
NetPlayClient.h
|
NetPlayClient.h
|
||||||
NetPlayServer.cpp
|
NetPlayServer.cpp
|
||||||
NetPlayServer.h
|
NetPlayServer.h
|
||||||
|
NetworkCaptureLogger.cpp
|
||||||
|
NetworkCaptureLogger.h
|
||||||
PatchEngine.cpp
|
PatchEngine.cpp
|
||||||
PatchEngine.h
|
PatchEngine.h
|
||||||
PowerPC/BreakPoints.cpp
|
PowerPC/BreakPoints.cpp
|
||||||
|
|
|
@ -534,6 +534,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||||
|
|
||||||
PatchEngine::Shutdown();
|
PatchEngine::Shutdown();
|
||||||
HLE::Clear();
|
HLE::Clear();
|
||||||
|
PowerPC::debug_interface.Clear();
|
||||||
}};
|
}};
|
||||||
|
|
||||||
VideoBackendBase::PopulateBackendInfo();
|
VideoBackendBase::PopulateBackendInfo();
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Common/Align.h"
|
#include "Common/Align.h"
|
||||||
#include "Common/GekkoDisassembler.h"
|
#include "Common/GekkoDisassembler.h"
|
||||||
|
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/Debugger/OSThread.h"
|
#include "Core/Debugger/OSThread.h"
|
||||||
#include "Core/HW/DSP.h"
|
#include "Core/HW/DSP.h"
|
||||||
|
@ -383,10 +384,33 @@ void PPCDebugInterface::RunToBreakpoint()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Core::NetworkCaptureLogger> PPCDebugInterface::NetworkLogger()
|
||||||
|
{
|
||||||
|
const bool has_ssl = Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ) ||
|
||||||
|
Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE);
|
||||||
|
const auto current_capture_type =
|
||||||
|
has_ssl ? Core::NetworkCaptureType::Raw : Core::NetworkCaptureType::None;
|
||||||
|
|
||||||
|
if (m_network_logger && m_network_logger->GetCaptureType() == current_capture_type)
|
||||||
|
return m_network_logger;
|
||||||
|
|
||||||
|
switch (current_capture_type)
|
||||||
|
{
|
||||||
|
case Core::NetworkCaptureType::Raw:
|
||||||
|
m_network_logger = std::make_shared<Core::BinarySSLCaptureLogger>();
|
||||||
|
break;
|
||||||
|
case Core::NetworkCaptureType::None:
|
||||||
|
m_network_logger = std::make_shared<Core::DummyNetworkCaptureLogger>();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return m_network_logger;
|
||||||
|
}
|
||||||
|
|
||||||
void PPCDebugInterface::Clear()
|
void PPCDebugInterface::Clear()
|
||||||
{
|
{
|
||||||
ClearAllBreakpoints();
|
ClearAllBreakpoints();
|
||||||
ClearAllMemChecks();
|
ClearAllMemChecks();
|
||||||
ClearPatches();
|
ClearPatches();
|
||||||
ClearWatches();
|
ClearWatches();
|
||||||
|
m_network_logger.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common/Debug/MemoryPatches.h"
|
#include "Common/Debug/MemoryPatches.h"
|
||||||
#include "Common/Debug/Watches.h"
|
#include "Common/Debug/Watches.h"
|
||||||
#include "Common/DebugInterface.h"
|
#include "Common/DebugInterface.h"
|
||||||
|
#include "Core/NetworkCaptureLogger.h"
|
||||||
|
|
||||||
class PPCPatches : public Common::Debug::MemoryPatches
|
class PPCPatches : public Common::Debug::MemoryPatches
|
||||||
{
|
{
|
||||||
|
@ -82,9 +84,12 @@ public:
|
||||||
u32 GetColor(u32 address) const override;
|
u32 GetColor(u32 address) const override;
|
||||||
std::string GetDescription(u32 address) const override;
|
std::string GetDescription(u32 address) const override;
|
||||||
|
|
||||||
|
std::shared_ptr<Core::NetworkCaptureLogger> NetworkLogger();
|
||||||
|
|
||||||
void Clear() override;
|
void Clear() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::Debug::Watches m_watches;
|
Common::Debug::Watches m_watches;
|
||||||
PPCPatches m_patches;
|
PPCPatches m_patches;
|
||||||
|
std::shared_ptr<Core::NetworkCaptureLogger> m_network_logger;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/IOFile.h"
|
#include "Common/IOFile.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/IOS/Device.h"
|
#include "Core/IOS/Device.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define ERRORCODE(name) WSA##name
|
#define ERRORCODE(name) WSA##name
|
||||||
|
@ -460,15 +460,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
int ret = mbedtls_ssl_write(&Device::NetSSL::_SSL[sslID].ctx,
|
int ret = mbedtls_ssl_write(&Device::NetSSL::_SSL[sslID].ctx,
|
||||||
Memory::GetPointer(BufferOut2), BufferOutSize2);
|
Memory::GetPointer(BufferOut2), BufferOutSize2);
|
||||||
|
|
||||||
if (Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE) && ret > 0)
|
|
||||||
{
|
|
||||||
std::string filename = File::GetUserPath(D_DUMPSSL_IDX) +
|
|
||||||
SConfig::GetInstance().GetGameID() + "_write.bin";
|
|
||||||
File::IOFile(filename, "ab").WriteBytes(Memory::GetPointer(BufferOut2), ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
|
PowerPC::debug_interface.NetworkLogger()->LogWrite(Memory::GetPointer(BufferOut2),
|
||||||
|
ret);
|
||||||
// Return bytes written or SSL_ERR_ZERO if none
|
// Return bytes written or SSL_ERR_ZERO if none
|
||||||
WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn);
|
WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn);
|
||||||
}
|
}
|
||||||
|
@ -498,15 +493,9 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
int ret = mbedtls_ssl_read(&Device::NetSSL::_SSL[sslID].ctx,
|
int ret = mbedtls_ssl_read(&Device::NetSSL::_SSL[sslID].ctx,
|
||||||
Memory::GetPointer(BufferIn2), BufferInSize2);
|
Memory::GetPointer(BufferIn2), BufferInSize2);
|
||||||
|
|
||||||
if (Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ) && ret > 0)
|
|
||||||
{
|
|
||||||
std::string filename = File::GetUserPath(D_DUMPSSL_IDX) +
|
|
||||||
SConfig::GetInstance().GetGameID() + "_read.bin";
|
|
||||||
File::IOFile(filename, "ab").WriteBytes(Memory::GetPointer(BufferIn2), ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
|
PowerPC::debug_interface.NetworkLogger()->LogRead(Memory::GetPointer(BufferIn2), ret);
|
||||||
// Return bytes read or SSL_ERR_ZERO if none
|
// Return bytes read or SSL_ERR_ZERO if none
|
||||||
WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn);
|
WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2021 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "Core/NetworkCaptureLogger.h"
|
||||||
|
|
||||||
|
#include "Common/FileUtil.h"
|
||||||
|
#include "Common/IOFile.h"
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
NetworkCaptureLogger::NetworkCaptureLogger() = default;
|
||||||
|
NetworkCaptureLogger::~NetworkCaptureLogger() = default;
|
||||||
|
|
||||||
|
void DummyNetworkCaptureLogger::LogRead(const void* data, std::size_t length)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DummyNetworkCaptureLogger::LogWrite(const void* data, std::size_t length)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkCaptureType DummyNetworkCaptureLogger::GetCaptureType() const
|
||||||
|
{
|
||||||
|
return NetworkCaptureType::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BinarySSLCaptureLogger::LogRead(const void* data, std::size_t length)
|
||||||
|
{
|
||||||
|
if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ))
|
||||||
|
return;
|
||||||
|
const std::string filename =
|
||||||
|
File::GetUserPath(D_DUMPSSL_IDX) + SConfig::GetInstance().GetGameID() + "_read.bin";
|
||||||
|
File::IOFile(filename, "ab").WriteBytes(data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BinarySSLCaptureLogger::LogWrite(const void* data, std::size_t length)
|
||||||
|
{
|
||||||
|
if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE))
|
||||||
|
return;
|
||||||
|
const std::string filename =
|
||||||
|
File::GetUserPath(D_DUMPSSL_IDX) + SConfig::GetInstance().GetGameID() + "_write.bin";
|
||||||
|
File::IOFile(filename, "ab").WriteBytes(data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkCaptureType BinarySSLCaptureLogger::GetCaptureType() const
|
||||||
|
{
|
||||||
|
return NetworkCaptureType::Raw;
|
||||||
|
}
|
||||||
|
} // namespace Core
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright 2021 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
enum class NetworkCaptureType
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Raw,
|
||||||
|
PCAP,
|
||||||
|
};
|
||||||
|
|
||||||
|
class NetworkCaptureLogger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NetworkCaptureLogger();
|
||||||
|
NetworkCaptureLogger(const NetworkCaptureLogger&) = delete;
|
||||||
|
NetworkCaptureLogger(NetworkCaptureLogger&&) = delete;
|
||||||
|
NetworkCaptureLogger& operator=(const NetworkCaptureLogger&) = delete;
|
||||||
|
NetworkCaptureLogger& operator=(NetworkCaptureLogger&&) = delete;
|
||||||
|
virtual ~NetworkCaptureLogger();
|
||||||
|
|
||||||
|
virtual void LogRead(const void* data, std::size_t length) = 0;
|
||||||
|
virtual void LogWrite(const void* data, std::size_t length) = 0;
|
||||||
|
virtual NetworkCaptureType GetCaptureType() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DummyNetworkCaptureLogger : public NetworkCaptureLogger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void LogRead(const void* data, std::size_t length) override;
|
||||||
|
void LogWrite(const void* data, std::size_t length) override;
|
||||||
|
NetworkCaptureType GetCaptureType() const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BinarySSLCaptureLogger final : public NetworkCaptureLogger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void LogRead(const void* data, std::size_t length) override;
|
||||||
|
void LogWrite(const void* data, std::size_t length) override;
|
||||||
|
NetworkCaptureType GetCaptureType() const override;
|
||||||
|
};
|
||||||
|
} // namespace Core
|
|
@ -375,6 +375,7 @@
|
||||||
<ClInclude Include="Core\NetPlayClient.h" />
|
<ClInclude Include="Core\NetPlayClient.h" />
|
||||||
<ClInclude Include="Core\NetPlayProto.h" />
|
<ClInclude Include="Core\NetPlayProto.h" />
|
||||||
<ClInclude Include="Core\NetPlayServer.h" />
|
<ClInclude Include="Core\NetPlayServer.h" />
|
||||||
|
<ClInclude Include="Core\NetworkCaptureLogger.h" />
|
||||||
<ClInclude Include="Core\PatchEngine.h" />
|
<ClInclude Include="Core\PatchEngine.h" />
|
||||||
<ClInclude Include="Core\PowerPC\BreakPoints.h" />
|
<ClInclude Include="Core\PowerPC\BreakPoints.h" />
|
||||||
<ClInclude Include="Core\PowerPC\CachedInterpreter\CachedInterpreter.h" />
|
<ClInclude Include="Core\PowerPC\CachedInterpreter\CachedInterpreter.h" />
|
||||||
|
@ -943,6 +944,7 @@
|
||||||
<ClCompile Include="Core\Movie.cpp" />
|
<ClCompile Include="Core\Movie.cpp" />
|
||||||
<ClCompile Include="Core\NetPlayClient.cpp" />
|
<ClCompile Include="Core\NetPlayClient.cpp" />
|
||||||
<ClCompile Include="Core\NetPlayServer.cpp" />
|
<ClCompile Include="Core\NetPlayServer.cpp" />
|
||||||
|
<ClCompile Include="Core\NetworkCaptureLogger.cpp" />
|
||||||
<ClCompile Include="Core\PatchEngine.cpp" />
|
<ClCompile Include="Core\PatchEngine.cpp" />
|
||||||
<ClCompile Include="Core\PowerPC\BreakPoints.cpp" />
|
<ClCompile Include="Core\PowerPC\BreakPoints.cpp" />
|
||||||
<ClCompile Include="Core\PowerPC\CachedInterpreter\CachedInterpreter.cpp" />
|
<ClCompile Include="Core\PowerPC\CachedInterpreter\CachedInterpreter.cpp" />
|
||||||
|
|
Loading…
Reference in New Issue