Black Desert Online Modding Tools (2 Viewers)

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Thanks for the info. I probably will not be able to dig in today, but probably over the weekend.

Just from my readthrough, I believe the 2 ints that are written by the injector, being the two right after the hash, are the folder and file numbers? Something like folder number 1 and file number for the region specific file?

ZSize looks like a compressed file size, so it knows how many bytes to read before decompressing to a pre-allocated Size bytes buffer when loading.
 

BlackFireBR

Content Creator
Joined
Sep 2, 2013
Thanks for the info. I probably will not be able to dig in today, but probably over the weekend.

Just from my readthrough, I believe the 2 ints that are written by the injector, being the two right after the hash, are the folder and file numbers? Something like folder number 1 and file number for the region specific file?

ZSize looks like a compressed file size, so it knows how many bytes to read before decompressing to a pre-allocated Size bytes buffer when loading.
Yes, they are folder number and file numbers. I got them from bdmod.exe, each region it patched with a different file number. I don't know if they have to be exactly that, or it could be any number so the game simply doesn't find the entry in the pad00000.meta file and it has to look in the game's folders.
Interesting enough is that you patch with the same 2 ints, regardless of the file you are patching, and it works.
Very interesting theory regarding the zsize and size values, I think you might be right.

Let me know if you find more about this.
 

Taira ミズ

Potential Patron
Joined
Apr 14, 2016
Hello! Сan fix something like this in the Russian version ?
Gaint.JPG

used: phm_00_uw_0015 - empty
phm_00_uw_0015_dec - empty
phm_00_uw_0015_n - empty
phm_00_uw_0015_ao - fill yellow
 

Attachments

texture.zip
1.6 KB · Views: 133

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Yes, they are folder number and file numbers. I got them from bdmod.exe, each region it patched with a different file number. I don't know if they have to be exactly that, or it could be any number so the game simply doesn't find the entry in the pad00000.meta file and it has to look in the game's folders.
Interesting enough is that you patch with the same 2 ints, regardless of the file you are patching, and it works.
Very interesting theory regarding the zsize and size values, I think you might be right.

Let me know if you find more about this.

If I had to guess, based off what you are saying:

The meta file is not what determines what an asset is for a given hash, it determines which PAZ file contains that asset in the "packed" version of the game. Content is normally referenced as "/character/texture/pkw_00_uw_0001.dds" in their setup during development. They then process it into PAZ files as part of preparing the game for release, and the META file is the indexing table into the PAZ files. That is, when someone looks up the file name "pkw_00_uw_0001.dds" in the folder "character/texture/" it will find that pair, then look up that pair in the META file data, and find the PAZ file number and offset (SizeZ would be the offset).

UE3 and UE4 (which I have some experience with) both do similar things when "cooking" which is the unreal term for turning raw assets into a shipping package. UE4 especially when it creates PAK files, though for those I believe the index is embedded into the file itself.

If the primary lookup value is actually the strings, then file is actually laid out in memory in the reverse of how it is actually used. The lookup chain is from the "bottom" (strings) to the "top" (PAZ file number, size, offset). It makes sense (to me) to do it this way so that forward linkages can be created as the file is loaded. It first loads the raw PAZ data, then loads file hash data that points towards the (now in memory) PAZ data, then creates folder/string lookup data that points to the (now in memory) file hash data.

At that point, the game logic would be the following:
  1. Get input string ("character/texture/filename.dds") and break into folder string ("character/texture/") and filename string ("filename.dds")
  2. Look up folder string in folder look up table, get folder index
  3. Look up file name in file name look up table, get file index
  4. Folder index is assigned to first entry in a struct, file index as second (for ease of use)
  5. Struct is looked up in file map table to get PAZ name, PAZ offset, and PAZ size
    1. If lookup succeeds
      1. Open PAZ file
      2. Seek to offset
      3. Read size bytes
    2. Else If lookup fails
      1. Try to open input string in file system relative to game install path
      2. If file exists
        1. Open file
        2. Read to end of file


All of this is speculation, but it means a truly exhaustive patcher would actually read the decrypted strings, find the indexes, lookup those indexes, then break the linkage by the index lookup rather than the file hash. If the file hash is actually just a checksum for doing verification, it would be possible for there to be duplicates in the file, so it may not be a unique index.
 

Heinz Boesel

Vivacious Visitor
Joined
Mar 6, 2016
Oi BlackFire!

In your Resorepless Mod, you managed to patch the witch texture so that the beautiful Joku's works for witches as well... but with the MetaInjector, this doesn't work anymore... can this somehow be fixed?
 

Kenith

Club Regular
Joined
Mar 7, 2016
I change Phw_00_ub_0039.dds to Phw_00_ub_0039.dds file ( same name and different texture ) in character and paz folder
then The texture is changed to Phw_00_ub_0039.dds file's
I didn't restart BDO, but change character
 

BlackFireBR

Content Creator
Joined
Sep 2, 2013
If I had to guess, based off what you are saying:

The meta file is not what determines what an asset is for a given hash, it determines which PAZ file contains that asset in the "packed" version of the game. Content is normally referenced as "/character/texture/pkw_00_uw_0001.dds" in their setup during development. They then process it into PAZ files as part of preparing the game for release, and the META file is the indexing table into the PAZ files. That is, when someone looks up the file name "pkw_00_uw_0001.dds" in the folder "character/texture/" it will find that pair, then look up that pair in the META file data, and find the PAZ file number and offset (SizeZ would be the offset).

UE3 and UE4 (which I have some experience with) both do similar things when "cooking" which is the unreal term for turning raw assets into a shipping package. UE4 especially when it creates PAK files, though for those I believe the index is embedded into the file itself.

If the primary lookup value is actually the strings, then file is actually laid out in memory in the reverse of how it is actually used. The lookup chain is from the "bottom" (strings) to the "top" (PAZ file number, size, offset). It makes sense (to me) to do it this way so that forward linkages can be created as the file is loaded. It first loads the raw PAZ data, then loads file hash data that points towards the (now in memory) PAZ data, then creates folder/string lookup data that points to the (now in memory) file hash data.

At that point, the game logic would be the following:
  1. Get input string ("character/texture/filename.dds") and break into folder string ("character/texture/") and filename string ("filename.dds")
  2. Look up folder string in folder look up table, get folder index
  3. Look up file name in file name look up table, get file index
  4. Folder index is assigned to first entry in a struct, file index as second (for ease of use)
  5. Struct is looked up in file map table to get PAZ name, PAZ offset, and PAZ size
    1. If lookup succeeds
      1. Open PAZ file
      2. Seek to offset
      3. Read size bytes
    2. Else If lookup fails
      1. Try to open input string in file system relative to game install path
      2. If file exists
        1. Open file
        2. Read to end of file


All of this is speculation, but it means a truly exhaustive patcher would actually read the decrypted strings, find the indexes, lookup those indexes, then break the linkage by the index lookup rather than the file hash. If the file hash is actually just a checksum for doing verification, it would be possible for there to be duplicates in the file, so it may not be a unique index.

This is very interesting, and that's exactly what I was thinking, but you added a few more details that makes total sense. I never thought they do a lookup for the hash. I know the hash is only for checksum, and I know it's unique, that's why I use it to find the entry I want to patch.

Actually, I got the image wrong of the "File Blocks" struct.
It's actually like this, according to the quickbms script:
Code:
        get HASH long
        get FOLDER_NUM long # 48c
        get FILE_NUM long   # 9ea5 e18d
        get PAZ_NUM long    # 9ec c20
        get OFFSET long     # 4603c 261cc
        get ZSIZE long      # 4a70 1970
        get SIZE long       # 5f13 2000

        getarray PAZ_NAME 0 PAZ_NUM

        open FDSE PAZ_NAME 1

So see, after the PAZ_NUM, we have the OFFSET which means the offset of that file, inside the PAZ file, so what you said makes totally sense.

The big problem is, I don't know if I told you that. I seems that they changed the encryption key only from the meta file, because quickbms doesn't work for the meta file anymore but it still works for the PAZ files.

But why do you think we can't find the hash of some files and even folder num + file num for them anymore in the meta file?
 

Kera

Vivacious Visitor
Joined
Mar 29, 2016
It might simply be a tools issue on our side.

Lets say we identify pkw_00_uw_0001.dds as being hash X in their file. If they edit the texture, the hash value changes to Y, but the folder name and file name for the lookup do not. At that point, the file hash based patching is broken since we cannot find the hash in the file anymore, but the file still loads because there is a new hash for that entry in the same spot.
 

Heinz Boesel

Vivacious Visitor
Joined
Mar 6, 2016
I change Phw_00_ub_0039.dds to Phw_00_ub_0039.dds file ( same name and different texture ) in character and paz folder
then The texture is changed to Phw_00_ub_0039.dds file's
I didn't restart BDO, but change character

that wasn't a reply to my question, or was it?
 

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Given that I do not have any experience breaking encryption, just with file structure serialization, something occurred to me.

Most directory lists are alphabetical. So if you know the hash for the file name in the folder that is just before or after, you could take the same folder number, and add/subtract one to get a searchable index string. That gives you the new hash as well for future use.
 

BlackFireBR

Content Creator
Joined
Sep 2, 2013
Given that I do not have any experience breaking encryption, just with file structure serialization, something occurred to me.

Most directory lists are alphabetical. So if you know the hash for the file name in the folder that is just before or after, you could take the same folder number, and add/subtract one to get a searchable index string. That gives you the new hash as well for future use.
I've already tried that
Code:
        for (i = 0; i < fileBlocksCount; i++)
        {
            if (fileBlocks[i].hashFound ==  0)
            {
                if (strcmpi(fileBlocks[i - 1].folderName,fileBlocks[i].folderName) == 0)
                {
                    if (fileBlocks[i - 1].folderNum != -1)
                    {
                        fileBlocks[i].folderNum = fileBlocks[i - 1].folderNum;
                        fileBlocks[i].fileNum = fileBlocks[i - 1].fileNum + 1;
                    }
                }
                else  if (strcmpi(fileBlocks[i + 1].folderName,fileBlocks[i].folderName) == 0)
                {
                    if (fileBlocks[i + 1].folderNum != -1)
                    {
                        fileBlocks[i].folderNum = fileBlocks[i + 1].folderNum;
                        fileBlocks[i].fileNum = fileBlocks[i + 1].fileNum -1;
                    }
                }
                else
                {
                    fileBlocks[i].folderNum = fileBlocks[i - 1].folderNum + 1;
                    fileBlocks[i].fileNum = fileBlocks[i - 1].fileNum + 1;
                }
            }
        }

I was able to "fill in the gaps" of the folder and file names. But when I search for the combo "folderNum fileNum" for the "guessed" folder and file numbers in the pad00000.meta file, they simply don't exist.
But if I seach for the folderNum fileNum of any file that we can find the hash, I'm able to find them.
 

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Even pulling the offset does not exist, assuming I am not failing my byteswaps.

Starting to think I am chasing the wrong thing. Thinking that META file is generated in full each patch based on what is believed to be used, and the texture I am looking at is not considered in the "in" set anymore, and I am looking in the wrong spot. Even breaking the internal lookup within the PAZ file the texture is in does not cause it to fail to load.
 

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Well, spent a couple hours without much in the way of results. Did find out that in the META file at least, the magic number that is plugged in is specific, not just a random number. Having one of the bytes different caused an infinite load.

The reason the substitution is partially working is that the _dec suffix texture is the paint-on to the body. There is an additional mesh that is added on top as well. However, there is some bleed-over on the paint on part normally, and having the _dec texture swapped does remove the blleed over. That leaves me with trying to figure out why the added mesh has a texture that I cannot replace and that does not appear to be referenced by the META file. Best thing I can figure is that it is actually referenced in some way by the model file that is being loaded.
 

BlackFireBR

Content Creator
Joined
Sep 2, 2013
Kera

I did some progress, but in the end, it's still the same.

This is the pad00000.meta file structure from the NA version, after the latest patch:
meta5.jpg


As you can see, they added an extra 256000 bytes in between the PAZ index and the "File Blocks Count". That's why the blackdesert.bms wasn't working for the .meta file anymore.

Here is the beginning of those 256,000 bytes, read as int:
Code:
-609700592 -989366122 -1264382127 1610423610
-1498462391 1317983309 -1231914785 -1247833054
617302022 -539096746 559995750 -1926496649
-1722457232 1593889863 -195020387 1359504096
1946774710 -1047669579 518850174 187914543
2060897727 -1957160002 1036726811 244572396
385894644 -1222499965 -2131444284 -1210134736
1885727731 1615984653 1263676661 1017845701
1966825468 -1041251904 -990633046 1446286233
-1581744680 -1502974880 1854731037 781064345

and here's the end:
Code:
-1027449227 -1112606888 1708330729 -271204380
-1061996228 -1997580859 -1263770798 -1867509871
-521725553 210403330 -773115432 2024327918
143794286 478388639 1376890279 -1456559484
-366881334 1663829922 1976108781 1006866297
399167063 48775660 -453276788 662802001
1916453129 1824348739 -1623306931 102022659
-468633767 1034427867 1123496557 225105009
-1244740936 -959317659 1491093277 1656348300
-174902358 -476071118 2118600919 -1560607624

It doesn't make any sense to me, maybe it's encrypted strings, I don't know.

Here's all the 256,000 bytes if you are interested:
256kbytes.zip

Here's my new version of the blackdesert.bms file that prints FILE_HASH | FOLDER_NUM | FOLE_NUM | FOLDER_NAME | FILE_NAME reading all from the .meta file:

quick_bms_script_print.zip
The only difference is that I manually added the offsets so quickbms would skip those 256,000 bytes.
Code:
    math OFFSET = 305932  # Pos after the 256,000 bytes (Where the file blocks starts)
    math TMP = 9231156    # Pos after the file blocks ends
    goto TMP

I discovered that number (305932) by doing this:
- Searching for the hash: 631490897 (from multiplemodeldesc.xml)
- Go back 28 bytes (7 * 4) (nFields(hash,folderNum,fileNum,pazNum,offset,zsize,size) * sizeof(int))
- Read hash,folderNum,fileNum,pazNum,offset,zsize,size
- If pazNum >= 1 or <= 4160
- Go back 28 bytes
- repeat.

Here's the code that does that:
metaexplorer.c

So my goal was to find which byte starts the first hash from the "file blocks" section.
Here is the full list of the file blocks, in the order they appear in the pad000.meta file.
script-meta-output.txt
The order is: HASH|FOLDER_NUM|FILE_NUM|PAZ_NUM|FOLDER_NAME|FILE_NAME

I also made a program that sorts this file by fileNum, and outputs the numbers of the files that are missing and how many of them are missing:
filesort.zip
Also, the sorted file is this:
sorted_file.zip

Interesting enough, as you can see, if I use a quickbms script just to print the file names, I get all 326,768 file names, in the order they appear from PAD00001.PAZ to PAD04160.PAZ.
meta6.jpg

But the File Blocks, really don't have more than 318,759 blocks.
meta7.jpg

If you run the program filesort, you'll see that 7791 file numbers are missing.
This is exactly the quantity of files the failed to patch, one time I decided to run Meta Injector Reloaded in all files of the game.

So I concluded that those 7791 files are not present at all in the .meta file, not even their hash, or their folderNumber, fileNumber, offset, size. Only the folder name and fileName are presen , which I don't know how it can be retrieved if the game doesn't know the folder and file number.

Let me know your thoughts on this.
 

Attachments

script-meta-output.zip
6.7 MB · Views: 480

metaexplorer.zip
10.1 KB · Views: 468

quick_bms_script_print.zip
2.2 KB · Views: 451

filesort.zip
6.7 MB · Views: 445

sorted_file.zip
4.1 MB · Views: 423

256kbytes.zip
342.3 KB · Views: 190

Last edited:

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Thats some good sleuthing.

Is it exactly 256000 bytes (which would be odd) or is it 256 * 1024 bytes? Either way, those sizes are clearly suspect given the power of 2 based sizing. Even encrypted strings would be extremely unlikely to fit in that block exactly. The data is very dense. Going from the end of the block backwards, it is a little over 256 bytes ballpark before it finds a zero byte.

There are a number of mechanisms that would allow the mystery files to be found. The most obvious one to me (and one I tried to break earlier without success) is that the PAZ files themselves have a filename registry in their first data block (lets call it their header). That data could be parsed on startup to build a more complete index. It was odd to me that the PAZ files had that data, since in theory the META file has all that data as well. Best guess was that it was a way to do file verification.

Given that the file names exist in the META file, and they exist in a PAZ somewhere, something knows how to find the PAZ file from the META file. I ran a slightly modified version of filesort, and do not notice any consistency with which files are missing references (its not like an entire old character is just hardcoded somewhere). Would be worthwhile to do a scan for a known-bad value in all PAZ files and see if we get any hits on the hash value or PAZ number (probably few false positives on hash, many on PAZ#). Assuming you can get the PAZ number and file string, you can open PAZ and use its header to find the rest.
 

BlackFireBR

Content Creator
Joined
Sep 2, 2013
Thats some good sleuthing.

Is it exactly 256000 bytes (which would be odd) or is it 256 * 1024 bytes? Either way, those sizes are clearly suspect given the power of 2 based sizing. Even encrypted strings would be extremely unlikely to fit in that block exactly. The data is very dense. Going from the end of the block backwards, it is a little over 256 bytes ballpark before it finds a zero byte.

There are a number of mechanisms that would allow the mystery files to be found. The most obvious one to me (and one I tried to break earlier without success) is that the PAZ files themselves have a filename registry in their first data block (lets call it their header). That data could be parsed on startup to build a more complete index. It was odd to me that the PAZ files had that data, since in theory the META file has all that data as well. Best guess was that it was a way to do file verification.

Given that the file names exist in the META file, and they exist in a PAZ somewhere, something knows how to find the PAZ file from the META file. I ran a slightly modified version of filesort, and do not notice any consistency with which files are missing references (its not like an entire old character is just hardcoded somewhere). Would be worthwhile to do a scan for a known-bad value in all PAZ files and see if we get any hits on the hash value or PAZ number (probably few false positives on hash, many on PAZ#). Assuming you can get the PAZ number and file string, you can open PAZ and use its header to find the rest.
It's exactly 256000 bytes, it starts at the byte 49,932 and it ends at the byte 305,932

Take a look at this part of the quickbms script:
Code:
get EXT extension
if EXT == "PAZ"

    get DUMMY long
    get PAZ_FILES long
    get NAMES_SIZE long

    savepos OFFSET
    xmath OFFSET "OFFSET + (PAZ_FILES * 4 * 6)"
    math TMP_SIZE = NAMES_SIZE
    callfunction SET_ENCRYPTION 1
    log MEMORY_FILE OFFSET NAMES_SIZE
    encryption "" ""

    math i = 0
    for TMP = 0 < NAMES_SIZE
        get NAME string MEMORY_FILE
        if NAME == ""
            break
        endif
        putarray 0 i NAME
        savepos TMP MEMORY_FILE
    next i

    for i = 0 < PAZ_FILES
        get HASH long
        get FOLDER_NUM long
        get FILE_NUM long
        get OFFSET long
        get ZSIZE long
        get SIZE long

        getarray NAME 0 FOLDER_NUM
        getarray TMP 0 FILE_NUM
        string NAME += TMP

        math TMP_SIZE = ZSIZE
        callfunction SET_ENCRYPTION 1
        if SIZE > ZSIZE
            clog NAME OFFSET ZSIZE SIZE
        else    # yeah SIZE is < ZSIZE
            log NAME OFFSET SIZE
        endif
        encryption "" ""
    next i

endif
startfunction SET_ENCRYPTION
encryption ice "\x51\xF3\x0F\x11\x04\x24\x6A\x00"
endfunction
according to the script, this is how a .PAZ file is structured:
paz_file.jpg


It was using the PAZ files that I discovered the hash of the files, before I figured it out how to navigate though the meta file.

A few things to notice:
- In the PAZ file, we find the hash for the files missing in the meta file, but it's worthless since you don't find them in the meta file, so you don't know where to replace it.
- folderNums and fileNums are local to the PAZ file, meaning each PAZ file will have folder 0 file 0 but in the meta file, this file has folder number X and folder number Y different from what you read in the PAZ file.
- The offsets you find in the PAZ file from the missing files, also can't be found in the meta file.
 
Last edited:

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Do you have a meta file from before the 256k was added? Does it have any missing entries?

Wtih regards to the PAZ files - in theory the META file is not required for the game to run. It could (but probably doesnt) scan the header block of every PAZ file in the folder at startup to build the lookup tree. I say probably doesnt because even breaking the file block list in the beginning of the PAZ file, the stuff inside loads fine.

That said, looking at the BMS script, the file strings come after the file blocks. It calcs the offset for the strings block, bulk reads them, then continues from where it left off and reads the fileblocks.
 

Kera

Vivacious Visitor
Joined
Mar 29, 2016
I grabbed one of the old meta files from the v1.0 injector, and it has a count of 0.

In your diagram for structure, the block is before the file size count, but in the BMS file you posted, it reads it before the block then uses it for the iteration later, so it is in theory the correct number.

That would mean that the "file block" actually has the 256k inside it, which would imply it is related.
 

Kera

Vivacious Visitor
Joined
Mar 29, 2016
Trying to figure out what is wrong with my file offsets.

From your script, the new addresses of note are:
math OFFSET = 305932 # Pos after the 256,000 bytes (Where the file blocks starts)
math TMP = 9231156 # Pos after the file blocks ends

But, when I try to calculate it based on the file structure with the following:
get FILES long
print "FILECOUNT=%FILES%"

savepos OFFSET
print "OFFSET BEFORE BLOCK=%OFFSET%"
# update the offset to after the 256000 byte block
xmath OFFSET "OFFSET + (256 * 1000)"
print "OFFSET AFTER 256k BLOCK=%OFFSET%"
# skip file block for now
xmath TMP "OFFSET + (FILES * 0x1c)"
print "OFFSET AFTER FILE BLOCK=%TMP%"
goto TMP

The output is:
- SCRIPT's MESSAGE:
FILECOUNT=326758

- SCRIPT's MESSAGE:
OFFSET BEFORE BLOCK=49932

- SCRIPT's MESSAGE:
OFFSET AFTER 256k BLOCK=305932

- SCRIPT's MESSAGE:
OFFSET AFTER FILE BLOCK=9455156

The "after file block" offset is different. The offset you have is clearly the correct one because that is when the folder names begins, but it is odd because it means that I am calculating the length of the file section to be longer than it actually is based on the file count. My offset is calculated as 28 bytes times the file count, which as far as I know is correct.

Running the script with the 2>test2.txt going, I see that it actually is erroring out after hitting a block that does not read correctly, so it is possible it is in fact overrunning. That would imply that the file count is actually correct, but there is file data in the 256k block that we are not reading, and then we are over-reading the later block until it errors.
 

BlackFireBR

Content Creator
Joined
Sep 2, 2013
Do you have a meta file from before the 256k was added? Does it have any missing entries?

Wtih regards to the PAZ files - in theory the META file is not required for the game to run. It could (but probably doesnt) scan the header block of every PAZ file in the folder at startup to build the lookup tree. I say probably doesnt because even breaking the file block list in the beginning of the PAZ file, the stuff inside loads fine.

That said, looking at the BMS script, the file strings come after the file blocks. It calcs the offset for the strings block, bulk reads them, then continues from where it left off and reads the fileblocks.
Yes I have. They are included in Meta Injector v1.0 to v1.4 in the "patcher_resources/pre-patch meta files".
And yes, they have all entries from all the files, including the ones we don't find in the current meta file.
Something happened in the patch that broke the script and made some files go missing.

About the script.
Yes, it bulk reads it, but it bulk reads the file strings, and then procceeds to the fileblocks
Code:
    savepos OFFSET
    xmath OFFSET "OFFSET + (PAZ_FILES * 4 * 6)"
This is OFFSET += FILES_COUNT * (4 * 6)
OFFSET is used to pre-alocate the size of the "vector" MEMORY_FILE later with the right amount of bytes. Since each File Block has 6 long ints and each long int has 4 bytes, that's why the 6 * 4
Then e have
Code:
log MEMORY_FILE OFFSET NAMES_SIZE
NAMES_SIZE contains the total length of the strings part.
this saves the next "NAMES_SIZE" bytes in the MEMORY_FILE file (like a vector), which has OFFSET positions.

Now, MEMORY_FILE has stuff like this:
"folder_name1/\0file_name1\0"
"folder_name2/\0file_name2\0"
....
Code:
    math i = 0
    for TMP = 0 < NAMES_SIZE
        get NAME string MEMORY_FILE
        if NAME == ""
            break
        endif
        putarray 0 i NAME
        savepos TMP MEMORY_FILE
    next i
So now, "get NAME string MEMORY_FILE" retrieves "folder_name1/\0" and saves it to the array "NAME"
next we have "savepos TMP MEMORY_FILE" which saves the byte right after the '\0' at the end of the string ""folder_name1/\0", which is where the second part of the string ("file_name1\0") starts.

Notice that this current part, doesn't move the file pointer at all, it stays at the same place, right after the strings end ( log MEMORY_FILE OFFSET NAMES_SIZE was the last thing to move the file pointer)

So now, the array NAMES have the folder names and the array TMP has the file names.

now the part
Code:
for i = 0 < PAZ_FILES
        get HASH long
        get FOLDER_NUM long
        get FILE_NUM long
        get OFFSET long
        get ZSIZE long
        get SIZE long

        getarray NAME 0 FOLDER_NUM
        getarray TMP 0 FILE_NUM
        string NAME += TMP

        math TMP_SIZE = ZSIZE
        callfunction SET_ENCRYPTION 1
        if SIZE > ZSIZE
            clog NAME OFFSET ZSIZE SIZE
        else    # yeah SIZE is < ZSIZE
            log NAME OFFSET SIZE
        endif
        encryption "" ""
    next i
Reads the File Blocks and then extracts the files, with the log command.

Notice that no "goto" was used, that means that the File Blocks are the last thing that the PAZ file contains.

This is different from what happens in the .meta file script:

....
savepos OFFSET # Position right after getting the total_files
xmath TMP "OFFSET + (FILES * 0x1c)" # 0x1c is 28 in dec, which is the size of a File Block
goto TMP # Skips All the file blocks (so they are what's comming next)

..... colects folder names and file names.....
goto OFFSET # Goes back to where the file blocks definition starts
for i = 0 < FILES
get HASH long
get FOLDER_NUM long # 48c
get FILE_NUM long # 9ea5 e18d
get PAZ_NUM long # 9ec c20
get OFFSET long # 4603c 261cc
get ZSIZE long # 4a70 1970
get SIZE long # 5f13 2000
...
 

Users who are viewing this thread

Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.