mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-12-27 06:21:02 +00:00
Lots of defect fixes
This commit is contained in:
parent
5dfc22a604
commit
fac9d74344
@ -327,7 +327,13 @@ int OSCopyFile(const char* source, const char* destination, bool overwrite)
|
||||
//sendfile will work with non-socket output (i.e. regular file) on Linux 2.6.33+
|
||||
off_t bytesCopied = 0;
|
||||
struct stat fileinfo = { 0 };
|
||||
fstat(input, &fileinfo);
|
||||
|
||||
s32 ret = fstat(input, &fileinfo);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int result = sendfile(output, input, &bytesCopied, fileinfo.st_size) == -1 ? -1 : 0;
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "Utilities/Log.h"
|
||||
#include "VirtualMemory.h"
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
@ -21,13 +22,23 @@ namespace memory_helper
|
||||
#endif
|
||||
}
|
||||
|
||||
void commit_page_memory(void* pointer, size_t page_size)
|
||||
s32 commit_page_memory(void* pointer, size_t page_size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
VirtualAlloc((u8*)pointer, page_size, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (VirtualAlloc((u8*)pointer, page_size, MEM_COMMIT, PAGE_READWRITE) == NULL)
|
||||
{
|
||||
LOG_ERROR(HLE, "commit_page_memory VirtualAlloc failed.");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
mprotect((u8*)pointer, page_size, PROT_READ | PROT_WRITE);
|
||||
s32 ret = mprotect((u8*)pointer, page_size, PROT_READ | PROT_WRITE)
|
||||
if (ret < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "commit_page_memory mprotect failed. (%d)", ret);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void free_reserved_memory(void* pointer, size_t size)
|
||||
|
@ -12,8 +12,11 @@ namespace memory_helper
|
||||
* Commit page_size bytes of virtual memory starting at pointer.
|
||||
* That is, bake reserved memory with physical memory.
|
||||
* pointer should belong to a range of reserved memory.
|
||||
*
|
||||
* Returns 0, if was successful.
|
||||
* Returns -1, if was unsuccessful.
|
||||
*/
|
||||
void commit_page_memory(void* pointer, size_t page_size);
|
||||
s32 commit_page_memory(void* pointer, size_t page_size);
|
||||
|
||||
/**
|
||||
* Free memory alloced via reserve_memory.
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "restore_new.h"
|
||||
#include "Utilities/Log.h"
|
||||
#pragma warning(push)
|
||||
#pragma message("TODO: remove wx dependency: <wx/image.h>")
|
||||
#pragma warning(disable : 4996)
|
||||
@ -42,7 +43,8 @@ void rImage::SaveFile(const std::string& name, rImageType type)
|
||||
std::string rPlatform::getConfigDir()
|
||||
{
|
||||
static std::string dir = ".";
|
||||
if (dir == ".") {
|
||||
if (dir == ".")
|
||||
{
|
||||
#ifdef _WIN32
|
||||
dir = "";
|
||||
//mkdir(dir.c_str());
|
||||
@ -54,7 +56,16 @@ std::string rPlatform::getConfigDir()
|
||||
else // Just in case
|
||||
dir = "./config";
|
||||
dir = dir + "/rpcs3/";
|
||||
mkdir(dir.c_str(), 0777);
|
||||
|
||||
s32 ret = mkdir(dir.c_str(), 0777)
|
||||
if (ret == EEXIST)
|
||||
{
|
||||
LOG_WARNING(HLE, "Configuration directory already exists. (%s)", dir);
|
||||
}
|
||||
else if (ret < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "An error occured during the creation of the configuration directory. (%d)", ret);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return dir;
|
||||
|
@ -253,11 +253,17 @@ int decompress(unsigned char *out, unsigned char *in, unsigned int size)
|
||||
|
||||
// Underflow.
|
||||
if (buf_start < out)
|
||||
{
|
||||
delete[] tmp;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Overflow.
|
||||
if (buf_end > end)
|
||||
{
|
||||
delete[] tmp;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Update offset.
|
||||
offset = ((((int)(buf_end - out)) + 1) & 1) + 6;
|
||||
|
@ -291,7 +291,10 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD
|
||||
{
|
||||
if (verbose)
|
||||
LOG_WARNING(LOADER, "EDAT: Block at offset 0x%llx has invalid hash!", (u64)offset);
|
||||
|
||||
|
||||
delete[] enc_data;
|
||||
delete[] dec_data;
|
||||
delete[] b_key;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -337,6 +340,7 @@ int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD
|
||||
|
||||
delete[] enc_data;
|
||||
delete[] dec_data;
|
||||
delete[] b_key;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -389,7 +393,11 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
|
||||
f->read(header, 0xA0);
|
||||
|
||||
// Read in the header and metadata section hashes.
|
||||
f->seek(0x90);
|
||||
if (f->seek(0x90) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "EDAT: Seeking header at 0x90 failed.");
|
||||
}
|
||||
|
||||
f->read(metadata_hash, 0x10);
|
||||
f->read(header_hash, 0x10);
|
||||
|
||||
@ -445,7 +453,10 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
|
||||
while (bytes_to_read > 0)
|
||||
{
|
||||
// Locate the metadata blocks.
|
||||
f->seek(metadata_section_offset);
|
||||
if (f->seek(metadata_section_offset) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "EDAT: Seeking metadata blocks at %u failed.", metadata_section_offset);
|
||||
}
|
||||
|
||||
// Read in the metadata.
|
||||
f->read(metadata + bytes_read, metadata_section_size);
|
||||
|
@ -86,7 +86,11 @@ bool UnpackPKG(const fs::file& pkg_f, const std::string& dir, volatile f64& prog
|
||||
// Define decryption subfunction (`psp` arg selects the key for specific block)
|
||||
auto decrypt = [&](u64 offset, u64 size, bool psp) -> u64
|
||||
{
|
||||
pkg_f.seek(start_offset + header.data_offset + offset);
|
||||
if (pkg_f.seek(start_offset + header.data_offset + offset) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "PKG: Package file seek to %u failed.", start_offset + header.data_offset + offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Read the data and set available size
|
||||
const u64 read = pkg_f.read(buf.get(), size);
|
||||
|
@ -890,7 +890,7 @@ bool SELFDecrypter::DecryptNPDRM(u8 *metadata, u32 metadata_size)
|
||||
memcpy(klicensee_key, key_v.GetKlicenseeKey(), 0x10);
|
||||
|
||||
// Use klicensee if available.
|
||||
if (klicensee_key != NULL)
|
||||
if (memcmp(klicensee_key, key_v.GetKlicenseeKey(), 0x10) != 0)
|
||||
memcpy(npdrm_key, klicensee_key, 0x10);
|
||||
|
||||
if (ctrl->npdrm.license == 1) // Network license.
|
||||
@ -1077,7 +1077,7 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
{
|
||||
// Create a new ELF file.
|
||||
fs::file e(elf, fom::write | fom::create | fom::trunc);
|
||||
if(!e)
|
||||
if (!e)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Could not create ELF file! (%s)", elf.c_str());
|
||||
return false;
|
||||
@ -1092,8 +1092,10 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
WriteEhdr(e, elf32_hdr);
|
||||
|
||||
// Write program headers.
|
||||
for(u32 i = 0; i < elf32_hdr.e_phnum; ++i)
|
||||
for (u32 i = 0; i < elf32_hdr.e_phnum; ++i)
|
||||
{
|
||||
WritePhdr(e, phdr32_arr[i]);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
{
|
||||
@ -1101,7 +1103,12 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
if (meta_shdr[i].type == 2)
|
||||
{
|
||||
// Seek to the program header data offset and write the data.
|
||||
e.seek(phdr32_arr[meta_shdr[i].program_idx].p_offset);
|
||||
if (e.seek(phdr32_arr[meta_shdr[i].program_idx].p_offset) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "MakeElf program header data seek to %u failed.", phdr32_arr[meta_shdr[i].program_idx].p_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
e.write(data_buf + data_buf_offset, meta_shdr[i].data_size);
|
||||
|
||||
// Advance the data buffer offset by data size.
|
||||
@ -1110,12 +1117,18 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
}
|
||||
|
||||
// Write section headers.
|
||||
if(self_hdr.se_shdroff != 0)
|
||||
if (self_hdr.se_shdroff != 0)
|
||||
{
|
||||
e.seek(elf32_hdr.e_shoff);
|
||||
if (e.seek(elf32_hdr.e_shoff) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "MakeElf section header seek to %u failed.", elf32_hdr.e_shoff);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(u32 i = 0; i < elf32_hdr.e_shnum; ++i)
|
||||
for (u32 i = 0; i < elf32_hdr.e_shnum; ++i)
|
||||
{
|
||||
WriteShdr(e, shdr32_arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1124,8 +1137,10 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
WriteEhdr(e, elf64_hdr);
|
||||
|
||||
// Write program headers.
|
||||
for(u32 i = 0; i < elf64_hdr.e_phnum; ++i)
|
||||
for (u32 i = 0; i < elf64_hdr.e_phnum; ++i)
|
||||
{
|
||||
WritePhdr(e, phdr64_arr[i]);
|
||||
}
|
||||
|
||||
// Write data.
|
||||
for (unsigned int i = 0; i < meta_hdr.section_count; i++)
|
||||
@ -1152,7 +1167,12 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
decomp_stream_out.CopyTo(decomp_buf, phdr64_arr[meta_shdr[i].program_idx].p_filesz);
|
||||
|
||||
// Seek to the program header data offset and write the data.
|
||||
e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset);
|
||||
if (e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "MakeElf program header data seek to %u failed.", phdr64_arr[meta_shdr[i].program_idx].p_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
e.write(decomp_buf, phdr64_arr[meta_shdr[i].program_idx].p_filesz);
|
||||
|
||||
// Release the decompression buffer.
|
||||
@ -1161,7 +1181,12 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
else
|
||||
{
|
||||
// Seek to the program header data offset and write the data.
|
||||
e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset);
|
||||
if (e.seek(phdr64_arr[meta_shdr[i].program_idx].p_offset) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "MakeElf program header data seek to %u failed.", phdr64_arr[meta_shdr[i].program_idx].p_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
e.write(data_buf + data_buf_offset, meta_shdr[i].data_size);
|
||||
}
|
||||
|
||||
@ -1171,12 +1196,18 @@ bool SELFDecrypter::MakeElf(const std::string& elf, bool isElf32)
|
||||
}
|
||||
|
||||
// Write section headers.
|
||||
if(self_hdr.se_shdroff != 0)
|
||||
if (self_hdr.se_shdroff != 0)
|
||||
{
|
||||
e.seek(elf64_hdr.e_shoff);
|
||||
if (e.seek(elf64_hdr.e_shoff) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "MakeElf section header seek to %u failed.", elf64_hdr.e_shoff);
|
||||
return false;
|
||||
}
|
||||
|
||||
for(u32 i = 0; i < elf64_hdr.e_shnum; ++i)
|
||||
for (u32 i = 0; i < elf64_hdr.e_shnum; ++i)
|
||||
{
|
||||
WriteShdr(e, shdr64_arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1246,7 +1277,13 @@ bool IsSelfElf32(const std::string& path)
|
||||
|
||||
// Locate the class byte and check it.
|
||||
u8 elf_class[0x8];
|
||||
f.Seek(sh.se_elfoff);
|
||||
|
||||
if (f.Seek(sh.se_elfoff) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "IsSelfElf32 seek to %u failed.", sh.se_elfoff);
|
||||
return false;
|
||||
}
|
||||
|
||||
f.Read(elf_class, 0x8);
|
||||
|
||||
return (elf_class[4] == 1);
|
||||
@ -1257,34 +1294,49 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf)
|
||||
// Open the SELF file.
|
||||
fs::file s(self);
|
||||
|
||||
if(!s)
|
||||
if (!s)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Could not open SELF file! (%s)", self.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the key version.
|
||||
s.seek(0x08);
|
||||
if (s.seek(0x08) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Seeking debug (S)ELF at 0x08 failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
u16 key_version;
|
||||
s.read(&key_version, sizeof(key_version));
|
||||
|
||||
// Check for DEBUG version.
|
||||
if(swap16(key_version) == 0x8000)
|
||||
if (swap16(key_version) == 0x8000)
|
||||
{
|
||||
LOG_WARNING(LOADER, "Debug SELF detected! Removing fake header...");
|
||||
|
||||
// Get the real elf offset.
|
||||
s.seek(0x10);
|
||||
if (s.seek(0x10) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Seeking debug (S)ELF at 0x10 failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
u64 elf_offset;
|
||||
s.read(&elf_offset, sizeof(elf_offset));
|
||||
|
||||
// Start at the real elf offset.
|
||||
elf_offset = swap64(elf_offset);
|
||||
s.seek(elf_offset);
|
||||
|
||||
if (s.seek(elf_offset) < 0)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Seeking debug (S)ELF at %u failed.", elf_offset);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write the real ELF file back.
|
||||
fs::file e(elf, fom::write | fom::create | fom::trunc);
|
||||
if(!e)
|
||||
if (!e)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Could not create ELF file! (%s)", elf.c_str());
|
||||
return false;
|
||||
@ -1293,7 +1345,9 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf)
|
||||
// Copy the data.
|
||||
char buf[2048];
|
||||
while (ssize_t size = s.read(buf, 2048))
|
||||
{
|
||||
e.write(buf, size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ void hex_to_bytes(unsigned char *data, const char *hex_str, unsigned int str_len
|
||||
|
||||
// Copy back to our array.
|
||||
memcpy(data, out, data_length);
|
||||
free(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ void vfsHDDManager::CreateEntry(vfsHDD_Entry& entry)
|
||||
CreateBlock(entry);
|
||||
}
|
||||
|
||||
void vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size)
|
||||
s32 vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size)
|
||||
{
|
||||
fs::file f(path, fom::write | fom::create | fom::trunc);
|
||||
|
||||
@ -47,8 +47,16 @@ void vfsHDDManager::CreateHDD(const std::string& path, u64 size, u64 block_size)
|
||||
}
|
||||
|
||||
u8 null = 0;
|
||||
f.seek(hdr.block_count * hdr.block_size - sizeof(null));
|
||||
|
||||
if (f.seek(hdr.block_count * hdr.block_size - sizeof(null)) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "CreateHDD seek to %u failed.", hdr.block_count * hdr.block_size - sizeof(null));
|
||||
return -1;
|
||||
}
|
||||
|
||||
f.write(&null, sizeof(null));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDManager::Format()
|
||||
@ -99,50 +107,99 @@ void vfsHDDFile::RemoveBlocks(u64 start_block)
|
||||
}
|
||||
}
|
||||
|
||||
void vfsHDDFile::WriteBlock(u64 block, const vfsHDD_Block& data)
|
||||
s32 vfsHDDFile::WriteBlock(u64 block, const vfsHDD_Block& data)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "WriteBlock seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd.Write(&data, sizeof(vfsHDD_Block));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::ReadBlock(u64 block, vfsHDD_Block& data)
|
||||
s32 vfsHDDFile::ReadBlock(u64 block, vfsHDD_Block& data)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadBlock seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd.Read(&data, sizeof(vfsHDD_Block));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data)
|
||||
s32 vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd.Write(&data, sizeof(vfsHDD_Entry));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data)
|
||||
s32 vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd.Read(&data, sizeof(vfsHDD_Entry));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name)
|
||||
s32 vfsHDDFile::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd.Read(&data, sizeof(vfsHDD_Entry));
|
||||
name.resize(GetMaxNameLen());
|
||||
m_hdd.Read(&name.front(), GetMaxNameLen());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::ReadEntry(u64 block, std::string& name)
|
||||
s32 vfsHDDFile::ReadEntry(u64 block, std::string& name)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry));
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size + sizeof(vfsHDD_Entry));
|
||||
return -1;
|
||||
}
|
||||
|
||||
name.resize(GetMaxNameLen());
|
||||
m_hdd.Read(&name.front(), GetMaxNameLen());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name)
|
||||
s32 vfsHDDFile::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name)
|
||||
{
|
||||
m_hdd.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd.Write(&data, sizeof(vfsHDD_Entry));
|
||||
m_hdd.Write(name.c_str(), std::min<size_t>(GetMaxNameLen() - 1, name.length() + 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDDFile::Open(u64 info_block)
|
||||
@ -361,7 +418,13 @@ vfsHDD::vfsHDD(vfsDevice* device, const std::string& hdd_path)
|
||||
LOG_ERROR(HLE, "Bad block size!");
|
||||
m_hdd_info.block_size = 2048;
|
||||
}
|
||||
m_hdd_file.Seek(m_cur_dir_block * m_hdd_info.block_size);
|
||||
|
||||
if (m_hdd_file.Seek(m_cur_dir_block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "vfsHDD initialization seek to %u failed.", m_cur_dir_block * m_hdd_info.block_size);
|
||||
return;
|
||||
}
|
||||
|
||||
m_hdd_file.Read(&m_cur_dir, sizeof(vfsHDD_Entry));
|
||||
}
|
||||
|
||||
@ -392,14 +455,22 @@ bool vfsHDD::SearchEntry(const std::string& name, u64& entry_block, u64* parent_
|
||||
return false;
|
||||
}
|
||||
|
||||
int vfsHDD::OpenDir(const std::string& name)
|
||||
s32 vfsHDD::OpenDir(const std::string& name)
|
||||
{
|
||||
LOG_WARNING(HLE, "OpenDir(%s)", name.c_str());
|
||||
u64 entry_block;
|
||||
if (!SearchEntry(name, entry_block))
|
||||
{
|
||||
LOG_ERROR(HLE, "OpenDir could not find the entry. (%s)", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Seek(entry_block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(entry_block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "OpenDir seek to %u failed.", entry_block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vfsHDD_Entry entry;
|
||||
m_hdd_file.Read(&entry, sizeof(vfsHDD_Entry));
|
||||
if (entry.type == vfsHDD_Entry_File)
|
||||
@ -443,50 +514,99 @@ u64 vfsHDD::FindFreeBlock()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::WriteBlock(u64 block, const vfsHDD_Block& data)
|
||||
s32 vfsHDD::WriteBlock(u64 block, const vfsHDD_Block& data)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "WriteBlock seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Write(&data, sizeof(vfsHDD_Block));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::ReadBlock(u64 block, vfsHDD_Block& data)
|
||||
s32 vfsHDD::ReadBlock(u64 block, vfsHDD_Block& data)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadBlock seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Read(&data, sizeof(vfsHDD_Block));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data)
|
||||
s32 vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Write(&data, sizeof(vfsHDD_Entry));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data)
|
||||
s32 vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Read(&data, sizeof(vfsHDD_Entry));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name)
|
||||
s32 vfsHDD::ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Read(&data, sizeof(vfsHDD_Entry));
|
||||
name.resize(GetMaxNameLen());
|
||||
m_hdd_file.Read(&name.front(), GetMaxNameLen());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::ReadEntry(u64 block, std::string& name)
|
||||
s32 vfsHDD::ReadEntry(u64 block, std::string& name)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry));
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size + sizeof(vfsHDD_Entry)) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "ReadEntry seek to %u failed.", block * m_hdd_info.block_size + sizeof(vfsHDD_Entry));
|
||||
return -1;
|
||||
}
|
||||
|
||||
name.resize(GetMaxNameLen());
|
||||
m_hdd_file.Read(&name.front(), GetMaxNameLen());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name)
|
||||
s32 vfsHDD::WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name)
|
||||
{
|
||||
m_hdd_file.Seek(block * m_hdd_info.block_size);
|
||||
if (m_hdd_file.Seek(block * m_hdd_info.block_size) < 0)
|
||||
{
|
||||
LOG_ERROR(HLE, "WriteEntry seek to %u failed.", block * m_hdd_info.block_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_hdd_file.Write(&data, sizeof(vfsHDD_Entry));
|
||||
m_hdd_file.Write(name.c_str(), std::min<size_t>(GetMaxNameLen() - 1, name.length() + 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool vfsHDD::Create(vfsHDD_EntryType type, const std::string& name)
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
|
||||
static void CreateEntry(vfsHDD_Entry& entry);
|
||||
|
||||
static void CreateHDD(const std::string& path, u64 size, u64 block_size);
|
||||
static s32 CreateHDD(const std::string& path, u64 size, u64 block_size);
|
||||
|
||||
void Format();
|
||||
|
||||
@ -68,19 +68,19 @@ class vfsHDDFile
|
||||
|
||||
void RemoveBlocks(u64 start_block);
|
||||
|
||||
void WriteBlock(u64 block, const vfsHDD_Block& data);
|
||||
s32 WriteBlock(u64 block, const vfsHDD_Block& data);
|
||||
|
||||
void ReadBlock(u64 block, vfsHDD_Block& data);
|
||||
s32 ReadBlock(u64 block, vfsHDD_Block& data);
|
||||
|
||||
void WriteEntry(u64 block, const vfsHDD_Entry& data);
|
||||
s32 WriteEntry(u64 block, const vfsHDD_Entry& data);
|
||||
|
||||
void ReadEntry(u64 block, vfsHDD_Entry& data);
|
||||
s32 ReadEntry(u64 block, vfsHDD_Entry& data);
|
||||
|
||||
void ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name);
|
||||
s32 ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name);
|
||||
|
||||
void ReadEntry(u64 block, std::string& name);
|
||||
s32 ReadEntry(u64 block, std::string& name);
|
||||
|
||||
void WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name);
|
||||
s32 WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name);
|
||||
|
||||
force_inline u32 GetMaxNameLen() const
|
||||
{
|
||||
@ -156,25 +156,25 @@ public:
|
||||
|
||||
bool SearchEntry(const std::string& name, u64& entry_block, u64* parent_block = nullptr);
|
||||
|
||||
int OpenDir(const std::string& name);
|
||||
s32 OpenDir(const std::string& name);
|
||||
|
||||
bool Rename(const std::string& from, const std::string& to);
|
||||
|
||||
u64 FindFreeBlock();
|
||||
|
||||
void WriteBlock(u64 block, const vfsHDD_Block& data);
|
||||
s32 WriteBlock(u64 block, const vfsHDD_Block& data);
|
||||
|
||||
void ReadBlock(u64 block, vfsHDD_Block& data);
|
||||
s32 ReadBlock(u64 block, vfsHDD_Block& data);
|
||||
|
||||
void WriteEntry(u64 block, const vfsHDD_Entry& data);
|
||||
s32 WriteEntry(u64 block, const vfsHDD_Entry& data);
|
||||
|
||||
void ReadEntry(u64 block, vfsHDD_Entry& data);
|
||||
s32 ReadEntry(u64 block, vfsHDD_Entry& data);
|
||||
|
||||
void ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name);
|
||||
s32 ReadEntry(u64 block, vfsHDD_Entry& data, std::string& name);
|
||||
|
||||
void ReadEntry(u64 block, std::string& name);
|
||||
s32 ReadEntry(u64 block, std::string& name);
|
||||
|
||||
void WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name);
|
||||
s32 WriteEntry(u64 block, const vfsHDD_Entry& data, const std::string& name);
|
||||
|
||||
bool Create(vfsHDD_EntryType type, const std::string& name);
|
||||
|
||||
|
@ -92,6 +92,8 @@ struct Mouse
|
||||
: m_data()
|
||||
, m_rawdata()
|
||||
{
|
||||
x_pos = 0;
|
||||
y_pos = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utilities/Log.h"
|
||||
|
||||
struct MemInfo
|
||||
{
|
||||
u32 addr;
|
||||
@ -82,7 +84,13 @@ public:
|
||||
u32 RealAddr(u32 addr)
|
||||
{
|
||||
u32 realAddr = 0;
|
||||
getRealAddr(addr, realAddr);
|
||||
|
||||
if (!getRealAddr(addr, realAddr))
|
||||
{
|
||||
LOG_ERROR(HLE, "Getting the real address failed. (addr=%u)", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return realAddr;
|
||||
}
|
||||
|
||||
|
@ -291,6 +291,7 @@ template<typename T> std::string FragmentProgramDecompiler::GetSRC(T src)
|
||||
|
||||
case 3: // ??? Used by a few games, what is it?
|
||||
LOG_ERROR(RSX, "Src type 3 used, please report this to a developer.");
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR(RSX, "Bad src type %d", u32{ src.reg_type });
|
||||
|
@ -108,7 +108,7 @@ std::string VertexProgramDecompiler::GetSRC(const u32 n)
|
||||
|
||||
if (swizzle != f) ret += '.' + swizzle;
|
||||
|
||||
bool abs;
|
||||
bool abs = false;
|
||||
|
||||
switch (n)
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
||||
free(pAddresses);
|
||||
#else
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int family, n;
|
||||
s32 family, n;
|
||||
|
||||
if (getifaddrs(&ifaddr) == -1)
|
||||
{
|
||||
@ -146,9 +146,7 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
||||
|
||||
if (family == AF_INET)
|
||||
{
|
||||
s32 fd, status;
|
||||
|
||||
fd = open("/proc/net/dev", O_RDONLY);
|
||||
u32 fd = open("/proc/net/dev", O_RDONLY);
|
||||
struct ifreq freq;
|
||||
|
||||
if (ioctl(fd, SIOCGIFMTU, &freq) == -1)
|
||||
@ -212,7 +210,7 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
||||
free(pAdapterInfo);
|
||||
#else
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int family, n;
|
||||
s32 family, n;
|
||||
|
||||
if (getifaddrs(&ifaddr) == -1)
|
||||
{
|
||||
@ -293,7 +291,7 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
||||
free(pAdapterInfo);
|
||||
#else
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int family, n;
|
||||
s32 family, n;
|
||||
|
||||
if (getifaddrs(&ifaddr) == -1)
|
||||
{
|
||||
|
@ -344,14 +344,17 @@ s32 CalculateSurfaceByteSize(u32 mode, CellRescDsts *dsts)
|
||||
|
||||
s32 CalculateMaxColorBuffersSize()
|
||||
{
|
||||
s32 oneBufSize, bufNum, totalBufSize, maxBufSize;
|
||||
s32 index, oneBufSize, bufNum, totalBufSize, maxBufSize;
|
||||
maxBufSize = 0;
|
||||
|
||||
for (u32 bufMode = CELL_RESC_720x480; bufMode <= CELL_RESC_1920x1080; bufMode <<= 1)
|
||||
{
|
||||
if (s_rescInternalInstance->m_initConfig.supportModes & bufMode)
|
||||
{
|
||||
oneBufSize = CalculateSurfaceByteSize(bufMode, &(s_rescInternalInstance->m_rescDsts[GetRescDestsIndex(bufMode)]));
|
||||
if ((index = GetRescDestsIndex(bufMode)) != 0)
|
||||
{
|
||||
oneBufSize = CalculateSurfaceByteSize(bufMode, &(s_rescInternalInstance->m_rescDsts[index]));
|
||||
}
|
||||
bufNum = cellRescGetNumColorBuffers(bufMode, s_rescInternalInstance->m_initConfig.palTemporalMode, 0);
|
||||
totalBufSize = oneBufSize * bufNum;
|
||||
maxBufSize = (maxBufSize > totalBufSize) ? maxBufSize : totalBufSize;
|
||||
|
@ -866,7 +866,8 @@ s32 cellSailPlayerRemoveDescriptor(vm::ptr<CellSailPlayer> pSelf, vm::ptr<CellSa
|
||||
if (pSelf->descriptors > 0)
|
||||
{
|
||||
ppDesc = pSelf->registeredDescriptors[pSelf->descriptors];
|
||||
delete &pSelf->registeredDescriptors[pSelf->descriptors];
|
||||
// TODO: Figure out how properly free a descriptor. Use game specified memory dealloc function?
|
||||
//delete &pSelf->registeredDescriptors[pSelf->descriptors];
|
||||
pSelf->descriptors--;
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ s32 cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
|
||||
cellSysutil.Warning("cellSysCacheMount(param=*0x%x)", param);
|
||||
|
||||
// TODO: implement
|
||||
char id[CELL_SYSCACHE_ID_SIZE];
|
||||
strncpy(id, param->cacheId, CELL_SYSCACHE_ID_SIZE);
|
||||
char id[CELL_SYSCACHE_ID_SIZE] = { '\0' };
|
||||
strncpy(id, param->cacheId, CELL_SYSCACHE_ID_SIZE - 1);
|
||||
strncpy(param->getCachePath, ("/dev_hdd1/cache/"s + id + "/").c_str(), CELL_SYSCACHE_PATH_MAX);
|
||||
param->getCachePath[CELL_SYSCACHE_PATH_MAX - 1] = '\0';
|
||||
Emu.GetVFS().CreateDir(param->getCachePath);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
class GSFrame : public wxFrame, public GSFrameBase
|
||||
{
|
||||
u64 m_frames;
|
||||
u64 m_frames = 0;
|
||||
|
||||
public:
|
||||
GSFrame(const wxString& title);
|
||||
|
@ -262,7 +262,13 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
// Fetch title ID from the header
|
||||
char title_id[10] = "?????????";
|
||||
pkg_f.seek(55);
|
||||
|
||||
if (!pkg_f.seek(55))
|
||||
{
|
||||
LOG_ERROR(LOADER, "PKG: Failed to seek offset 55.");
|
||||
return;
|
||||
}
|
||||
|
||||
pkg_f.read(title_id, 9);
|
||||
pkg_f.seek(0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user