Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion xbiso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cinttypes>
#include "optionparser.h"
#include <xbisoConfig.h>

Expand Down Expand Up @@ -94,6 +96,8 @@ int main (int argc, char* argv[])
{
argc -= (argc>0); argv += (argc>0);

xdvdfs::mfile = fopen("meta.txt", "wb");

option::Stats stats(usage, argc, argv);
std::vector<option::Option> options(stats.options_max);
std::vector<option::Option> buffer(stats.buffer_max);
Expand Down Expand Up @@ -173,7 +177,8 @@ void handleDirectoryEntry (std::ifstream& file, xdvdfs::DirectoryEntry& dirent)
}
else
{
std::cout << "extracting " << dirent.getFilename() << std::endl;
uint64_t offset = xdvdfs::SECTOR_SIZE * dirent.startSector + xdvdfs::OFFSET;
std::fprintf(xdvdfs::mfile, "%" PRIu64 " %" PRIu64 " file '%s'\n", offset, offset + dirent.getFileSize() - 1, dirent.getFilename().c_str());

if (!dryRun)
{
Expand Down
18 changes: 14 additions & 4 deletions xdvdfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <vector>
#include <cstring>
#include <iostream>
#include <cstdio>
#include <cinttypes>

FILE* xdvdfs::mfile = NULL;

// TODO: support for big endian architectures

Expand All @@ -11,7 +15,9 @@ void xdvdfs::VolumeDescriptor::readFromFile (std::ifstream& file)
std::vector<char> buffer(2048);

// read the whole sector
file.seekg(VOLUME_DESCRIPTOR_SECTOR*SECTOR_SIZE, file.beg);
uint64_t offset = VOLUME_DESCRIPTOR_SECTOR*SECTOR_SIZE + OFFSET;
fprintf(mfile, "%" PRIu64 " %" PRIu64 " volume_desc\n", offset, offset + 4096 - 1);
file.seekg(offset, file.beg);
file.read(buffer.data(), buffer.size());

// TODO: couldn't we use the stream operator instead?
Expand Down Expand Up @@ -47,12 +53,13 @@ xdvdfs::DirectoryEntry xdvdfs::VolumeDescriptor::getRootDirEntry (std::ifstream&
return dirent;
}

void xdvdfs::DirectoryEntry::readFromFile (std::ifstream& file, std::streampos sector, std::streampos offset)
void xdvdfs::DirectoryEntry::readFromFile (std::ifstream& file, std::streampos sector, std::streampos file_offset)
{
std::vector<char> buffer(2048);

// read the whole sector
file.seekg(sector*xdvdfs::SECTOR_SIZE + offset, file.beg);
uint64_t offset = sector*xdvdfs::SECTOR_SIZE + file_offset + OFFSET;
file.seekg(offset, file.beg);
file.read(buffer.data(), buffer.size());

std::copy(buffer.begin(), buffer.begin()+0x02, reinterpret_cast<char*>(&this->leftSubTree));
Expand All @@ -65,6 +72,8 @@ void xdvdfs::DirectoryEntry::readFromFile (std::ifstream& file, std::streampos s
uint8_t* filenameLength = reinterpret_cast<uint8_t*>(&buffer[0x0D]);
this->filename = std::string(&buffer[0x0E], *filenameLength);

fprintf(mfile, "%" PRIu64 " %" PRIu64 " dirent '%s'\n", offset, offset + buffer.size() - 1, this->filename.c_str());

this->sectorNumber = sector;

// endianess conversion
Expand Down Expand Up @@ -92,7 +101,8 @@ void xdvdfs::DirectoryEntry::extractFile(std::ifstream& file, std::ofstream& ofi
std::vector<char> buffer(4096);
std::size_t filesize = this->fileSize;

file.seekg(xdvdfs::SECTOR_SIZE * this->startSector);
uint64_t offset = xdvdfs::SECTOR_SIZE * this->startSector + OFFSET;
file.seekg(offset, file.beg);

while (filesize > 0)
{
Expand Down
7 changes: 6 additions & 1 deletion xdvdfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

namespace xdvdfs
{
static const uint64_t OFFSET = 198144*2048;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might actually be my hack to support redump XISO?


static const int SECTOR_SIZE = 2048;
static const int VOLUME_DESCRIPTOR_SECTOR = 32;

static const char MAGIC_NUMBER[] = "MICROSOFT*XBOX*MEDIA";

extern FILE* mfile;

class Exception : public std::exception
{
public:
Expand Down Expand Up @@ -81,10 +85,11 @@ namespace xdvdfs
static const uint8_t FILE_ARCHIVE = 0x20;
static const uint8_t FILE_NORMAL = 0x80;

uint32_t startSector;

private:
uint16_t leftSubTree;
uint16_t rightSubTree;
uint32_t startSector;
uint32_t fileSize;
uint8_t attributes;
std::string filename;
Expand Down