-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add C++ port #3
base: master
Are you sure you want to change the base?
Add C++ port #3
Conversation
Easily buildable For Linux: g++ main.cpp -llz4 For Windows: x86_64-w64-mingw32-g++ main.cpp -llz4 -static
try { | ||
f.seekg(0x18310000, std::ios::beg); | ||
} catch (std::exception const& e) { | ||
std::cout << "File not big enough to be a Redump style image." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Why are we flushing on almost every cout, and some cerr's where we immediately exit, are we not trusting the OS?
const std::string CISO_MAGIC = "CISO"; | ||
const uint32_t CISO_HEADER_SIZE = 0x18; | ||
const uint32_t CISO_BLOCK_SIZE = 0x800; | ||
const uint32_t CISO_PLAIN_BLOCK = 0x80000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Above should probably be constexpr
|
||
void detect_iso_type(std::ifstream& f) { | ||
try { | ||
f.seekg(0x18310000, std::ios::beg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Magic offsets all over
if (f.tellg() == 0x18310000) { | ||
std::string buf(20, '\0'); | ||
f.read(&buf[0], 20); | ||
if (buf == "MICROSOFT*XBOX*MEDIA") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Used more than once should probably be a constexpr var
|
||
uint32_t get_block_size() { return block_size; }; | ||
uint32_t get_total_blocks() { return total_blocks; }; | ||
uint32_t get_align() { return align; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Extra ;
?
|
||
void write_block_index(std::ofstream& f, std::vector<uint32_t> const& block_index) { | ||
for (uint32_t i: block_index) { | ||
f.write((char*)&i, sizeof(i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: C style casts throughout
std::cerr << "CompressionContext creation failed, exiting..."; | ||
exit(2); | ||
} | ||
std::ofstream fout_1(infile + ".1.cso", std::ios::binary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Output file should truncate the .iso
.
Non-functional
Produces a ~2.6GB ISO that does not work. |
Do you get a different result if you use the mingw64 packages ( |
Same thing. |
Same thing on WSL. Untested? |
Works fine on my machines, both under Linux and MinGW64. Sorry, not sure what to tell you. |
Ah, damn. I had looked into this PR before and confirmed the issue that @GXTX was running into. It appears related to large files, but I must have forgotten to track which flags must be set to build the code correctly. |
|
||
ciso (std::ifstream &f) { | ||
f.seekg(0, std::ios::end); | ||
uint32_t file_size = (int32_t)f.tellg() - image_offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be causing issues, should (probably) be uint64_t
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That brings us closer at least; now redump input results in two files with reasonable sizes. Output doesn't match the python script past the header though...
Easily buildable
For Linux:
g++ main.cpp -llz4
For Windows:
x86_64-w64-mingw32-g++ main.cpp -llz4 -static