mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
fix some style inconsistencies that drove me nuts
This commit is contained in:
parent
3ff56aa192
commit
1e28d06f26
@ -323,21 +323,21 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
||||
|
||||
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
|
||||
|
||||
const DiscIO::CNANDContentLoader& rNANDCOntent = AccessContentDevice(TitleID);
|
||||
if (rNANDCOntent.IsValid()) // Not sure if dolphin will ever fail this check
|
||||
const DiscIO::CNANDContentLoader& rNANDContent = AccessContentDevice(TitleID);
|
||||
if (rNANDContent.IsValid()) // Not sure if dolphin will ever fail this check
|
||||
{
|
||||
for (u16 i = 0; i < rNANDCOntent.GetNumEntries(); i++)
|
||||
for (u16 i = 0; i < rNANDContent.GetNumEntries(); i++)
|
||||
{
|
||||
Memory::Write_U32(rNANDCOntent.GetContentByIndex(i)->m_ContentID, Buffer.PayloadBuffer[0].m_Address + i*4);
|
||||
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Index %d: %08x", i, rNANDCOntent.GetContentByIndex(i)->m_ContentID);
|
||||
Memory::Write_U32(rNANDContent.GetContentByIndex(i)->m_ContentID, Buffer.PayloadBuffer[0].m_Address + i*4);
|
||||
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Index %d: %08x", i, rNANDContent.GetContentByIndex(i)->m_ContentID);
|
||||
}
|
||||
Memory::Write_U32(0, _CommandAddress + 0x4);
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32((u32)rNANDCOntent.GetContentSize(), _CommandAddress + 0x4);
|
||||
Memory::Write_U32((u32)rNANDContent.GetContentSize(), _CommandAddress + 0x4);
|
||||
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Unable to open content %zu",
|
||||
rNANDCOntent.GetContentSize());
|
||||
rNANDContent.GetContentSize());
|
||||
}
|
||||
|
||||
return GetDefaultReply();
|
||||
@ -1078,19 +1078,19 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
|
||||
}
|
||||
|
||||
// TODO: This cache is redundant with the one in CNANDContentManager.h
|
||||
const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u64 _TitleID)
|
||||
const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u64 title_id)
|
||||
{
|
||||
if (m_pContentLoader->IsValid() && m_pContentLoader->GetTitleID() == _TitleID)
|
||||
if (m_pContentLoader->IsValid() && m_pContentLoader->GetTitleID() == title_id)
|
||||
return *m_pContentLoader;
|
||||
|
||||
CTitleToContentMap::iterator itr = m_NANDContent.find(_TitleID);
|
||||
CTitleToContentMap::iterator itr = m_NANDContent.find(title_id);
|
||||
if (itr != m_NANDContent.end())
|
||||
return *itr->second;
|
||||
|
||||
m_NANDContent[_TitleID] = &DiscIO::CNANDContentManager::Access().GetNANDLoader(_TitleID, Common::FROM_SESSION_ROOT);
|
||||
m_NANDContent[title_id] = &DiscIO::CNANDContentManager::Access().GetNANDLoader(title_id, Common::FROM_SESSION_ROOT);
|
||||
|
||||
_dbg_assert_msg_(WII_IPC_ES, ((u32)(_TitleID >> 32) == 0x00010000) || m_NANDContent[_TitleID]->IsValid(), "NandContent not valid for TitleID %08x/%08x", (u32)(_TitleID >> 32), (u32)_TitleID);
|
||||
return *m_NANDContent[_TitleID];
|
||||
_dbg_assert_msg_(WII_IPC_ES, ((u32)(title_id >> 32) == 0x00010000) || m_NANDContent[title_id]->IsValid(), "NandContent not valid for TitleID %08x/%08x", (u32)(title_id >> 32), (u32)title_id);
|
||||
return *m_NANDContent[title_id];
|
||||
}
|
||||
|
||||
bool CWII_IPC_HLE_Device_es::IsValid(u64 _TitleID) const
|
||||
|
@ -144,7 +144,7 @@ private:
|
||||
|
||||
static u8 *keyTable[11];
|
||||
|
||||
const DiscIO::CNANDContentLoader& AccessContentDevice(u64 _TitleID);
|
||||
const DiscIO::CNANDContentLoader& AccessContentDevice(u64 title_id);
|
||||
u32 OpenTitleContent(u32 CFD, u64 TitleID, u16 Index);
|
||||
|
||||
bool IsValid(u64 _TitleID) const;
|
||||
|
@ -38,26 +38,26 @@ CSharedContent::CSharedContent()
|
||||
void CSharedContent::UpdateLocation()
|
||||
{
|
||||
m_Elements.clear();
|
||||
m_lastID = 0;
|
||||
m_contentMap = StringFromFormat("%s/shared1/content.map", File::GetUserPath(D_WIIROOT_IDX).c_str());
|
||||
m_LastID = 0;
|
||||
m_ContentMap = StringFromFormat("%s/shared1/content.map", File::GetUserPath(D_WIIROOT_IDX).c_str());
|
||||
|
||||
File::IOFile pFile(m_contentMap, "rb");
|
||||
File::IOFile pFile(m_ContentMap, "rb");
|
||||
SElement Element;
|
||||
while (pFile.ReadArray(&Element, 1))
|
||||
{
|
||||
m_Elements.push_back(Element);
|
||||
m_lastID++;
|
||||
m_LastID++;
|
||||
}
|
||||
}
|
||||
|
||||
CSharedContent::~CSharedContent()
|
||||
{}
|
||||
|
||||
std::string CSharedContent::GetFilenameFromSHA1(const u8* _pHash)
|
||||
std::string CSharedContent::GetFilenameFromSHA1(const u8* hash)
|
||||
{
|
||||
for (auto& Element : m_Elements)
|
||||
{
|
||||
if (memcmp(_pHash, Element.SHA1Hash, 20) == 0)
|
||||
if (memcmp(hash, Element.SHA1Hash, 20) == 0)
|
||||
{
|
||||
return StringFromFormat("%s/shared1/%c%c%c%c%c%c%c%c.app", File::GetUserPath(D_WIIROOT_IDX).c_str(),
|
||||
Element.FileName[0], Element.FileName[1], Element.FileName[2], Element.FileName[3],
|
||||
@ -67,39 +67,39 @@ std::string CSharedContent::GetFilenameFromSHA1(const u8* _pHash)
|
||||
return "unk";
|
||||
}
|
||||
|
||||
std::string CSharedContent::AddSharedContent(const u8* _pHash)
|
||||
std::string CSharedContent::AddSharedContent(const u8* hash)
|
||||
{
|
||||
std::string filename = GetFilenameFromSHA1(_pHash);
|
||||
std::string filename = GetFilenameFromSHA1(hash);
|
||||
|
||||
if (strcasecmp(filename.c_str(), "unk") == 0)
|
||||
{
|
||||
std::string id = StringFromFormat("%08x", m_lastID);
|
||||
std::string id = StringFromFormat("%08x", m_LastID);
|
||||
SElement Element;
|
||||
memcpy(Element.FileName, id.c_str(), 8);
|
||||
memcpy(Element.SHA1Hash, _pHash, 20);
|
||||
memcpy(Element.SHA1Hash, hash, 20);
|
||||
m_Elements.push_back(Element);
|
||||
|
||||
File::CreateFullPath(m_contentMap);
|
||||
File::CreateFullPath(m_ContentMap);
|
||||
|
||||
File::IOFile pFile(m_contentMap, "ab");
|
||||
File::IOFile pFile(m_ContentMap, "ab");
|
||||
pFile.WriteArray(&Element, 1);
|
||||
|
||||
filename = StringFromFormat("%s/shared1/%s.app", File::GetUserPath(D_WIIROOT_IDX).c_str(), id.c_str());
|
||||
m_lastID++;
|
||||
m_LastID++;
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
CNANDContentLoader::CNANDContentLoader(const std::string& name)
|
||||
CNANDContentLoader::CNANDContentLoader(const std::string& content_name)
|
||||
: m_Valid(false)
|
||||
, m_isWAD(false)
|
||||
, m_IsWAD(false)
|
||||
, m_TitleID(-1)
|
||||
, m_IosVersion(0x09)
|
||||
, m_BootIndex(-1)
|
||||
{
|
||||
m_Valid = Initialize(name);
|
||||
m_Valid = Initialize(content_name);
|
||||
}
|
||||
|
||||
CNANDContentLoader::~CNANDContentLoader()
|
||||
@ -132,9 +132,9 @@ bool CNANDContentLoader::Initialize(const std::string& name)
|
||||
|
||||
if (wad.IsValid())
|
||||
{
|
||||
m_isWAD = true;
|
||||
m_ticket = wad.GetTicket();
|
||||
decrypted_title_key = GetKeyFromTicket(m_ticket);
|
||||
m_IsWAD = true;
|
||||
m_Ticket = wad.GetTicket();
|
||||
decrypted_title_key = GetKeyFromTicket(m_Ticket);
|
||||
tmd = wad.GetTMD();
|
||||
data_app = wad.GetDataApp();
|
||||
}
|
||||
@ -162,7 +162,7 @@ bool CNANDContentLoader::Initialize(const std::string& name)
|
||||
std::copy(&tmd[0x180], &tmd[0x180 + TMD_VIEW_SIZE], m_TMDView);
|
||||
|
||||
m_TitleVersion = Common::swap16(&tmd[0x01DC]);
|
||||
m_numEntries = Common::swap16(&tmd[0x01DE]);
|
||||
m_NumEntries = Common::swap16(&tmd[0x01DE]);
|
||||
m_BootIndex = Common::swap16(&tmd[0x01E0]);
|
||||
m_TitleID = Common::swap64(&tmd[0x018C]);
|
||||
m_IosVersion = Common::swap16(&tmd[0x018A]);
|
||||
@ -177,12 +177,12 @@ bool CNANDContentLoader::Initialize(const std::string& name)
|
||||
|
||||
void CNANDContentLoader::InitializeContentEntries(const std::vector<u8>& tmd, const std::vector<u8>& decrypted_title_key, const std::vector<u8>& data_app)
|
||||
{
|
||||
m_Content.resize(m_numEntries);
|
||||
m_Content.resize(m_NumEntries);
|
||||
|
||||
std::array<u8, 16> iv;
|
||||
u32 data_app_offset = 0;
|
||||
|
||||
for (u32 i = 0; i < m_numEntries; i++)
|
||||
for (u32 i = 0; i < m_NumEntries; i++)
|
||||
{
|
||||
const u32 entry_offset = 0x24 * i;
|
||||
|
||||
@ -200,7 +200,7 @@ void CNANDContentLoader::InitializeContentEntries(const std::vector<u8>& tmd, co
|
||||
const auto hash_end = std::next(hash_begin, ArraySize(content.m_SHA1Hash));
|
||||
std::copy(hash_begin, hash_end, content.m_SHA1Hash);
|
||||
|
||||
if (m_isWAD)
|
||||
if (m_IsWAD)
|
||||
{
|
||||
u32 rounded_size = ROUND_UP(content.m_Size, 0x40);
|
||||
|
||||
@ -292,7 +292,7 @@ void CNANDContentLoader::RemoveTitle() const
|
||||
if (IsValid())
|
||||
{
|
||||
// remove TMD?
|
||||
for (u32 i = 0; i < m_numEntries; i++)
|
||||
for (u32 i = 0; i < m_NumEntries; i++)
|
||||
{
|
||||
if (!(m_Content[i].m_Type & 0x8000)) // skip shared apps
|
||||
{
|
||||
@ -313,14 +313,14 @@ cUIDsys::cUIDsys()
|
||||
void cUIDsys::UpdateLocation()
|
||||
{
|
||||
m_Elements.clear();
|
||||
m_lastUID = 0x00001000;
|
||||
m_uidSys = File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/sys/uid.sys";
|
||||
m_LastUID = 0x00001000;
|
||||
m_UidSys = File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/sys/uid.sys";
|
||||
|
||||
File::IOFile pFile(m_uidSys, "rb");
|
||||
File::IOFile pFile(m_UidSys, "rb");
|
||||
SElement Element;
|
||||
while (pFile.ReadArray(&Element, 1))
|
||||
{
|
||||
*(u32*)&(Element.UID) = Common::swap32(m_lastUID++);
|
||||
*(u32*)&(Element.UID) = Common::swap32(m_LastUID++);
|
||||
m_Elements.push_back(Element);
|
||||
}
|
||||
pFile.Close();
|
||||
@ -328,23 +328,23 @@ void cUIDsys::UpdateLocation()
|
||||
if (m_Elements.empty())
|
||||
{
|
||||
*(u64*)&(Element.titleID) = Common::swap64(TITLEID_SYSMENU);
|
||||
*(u32*)&(Element.UID) = Common::swap32(m_lastUID++);
|
||||
*(u32*)&(Element.UID) = Common::swap32(m_LastUID++);
|
||||
|
||||
File::CreateFullPath(m_uidSys);
|
||||
pFile.Open(m_uidSys, "wb");
|
||||
File::CreateFullPath(m_UidSys);
|
||||
pFile.Open(m_UidSys, "wb");
|
||||
if (!pFile.WriteArray(&Element, 1))
|
||||
ERROR_LOG(DISCIO, "Failed to write to %s", m_uidSys.c_str());
|
||||
ERROR_LOG(DISCIO, "Failed to write to %s", m_UidSys.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
cUIDsys::~cUIDsys()
|
||||
{}
|
||||
|
||||
u32 cUIDsys::GetUIDFromTitle(u64 _Title)
|
||||
u32 cUIDsys::GetUIDFromTitle(u64 title_id)
|
||||
{
|
||||
for (auto& Element : m_Elements)
|
||||
{
|
||||
if (Common::swap64(_Title) == *(u64*)&(Element.titleID))
|
||||
if (Common::swap64(title_id) == *(u64*)&(Element.titleID))
|
||||
{
|
||||
return Common::swap32(Element.UID);
|
||||
}
|
||||
@ -352,33 +352,33 @@ u32 cUIDsys::GetUIDFromTitle(u64 _Title)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cUIDsys::AddTitle(u64 _TitleID)
|
||||
void cUIDsys::AddTitle(u64 title_id)
|
||||
{
|
||||
if (GetUIDFromTitle(_TitleID))
|
||||
if (GetUIDFromTitle(title_id))
|
||||
{
|
||||
INFO_LOG(DISCIO, "Title %08x%08x, already exists in uid.sys", (u32)(_TitleID >> 32), (u32)_TitleID);
|
||||
INFO_LOG(DISCIO, "Title %08x%08x, already exists in uid.sys", (u32)(title_id >> 32), (u32)title_id);
|
||||
return;
|
||||
}
|
||||
|
||||
SElement Element;
|
||||
*(u64*)&(Element.titleID) = Common::swap64(_TitleID);
|
||||
*(u32*)&(Element.UID) = Common::swap32(m_lastUID++);
|
||||
*(u64*)&(Element.titleID) = Common::swap64(title_id);
|
||||
*(u32*)&(Element.UID) = Common::swap32(m_LastUID++);
|
||||
m_Elements.push_back(Element);
|
||||
|
||||
File::CreateFullPath(m_uidSys);
|
||||
File::IOFile pFile(m_uidSys, "ab");
|
||||
File::CreateFullPath(m_UidSys);
|
||||
File::IOFile pFile(m_UidSys, "ab");
|
||||
|
||||
if (!pFile.WriteArray(&Element, 1))
|
||||
ERROR_LOG(DISCIO, "fwrite failed");
|
||||
}
|
||||
|
||||
void cUIDsys::GetTitleIDs(std::vector<u64>& _TitleIDs, bool _owned)
|
||||
void cUIDsys::GetTitleIDs(std::vector<u64>& title_ids, bool owned)
|
||||
{
|
||||
for (auto& Element : m_Elements)
|
||||
{
|
||||
if ((_owned && Common::CheckTitleTIK(Common::swap64(Element.titleID), Common::FROM_SESSION_ROOT)) ||
|
||||
(!_owned && Common::CheckTitleTMD(Common::swap64(Element.titleID), Common::FROM_SESSION_ROOT)))
|
||||
_TitleIDs.push_back(Common::swap64(Element.titleID));
|
||||
if ((owned && Common::CheckTitleTIK(Common::swap64(Element.titleID), Common::FROM_SESSION_ROOT)) ||
|
||||
(!owned && Common::CheckTitleTMD(Common::swap64(Element.titleID), Common::FROM_SESSION_ROOT)))
|
||||
title_ids.push_back(Common::swap64(Element.titleID));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,26 +34,26 @@ struct SNANDContent
|
||||
class CNANDContentLoader final
|
||||
{
|
||||
public:
|
||||
CNANDContentLoader(const std::string& _rName);
|
||||
CNANDContentLoader(const std::string& content_name);
|
||||
virtual ~CNANDContentLoader();
|
||||
|
||||
bool IsValid() const { return m_Valid; }
|
||||
void RemoveTitle() const;
|
||||
u64 GetTitleID() const { return m_TitleID; }
|
||||
u64 GetTitleID() const { return m_TitleID; }
|
||||
u16 GetIosVersion() const { return m_IosVersion; }
|
||||
u32 GetBootIndex() const { return m_BootIndex; }
|
||||
u32 GetBootIndex() const { return m_BootIndex; }
|
||||
size_t GetContentSize() const { return m_Content.size(); }
|
||||
const SNANDContent* GetContentByIndex(int index) const;
|
||||
const u8* GetTMDView() const { return m_TMDView; }
|
||||
const u8* GetTMDHeader() const { return m_TMDHeader; }
|
||||
const std::vector<u8>& GetTicket() const { return m_ticket; }
|
||||
const std::vector<u8>& GetTicket() const { return m_Ticket; }
|
||||
|
||||
const std::vector<SNANDContent>& GetContent() const { return m_Content; }
|
||||
|
||||
u16 GetTitleVersion() const {return m_TitleVersion;}
|
||||
u16 GetNumEntries() const {return m_numEntries;}
|
||||
u16 GetTitleVersion() const { return m_TitleVersion; }
|
||||
u16 GetNumEntries() const { return m_NumEntries; }
|
||||
DiscIO::IVolume::ECountry GetCountry() const;
|
||||
u8 GetCountryChar() const {return m_Country; }
|
||||
u8 GetCountryChar() const { return m_Country; }
|
||||
|
||||
enum
|
||||
{
|
||||
@ -71,16 +71,16 @@ private:
|
||||
static std::vector<u8> GetKeyFromTicket(const std::vector<u8>& ticket);
|
||||
|
||||
bool m_Valid;
|
||||
bool m_isWAD;
|
||||
bool m_IsWAD;
|
||||
std::string m_Path;
|
||||
u64 m_TitleID;
|
||||
u16 m_IosVersion;
|
||||
u32 m_BootIndex;
|
||||
u16 m_numEntries;
|
||||
u16 m_NumEntries;
|
||||
u16 m_TitleVersion;
|
||||
u8 m_TMDView[TMD_VIEW_SIZE];
|
||||
u8 m_TMDHeader[TMD_HEADER_SIZE];
|
||||
std::vector<u8> m_ticket;
|
||||
std::vector<u8> m_Ticket;
|
||||
u8 m_Country;
|
||||
|
||||
std::vector<SNANDContent> m_Content;
|
||||
@ -96,7 +96,7 @@ public:
|
||||
|
||||
const CNANDContentLoader& GetNANDLoader(const std::string& content_path);
|
||||
const CNANDContentLoader& GetNANDLoader(u64 title_id, Common::FromWhichRoot from);
|
||||
bool RemoveTitle(u64 titl_id, Common::FromWhichRoot from);
|
||||
bool RemoveTitle(u64 title_id, Common::FromWhichRoot from);
|
||||
void ClearCache();
|
||||
|
||||
private:
|
||||
@ -114,8 +114,8 @@ class CSharedContent
|
||||
public:
|
||||
static CSharedContent& AccessInstance() { static CSharedContent instance; return instance; }
|
||||
|
||||
std::string GetFilenameFromSHA1(const u8* _pHash);
|
||||
std::string AddSharedContent(const u8* _pHash);
|
||||
std::string GetFilenameFromSHA1(const u8* hash);
|
||||
std::string AddSharedContent(const u8* hash);
|
||||
void UpdateLocation();
|
||||
|
||||
private:
|
||||
@ -133,8 +133,8 @@ private:
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
u32 m_lastID;
|
||||
std::string m_contentMap;
|
||||
u32 m_LastID;
|
||||
std::string m_ContentMap;
|
||||
std::vector<SElement> m_Elements;
|
||||
};
|
||||
|
||||
@ -143,9 +143,9 @@ class cUIDsys
|
||||
public:
|
||||
static cUIDsys& AccessInstance() { static cUIDsys instance; return instance; }
|
||||
|
||||
u32 GetUIDFromTitle(u64 _Title);
|
||||
void AddTitle(u64 _Title);
|
||||
void GetTitleIDs(std::vector<u64>& _TitleIDs, bool _owned = false);
|
||||
u32 GetUIDFromTitle(u64 title_id);
|
||||
void AddTitle(u64 title_id);
|
||||
void GetTitleIDs(std::vector<u64>& title_ids, bool owned = false);
|
||||
void UpdateLocation();
|
||||
|
||||
private:
|
||||
@ -163,8 +163,8 @@ private:
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
u32 m_lastUID;
|
||||
std::string m_uidSys;
|
||||
u32 m_LastUID;
|
||||
std::string m_UidSys;
|
||||
std::vector<SElement> m_Elements;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user