types.hpp: remove intrinsic includes

Replace v128 with u128 in some places.
Removed some unused files.
This commit is contained in:
Nekotekina 2020-12-21 17:12:05 +03:00
parent 5f618814f6
commit bd269bccaf
64 changed files with 899 additions and 2265 deletions

View file

@ -885,12 +885,12 @@ void main_window::DecryptSPRXLibraries()
gui_log.notice("Decrypting binaries...");
// Always start with no KLIC
std::vector<v128> klics{v128{}};
std::vector<u128> klics{u128{}};
if (const auto keys = g_fxo->get<loaded_npdrm_keys>())
{
// Second klic: get it from a running game
if (const v128 klic = keys->devKlic; klic != v128{})
if (const u128 klic = keys->devKlic)
{
klics.emplace_back(klic);
}
@ -913,7 +913,7 @@ void main_window::DecryptSPRXLibraries()
if (elf_file.open(old_path) && elf_file.size() >= 4 && elf_file.read<u32>() == "SCE\0"_u32)
{
// First KLIC is no KLIC
elf_file = decrypt_self(std::move(elf_file), key_it != 0 ? klics[key_it]._bytes : nullptr);
elf_file = decrypt_self(std::move(elf_file), key_it != 0 ? reinterpret_cast<u8*>(&klics[key_it]) : nullptr);
if (!elf_file)
{
@ -985,11 +985,15 @@ void main_window::DecryptSPRXLibraries()
ensure(text.size() == 32);
// It must succeed (only hex characters are present)
std::from_chars(&text[0], &text[16], klic._u64[1], 16); // Not a typo: on LE systems the u64[1] part will be swapped with u64[0] later
std::from_chars(&text[16], &text[32], klic._u64[0], 16); // And on BE systems it will be already swapped by index internally
u64 lo_ = 0;
u64 hi_ = 0;
std::from_chars(&text[0], &text[16], lo_, 16);
std::from_chars(&text[16], &text[32], hi_, 16);
// Needs to be in big endian because the left to right byte-order means big endian
klic = std::bit_cast<be_t<v128>>(klic);
be_t<u64> lo = std::bit_cast<be_t<u64>>(lo_);
be_t<u64> hi = std::bit_cast<be_t<u64>>(hi_);
klic = (u128{+hi} << 64) | +lo;
// Retry with specified KLIC
key_it -= +std::exchange(tried, true); // Rewind on second and above attempt