mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-18 02:11:28 +00:00
Removed old / unnecessary code
* Removed Plugins.h file as I assume setting up a plugin hell is a bad idea (does anyone disagree?). * Removed FnIdGenerator, and moved FnIdGenerator::GenerateFnId to getFunctionId in Modules.cpp * Disabled RSX Debugger and Memory Viewer when the emulator is stopped. * ELF64Loader::LoadPhdrData refactored.
This commit is contained in:
parent
08d61163ea
commit
0002cc0af3
@ -5,12 +5,20 @@
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
#include "Emu/SysCalls/SC_FUNC.h"
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
#include "Crypto/sha1.h"
|
||||
#include <mutex>
|
||||
#include "Emu/System.h"
|
||||
#include "ModuleManager.h"
|
||||
|
||||
u32 getFunctionId(const std::string& name)
|
||||
{
|
||||
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 = name + suffix;
|
||||
unsigned char output[20];
|
||||
|
||||
|
||||
sha1((unsigned char*)input.c_str(), input.length(), output); // Compute SHA-1 hash
|
||||
return (u32&)output[0];
|
||||
}
|
||||
|
||||
Module::Module(u16 id, const char* name)
|
||||
: m_is_loaded(false)
|
||||
@ -217,4 +225,3 @@ bool Module::CheckID(u32 id, ID*& _id) const
|
||||
{
|
||||
return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == GetName();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#define declCPU PPUThread& CPU = GetCurrentPPUThread
|
||||
|
||||
|
||||
//TODO
|
||||
struct ModuleFunc
|
||||
{
|
||||
@ -120,16 +119,24 @@ public:
|
||||
}
|
||||
|
||||
template<typename T> __forceinline void AddFunc(u32 id, T func);
|
||||
|
||||
template<typename T> __forceinline void AddFunc(const std::string& name, T func);
|
||||
template<typename T> __forceinline void AddFuncSub(const char group[8], const u64 ops[], const char* name, T func);
|
||||
};
|
||||
|
||||
u32 getFunctionId(const std::string& name);
|
||||
|
||||
template<typename T>
|
||||
__forceinline void Module::AddFunc(u32 id, T func)
|
||||
{
|
||||
m_funcs_list.emplace_back(new ModuleFunc(id, bind_func(func)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__forceinline void Module::AddFunc(const std::string& name, T func)
|
||||
{
|
||||
AddFunc(getFunctionId(name), func);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
__forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], const char* name, T func)
|
||||
{
|
||||
@ -144,7 +151,6 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
|
||||
sf->found = 0;
|
||||
|
||||
// TODO: check for self-inclusions, use CRC
|
||||
|
||||
for (u32 i = 0; ops[i]; i++)
|
||||
{
|
||||
SFuncOp op;
|
||||
@ -157,4 +163,3 @@ __forceinline void Module::AddFuncSub(const char group[8], const u64 ops[], cons
|
||||
}
|
||||
Emu.GetSFuncManager().push_back(sf);
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,6 @@ public:
|
||||
static std::string GetHLEFuncName(const u32 fid);
|
||||
};
|
||||
|
||||
//extern SysCalls SysCallsManager;
|
||||
|
||||
#define REG_SUB(module, group, name, ...) \
|
||||
static const u64 name ## _table[] = {__VA_ARGS__ , 0}; \
|
||||
module->AddFuncSub(group, name ## _table, #name, name)
|
||||
|
@ -22,7 +22,6 @@ s32 sys_lwcond_create(mem_ptr_t<sys_lwcond_t> lwcond, mem_ptr_t<sys_lwmutex_t> l
|
||||
u32 id = sys_lwcond.GetNewId(new Lwcond(attr->name_u64));
|
||||
lwcond->lwmutex = lwmutex.GetAddr();
|
||||
lwcond->lwcond_queue = id;
|
||||
procObjects.lwcond_objects.insert(id);
|
||||
|
||||
if (lwmutex.IsGood())
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ s32 sys_lwmutex_create(mem_ptr_t<sys_lwmutex_t> lwmutex, mem_ptr_t<sys_lwmutex_a
|
||||
|
||||
u32 sq_id = sc_lwmutex.GetNewId(new SleepQueue(attr->name_u64));
|
||||
lwmutex->sleep_queue = sq_id;
|
||||
procObjects.lwmutex_objects.insert(sq_id);
|
||||
|
||||
sc_lwmutex.Warning("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d",
|
||||
std::string(attr->name, 8).c_str(), (u32) lwmutex->attribute, sq_id);
|
||||
|
@ -129,7 +129,6 @@ s32 sys_memory_container_create(mem32_t cid, u32 yield_size)
|
||||
// Wrap the allocated memory in a memory container.
|
||||
MemoryContainerInfo *ct = new MemoryContainerInfo(addr, yield_size);
|
||||
cid = sc_mem.GetNewId(ct);
|
||||
procObjects.mem_objects.insert(cid);
|
||||
|
||||
sc_mem.Warning("*** memory_container created(addr=0x%llx): id = %d", addr, cid.GetValue());
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "sys_memory.h"
|
||||
#include "sys_mmapper.h"
|
||||
#include <map>
|
||||
|
||||
|
@ -44,7 +44,6 @@ s32 sys_mutex_create(mem32_t mutex_id, mem_ptr_t<sys_mutex_attribute> attr)
|
||||
u32 tid = GetCurrentPPUThread().GetId();
|
||||
Mutex* mutex = new Mutex((u32)attr->protocol, is_recursive, attr->name_u64);
|
||||
u32 id = sys_mtx.GetNewId(mutex);
|
||||
procObjects.mutex_objects.insert(id);
|
||||
mutex->m_mutex.lock(tid);
|
||||
mutex->id = id;
|
||||
mutex_id = id;
|
||||
|
@ -3,8 +3,8 @@
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
#include "sys_rwlock.h"
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "sys_rwlock.h"
|
||||
|
||||
SysCallBase sys_rwlock("sys_rwlock");
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "sys_semaphore.h"
|
||||
#include "sys_time.h"
|
||||
|
||||
SysCallBase sys_sem("sys_semaphore");
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include "Utilities/Log.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "sys_timer.h"
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "Emu/event.h"
|
||||
#include "sys_timer.h"
|
||||
|
||||
SysCallBase sys_timer("sys_timer");
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "sys_trace.h"
|
||||
|
||||
SysCallBase sys_trace("sys_trace");
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/SysCalls/SysCalls.h"
|
||||
#include "sys_tty.h"
|
||||
|
||||
s32 sys_tty_read(u32 ch, u64 buf_addr, u32 len, u64 preadlen_addr)
|
||||
{
|
||||
|
@ -407,7 +407,6 @@ void Emulator::Stop()
|
||||
GetAudioManager().Close();
|
||||
GetEventManager().Clear();
|
||||
GetCPU().Close();
|
||||
//SysCallsManager.Close();
|
||||
GetIdManager().Clear();
|
||||
GetPadManager().Close();
|
||||
GetKeyboardManager().Close();
|
||||
|
@ -1,102 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "FnIdGenerator.h"
|
||||
|
||||
FnIdGenerator::FnIdGenerator(wxWindow* parent)
|
||||
: wxDialog(parent, wxID_ANY, "FunctionID Generator")
|
||||
, 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));
|
||||
b_input_name->Bind(wxEVT_BUTTON, &FnIdGenerator::OnInput, this);
|
||||
|
||||
wxButton *b_clear = new wxButton(this, wxID_ANY, "Clear List", wxDefaultPosition, wxSize(140, -1));
|
||||
b_clear->Bind(wxEVT_BUTTON, &FnIdGenerator::OnClear, this);
|
||||
|
||||
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);
|
||||
|
||||
SetSizerAndFit(s_panel);
|
||||
}
|
||||
|
||||
FnIdGenerator::~FnIdGenerator()
|
||||
{
|
||||
delete m_list;
|
||||
m_list = nullptr;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
TextInputDialog dial(0, "", "Please input function name");
|
||||
if (dial.ShowModal() == wxID_OK)
|
||||
{
|
||||
const std::string& func_name = dial.GetResult();
|
||||
|
||||
if (func_name.length() == 0)
|
||||
return;
|
||||
|
||||
const be_t<u32> result = GenerateFnId(func_name);
|
||||
m_func_name.push_back(func_name);
|
||||
m_func_id.push_back(result);
|
||||
|
||||
LOG_NOTICE(HLE, "Function: %s, Id: 0x%08x ", func_name.c_str(), result);
|
||||
UpdateInformation();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void FnIdGenerator::UpdateInformation()
|
||||
{
|
||||
m_list->DeleteAllItems();
|
||||
|
||||
for(u32 i = 0; i < m_func_name.size(); i++)
|
||||
{
|
||||
m_list->InsertItem(m_func_name.size(), wxEmptyString);
|
||||
m_list->SetItem(i, 0, m_func_name[i]);
|
||||
m_list->SetItem(i, 1, wxString::Format("0x%08x", re(m_func_id[i])));
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "TextInputDialog.h"
|
||||
#include "../Crypto/aes.h"
|
||||
#include "../Crypto/sha1.h"
|
||||
|
||||
class FnIdGenerator : public wxDialog
|
||||
{
|
||||
private:
|
||||
std::vector<std::string> m_func_name;
|
||||
std::vector<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();
|
||||
};
|
@ -9,7 +9,6 @@
|
||||
#include "MemoryViewer.h"
|
||||
#include "RSXDebugger.h"
|
||||
#include "PADManager.h"
|
||||
#include "FnIdGenerator.h"
|
||||
|
||||
#include "git-version.h"
|
||||
#include "Ini.h"
|
||||
@ -96,9 +95,8 @@ MainFrame::MainFrame()
|
||||
wxMenu* menu_tools = new wxMenu();
|
||||
menubar->Append(menu_tools, "Tools");
|
||||
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");
|
||||
menu_tools->Append(id_tools_memory_viewer, "Memory Viewer")->Enable(false);
|
||||
menu_tools->Append(id_tools_rsx_debugger, "RSX Debugger")->Enable(false);
|
||||
|
||||
wxMenu* menu_help = new wxMenu();
|
||||
menubar->Append(menu_help, "Help");
|
||||
@ -134,7 +132,6 @@ MainFrame::MainFrame()
|
||||
Bind(wxEVT_MENU, &MainFrame::OpenELFCompiler, this, id_tools_compiler);
|
||||
Bind(wxEVT_MENU, &MainFrame::OpenMemoryViewer, this, id_tools_memory_viewer);
|
||||
Bind(wxEVT_MENU, &MainFrame::OpenRSXDebugger, this, id_tools_rsx_debugger);
|
||||
Bind(wxEVT_MENU, &MainFrame::OpenFnIdGenerator, this, id_tools_fnid_generator);
|
||||
|
||||
Bind(wxEVT_MENU, &MainFrame::AboutDialogHandler, this, id_help_about);
|
||||
|
||||
@ -656,11 +653,6 @@ 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))
|
||||
{
|
||||
@ -729,21 +721,31 @@ void MainFrame::UpdateUI(wxCommandEvent& event)
|
||||
is_ready = Emu.IsReady();
|
||||
}
|
||||
|
||||
// Update menu items based on the state of the emulator
|
||||
wxMenuBar& menubar( *GetMenuBar() );
|
||||
|
||||
// Emulation
|
||||
wxMenuItem& pause = *menubar.FindItem( id_sys_pause );
|
||||
wxMenuItem& stop = *menubar.FindItem( id_sys_stop );
|
||||
wxMenuItem& send_exit = *menubar.FindItem( id_sys_send_exit );
|
||||
wxMenuItem& send_open_menu = *menubar.FindItem( id_sys_send_open_menu );
|
||||
pause.SetItemLabel(is_running ? "Pause\tCtrl + P" : is_ready ? "Start\tCtrl + C" : "Resume\tCtrl + C");
|
||||
pause.SetItemLabel(is_running ? "Pause\tCtrl + P" : is_ready ? "Start\tCtrl + E" : "Resume\tCtrl + E");
|
||||
pause.Enable(!is_stopped);
|
||||
stop.Enable(!is_stopped);
|
||||
//send_exit.Enable(false);
|
||||
bool enable_commands = !is_stopped && Emu.GetCallbackManager().m_exit_callback.m_callbacks.size();
|
||||
|
||||
// PS3 Commands
|
||||
wxMenuItem& send_exit = *menubar.FindItem( id_sys_send_exit );
|
||||
wxMenuItem& send_open_menu = *menubar.FindItem( id_sys_send_open_menu );
|
||||
bool enable_commands = !is_stopped && Emu.GetCallbackManager().m_exit_callback.m_callbacks.size();
|
||||
send_open_menu.SetItemLabel(wxString::Format("Send %s system menu cmd", (m_sys_menu_opened ? "close" : "open")));
|
||||
send_open_menu.Enable(enable_commands);
|
||||
send_exit.Enable(enable_commands);
|
||||
|
||||
// Tools
|
||||
wxMenuItem& memory_viewer = *menubar.FindItem( id_tools_memory_viewer );
|
||||
wxMenuItem& rsx_debugger = *menubar.FindItem( id_tools_rsx_debugger);
|
||||
memory_viewer.Enable(!is_stopped);
|
||||
rsx_debugger.Enable(!is_stopped);
|
||||
|
||||
|
||||
//m_aui_mgr.Update();
|
||||
|
||||
//wxCommandEvent refit( wxEVT_COMMAND_MENU_SELECTED, id_update_dbg );
|
||||
|
@ -1,362 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define LOAD_SYMBOL(x) if(m_dll.HasSymbol(#x)) x = (_##x)m_dll.GetSymbol(#x)
|
||||
struct Ps3EmuPlugin
|
||||
{
|
||||
enum PS3EMULIB_TYPE
|
||||
{
|
||||
LIB_PAD = (1 << 0),
|
||||
LIB_KB = (1 << 1),
|
||||
LIB_MOUSE = (1 << 2),
|
||||
LIB_FS = (1 << 3),
|
||||
};
|
||||
|
||||
typedef u32 (*_Ps3EmuLibGetType)();
|
||||
typedef u32 (*_Ps3EmuLibGetVersion)();
|
||||
typedef const char* (*_Ps3EmuLibGetName)();
|
||||
typedef const char* (*_Ps3EmuLibGetFullName)();
|
||||
typedef void (*_Ps3EmuLibSetSettingsPath)(const char* path);
|
||||
typedef void (*_Ps3EmuLibSetLogPath)(const char* path);
|
||||
typedef const char* (*_Ps3EmuLibGetSettingsName)();
|
||||
typedef const char* (*_Ps3EmuLibGetLogName)();
|
||||
typedef void (*_Ps3EmuLibConfigure)(PS3EMULIB_TYPE type);
|
||||
typedef void (*_Ps3EmuLibAbout)();
|
||||
typedef u32 (*_Ps3EmuLibTest)(PS3EMULIB_TYPE type);
|
||||
|
||||
_Ps3EmuLibGetType Ps3EmuLibGetType;
|
||||
_Ps3EmuLibGetVersion Ps3EmuLibGetVersion;
|
||||
_Ps3EmuLibGetName Ps3EmuLibGetName;
|
||||
_Ps3EmuLibGetFullName Ps3EmuLibGetFullName;
|
||||
_Ps3EmuLibSetSettingsPath Ps3EmuLibSetSettingsPath;
|
||||
_Ps3EmuLibSetLogPath Ps3EmuLibSetLogPath;
|
||||
_Ps3EmuLibGetSettingsName Ps3EmuLibGetSettingsName;
|
||||
_Ps3EmuLibGetLogName Ps3EmuLibGetLogName;
|
||||
_Ps3EmuLibConfigure Ps3EmuLibConfigure;
|
||||
_Ps3EmuLibAbout Ps3EmuLibAbout;
|
||||
_Ps3EmuLibTest Ps3EmuLibTest;
|
||||
|
||||
wxDynamicLibrary m_dll;
|
||||
|
||||
Ps3EmuPlugin()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
Ps3EmuPlugin(const wxString& path)
|
||||
{
|
||||
Load(path);
|
||||
}
|
||||
|
||||
virtual ~Ps3EmuPlugin() throw()
|
||||
{
|
||||
Unload();
|
||||
}
|
||||
|
||||
wxString FormatVersion()
|
||||
{
|
||||
if(!Ps3EmuLibGetVersion) return wxEmptyString;
|
||||
|
||||
const u32 v = Ps3EmuLibGetVersion();
|
||||
|
||||
const u8 v0 = v >> 24;
|
||||
const u8 v1 = v >> 16;
|
||||
const u8 v2 = v >> 8;
|
||||
const u8 v3 = v;
|
||||
|
||||
if(!v2 && !v3) return wxString::Format("%d.%d", v0, v1);
|
||||
if(!v3) return wxString::Format("%d.%d.%d", v0, v1, v2);
|
||||
|
||||
return wxString::Format("%d.%d.%d.%d", v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Load(const wxString& path)
|
||||
{
|
||||
if(m_dll.Load(path))
|
||||
{
|
||||
Init();
|
||||
}
|
||||
else
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Unload()
|
||||
{
|
||||
Reset();
|
||||
|
||||
if(m_dll.IsLoaded()) m_dll.Unload();
|
||||
}
|
||||
|
||||
virtual bool Test()
|
||||
{
|
||||
return
|
||||
m_dll.IsLoaded() &&
|
||||
Ps3EmuLibGetType &&
|
||||
Ps3EmuLibGetVersion &&
|
||||
Ps3EmuLibGetName &&
|
||||
Ps3EmuLibGetFullName &&
|
||||
Ps3EmuLibSetSettingsPath &&
|
||||
Ps3EmuLibSetLogPath &&
|
||||
Ps3EmuLibGetSettingsName &&
|
||||
Ps3EmuLibGetLogName &&
|
||||
Ps3EmuLibConfigure &&
|
||||
Ps3EmuLibAbout &&
|
||||
Ps3EmuLibTest;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
LOAD_SYMBOL(Ps3EmuLibGetType);
|
||||
LOAD_SYMBOL(Ps3EmuLibGetVersion);
|
||||
LOAD_SYMBOL(Ps3EmuLibGetName);
|
||||
LOAD_SYMBOL(Ps3EmuLibGetFullName);
|
||||
LOAD_SYMBOL(Ps3EmuLibSetSettingsPath);
|
||||
LOAD_SYMBOL(Ps3EmuLibSetLogPath);
|
||||
LOAD_SYMBOL(Ps3EmuLibGetSettingsName);
|
||||
LOAD_SYMBOL(Ps3EmuLibGetLogName);
|
||||
LOAD_SYMBOL(Ps3EmuLibConfigure);
|
||||
LOAD_SYMBOL(Ps3EmuLibAbout);
|
||||
LOAD_SYMBOL(Ps3EmuLibTest);
|
||||
}
|
||||
|
||||
virtual void Reset()
|
||||
{
|
||||
Ps3EmuLibGetType = nullptr;
|
||||
Ps3EmuLibGetVersion = nullptr;
|
||||
Ps3EmuLibGetName = nullptr;
|
||||
Ps3EmuLibGetFullName = nullptr;
|
||||
Ps3EmuLibSetSettingsPath = nullptr;
|
||||
Ps3EmuLibSetLogPath = nullptr;
|
||||
Ps3EmuLibGetSettingsName = nullptr;
|
||||
Ps3EmuLibGetLogName = nullptr;
|
||||
Ps3EmuLibConfigure = nullptr;
|
||||
Ps3EmuLibAbout = nullptr;
|
||||
Ps3EmuLibTest = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
struct Ps3EmuPluginPAD : public Ps3EmuPlugin
|
||||
{
|
||||
typedef int (*_PadInit)(u32 max_connect);
|
||||
typedef int (*_PadEnd)();
|
||||
typedef int (*_PadClearBuf)(u32 port_no);
|
||||
typedef int (*_PadGetData)(u32 port_no, void* data);
|
||||
typedef int (*_PadGetDataExtra)(u32 port_no, u32* device_type, void* data);
|
||||
typedef int (*_PadSetActDirect)(u32 port_no, void* param);
|
||||
typedef int (*_PadGetInfo)(void* info);
|
||||
typedef int (*_PadGetInfo2)(void* info);
|
||||
typedef int (*_PadSetPortSetting)(u32 port_no, u32 port_setting);
|
||||
typedef int (*_PadLddRegisterController)();
|
||||
typedef int (*_PadLddUnregisterController)(int handle);
|
||||
typedef int (*_PadLddDataInsert)(int handle, void* data);
|
||||
typedef int (*_PadLddGetPortNo)(int handle);
|
||||
typedef int (*_PadPeriphGetInfo)(void* info);
|
||||
typedef int (*_PadPeriphGetData)(u32 port_no, void* data);
|
||||
typedef int (*_PadInfoPressMode)(u32 port_no);
|
||||
typedef int (*_PadSetPressMode)(u32 port_no, u8 mode);
|
||||
typedef int (*_PadInfoSensorMode)(u32 port_no);
|
||||
typedef int (*_PadSetSensorMode)(u32 port_no, u8 mode);
|
||||
typedef int (*_PadGetRawData)(u32 port_no, void* data);
|
||||
typedef int (*_PadDbgLddRegisterController)(u32 device_capability);
|
||||
typedef int (*_PadDbgLddSetDataInsertMode)(int handle, u8 mode);
|
||||
typedef int (*_PadDbgPeriphRegisterDevice)(u16 vid, u16 pid, u32 pclass_type, u32 pclass_profile, void* mapping);
|
||||
typedef int (*_PadDbgGetData)(u32 port_no, void* data);
|
||||
|
||||
_PadInit PadInit;
|
||||
_PadEnd PadEnd;
|
||||
_PadClearBuf PadClearBuf;
|
||||
_PadGetData PadGetData;
|
||||
_PadGetDataExtra PadGetDataExtra;
|
||||
_PadSetActDirect PadSetActDirect;
|
||||
_PadGetInfo PadGetInfo;
|
||||
_PadGetInfo2 PadGetInfo2;
|
||||
_PadSetPortSetting PadSetPortSetting;
|
||||
_PadLddRegisterController PadLddRegisterController;
|
||||
_PadLddUnregisterController PadLddUnregisterController;
|
||||
_PadLddDataInsert PadLddDataInsert;
|
||||
_PadLddGetPortNo PadLddGetPortNo;
|
||||
_PadPeriphGetInfo PadPeriphGetInfo;
|
||||
_PadPeriphGetData PadPeriphGetData;
|
||||
_PadInfoPressMode PadInfoPressMode;
|
||||
_PadSetPressMode PadSetPressMode;
|
||||
_PadInfoSensorMode PadInfoSensorMode;
|
||||
_PadSetSensorMode PadSetSensorMode;
|
||||
_PadGetRawData PadGetRawData;
|
||||
_PadDbgLddRegisterController PadDbgLddRegisterController;
|
||||
_PadDbgLddSetDataInsertMode PadDbgLddSetDataInsertMode;
|
||||
_PadDbgPeriphRegisterDevice PadDbgPeriphRegisterDevice;
|
||||
_PadDbgGetData PadDbgGetData;
|
||||
|
||||
Ps3EmuPluginPAD()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
Ps3EmuPluginPAD(const wxString& path)
|
||||
{
|
||||
Load(path);
|
||||
}
|
||||
|
||||
virtual bool Test()
|
||||
{
|
||||
return Ps3EmuPlugin::Test() &&
|
||||
PadInit &&
|
||||
PadEnd &&
|
||||
PadClearBuf &&
|
||||
PadGetData &&
|
||||
PadGetDataExtra &&
|
||||
PadSetActDirect &&
|
||||
PadGetInfo &&
|
||||
PadGetInfo2 &&
|
||||
PadSetPortSetting &&
|
||||
PadLddRegisterController &&
|
||||
PadLddUnregisterController &&
|
||||
PadLddDataInsert &&
|
||||
PadLddGetPortNo &&
|
||||
PadPeriphGetInfo &&
|
||||
PadPeriphGetData &&
|
||||
PadInfoPressMode &&
|
||||
PadSetPressMode &&
|
||||
PadInfoSensorMode &&
|
||||
PadSetSensorMode &&
|
||||
PadGetRawData &&
|
||||
PadDbgLddRegisterController &&
|
||||
PadDbgLddSetDataInsertMode &&
|
||||
PadDbgPeriphRegisterDevice &&
|
||||
PadDbgGetData;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
LOAD_SYMBOL(PadInit);
|
||||
LOAD_SYMBOL(PadEnd);
|
||||
LOAD_SYMBOL(PadClearBuf);
|
||||
LOAD_SYMBOL(PadGetData);
|
||||
LOAD_SYMBOL(PadGetDataExtra);
|
||||
LOAD_SYMBOL(PadSetActDirect);
|
||||
LOAD_SYMBOL(PadGetInfo);
|
||||
LOAD_SYMBOL(PadGetInfo2);
|
||||
LOAD_SYMBOL(PadSetPortSetting);
|
||||
LOAD_SYMBOL(PadLddRegisterController);
|
||||
LOAD_SYMBOL(PadLddUnregisterController);
|
||||
LOAD_SYMBOL(PadLddDataInsert);
|
||||
LOAD_SYMBOL(PadLddGetPortNo);
|
||||
LOAD_SYMBOL(PadPeriphGetInfo);
|
||||
LOAD_SYMBOL(PadPeriphGetData);
|
||||
LOAD_SYMBOL(PadInfoPressMode);
|
||||
LOAD_SYMBOL(PadSetPressMode);
|
||||
LOAD_SYMBOL(PadInfoSensorMode);
|
||||
LOAD_SYMBOL(PadSetSensorMode);
|
||||
LOAD_SYMBOL(PadGetRawData);
|
||||
LOAD_SYMBOL(PadDbgLddRegisterController);
|
||||
LOAD_SYMBOL(PadDbgLddSetDataInsertMode);
|
||||
LOAD_SYMBOL(PadDbgPeriphRegisterDevice);
|
||||
LOAD_SYMBOL(PadDbgGetData);
|
||||
|
||||
Ps3EmuPlugin::Init();
|
||||
}
|
||||
|
||||
virtual void Reset()
|
||||
{
|
||||
PadInit = nullptr;
|
||||
PadEnd = nullptr;
|
||||
PadClearBuf = nullptr;
|
||||
PadGetData = nullptr;
|
||||
PadGetDataExtra = nullptr;
|
||||
PadSetActDirect = nullptr;
|
||||
PadGetInfo = nullptr;
|
||||
PadGetInfo2 = nullptr;
|
||||
PadSetPortSetting = nullptr;
|
||||
PadLddRegisterController = nullptr;
|
||||
PadLddUnregisterController = nullptr;
|
||||
PadLddDataInsert = nullptr;
|
||||
PadLddGetPortNo = nullptr;
|
||||
PadPeriphGetInfo = nullptr;
|
||||
PadPeriphGetData = nullptr;
|
||||
PadInfoPressMode = nullptr;
|
||||
PadSetPressMode = nullptr;
|
||||
PadInfoSensorMode = nullptr;
|
||||
PadSetSensorMode = nullptr;
|
||||
PadGetRawData = nullptr;
|
||||
PadDbgLddRegisterController = nullptr;
|
||||
PadDbgLddSetDataInsertMode = nullptr;
|
||||
PadDbgPeriphRegisterDevice = nullptr;
|
||||
PadDbgGetData = nullptr;
|
||||
|
||||
Ps3EmuPlugin::Reset();
|
||||
}
|
||||
};
|
||||
|
||||
struct PluginsManager
|
||||
{
|
||||
struct PluginInfo
|
||||
{
|
||||
wxString path;
|
||||
wxString name;
|
||||
u32 type;
|
||||
};
|
||||
|
||||
std::vector<PluginInfo> m_plugins;
|
||||
std::vector<PluginInfo*> m_pad_plugins;
|
||||
|
||||
void Load(const wxString& path)
|
||||
{
|
||||
if(!wxDirExists(path)) return;
|
||||
|
||||
m_plugins.clear();
|
||||
wxDir dir(path);
|
||||
|
||||
wxArrayString res;
|
||||
wxDir::GetAllFiles(path, &res, "*.dll", wxDIR_FILES);
|
||||
|
||||
for(u32 i=0; i<res.GetCount(); ++i)
|
||||
{
|
||||
LOG_NOTICE(HLE, "loading " + res[i] + "...");
|
||||
Ps3EmuPlugin l(res[i]);
|
||||
if(!l.Test()) continue;
|
||||
|
||||
m_plugins.emplace_back();
|
||||
PluginInfo& info = m_plugins.back();
|
||||
info.path = res[i];
|
||||
info.name.Printf("%s v%s", l.Ps3EmuLibGetFullName(), l.FormatVersion());
|
||||
info.type = l.Ps3EmuLibGetType();
|
||||
}
|
||||
}
|
||||
|
||||
wxSizer* GetNewComboBox(wxWindow* parent, const wxString& name, wxComboBox*& cb)
|
||||
{
|
||||
wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL));
|
||||
|
||||
s_panel->Add(new wxStaticText(parent, wxID_ANY, name), wxSizerFlags().Border(wxRIGHT, 5).Center().Left());
|
||||
s_panel->Add(cb = new wxComboBox(parent, wxID_ANY), wxSizerFlags().Center().Right());
|
||||
|
||||
return s_panel;
|
||||
}
|
||||
|
||||
void Dialog()
|
||||
{
|
||||
wxDialog dial(nullptr, wxID_ANY, "Select plugins...", wxDefaultPosition);
|
||||
|
||||
wxBoxSizer& s_panel(*new wxBoxSizer(wxVERTICAL));
|
||||
|
||||
wxComboBox* cbox_pad_plugins;
|
||||
s_panel.Add(GetNewComboBox(&dial, "Pad", cbox_pad_plugins), wxSizerFlags().Border(wxALL, 5).Expand());
|
||||
|
||||
for(u32 i=0; i<m_plugins.size(); ++i)
|
||||
{
|
||||
if(m_plugins[i].type & Ps3EmuPlugin::LIB_PAD)
|
||||
{
|
||||
m_pad_plugins.push_back(&m_plugins[i]);
|
||||
cbox_pad_plugins->Append(m_plugins[i].name + " (" + wxFileName(m_plugins[i].path).GetName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if(cbox_pad_plugins->GetCount()) cbox_pad_plugins->Select(0);
|
||||
|
||||
dial.SetSizerAndFit(&s_panel);
|
||||
dial.ShowModal();
|
||||
}
|
||||
};
|
@ -210,31 +210,27 @@ bool ELF64Loader::LoadEhdrData(u64 offset)
|
||||
|
||||
bool ELF64Loader::LoadPhdrData(u64 offset)
|
||||
{
|
||||
for(u32 i=0; i<phdr_arr.size(); ++i)
|
||||
for(auto& phdr: phdr_arr)
|
||||
{
|
||||
phdr_arr[i].Show();
|
||||
phdr.Show();
|
||||
|
||||
if(phdr_arr[i].p_vaddr < min_addr)
|
||||
if (phdr.p_vaddr < min_addr)
|
||||
{
|
||||
min_addr = phdr_arr[i].p_vaddr;
|
||||
min_addr = phdr.p_vaddr;
|
||||
}
|
||||
|
||||
if(phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz > max_addr)
|
||||
if (phdr.p_vaddr + phdr.p_memsz > max_addr)
|
||||
{
|
||||
max_addr = phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz;
|
||||
max_addr = phdr.p_vaddr + phdr.p_memsz;
|
||||
}
|
||||
|
||||
if(phdr_arr[i].p_vaddr != phdr_arr[i].p_paddr)
|
||||
if (phdr.p_vaddr != phdr.p_paddr)
|
||||
{
|
||||
LOG_WARNING
|
||||
(
|
||||
LOADER,
|
||||
"ElfProgram different load addrs: paddr=0x%8.8x, vaddr=0x%8.8x",
|
||||
phdr_arr[i].p_paddr, phdr_arr[i].p_vaddr
|
||||
);
|
||||
LOG_WARNING(LOADER, "ElfProgram different load addrs: paddr=0x%8.8x, vaddr=0x%8.8x",
|
||||
phdr.p_paddr, phdr.p_vaddr);
|
||||
}
|
||||
|
||||
if(!Memory.MainMem.IsInMyRange(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_memsz))
|
||||
if(!Memory.MainMem.IsInMyRange(offset + phdr.p_vaddr, phdr.p_memsz))
|
||||
{
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_WARNING(LOADER, "Skipping...");
|
||||
@ -243,57 +239,48 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(phdr_arr[i].p_type)
|
||||
switch(phdr.p_type)
|
||||
{
|
||||
case 0x00000001: //LOAD
|
||||
if(phdr_arr[i].p_memsz)
|
||||
if(phdr.p_memsz)
|
||||
{
|
||||
Memory.MainMem.AllocFixed(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_memsz);
|
||||
Memory.MainMem.AllocFixed(offset + phdr.p_vaddr, phdr.p_memsz);
|
||||
|
||||
if(phdr_arr[i].p_filesz)
|
||||
if(phdr.p_filesz)
|
||||
{
|
||||
elf64_f.Seek(phdr_arr[i].p_offset);
|
||||
elf64_f.Read(&Memory[offset + phdr_arr[i].p_vaddr], phdr_arr[i].p_filesz);
|
||||
Emu.GetSFuncManager().StaticAnalyse(&Memory[offset + phdr_arr[i].p_vaddr], phdr_arr[i].p_filesz, phdr_arr[i].p_vaddr);
|
||||
elf64_f.Seek(phdr.p_offset);
|
||||
elf64_f.Read(&Memory[offset + phdr.p_vaddr], phdr.p_filesz);
|
||||
Emu.GetSFuncManager().StaticAnalyse(&Memory[offset + phdr.p_vaddr], phdr.p_filesz, phdr.p_vaddr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x00000007: //TLS
|
||||
Emu.SetTLSData(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_filesz, phdr_arr[i].p_memsz);
|
||||
Emu.SetTLSData(offset + phdr.p_vaddr, phdr.p_filesz, phdr.p_memsz);
|
||||
break;
|
||||
|
||||
case 0x60000001: //LOOS+1
|
||||
{
|
||||
if(!phdr_arr[i].p_filesz) break;
|
||||
if(!phdr.p_filesz)
|
||||
break;
|
||||
|
||||
const sys_process_param& proc_param = *(sys_process_param*)&Memory[offset + phdr_arr[i].p_vaddr];
|
||||
const sys_process_param& proc_param = *(sys_process_param*)&Memory[offset + phdr.p_vaddr];
|
||||
|
||||
if(re(proc_param.size) < sizeof(sys_process_param))
|
||||
{
|
||||
LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", re(proc_param.size), sizeof(sys_process_param));
|
||||
if (proc_param.size < sizeof(sys_process_param)) {
|
||||
LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param));
|
||||
}
|
||||
|
||||
if(re(proc_param.magic) != 0x13bcc5f6)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Bad magic! [0x%x]", Memory.Reverse32(proc_param.magic));
|
||||
if (proc_param.magic != 0x13bcc5f6) {
|
||||
LOG_ERROR(LOADER, "Bad magic! [0x%x]", proc_param.magic);
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_process_param_info& info = Emu.GetInfo().GetProcParam();
|
||||
info.sdk_version = re(proc_param.info.sdk_version);
|
||||
info.primary_prio = re(proc_param.info.primary_prio);
|
||||
info.primary_stacksize = re(proc_param.info.primary_stacksize);
|
||||
info.malloc_pagesize = re(proc_param.info.malloc_pagesize);
|
||||
info.ppc_seg = re(proc_param.info.ppc_seg);
|
||||
//info.crash_dump_param_addr = re(proc_param.info.crash_dump_param_addr);
|
||||
else {
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, "*** sdk version: 0x%x", info.sdk_version);
|
||||
LOG_NOTICE(LOADER, "*** primary prio: %d", info.primary_prio);
|
||||
LOG_NOTICE(LOADER, "*** primary stacksize: 0x%x", info.primary_stacksize);
|
||||
LOG_NOTICE(LOADER, "*** malloc pagesize: 0x%x", info.malloc_pagesize);
|
||||
LOG_NOTICE(LOADER, "*** ppc seg: 0x%x", info.ppc_seg);
|
||||
//LOG_NOTICE(LOADER, "*** crash dump param addr: 0x%x", info.crash_dump_param_addr);
|
||||
sys_process_param_info& info = Emu.GetInfo().GetProcParam();
|
||||
LOG_NOTICE(LOADER, "*** sdk version: 0x%x", info.sdk_version.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** primary prio: %d", info.primary_prio.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** primary stacksize: 0x%x", info.primary_stacksize.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** malloc pagesize: 0x%x", info.malloc_pagesize.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** ppc seg: 0x%x", info.ppc_seg.ToLE());
|
||||
//LOG_NOTICE(LOADER, "*** crash dump param addr: 0x%x", info.crash_dump_param_addr.ToLE());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -301,113 +288,89 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
||||
|
||||
case 0x60000002: //LOOS+2
|
||||
{
|
||||
if(!phdr_arr[i].p_filesz) break;
|
||||
if(!phdr.p_filesz)
|
||||
break;
|
||||
|
||||
sys_proc_prx_param proc_prx_param = *(sys_proc_prx_param*)&Memory[offset + phdr_arr[i].p_vaddr];
|
||||
sys_proc_prx_param proc_prx_param = *(sys_proc_prx_param*)&Memory[offset + phdr.p_vaddr];
|
||||
|
||||
proc_prx_param.size = re(proc_prx_param.size);
|
||||
proc_prx_param.magic = re(proc_prx_param.magic);
|
||||
proc_prx_param.version = re(proc_prx_param.version);
|
||||
proc_prx_param.libentstart = re(proc_prx_param.libentstart);
|
||||
proc_prx_param.libentend = re(proc_prx_param.libentend);
|
||||
proc_prx_param.libstubstart = re(proc_prx_param.libstubstart);
|
||||
proc_prx_param.libstubend = re(proc_prx_param.libstubend);
|
||||
proc_prx_param.ver = re(proc_prx_param.ver);
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, "*** size: 0x%x", proc_prx_param.size);
|
||||
LOG_NOTICE(LOADER, "*** magic: 0x%x", proc_prx_param.magic);
|
||||
LOG_NOTICE(LOADER, "*** version: 0x%x", proc_prx_param.version);
|
||||
LOG_NOTICE(LOADER, "*** libentstart: 0x%x", proc_prx_param.libentstart);
|
||||
LOG_NOTICE(LOADER, "*** libentend: 0x%x", proc_prx_param.libentend);
|
||||
LOG_NOTICE(LOADER, "*** libstubstart: 0x%x", proc_prx_param.libstubstart);
|
||||
LOG_NOTICE(LOADER, "*** libstubend: 0x%x", proc_prx_param.libstubend);
|
||||
LOG_NOTICE(LOADER, "*** ver: 0x%x", proc_prx_param.ver);
|
||||
LOG_NOTICE(LOADER, "*** size: 0x%x", proc_prx_param.size.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** magic: 0x%x", proc_prx_param.magic.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** version: 0x%x", proc_prx_param.version.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** libentstart: 0x%x", proc_prx_param.libentstart.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** libentend: 0x%x", proc_prx_param.libentend.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** libstubstart: 0x%x", proc_prx_param.libstubstart.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** libstubend: 0x%x", proc_prx_param.libstubend.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** ver: 0x%x", proc_prx_param.ver.ToLE());
|
||||
#endif
|
||||
|
||||
if(proc_prx_param.magic != 0x1b434cec)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Bad magic! (0x%x)", proc_prx_param.magic);
|
||||
if (proc_prx_param.magic != 0x1b434cec) {
|
||||
LOG_ERROR(LOADER, "Bad magic! (0x%x)", proc_prx_param.magic.ToLE());
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
for(u32 s=proc_prx_param.libstubstart; s<proc_prx_param.libstubend; s+=sizeof(Elf64_StubHeader))
|
||||
{
|
||||
for(u32 s=proc_prx_param.libstubstart; s<proc_prx_param.libstubend; s+=sizeof(Elf64_StubHeader))
|
||||
{
|
||||
Elf64_StubHeader stub = *(Elf64_StubHeader*)Memory.GetMemFromAddr(offset + s);
|
||||
Elf64_StubHeader stub = *(Elf64_StubHeader*)Memory.GetMemFromAddr(offset + s);
|
||||
|
||||
stub.s_size = re(stub.s_size);
|
||||
stub.s_version = re(stub.s_version);
|
||||
stub.s_unk0 = re(stub.s_unk0);
|
||||
stub.s_unk1 = re(stub.s_unk1);
|
||||
stub.s_imports = re(stub.s_imports);
|
||||
stub.s_modulename = re(stub.s_modulename);
|
||||
stub.s_nid = re(stub.s_nid);
|
||||
stub.s_text = re(stub.s_text);
|
||||
|
||||
const std::string& module_name = Memory.ReadString(stub.s_modulename);
|
||||
Module* module = Emu.GetModuleManager().GetModuleByName(module_name);
|
||||
if(module)
|
||||
{
|
||||
//module->SetLoaded();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING(LOADER, "Unknown module '%s'", module_name.c_str());
|
||||
}
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, "");
|
||||
LOG_NOTICE(LOADER, "*** size: 0x%x", stub.s_size);
|
||||
LOG_NOTICE(LOADER, "*** version: 0x%x", stub.s_version);
|
||||
LOG_NOTICE(LOADER, "*** unk0: 0x%x", stub.s_unk0);
|
||||
LOG_NOTICE(LOADER, "*** unk1: 0x%x", stub.s_unk1);
|
||||
LOG_NOTICE(LOADER, "*** imports: %d", stub.s_imports);
|
||||
LOG_NOTICE(LOADER, "*** module name: %s [0x%x]", module_name.c_str(), stub.s_modulename);
|
||||
LOG_NOTICE(LOADER, "*** nid: 0x%x", stub.s_nid);
|
||||
LOG_NOTICE(LOADER, "*** text: 0x%x", stub.s_text);
|
||||
#endif
|
||||
static const u32 section = 4 * 3;
|
||||
u64 tbl = Memory.MainMem.AllocAlign(stub.s_imports * 4 * 2);
|
||||
u64 dst = Memory.MainMem.AllocAlign(stub.s_imports * section);
|
||||
|
||||
for(u32 i=0; i<stub.s_imports; ++i)
|
||||
{
|
||||
const u32 nid = Memory.Read32(stub.s_nid + i*4);
|
||||
const u32 text = Memory.Read32(stub.s_text + i*4);
|
||||
|
||||
if(module)
|
||||
{
|
||||
if(!module->Load(nid))
|
||||
{
|
||||
LOG_WARNING(LOADER, "Unimplemented function '%s' in '%s' module", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str());
|
||||
}
|
||||
}
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, "import %d:", i+1);
|
||||
LOG_NOTICE(LOADER, "*** nid: 0x%x (0x%x)", nid, stub.s_nid + i*4);
|
||||
LOG_NOTICE(LOADER, "*** text: 0x%x (0x%x)", text, stub.s_text + i*4);
|
||||
#endif
|
||||
Memory.Write32(stub.s_text + i*4, tbl + i*8);
|
||||
|
||||
mem32_ptr_t out_tbl(tbl + i*8);
|
||||
out_tbl += dst + i*section;
|
||||
out_tbl += Emu.GetModuleManager().GetFuncNumById(nid);
|
||||
|
||||
mem32_ptr_t out_dst(dst + i*section);
|
||||
out_dst += OR(11, 2, 2, 0);
|
||||
out_dst += SC(2);
|
||||
out_dst += BCLR(0x10 | 0x04, 0, 0, 0);
|
||||
}
|
||||
const std::string& module_name = Memory.ReadString(stub.s_modulename);
|
||||
Module* module = Emu.GetModuleManager().GetModuleByName(module_name);
|
||||
if (module) {
|
||||
//module->SetLoaded();
|
||||
}
|
||||
else {
|
||||
LOG_WARNING(LOADER, "Unknown module '%s'", module_name.c_str());
|
||||
}
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, " ");
|
||||
LOG_NOTICE(LOADER, "");
|
||||
LOG_NOTICE(LOADER, "*** size: 0x%x", stub.s_size);
|
||||
LOG_NOTICE(LOADER, "*** version: 0x%x", stub.s_version.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** unk0: 0x%x", stub.s_unk0);
|
||||
LOG_NOTICE(LOADER, "*** unk1: 0x%x", stub.s_unk1.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** imports: %d", stub.s_imports.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** module name: %s [0x%x]", module_name.c_str(), stub.s_modulename.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** nid: 0x%016llx [0x%x]", Memory.Read64(stub.s_nid), stub.s_nid.ToLE());
|
||||
LOG_NOTICE(LOADER, "*** text: 0x%x", stub.s_text.ToLE());
|
||||
#endif
|
||||
static const u32 section = 4 * 3;
|
||||
u64 tbl = Memory.MainMem.AllocAlign(stub.s_imports * 4 * 2);
|
||||
u64 dst = Memory.MainMem.AllocAlign(stub.s_imports * section);
|
||||
|
||||
for(u32 i=0; i<stub.s_imports; ++i)
|
||||
{
|
||||
const u32 nid = Memory.Read32(stub.s_nid + i*4);
|
||||
const u32 text = Memory.Read32(stub.s_text + i*4);
|
||||
|
||||
if (module && !module->Load(nid)) {
|
||||
LOG_WARNING(LOADER, "Unimplemented function '%s' in '%s' module", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str());
|
||||
}
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, "import %d:", i+1);
|
||||
LOG_NOTICE(LOADER, "*** nid: 0x%x (0x%x)", nid, stub.s_nid + i*4);
|
||||
LOG_NOTICE(LOADER, "*** text: 0x%x (0x%x)", text, stub.s_text + i*4);
|
||||
#endif
|
||||
Memory.Write32(stub.s_text + i*4, tbl + i*8);
|
||||
|
||||
mem32_ptr_t out_tbl(tbl + i*8);
|
||||
out_tbl += dst + i*section;
|
||||
out_tbl += Emu.GetModuleManager().GetFuncNumById(nid);
|
||||
|
||||
mem32_ptr_t out_dst(dst + i*section);
|
||||
out_dst += OR(11, 2, 2, 0);
|
||||
out_dst += SC(2);
|
||||
out_dst += BCLR(0x10 | 0x04, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, "");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifdef LOADER_DEBUG
|
||||
LOG_NOTICE(LOADER, " ");
|
||||
LOG_NOTICE(LOADER, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -461,7 +424,7 @@ bool ELF64Loader::LoadShdrData(u64 offset)
|
||||
switch(shdr.sh_type)
|
||||
{
|
||||
case SHT_NOBITS:
|
||||
//ConLog.Warning("SHT_NOBITS: addr=0x%llx, size=0x%llx", offset + addr, size);
|
||||
//LOG_WARNING(LOADER, "SHT_NOBITS: addr=0x%llx, size=0x%llx", offset + addr, size);
|
||||
//memset(&Memory[offset + addr], 0, size);
|
||||
break;
|
||||
|
||||
|
@ -125,53 +125,53 @@ const std::string Phdr_TypeToString(const u32 type);
|
||||
|
||||
struct sys_process_param_info
|
||||
{
|
||||
u32 sdk_version;
|
||||
s32 primary_prio;
|
||||
u32 primary_stacksize;
|
||||
u32 malloc_pagesize;
|
||||
u32 ppc_seg;
|
||||
//u32 crash_dump_param_addr;
|
||||
be_t<u32> sdk_version;
|
||||
be_t<s32> primary_prio;
|
||||
be_t<u32> primary_stacksize;
|
||||
be_t<u32> malloc_pagesize;
|
||||
be_t<u32> ppc_seg;
|
||||
//be_t<u32> crash_dump_param_addr;
|
||||
};
|
||||
|
||||
struct sys_process_param
|
||||
{
|
||||
u32 size;
|
||||
u32 magic;
|
||||
u32 version;
|
||||
be_t<u32> size;
|
||||
be_t<u32> magic;
|
||||
be_t<u32> version;
|
||||
sys_process_param_info info;
|
||||
};
|
||||
|
||||
struct sys_proc_prx_param
|
||||
{
|
||||
u32 size;
|
||||
u32 magic;
|
||||
u32 version;
|
||||
u32 pad0;
|
||||
u32 libentstart;
|
||||
u32 libentend;
|
||||
u32 libstubstart;
|
||||
u32 libstubend;
|
||||
u16 ver;
|
||||
u16 pad1;
|
||||
u32 pad2;
|
||||
be_t<u32> size;
|
||||
be_t<u32> magic;
|
||||
be_t<u32> version;
|
||||
be_t<u32> pad0;
|
||||
be_t<u32> libentstart;
|
||||
be_t<u32> libentend;
|
||||
be_t<u32> libstubstart;
|
||||
be_t<u32> libstubend;
|
||||
be_t<u16> ver;
|
||||
be_t<u16> pad1;
|
||||
be_t<u32> pad2;
|
||||
};
|
||||
|
||||
struct Elf64_StubHeader
|
||||
{
|
||||
u8 s_size; // = 0x2c
|
||||
u8 s_unk0;
|
||||
u16 s_version; // = 0x1
|
||||
u16 s_unk1; // = 0x9 // flags?
|
||||
u16 s_imports;
|
||||
u32 s_unk2; // = 0x0
|
||||
u32 s_unk3; // = 0x0
|
||||
u32 s_modulename;
|
||||
u32 s_nid;
|
||||
u32 s_text;
|
||||
u32 s_unk4; // = 0x0
|
||||
u32 s_unk5; // = 0x0
|
||||
u32 s_unk6; // = 0x0
|
||||
u32 s_unk7; // = 0x0
|
||||
be_t<u16> s_version; // = 0x1
|
||||
be_t<u16> s_unk1; // = 0x9 // flags?
|
||||
be_t<u16> s_imports;
|
||||
be_t<u32> s_unk2; // = 0x0
|
||||
be_t<u32> s_unk3; // = 0x0
|
||||
be_t<u32> s_modulename;
|
||||
be_t<u32> s_nid;
|
||||
be_t<u32> s_text;
|
||||
be_t<u32> s_unk4; // = 0x0
|
||||
be_t<u32> s_unk5; // = 0x0
|
||||
be_t<u32> s_unk6; // = 0x0
|
||||
be_t<u32> s_unk7; // = 0x0
|
||||
};
|
||||
|
||||
class LoaderBase
|
||||
|
@ -92,9 +92,9 @@
|
||||
<ClCompile Include="Emu\Memory\Memory.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\Callback.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\FuncList.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\lv2Fs.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_cond.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_event.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\lv2Fs.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_interrupt.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_lwcond.cpp" />
|
||||
<ClCompile Include="Emu\SysCalls\lv2\sys_lwmutex.cpp" />
|
||||
@ -316,9 +316,9 @@
|
||||
<ClInclude Include="Emu\Memory\MemoryBlock.h" />
|
||||
<ClInclude Include="Emu\SysCalls\Callback.h" />
|
||||
<ClInclude Include="Emu\SysCalls\ErrorCodes.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\lv2Fs.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_cond.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_event.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\lv2Fs.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_interrupt.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_lwcond.h" />
|
||||
<ClInclude Include="Emu\SysCalls\lv2\sys_lwmutex.h" />
|
||||
|
@ -175,7 +175,6 @@
|
||||
<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" />
|
||||
@ -224,7 +223,6 @@
|
||||
<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="rpcs3.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
|
@ -60,9 +60,6 @@
|
||||
<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>
|
||||
@ -158,9 +155,6 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user