/dev_bdvd/, rap file loading fix
This commit is contained in:
Nekotekina 2016-01-14 15:56:26 +03:00
parent 74ec128e62
commit 8464ab6a23
6 changed files with 92 additions and 95 deletions

View file

@ -820,7 +820,6 @@ int DecryptEDAT(const std::string& input_file_name, const std::string& output_fi
// Prepare the files.
fs::file input(input_file_name);
fs::file output(output_file_name, fom::rewrite);
fs::file rap(rap_file_name);
// Set keys (RIF and DEVKLIC).
unsigned char rifkey[0x10];
@ -879,8 +878,10 @@ int DecryptEDAT(const std::string& input_file_name, const std::string& output_fi
}
// Read the RAP file, if provided.
if (rap)
if (rap_file_name.size())
{
fs::file rap(rap_file_name);
unsigned char rapkey[0x10];
memset(rapkey, 0, 0x10);

View file

@ -75,7 +75,7 @@ s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr<char> drm_path)
std::string pf_str("00000001"); // TODO: Allow multiple profiles. Use default for now.
std::string rap_path("/dev_hdd0/home/" + pf_str + "/exdata/");
// Search dev_usb000 for a compatible RAP file.
// Search for a compatible RAP file.
for (const auto entry : vfsDir(rap_path))
{
if (entry->name.find(titleID) != std::string::npos)
@ -88,13 +88,19 @@ s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr<char> drm_path)
if (rap_path.back() == '/')
{
sceNp.warning("npDrmIsAvailable(): Can't find RAP file for '%s' (titleID='%s')", drm_path.get_ptr(), titleID);
rap_path.clear();
}
// Decrypt this EDAT using the supplied k_licensee and matching RAP file.
std::string enc_drm_path_local, dec_drm_path_local, rap_path_local;
Emu.GetVFS().GetDevice(enc_drm_path, enc_drm_path_local);
Emu.GetVFS().GetDevice(dec_drm_path, dec_drm_path_local);
Emu.GetVFS().GetDevice(rap_path, rap_path_local);
if (rap_path.size())
{
Emu.GetVFS().GetDevice(rap_path, rap_path_local);
}
if (DecryptEDAT(enc_drm_path_local, dec_drm_path_local, 8, rap_path_local, k_licensee, false) >= 0)
{

View file

@ -218,7 +218,7 @@ void Emulator::Load()
if (dir_list.size() >= 2 && dir_list.back() == "USRDIR" && *(dir_list.end() - 2) == "PS3_GAME")
{
// mount detected /dev_bdvd/ directory
Emu.GetVFS().Mount("/dev_bdvd/", elf_dir.substr(0, elf_dir.length() - 17), new vfsDeviceLocalFile());
Emu.GetVFS().Mount("/dev_bdvd/", elf_dir.substr(0, elf_dir.length() - 16), new vfsDeviceLocalFile());
}
}

View file

@ -27,12 +27,10 @@ LogFrame::LogFrame(wxWindow* parent)
m_log_file.open(fs::get_config_dir() + "RPCS3.log", fom::read | fom::create);
m_tty_file.open(fs::get_config_dir() + "TTY.log", fom::read | fom::create);
// Check for updates every ~10 ms
m_timer.Start(10);
m_tty->SetBackgroundColour(wxColour("Black"));
m_log->SetBackgroundColour(wxColour("Black"));
m_tty->SetFont(wxFont(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
m_tty->SetDefaultStyle(wxColour(255, 255, 255));
m_tabs.AddPage(m_log, "Log");
m_tabs.AddPage(m_tty, "TTY");
@ -46,6 +44,9 @@ LogFrame::LogFrame(wxWindow* parent)
Bind(wxEVT_MENU, &LogFrame::OnContextMenu, this, id_log_copy);
Show();
// Check for updates every ~10 ms
m_timer.Start(10);
}
LogFrame::~LogFrame()
@ -101,42 +102,42 @@ void LogFrame::OnContextMenu(wxCommandEvent& event)
void LogFrame::OnTimer(wxTimerEvent& event)
{
char buf[8192];
const auto stamp0 = std::chrono::high_resolution_clock::now();
char buf[4096];
// Get UTF-8 string from file
auto get_utf8 = [&](const fs::file& file, u64 size) -> wxString
{
// Bruteforce valid UTF-8 (TODO)
for (u64 read = file.read(buf, size); read; read--)
size = file.read(buf, size);
for (u64 i = 0; i < size; i++)
{
wxString text = wxString::FromUTF8(buf, read);
if (!text.empty())
// Get UTF-8 sequence length (no real validation performed)
const u64 tail =
(buf[i] & 0xF0) == 0xF0 ? 3 :
(buf[i] & 0xE0) == 0xE0 ? 2 :
(buf[i] & 0xC0) == 0xC0 ? 1 : 0;
if (i + tail >= size)
{
file.seek(read - size, fs::seek_cur);
return text;
file.seek(i - size, fs::seek_cur);
return wxString::FromUTF8(buf, i);
}
}
return{};
return wxString::FromUTF8(buf, size);
};
const auto stamp0 = std::chrono::high_resolution_clock::now();
// Check TTY logs
while (const u64 size = std::min<u64>(sizeof(buf), _log::g_tty_file.size() - m_tty_file.seek(0, fs::seek_cur)))
{
const wxString& text = get_utf8(m_tty_file, size);
if (text.size())
{
m_tty->SetDefaultStyle(wxColour(255, 255, 255));
m_tty->AppendText(text);
}
m_tty->AppendText(text);
// Limit processing time
if (std::chrono::high_resolution_clock::now() >= stamp0 + 4ms)
{
break;
}
if (std::chrono::high_resolution_clock::now() >= stamp0 + 4ms || text.empty()) break;
}
const auto stamp1 = std::chrono::high_resolution_clock::now();
@ -146,16 +147,27 @@ void LogFrame::OnTimer(wxTimerEvent& event)
{
const wxString& text = get_utf8(m_log_file, size);
std::size_t start = 0, pos = 0;
// Append text if necessary
auto flush_logs = [&](u64 start, u64 pos)
{
if (pos != start && m_level <= rpcs3::config.misc.log.level.value())
{
m_log->SetDefaultStyle(m_color);
m_log->AppendText(text.substr(start, pos - start));
}
};
for (; pos < text.size(); pos++)
// Parse log level formatting
for (std::size_t start = 0, pos = 0;; pos++)
{
if (text[pos] == L'·')
{
if (text.size() - pos <= 3)
{
// Cannot get log string: abort
// Cannot get log formatting: abort
m_log_file.seek(0 - text.substr(pos).ToUTF8().length(), fs::seek_cur);
flush_logs(start, pos);
break;
}
@ -177,34 +189,22 @@ void LogFrame::OnTimer(wxTimerEvent& event)
default: continue;
}
if (pos != start && m_level <= rpcs3::config.misc.log.level.value())
{
m_log->SetDefaultStyle(m_color);
m_log->AppendText(text.substr(start, pos - start));
}
flush_logs(start, pos);
start = pos + 3;
m_level = level;
m_color = color;
}
}
}
if (pos != start && m_level <= rpcs3::config.misc.log.level.value())
{
m_log->SetDefaultStyle(m_color);
m_log->AppendText(text.substr(start, pos - start));
}
if (m_log->GetLastPosition() > 1024 * 1024)
{
m_log->Remove(0, m_log->GetLastPosition() - 512 * 1024);
if (pos >= text.size())
{
flush_logs(start, pos);
break;
}
}
// Limit processing time
if (std::chrono::high_resolution_clock::now() >= stamp1 + 3ms)
{
break;
}
if (std::chrono::high_resolution_clock::now() >= stamp1 + 3ms || text.empty()) break;
}
}