mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-27 10:09:52 +00:00
some intial work on PKG reading
This commit is contained in:
parent
7c552ddb38
commit
711e9e917d
|
@ -34,6 +34,14 @@ public:
|
|||
U64 Tell() const;
|
||||
~FsFile();
|
||||
|
||||
template< typename T > bool ReadBE(T& dst)
|
||||
{
|
||||
if (!Read(&dst, sizeof(T))) {
|
||||
return false;
|
||||
}
|
||||
::ReadBE(dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* getOpenMode(fsOpenMode mode)
|
||||
{
|
||||
|
|
31
shadPS4/emulator/fileFormat/PKG.cpp
Normal file
31
shadPS4/emulator/fileFormat/PKG.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "PKG.h"
|
||||
#include "../../core/FsFile.h"
|
||||
|
||||
PKG::PKG()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PKG::~PKG()
|
||||
{
|
||||
}
|
||||
|
||||
bool PKG::open(const std::string& filepath) {
|
||||
FsFile file;
|
||||
if (!file.Open(filepath, fsRead))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pkgSize = file.getFileSize();
|
||||
PKGHeader pkgheader;
|
||||
file.ReadBE(pkgheader);
|
||||
//we have already checked magic should be ok
|
||||
|
||||
//find title id it is part of pkg_content_id starting at offset 0x40
|
||||
file.Seek(0x47, fsSeekSet);//skip first 7 characters of content_id
|
||||
file.Read(&pkgTitleID, sizeof(pkgTitleID));
|
||||
|
||||
file.Close();
|
||||
|
||||
return true;
|
||||
}
|
29
shadPS4/emulator/fileFormat/PKG.h
Normal file
29
shadPS4/emulator/fileFormat/PKG.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "../../Types.h"
|
||||
|
||||
struct PKGHeader {
|
||||
/*BE*/U32 magic; // Magic
|
||||
};
|
||||
|
||||
class PKG
|
||||
{
|
||||
private:
|
||||
U08* pkg;
|
||||
U64 pkgSize = 0;
|
||||
S08 pkgTitleID[9];
|
||||
|
||||
public:
|
||||
PKG();
|
||||
~PKG();
|
||||
bool open(const std::string& filepath);
|
||||
U64 getPkgSize()
|
||||
{
|
||||
return pkgSize;
|
||||
}
|
||||
std::string getTitleID()
|
||||
{
|
||||
return std::string(pkgTitleID);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
#include "shadps4gui.h"
|
||||
#include "../emulator/Loader.h"
|
||||
#include "../emulator/fileFormat/PKG.h"
|
||||
#include "../core/FsFile.h"
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QProgressDialog>
|
||||
|
||||
shadps4gui::shadps4gui(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
|
@ -22,7 +26,9 @@ void shadps4gui::installPKG()
|
|||
std::string file(QFileDialog::getOpenFileName(this, tr("Install PKG File"), QDir::currentPath(), tr("PKG File (*.PKG)")).toStdString());
|
||||
if (detectFileType(file) == FILETYPE_PKG)
|
||||
{
|
||||
|
||||
PKG pkg;
|
||||
pkg.open(file);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="core\FsFile.cpp" />
|
||||
<ClCompile Include="emulator\fileFormat\PKG.cpp" />
|
||||
<ClCompile Include="emulator\fileFormat\PSF.cpp" />
|
||||
<ClCompile Include="emulator\Loader.cpp" />
|
||||
<ClCompile Include="gui\GameListViewer.cpp" />
|
||||
|
@ -29,6 +30,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="core\FsFile.h" />
|
||||
<ClInclude Include="emulator\fileFormat\PKG.h" />
|
||||
<ClInclude Include="emulator\fileFormat\PSF.h" />
|
||||
<ClInclude Include="emulator\Loader.h" />
|
||||
<ClInclude Include="Types.h" />
|
||||
|
|
|
@ -53,6 +53,9 @@
|
|||
<ClCompile Include="emulator\Loader.cpp">
|
||||
<Filter>emulator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="emulator\fileFormat\PKG.cpp">
|
||||
<Filter>emulator\fileFormat</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="gui\shadps4gui.ui">
|
||||
|
@ -80,5 +83,8 @@
|
|||
<ClInclude Include="emulator\Loader.h">
|
||||
<Filter>emulator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="emulator\fileFormat\PKG.h">
|
||||
<Filter>emulator\fileFormat</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in a new issue