Add usz alias for std::size_t

This commit is contained in:
Nekotekina 2020-12-18 10:39:54 +03:00
parent 360c4d1554
commit fb29933d3d
173 changed files with 718 additions and 717 deletions

View file

@ -578,7 +578,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
int dev_hash_result = 0;
const s32 file_name_length = ::narrow<s32>(std::strlen(file_name));
const std::size_t buf_len = 0x30 + file_name_length;
const usz buf_len = 0x30 + file_name_length;
std::unique_ptr<u8[]> buf(new u8[buf_len]);
std::unique_ptr<u8[]> buf_lower(new u8[buf_len]);
@ -591,7 +591,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
std::memcpy(buf_lower.get(), buf.get(), buf_len);
std::memcpy(buf_upper.get(), buf.get(), buf_len);
for (std::size_t i = std::basic_string_view<u8>(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++)
for (usz i = std::basic_string_view<u8>(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++)
{
const u8 c = static_cast<u8>(buf[i]);
buf_upper[i] = std::toupper(c);

View file

@ -697,7 +697,7 @@ bool package_reader::extract_data(atomic_t<double>& sync)
return false;
}
size_t num_failures = 0;
usz num_failures = 0;
std::vector<PKGEntry> entries(header.file_count);
@ -857,7 +857,7 @@ void package_reader::archive_seek(const s64 new_offset, const fs::seek_mode damo
cur_offset += new_offset;
u64 _offset = 0;
for (size_t i = 0; i < filelist.size(); i++)
for (usz i = 0; i < filelist.size(); i++)
{
if (cur_offset < (_offset + filelist[i].size()))
{

View file

@ -117,16 +117,16 @@ struct PKGEntry
struct PKGMetaData
{
private:
static std::string to_hex_string(u8 buf[], size_t size)
static std::string to_hex_string(u8 buf[], usz size)
{
std::stringstream sstream;
for (size_t i = 0; i < size; i++)
for (usz i = 0; i < size; i++)
{
sstream << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(buf[i]);
}
return sstream.str();
}
static std::string to_hex_string(u8 buf[], size_t size, size_t dotpos)
static std::string to_hex_string(u8 buf[], usz size, usz dotpos)
{
std::string result = to_hex_string(buf, size);
if (result.size() > dotpos)
@ -312,14 +312,14 @@ private:
u64 archive_read(void* data_ptr, const u64 num_bytes);
u64 decrypt(u64 offset, u64 size, const uchar* key);
const std::size_t BUF_SIZE = 8192 * 1024; // 8 MB
const usz BUF_SIZE = 8192 * 1024; // 8 MB
bool m_is_valid = false;
std::string m_path;
std::string install_dir;
std::vector<fs::file> filelist;
size_t cur_file = 0;
usz cur_file = 0;
u64 cur_offset = 0;
u64 cur_file_offset = 0;
std::unique_ptr<u128[]> buf;

View file

@ -715,7 +715,7 @@ bool SCEDecrypter::LoadMetadata(const u8 erk[32], const u8 riv[16])
}
// Perform AES-CTR encryption on the metadata headers.
size_t ctr_nc_off = 0;
usz ctr_nc_off = 0;
u8 ctr_stream_block[0x10];
aes_setkey_enc(&aes, meta_info.key, 128);
aes_crypt_ctr(&aes, metadata_headers_size, &ctr_nc_off, meta_info.iv, ctr_stream_block, metadata_headers.get(), metadata_headers.get());
@ -758,7 +758,7 @@ bool SCEDecrypter::DecryptData()
// Parse the metadata section headers to find the offsets of encrypted data.
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
{
size_t ctr_nc_off = 0;
usz ctr_nc_off = 0;
u8 ctr_stream_block[0x10];
u8 data_key[0x10];
u8 data_iv[0x10];
@ -824,7 +824,7 @@ std::vector<fs::file> SCEDecrypter::MakeFile()
// Decompress if necessary.
if (meta_shdr[i].compressed == 2)
{
const size_t BUFSIZE = 32 * 1024;
const usz BUFSIZE = 32 * 1024;
u8 tempbuf[BUFSIZE];
z_stream strm;
strm.zalloc = Z_NULL;
@ -1210,7 +1210,7 @@ bool SELFDecrypter::LoadMetadata(u8* klic_key)
}
// Perform AES-CTR encryption on the metadata headers.
size_t ctr_nc_off = 0;
usz ctr_nc_off = 0;
u8 ctr_stream_block[0x10];
aes_setkey_enc(&aes, meta_info.key, 128);
aes_crypt_ctr(&aes, metadata_headers_size, &ctr_nc_off, meta_info.iv, ctr_stream_block, metadata_headers.get(), metadata_headers.get());
@ -1257,7 +1257,7 @@ bool SELFDecrypter::DecryptData()
// Parse the metadata section headers to find the offsets of encrypted data.
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
{
size_t ctr_nc_off = 0;
usz ctr_nc_off = 0;
u8 ctr_stream_block[0x10];
u8 data_key[0x10];
u8 data_iv[0x10];