From 5f81226d8d728c48224d7efed1f743434f1a6d64 Mon Sep 17 00:00:00 2001 From: Sepalani Date: Fri, 31 Mar 2017 13:00:19 +0100 Subject: [PATCH] SignatureDB: MEGA FormatHandler added --- .../PowerPC/SignatureDB/MEGASignatureDB.cpp | 22 +++++++++++++++++++ .../PowerPC/SignatureDB/MEGASignatureDB.h | 11 ++++++++-- .../Core/PowerPC/SignatureDB/SignatureDB.cpp | 5 +++++ .../Core/PowerPC/SignatureDB/SignatureDB.h | 3 ++- .../Debugger/CodeWindowFunctions.cpp | 19 ++-------------- Source/Core/DolphinWX/FrameTools.cpp | 1 - Source/Core/DolphinWX/Globals.h | 1 - Source/Core/DolphinWX/MainMenuBar.cpp | 6 +---- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp index afa39687e0..91ff8eb0e1 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.cpp @@ -119,6 +119,11 @@ bool Compare(u32 address, u32 size, const MEGASignature& sig) MEGASignatureDB::MEGASignatureDB() = default; MEGASignatureDB::~MEGASignatureDB() = default; +void MEGASignatureDB::Clear() +{ + m_signatures.clear(); +} + bool MEGASignatureDB::Load(const std::string& file_path) { std::ifstream ifs; @@ -145,6 +150,12 @@ bool MEGASignatureDB::Load(const std::string& file_path) return true; } +bool MEGASignatureDB::Save(const std::string& file_path) const +{ + ERROR_LOG(OSHLE, "MEGA database save unsupported yet."); + return false; +} + void MEGASignatureDB::Apply(PPCSymbolDB* symbol_db) const { for (auto& it : symbol_db->AccessSymbols()) @@ -164,6 +175,17 @@ void MEGASignatureDB::Apply(PPCSymbolDB* symbol_db) const symbol_db->Index(); } +void MEGASignatureDB::Populate(const PPCSymbolDB* func_db, const std::string& filter) +{ + ERROR_LOG(OSHLE, "MEGA database can't be populated yet."); +} + +bool MEGASignatureDB::Add(u32 startAddr, u32 size, const std::string& name) +{ + ERROR_LOG(OSHLE, "Can't add symbol to MEGA database yet."); + return false; +} + void MEGASignatureDB::List() const { for (const auto& entry : m_signatures) diff --git a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.h b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.h index 837b24d228..8dad614791 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.h +++ b/Source/Core/Core/PowerPC/SignatureDB/MEGASignatureDB.h @@ -8,6 +8,7 @@ #include #include "Common/CommonTypes.h" +#include "Core/PowerPC/SignatureDB/SignatureDB.h" class PPCSymbolDB; @@ -35,16 +36,22 @@ struct MEGASignature // - Hexstring representation with "." acting as a wildcard // - Name, represented as follow: ":0000 function_name" // - References located in the hexstring at offset: "^offset reference_name" -class MEGASignatureDB +class MEGASignatureDB : public SignatureDBFormatHandler { public: MEGASignatureDB(); ~MEGASignatureDB(); + void Clear(); bool Load(const std::string& file_path); - void Apply(PPCSymbolDB* symbol_db) const; + bool Save(const std::string& file_path) const; void List() const; + void Apply(PPCSymbolDB* symbol_db) const; + void Populate(const PPCSymbolDB* func_db, const std::string& filter = ""); + + bool Add(u32 startAddr, u32 size, const std::string& name); + private: std::vector m_signatures; }; diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp index 80c88c6f2f..762bd39a71 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.cpp @@ -16,6 +16,7 @@ // Format Handlers #include "Core/PowerPC/SignatureDB/CSVSignatureDB.h" #include "Core/PowerPC/SignatureDB/DSYSignatureDB.h" +#include "Core/PowerPC/SignatureDB/MEGASignatureDB.h" SignatureDB::SignatureDB(SignatureDB::HandlerType handler) : m_handler(std::move(CreateFormatHandler(handler))) @@ -30,6 +31,8 @@ SignatureDB::HandlerType SignatureDB::GetHandlerType(const std::string& file_pat { if (StringEndsWith(file_path, ".csv")) return SignatureDB::HandlerType::CSV; + if (StringEndsWith(file_path, ".mega")) + return SignatureDB::HandlerType::MEGA; return SignatureDB::HandlerType::DSY; } @@ -43,6 +46,8 @@ SignatureDB::CreateFormatHandler(SignatureDB::HandlerType handler) const return std::make_unique(); case SignatureDB::HandlerType::CSV: return std::make_unique(); + case SignatureDB::HandlerType::MEGA: + return std::make_unique(); } } diff --git a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h index 7487699479..01277c9bd5 100644 --- a/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h +++ b/Source/Core/Core/PowerPC/SignatureDB/SignatureDB.h @@ -21,7 +21,8 @@ public: enum class HandlerType { DSY, - CSV + CSV, + MEGA }; explicit SignatureDB(HandlerType handler); explicit SignatureDB(const std::string& file_path); diff --git a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp index 170027068d..ad37367bb3 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp @@ -166,7 +166,8 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) { static const wxString signature_selector = _("Dolphin Signature File (*.dsy)") + "|*.dsy|" + _("Dolphin Signature CSV File (*.csv)") + "|*.csv|" + - wxGetTranslation(wxALL_FILES); + _("WiiTools Signature MEGA File (*.mega)") + + "|*.mega|" + wxGetTranslation(wxALL_FILES); Parent->ClearStatusBar(); if (!Core::IsRunning()) @@ -429,22 +430,6 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) } } break; - case IDM_USE_MEGA_SIGNATURE_FILE: - { - wxString path = wxFileSelector( - _("Apply MEGA signature file"), File::GetSysDirectory(), wxEmptyString, wxEmptyString, - _("MEGA Signature File (*.mega)") + "|*.mega|" + wxGetTranslation(wxALL_FILES), - wxFD_OPEN | wxFD_FILE_MUST_EXIST, this); - if (!path.IsEmpty()) - { - MEGASignatureDB db; - db.Load(WxStrToStr(path)); - db.Apply(&g_symbolDB); - db.List(); - NotifyMapLoaded(); - } - } - break; case IDM_PATCH_HLE_FUNCTIONS: HLE::PatchFunctions(); Repopulate(); diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 996c7770a6..38d165400f 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -246,7 +246,6 @@ void CFrame::BindDebuggerMenuBarUpdateEvents() Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_COMBINE_SIGNATURE_FILES); Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_RENAME_SYMBOLS); Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_USE_SIGNATURE_FILE); - Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_USE_MEGA_SIGNATURE_FILE); Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreInitialized, IDM_PATCH_HLE_FUNCTIONS); Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreUninitialized, IDM_JIT_NO_BLOCK_CACHE); diff --git a/Source/Core/DolphinWX/Globals.h b/Source/Core/DolphinWX/Globals.h index 9dfc6bc0e4..8d2a79fdd6 100644 --- a/Source/Core/DolphinWX/Globals.h +++ b/Source/Core/DolphinWX/Globals.h @@ -232,7 +232,6 @@ enum IDM_COMBINE_SIGNATURE_FILES, IDM_RENAME_SYMBOLS, IDM_USE_SIGNATURE_FILE, - IDM_USE_MEGA_SIGNATURE_FILE, IDM_PATCH_HLE_FUNCTIONS, // JIT diff --git a/Source/Core/DolphinWX/MainMenuBar.cpp b/Source/Core/DolphinWX/MainMenuBar.cpp index 8994871cd6..f5cae338ab 100644 --- a/Source/Core/DolphinWX/MainMenuBar.cpp +++ b/Source/Core/DolphinWX/MainMenuBar.cpp @@ -471,11 +471,7 @@ wxMenu* MainMenuBar::CreateSymbolsMenu() const symbols_menu->Append( IDM_USE_SIGNATURE_FILE, _("Apply Signat&ure File..."), _("Must use Generate Symbols first! Recognise names of any standard library functions " - "used in multiple games, by loading them from a .dsy file.")); - symbols_menu->Append( - IDM_USE_MEGA_SIGNATURE_FILE, _("Apply &MEGA Signature File..."), - _("Must use Generate Symbols first! Recognise names of any standard library functions " - "used in multiple games, by loading them from a .mega file.")); + "used in multiple games, by loading them from a .dsy, .csv, or .mega file.")); symbols_menu->AppendSeparator(); symbols_menu->Append(IDM_PATCH_HLE_FUNCTIONS, _("&Patch HLE Functions")); symbols_menu->Append(IDM_RENAME_SYMBOLS, _("&Rename Symbols from File..."));