Ryan-rsm-McKenzie / bsa

C++ library for working with the Bethesda archive file format
MIT License
41 stars 6 forks source link

Textures are not written correctly #5

Closed Guekka closed 2 years ago

Guekka commented 2 years ago

I am able to reproduce this bug with this simple code

#include <bsa/fo4.hpp>

int main()
{
    using namespace bsa::fo4;
    file f;
    f.read("textures/in.dds", format::directx);
    f.write("textures/out.dds", format::directx);
}

This corrupts all tested textures. : Example

By looking at it in a hex editor, the header appears to be fine. The corruption starts at the end of the header, as soon as we enter the data section

The issue appears to be in write . Creating a textures BSA, and extracting it with another tool seems to work

Guekka commented 2 years ago

Well, I investigated a bit more. By looking more closely in a hex editor, the issue is simpler than I thought

Some (20) CD bytes were inserted right after the header and before the data. The rest of the data is fine, just shifted

Guekka commented 2 years ago

These bytes are in the place of the DX10 header. Maybe we need to force creation of a DX10 header

Ryan-rsm-McKenzie commented 2 years ago

fixed by #6