Implement DXBC ReplaceChunk adding a new chunk if it's not present

This commit is contained in:
baldurk
2024-01-22 14:10:43 +00:00
parent a232dc9a40
commit f7eccf03ff
@@ -743,6 +743,20 @@ void DXBCContainer::ReplaceChunk(bytebuf &ByteCode, uint32_t fourcc, const byte
return;
}
}
uint32_t newOffs = uint32_t(ByteCode.size() + sizeof(uint32_t));
ByteCode.insert(sizeof(FileHeader) + header->numChunks * sizeof(uint32_t), (byte *)&newOffs,
sizeof(newOffs));
for(uint32_t chunkIdx = 0; chunkIdx < header->numChunks; chunkIdx++)
chunkOffsets[chunkIdx] += sizeof(uint32_t);
ByteCode.append(replacement, size);
header->numChunks++;
header->fileLength = (uint32_t)ByteCode.size();
HashContainer(ByteCode.data(), ByteCode.size());
}
const byte *DXBCContainer::FindChunk(const bytebuf &ByteCode, uint32_t fourcc, size_t &size)