Skip to content

Commit

Permalink
Merge pull request #179 from O1L/master
Browse files Browse the repository at this point in the history
Minor fix in GUI an other changes.
  • Loading branch information
AlexAltea committed Apr 9, 2014
2 parents 8183ee4 + 0763e42 commit c8d8428
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 12 deletions.
102 changes: 102 additions & 0 deletions rpcs3/Gui/FnIdGenerator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#include "stdafx.h"
#include "FnIdGenerator.h"

FnIdGenerator::FnIdGenerator(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "FunctionID Generator", wxDefaultPosition)
, m_list(nullptr)
{
wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL));
wxBoxSizer* s_subpanel(new wxBoxSizer(wxVERTICAL));
wxBoxSizer* s_subpanel2(new wxBoxSizer(wxHORIZONTAL));

m_list = new wxListView(this, wxID_ANY, wxDefaultPosition, wxSize(300, 450));
m_list->InsertColumn(0, "Function Name", 0, 200);
m_list->InsertColumn(1, "Function ID", 0, 100);

wxButton *b_input_name = new wxButton(this, wxID_ANY, "Input Function Name", wxDefaultPosition, wxSize(140, -1));
wxButton *b_clear = new wxButton(this, wxID_ANY, "Clear List", wxDefaultPosition, wxSize(140, -1));

s_subpanel2->Add(b_input_name);
s_subpanel2->AddSpacer(10);
s_subpanel2->Add(b_clear);

s_subpanel->AddSpacer(5);
s_subpanel->Add(m_list);
s_subpanel->AddSpacer(5);
s_subpanel->Add(s_subpanel2);

s_panel->AddSpacer(5);
s_panel->Add(s_subpanel);
s_panel->AddSpacer(5);

this->SetSizerAndFit(s_panel);

Connect(b_input_name->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FnIdGenerator::OnInput));
Connect(b_clear->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FnIdGenerator::OnClear));
}

FnIdGenerator::~FnIdGenerator()
{
m_func_name.Clear();
m_func_id.Clear();
delete m_list;
}

void FnIdGenerator::OnInput(wxCommandEvent &event)
{
PrintId();
event.Skip();
}

void FnIdGenerator::OnClear(wxCommandEvent &event)
{
m_list->DeleteAllItems();
m_func_name.Clear();
m_func_id.Clear();
event.Skip();
}

u32 FnIdGenerator::GenerateFnId(const std::string& func_name)
{
static const char* suffix = "\x67\x59\x65\x99\x04\x25\x04\x90\x56\x64\x27\x49\x94\x89\x74\x1A"; //symbol name suffix
std::string input = func_name + suffix;
unsigned char output[20];

sha1((unsigned char*)input.c_str(), input.length(), output); //compute SHA-1 hash

return (be_t<u32>&) output[0];
}

void FnIdGenerator::PrintId()
{
const std::string temp;
TextInputDialog dial(0, temp, "Please input function name");
if (dial.ShowModal() == wxID_OK)
{
dial.GetResult();
}

const std::string& func_name = dial.GetResult();

if (func_name.length() == 0)
return;

const be_t<u32> result = GenerateFnId(func_name);
m_func_name.AddCpy(func_name);
m_func_id.AddCpy(result);

ConLog.Write("Function: %s, Id: 0x%08x ", func_name.c_str(), result);
UpdateInformation();
}

void FnIdGenerator::UpdateInformation()
{
m_list->DeleteAllItems();

for(u32 i = 0; i < m_func_name.GetCount(); i++)
{
m_list->InsertItem(m_func_name.GetCount(), wxEmptyString);
m_list->SetItem(i, 0, m_func_name[i]);
m_list->SetItem(i, 1, wxString::Format("0x%08x", re(m_func_id[i])));
}
}
21 changes: 21 additions & 0 deletions rpcs3/Gui/FnIdGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "TextInputDialog.h"
#include "../Crypto/aes.h"
#include "../Crypto/sha1.h"

class FnIdGenerator : public wxDialog
{
private:
Array<std::string> m_func_name;
Array<u32> m_func_id;
wxListView* m_list;

public:
FnIdGenerator(wxWindow* parent);
~FnIdGenerator();

void OnInput(wxCommandEvent &event);
void OnClear(wxCommandEvent &event);
u32 GenerateFnId(const std::string& func_name);
void UpdateInformation();
void PrintId();
};
10 changes: 10 additions & 0 deletions rpcs3/Gui/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MemoryViewer.h"
#include "RSXDebugger.h"
#include "PADManager.h"
#include "FnIdGenerator.h"

#include "git-version.h"
#include "Ini.h"
Expand Down Expand Up @@ -35,6 +36,7 @@ enum IDs
id_tools_compiler,
id_tools_memory_viewer,
id_tools_rsx_debugger,
id_tools_fnid_generator,
id_help_about,
id_update_dbg,
};
Expand Down Expand Up @@ -88,6 +90,7 @@ MainFrame::MainFrame()
menu_tools.Append(id_tools_compiler, "ELF Compiler");
menu_tools.Append(id_tools_memory_viewer, "Memory Viewer");
menu_tools.Append(id_tools_rsx_debugger, "RSX Debugger");
menu_tools.Append(id_tools_fnid_generator, "FunctionID Generator");

wxMenu& menu_help(*new wxMenu());
menubar.Append(&menu_help, "Help");
Expand Down Expand Up @@ -122,6 +125,7 @@ MainFrame::MainFrame()
Connect( id_tools_compiler, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenELFCompiler));
Connect( id_tools_memory_viewer, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenMemoryViewer));
Connect( id_tools_rsx_debugger, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenRSXDebugger));
Connect(id_tools_fnid_generator, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OpenFnIdGenerator));

Connect( id_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::AboutDialogHandler) );

Expand Down Expand Up @@ -583,6 +587,12 @@ void MainFrame::OpenRSXDebugger(wxCommandEvent& WXUNUSED(event))
(new RSXDebugger(this)) -> Show();
}

void MainFrame::OpenFnIdGenerator(wxCommandEvent& WXUNUSED(event))
{
FnIdGenerator(this).ShowModal();
}


void MainFrame::AboutDialogHandler(wxCommandEvent& WXUNUSED(event))
{
AboutDialog(this).ShowModal();
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Gui/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class MainFrame : public FrameBase
void OpenELFCompiler(wxCommandEvent& evt);
void OpenMemoryViewer(wxCommandEvent& evt);
void OpenRSXDebugger(wxCommandEvent& evt);
void OpenFnIdGenerator(wxCommandEvent& evt);
void AboutDialogHandler(wxCommandEvent& event);
void UpdateUI(wxCommandEvent& event);
void OnKeyDown(wxKeyEvent& event);
Expand Down
7 changes: 2 additions & 5 deletions rpcs3/Gui/PADManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ PADManager::PADManager(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "PAD Settings", wxDefaultPosition)
, m_button_id(0)
, m_key_pressed(false)
, m_emu_paused(false)
{
bool paused = false;

if(Emu.IsRunning())
{
Emu.Pause();
paused = true;
m_emu_paused = true;
}

wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL));
Expand Down Expand Up @@ -246,8 +245,6 @@ PADManager::PADManager(wxWindow* parent)
Connect(b_ok->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_reset->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));
Connect(b_cancel->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PADManager::OnButtonClicked));

if(paused) Emu.Resume();
}

void PADManager::OnKeyDown(wxKeyEvent &keyEvent)
Expand Down
6 changes: 2 additions & 4 deletions rpcs3/Gui/PADManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ class PADManager : public wxDialog, PadButtons
AppConnector m_app_connector;
u32 m_seconds;
u32 m_button_id;
bool m_key_pressed;
bool m_key_pressed, m_emu_paused;

public:
PADManager(wxWindow* parent);
~PADManager()
{
}
~PADManager() { if(m_emu_paused) Emu.Resume(); }

void OnKeyDown(wxKeyEvent &keyEvent);
void OnKeyUp(wxKeyEvent &keyEvent);
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Gui/TextInputDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "stdafx.h"
#include "TextInputDialog.h"

TextInputDialog::TextInputDialog(wxWindow* parent, const std::string& defvalue)
: wxDialog(parent, wxID_ANY, "Input text", wxDefaultPosition)
TextInputDialog::TextInputDialog(wxWindow* parent, const std::string& defvalue, const std::string& label)
: wxDialog(parent, wxID_ANY, label, wxDefaultPosition)
{
m_tctrl_text = new wxTextCtrl(this, wxID_ANY, fmt::ToUTF8(defvalue));

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Gui/TextInputDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TextInputDialog : public wxDialog
std::string m_result;

public:
TextInputDialog(wxWindow* parent, const std::string& defvalue = "");
TextInputDialog(wxWindow* parent, const std::string& defvalue = "", const std::string& label = "Input text");
void OnOk(wxCommandEvent& event);

std::string GetResult();
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/rpcs3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
<ClCompile Include="Gui\MemoryViewer.cpp" />
<ClCompile Include="Gui\PADManager.cpp" />
<ClCompile Include="Gui\RSXDebugger.cpp" />
<ClCompile Include="Gui\FnIdGenerator.cpp" />
<ClCompile Include="Gui\TextInputDialog.cpp" />
<ClCompile Include="Gui\VFSManager.cpp" />
<ClCompile Include="Gui\VHDDManager.cpp" />
Expand Down Expand Up @@ -502,6 +503,7 @@
<ClInclude Include="Gui\TextInputDialog.h" />
<ClInclude Include="Gui\VFSManager.h" />
<ClInclude Include="Gui\VHDDManager.h" />
<ClInclude Include="Gui\FnIdGenerator.h" />
<ClInclude Include="Ini.h" />
<ClInclude Include="Loader\ELF.h" />
<ClInclude Include="Loader\ELF32.h" />
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/rpcs3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@
<ClCompile Include="Gui\RSXDebugger.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Gui\FnIdGenerator.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Gui\PADManager.cpp">
<Filter>Gui</Filter>
</ClCompile>
Expand Down Expand Up @@ -579,6 +582,9 @@
<ClInclude Include="Gui\RSXDebugger.h">
<Filter>Gui</Filter>
</ClInclude>
<ClInclude Include="Gui\FnIdGenerator.h">
<Filter>Gui</Filter>
</ClInclude>
<ClInclude Include="Gui\TextInputDialog.h">
<Filter>Gui</Filter>
</ClInclude>
Expand Down

0 comments on commit c8d8428

Please sign in to comment.