DDS Texture archive, extract with real filenames

Textures, recreate headers, conversions, algorithms and parsing of image files
beastedot9
Posts: 9
Joined: Mon Mar 07, 2016 4:54 pm

DDS Texture archive, extract with real filenames

Post by beastedot9 »

Hello everyone, I'm having a little issue with these texture archives. I can extract them but I'm wondering what I could do with the script to get the filenames and make the files output with those. Because right now the files extract with 0000000000.dds, 00000000001.dds etc.

Here is a screenshot of the archive:

Image

The bit marked in red is the number of archives, the green highlighted area is the filename and the blue highlighted area is the offset of the texture in the archive (little endian). 4 bytes before the offset is the file size of the textures I'm assuming.

So far I'm using this script by AlphaTwentyThree to extract the DDS files where it finds instances of them:

Code: Select all

findloc OFFSET string "DDS"
do
    goto OFFSET
    get DUMMY long
    findloc NEXT_OFFSET string "DDS" 0 ""
    if NEXT_OFFSET == ""
        get SIZE asize
    else
        math SIZE = NEXT_OFFSET
    endif
    math SIZE -= OFFSET
    log "" OFFSET SIZE
    math OFFSET = NEXT_OFFSET
while NEXT_OFFSET != ""


How can I rewrite this to also get the filenames and extract the files with the names? Any help is appreciated.

Also a sample file if needed: https://mega.nz/#!1xw1FT6C!Z2bFmvHKYpLi ... F9xn-4XAAs
MerlinSVK
Posts: 165
Joined: Wed Aug 13, 2014 10:00 am

Re: DDS Texture archive, extract with real filenames

Post by MerlinSVK »

It's not super cool, but it works. At least on that provided example file.

Code: Select all

get FILES long
get UNK1 long
get UNK2 long
get MAXNAMESIZE long
for i = 0 < FILES
get FBASENAME string
   savepos POSITION
   strlen NAMELENGTH FBASENAME
   xmath POSITION "POSITION + (MAXNAMESIZE - NAMELENGTH) - 0x01"
goto POSITION
get FEXTNAME string
   string FBASENAME + "."
   string FBASENAME + FEXTNAME
get FSIZE long
get FOFFSET long
get NULL long
   log FBASENAME FOFFSET FSIZE
next i
beastedot9
Posts: 9
Joined: Mon Mar 07, 2016 4:54 pm

Re: DDS Texture archive, extract with real filenames

Post by beastedot9 »

It's been a while but I just want to say thank you for taking the time to help out, really appreciate it :)