![]() |
How to create XTool plugins (configuration based)
|
Introduction
Sometimes it is better to have a plugin for XTool to catch all the streams, or even speed up the precompression. Here I will show you how to write it and where to start. In this example I will choose a easy one, namely "LEGO Star Wars The Skywalker Saga", which is compressed with oodle kraken. XTool/oo2reck already performs good, but with a plugin it is even better. Side Notes Theoretically it is possible to make a plugin for majority of games, but only the minority of them are interestingly enough to make a plugin anyways. Other compression algorithms are a bit harder to understand, and for others it's totally useless to make one (example zlib and zstd). Maybe someone else can make a quick "how to" for algos like lz4/lz4hc. What do you need? HxD - https://mh-nexus.de/en/downloads.php?product=HxD20 Notepad (or notepad++) XTool UI verbose mode Lets start First lets take a look on a easy plugin sample: Code:
[Stream1]Simultaneously open the same file in HxD. https://i.imgur.com/Z5xmjgt.png https://i.imgur.com/Z5xmjgt.png Copy the first offset 135674 and go to it in HxD (CTRL+G). You will see kraken header "8C 06". So now we have our kraken header "8C 06" at offset 135674. Again looking at XTool verbose information on the first stream: Code:
Actual kraken stream found at 0000000000135674 (2139 >> 9287)https://i.imgur.com/juCSHtr.png https://i.imgur.com/juCSHtr.png Now we have to know how such streams are constructed. For the oodle compression family it is mostly a shemata like this (at least for kraken and mermaid): Code:
CSize - DSize - Headerhttps://i.imgur.com/AzO89a7.png https://i.imgur.com/AzO89a7.png Now we can check if our thoughts are correct. Again we look at our first stream in XTool verbose information: Code:
Actual kraken stream found at 0000000000135674 (2139 >> 9287)Code:
CSize (4 bytes) - DSize (4 bytes) - Header (2 bytes)https://i.imgur.com/xtfzlRh.png The same with CSize https://i.imgur.com/Y5usWSO.png https://i.imgur.com/Y5usWSO.png So basically we know now everything what XTool is looking for. Now comes the part what makes a plugin usefull. But first we note what informations we got until now: We know the oodle kraken header, which is 2 bytes We know the DSize for the stream which is 4 bytes We know the CSize for the stream which is 4 bytes Which for the Structure key it is like this: Code:
CSize(number of bytes),DSize(number of bytes),OodleHdr(number of bytes)So lets write them right away in our configuration plugin as follow: Code:
[Stream1]Code:
A2 0F 00 27 00 14 4F 4F 44 4C 5B 08 00 00 47 24 00 00 8C 06In the above table of streams we see a repetitive pattern, our signature. The Signature in this case is "4F 4F 44 4C", so 4 bytes long. https://i.imgur.com/jRBnaMA.png https://i.imgur.com/jRBnaMA.png Now that we have our repetitive pattern (Signature), we fill in the information again: Code:
Signature(number of bytes),CSize(number of bytes),DSize(number of bytes),OodleHdr(number of bytes)Code:
[Stream1]Also we have to fill the Signature= key with our pattern. Because of endianness and the inclusion of "0x", we have to write the signature "backwards". "4F 4F 44 4C" will become "4C 44 4F 4F" and adding "0x" at the start will finally become this: Code:
Signature=0x4C444F4FAgain we fill in the informations: Code:
[Stream1]The BigEndian key is important because it will tell XTool if a file is Little- or BigEndian. To find out the endianness just mark the CSize or DSize and change the endianness with the radio buttons. If the numbers you see there don't make any sense, then you know that the endianness is wrong. https://i.imgur.com/py1hfSR.png https://i.imgur.com/py1hfSR.png We know in this case that it is little endianness, so it should be BigEndian=0 in our plugin. The other key is StreamOffset. Since our oodle kraken header "8C 06" is part of the entire stream, the offset should be set to "-2" because of the 2 bytes difference. Theoretically you can skip this part and just set is as "0", but XTool have to ensure that this is really a kraken stream, otherwise XTool would think anything beginning from the signature is a kraken stream, even if the signature is something else and there is nothing following. So basically this is just a safety measurement, if you say so. Now our configuration is complete and it should look like this: Code:
[Stream1]So finally lets test our plugin. Code:
xtool:kraken----------------------------------------------- Here is another example for oodle kraken for the game "Shadow of War". In this case making a plugin is useless, because there are many different signatures. Here are the first 20 streams as 20 bytes long: Code:
00 00 00 00 00 00 00 00 00 00 D7 0E 00 00 DD 36 00 00 8C 06Testing: Code:
xtool:krakenCode:
[Stream1]Code:
[Stream1]Did you remember, in the beginning I said that plugins for zlib or zstd are useless? However some time ago I made one for zstd, just for fun and for learning stuff. Code:
[Stream1] |
Oodle kraken with size byte difference
Introduction Sometimes it could be the case that either CSize or DSize has a byte difference. In this case I will show you how to deal with such things. Lets start First lets take a look on the data we have. https://i.imgur.com/pJAVOGK.png https://i.imgur.com/pJAVOGK.png We have a repetitive pattern (Signature) 7 bytes long, some unknown trash 10 bytes long, DSize 4 bytes, CSize 4 bytes and our kraken header 2 bytes. Now lets look for the sizes. I can say here that DSize matches, but what happened to CSize? https://i.imgur.com/THt7MkJ.png https://i.imgur.com/THt7MkJ.png Next stream, same thing. https://i.imgur.com/0ZYM8ey.png https://i.imgur.com/0ZYM8ey.png And again, same thing on the next stream. https://i.imgur.com/Y1nEpCR.png https://i.imgur.com/Y1nEpCR.png So the CSize does not match here. In fact on every stream you have a 12 byte difference. I cannot tell you how that comes, or what happened here technically, but we can fix it within the plugin configuration. All we have to do now is to subtract the 12 bytes from the CSize. Code:
CompressedSize=CSize - 12Code:
[Stream1]Code:
xtool:kraken |
Introduction
This post is about the frostbite 3 engine, how to deal with lz4, zlib, zstd and oodle kraken streams. It is recommended to read the previous posts, about how to search for offsets and such. In frostbite3 engine the structure is like this commonly for lz4: Code:
DSize(#),Signature(#),CSize(#),StreamBeginning with lz4, first make a batch file next to xtool.exe with the following command Code:
xtool.exe precomp -mlz4:s64k -t100p -v -s - - < %1 > %1.outCode:
XTool is created by Razor12911However, go to the first offset (in this case BF1EA). Unlike in the previous examples, this one has no specific header, but we don't need one here. https://i.imgur.com/BFEKAsp.png https://i.imgur.com/BFEKAsp.png Now we have to go just 2 bytes back before the offset starts and we will see the CSize (you might want to change the endianness). https://i.imgur.com/R2nZnYo.png https://i.imgur.com/R2nZnYo.png DSize and Signature: https://i.imgur.com/9RrSGGd.png https://i.imgur.com/9RrSGGd.png We use BigEndian and Streamoffset is set to 0. Now the plugin is nearly complete. Code:
[Stream1]Testing: Code:
xtool:testplugin |
i have tried your method of creating ini based xtool plugins the idea in its core is nice to be able with simple adjustments to gain 2%~ 3% ratio and about 10%~15% in speed. speed only comes in compression mode where compress once decompress many applies!!
generally i have tried 2 games to create with your guide above one is Sekiro which uses kraken and the second one is zstd only for resident evil 2 and resident evil 3 series!! and failed an average user will fail this easily i will upload samples and an explanation. maybe this idea is very nice if we get it as per engine because as it is, it cant be used!! |
Of course this is not the same case for every game or engine. Initially I wanted to point it out on second post, but unfortunatelly I cannot edit it because the forum will kick me back to front page of fileforums.com. Most like it is some bug in the software this forum is using.
As for the game Sekiro, I guess it is not possible here to create ini based plugins, because most likely some of the information is stored in the bhd files. I once looked on the game Armored Core 6, which is using the same engine. All I found was header and csize, nothing more. It looked like this Code:
header unk csize |
4 Attachment(s)
i didnt have time last night to post an explanation of my findings so here we go
sample = a chunk of resident evil 2 with 2 zstd streams. re2.ini [Stream1] Name=zstd Codec=zstd:l11:f0:b0 BigEndian=1 Signature=0xA7DA Structure=Dict(1),DSize(3),Signature(2),CSize(2),Z StdHdr(4),Stream StreamOffset=0 CompressedSize=CSize DecompressedSize=DSize Condition1=ZStdHdr = 0x28B52FFD attachment1= ZStdHdr attachment2= xtool verbose attachment3= HEX csize |
| All times are GMT -7. The time now is 14:21. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com