diff --git a/libuuu/rominfo.cpp b/libuuu/rominfo.cpp index c92a647a..89b51a28 100644 --- a/libuuu/rominfo.cpp +++ b/libuuu/rominfo.cpp @@ -94,6 +94,7 @@ const ROM_INFO * search_rom_info(const ConfigItem *item) #define CONTAINER_HDR_ALIGNMENT 0x400 #define CONTAINER_HDR_ALIGNMENT_V2 0x4000 static constexpr uint8_t CONTAINER_TAG = 0x87; +static constexpr uint8_t V2X_TAG = 0x82; // After imx943 #pragma pack (1) struct rom_container { @@ -130,6 +131,7 @@ static constexpr uint32_t IMG_V2X = 0x0B; size_t GetContainerActualSize(shared_ptr p, size_t offset, bool bROMAPI, bool skipspl) { uint32_t align = CONTAINER_HDR_ALIGNMENT; + unsigned int cindex = 1; if(bROMAPI) return p->size() - offset; @@ -142,30 +144,33 @@ size_t GetContainerActualSize(shared_ptr p, size_t offset, bool bROM else if (hdr->version >= 2) { /* after imx943 align change to 0x4000 from 0x400 */ align = CONTAINER_HDR_ALIGNMENT_V2; + hdr = reinterpret_cast(p->data() + offset + align); + if (hdr->tag == V2X_TAG) + cindex++; } - - hdr = reinterpret_cast(p->data() + offset + align); - if (hdr->tag != CONTAINER_TAG) - { - return p->size() - offset; - } - - /* Check if include V2X container*/ - auto image = reinterpret_cast(p->data() + offset + align - + sizeof(struct rom_container)); - - unsigned int cindex = 1; - if ((image->flags & 0xF) == IMG_V2X) + else { - cindex = 2; - hdr = reinterpret_cast(p->data() + offset + cindex * align); + hdr = reinterpret_cast(p->data() + offset + align); if (hdr->tag != CONTAINER_TAG) - { + { return p->size() - offset; } + + /* Check if include V2X container*/ + auto image = reinterpret_cast(p->data() + offset + align + + sizeof(struct rom_container)); + + if ((image->flags & 0xF) == IMG_V2X) + cindex++; + } + + hdr = reinterpret_cast(p->data() + offset + cindex * align); + if (hdr->tag != CONTAINER_TAG) + { + return p->size() - offset; } - image = reinterpret_cast(p->data() + offset + cindex * align + auto image = reinterpret_cast(p->data() + offset + cindex * align + sizeof(struct rom_container) + sizeof(struct rom_bootimg) * (hdr->num_images - 1));