mirror of
https://github.com/jakcron/nstool
synced 2024-12-25 22:21:13 +00:00
[nx] Updated FacHeader/FacBinary
This commit is contained in:
parent
c4c2610417
commit
19bd03630d
3 changed files with 17 additions and 19 deletions
|
@ -56,10 +56,10 @@ namespace nx
|
||||||
void setFsaRightsList(const fnd::List<fac::FsAccessFlag>& list);
|
void setFsaRightsList(const fnd::List<fac::FsAccessFlag>& list);
|
||||||
|
|
||||||
const sSection& getContentOwnerIdPos() const;
|
const sSection& getContentOwnerIdPos() const;
|
||||||
void setContentOwnerIdSize(size_t size);
|
void setContentOwnerIdPos(const sSection& pos);
|
||||||
|
|
||||||
const sSection& getSaveDataOwnerIdPos() const;;
|
const sSection& getSaveDataOwnerIdPos() const;;
|
||||||
void setSaveDataOwnerIdSize(size_t size);
|
void setSaveDataOwnerIdPos(const sSection& pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string kModuleName = "FAC_HEADER";
|
const std::string kModuleName = "FAC_HEADER";
|
||||||
|
@ -72,8 +72,6 @@ namespace nx
|
||||||
fnd::List<fac::FsAccessFlag> mFsaRights;
|
fnd::List<fac::FsAccessFlag> mFsaRights;
|
||||||
sSection mContentOwnerIdPos;
|
sSection mContentOwnerIdPos;
|
||||||
sSection mSaveDataOwnerIdPos;
|
sSection mSaveDataOwnerIdPos;
|
||||||
|
|
||||||
void calculateOffsets();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,22 +42,29 @@ void nx::FacBinary::toBytes()
|
||||||
{
|
{
|
||||||
FacHeader hdr;
|
FacHeader hdr;
|
||||||
|
|
||||||
|
FacHeader::sSection content_id_list_pos, savedata_owner_id_list_pos;
|
||||||
|
|
||||||
|
content_id_list_pos.size = mContentOwnerIdList.size() * sizeof(uint32_t);
|
||||||
|
content_id_list_pos.offset = align(sizeof(sFacHeader), 4);
|
||||||
|
savedata_owner_id_list_pos.size = mSaveDataOwnerIdList.size() * sizeof(uint32_t);
|
||||||
|
savedata_owner_id_list_pos.offset = content_id_list_pos.offset + align(content_id_list_pos.size, 4);
|
||||||
|
|
||||||
hdr.setFormatVersion(fac::kFacFormatVersion);
|
hdr.setFormatVersion(fac::kFacFormatVersion);
|
||||||
hdr.setFsaRightsList(mFsaRights);
|
hdr.setFsaRightsList(mFsaRights);
|
||||||
hdr.setContentOwnerIdSize(mContentOwnerIdList.size() * sizeof(uint32_t));
|
hdr.setContentOwnerIdPos(content_id_list_pos);
|
||||||
hdr.setSaveDataOwnerIdSize(mSaveDataOwnerIdList.size() * sizeof(uint32_t));
|
hdr.setSaveDataOwnerIdPos(savedata_owner_id_list_pos);
|
||||||
hdr.toBytes();
|
hdr.toBytes();
|
||||||
|
|
||||||
mRawBinary.alloc(hdr.getFacSize());
|
mRawBinary.alloc(hdr.getFacSize());
|
||||||
memcpy(mRawBinary.data(), hdr.getBytes().data(), hdr.getBytes().size());
|
memcpy(mRawBinary.data(), hdr.getBytes().data(), hdr.getBytes().size());
|
||||||
|
|
||||||
uint32_t* rawContentOwnerIds = (uint32_t*)(mRawBinary.data() + hdr.getContentOwnerIdPos().offset);
|
uint32_t* rawContentOwnerIds = (uint32_t*)(mRawBinary.data() + content_id_list_pos.offset);
|
||||||
for (size_t i = 0; i < mContentOwnerIdList.size(); i++)
|
for (size_t i = 0; i < mContentOwnerIdList.size(); i++)
|
||||||
{
|
{
|
||||||
rawContentOwnerIds[i] = le_word(mContentOwnerIdList[i]);
|
rawContentOwnerIds[i] = le_word(mContentOwnerIdList[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t* rawSaveDataOwnerIds = (uint32_t*)(mRawBinary.data() + hdr.getSaveDataOwnerIdPos().offset);
|
uint32_t* rawSaveDataOwnerIds = (uint32_t*)(mRawBinary.data() + savedata_owner_id_list_pos.offset);
|
||||||
for (size_t i = 0; i < mSaveDataOwnerIdList.size(); i++)
|
for (size_t i = 0; i < mSaveDataOwnerIdList.size(); i++)
|
||||||
{
|
{
|
||||||
rawSaveDataOwnerIds[i] = le_word(mSaveDataOwnerIdList[i]);
|
rawSaveDataOwnerIds[i] = le_word(mSaveDataOwnerIdList[i]);
|
||||||
|
|
|
@ -61,7 +61,6 @@ void nx::FacHeader::toBytes()
|
||||||
}
|
}
|
||||||
hdr->fac_flags = (flag);
|
hdr->fac_flags = (flag);
|
||||||
|
|
||||||
calculateOffsets();
|
|
||||||
hdr->content_owner_ids.start = (uint32_t)(mContentOwnerIdPos.offset);
|
hdr->content_owner_ids.start = (uint32_t)(mContentOwnerIdPos.offset);
|
||||||
hdr->content_owner_ids.end = (uint32_t)(mContentOwnerIdPos.offset + mContentOwnerIdPos.size);
|
hdr->content_owner_ids.end = (uint32_t)(mContentOwnerIdPos.offset + mContentOwnerIdPos.size);
|
||||||
hdr->save_data_owner_ids.start = (uint32_t)(mSaveDataOwnerIdPos.offset);
|
hdr->save_data_owner_ids.start = (uint32_t)(mSaveDataOwnerIdPos.offset);
|
||||||
|
@ -151,9 +150,9 @@ const nx::FacHeader::sSection& nx::FacHeader::getContentOwnerIdPos() const
|
||||||
return mContentOwnerIdPos;
|
return mContentOwnerIdPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nx::FacHeader::setContentOwnerIdSize(size_t size)
|
void nx::FacHeader::setContentOwnerIdPos(const sSection& pos)
|
||||||
{
|
{
|
||||||
mContentOwnerIdPos.size = size;
|
mContentOwnerIdPos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nx::FacHeader::sSection& nx::FacHeader::getSaveDataOwnerIdPos() const
|
const nx::FacHeader::sSection& nx::FacHeader::getSaveDataOwnerIdPos() const
|
||||||
|
@ -161,13 +160,7 @@ const nx::FacHeader::sSection& nx::FacHeader::getSaveDataOwnerIdPos() const
|
||||||
return mSaveDataOwnerIdPos;
|
return mSaveDataOwnerIdPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nx::FacHeader::setSaveDataOwnerIdSize(size_t size)
|
void nx::FacHeader::setSaveDataOwnerIdPos(const sSection& pos)
|
||||||
{
|
{
|
||||||
mSaveDataOwnerIdPos.size = size;
|
mSaveDataOwnerIdPos = pos;
|
||||||
}
|
|
||||||
|
|
||||||
void nx::FacHeader::calculateOffsets()
|
|
||||||
{
|
|
||||||
mContentOwnerIdPos.offset = align(sizeof(sFacHeader), 4);
|
|
||||||
mSaveDataOwnerIdPos.offset = mContentOwnerIdPos.offset + align(mContentOwnerIdPos.size, 4);
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue