MERCH!
Giant Bomb - a website about video games and the people that make them

Falling into the Rabbit Hole

by shinali

I've got a window to show up with MonoXNA, but stopped short of loading content. The culprit lies with the XNB files, which is basically images that XNA generates. The problem is the release version of the XNB files are compressed using some proprietary Microsoft compression scheme called XMemCompress, which are only accessed by XDK recipients. The very compression and decompression algorithms...

I've got a window to show up with MonoXNA, but stopped short of loading content. The culprit lies with the XNB files, which is basically images that XNA generates. The problem is the release version of the XNB files are compressed using some proprietary Microsoft compression scheme called XMemCompress, which are only accessed by XDK recipients. The very compression and decompression algorithms are within the confines of the XnaNative.dll library that ships with the XNA runtime, but I'm aiming for more of a clean room implementation so I won't be disassembling it (that and reading thousands of instructions gets boring). From my preliminary research through the webs, it seems to be a variant of the classic LZ77 compression algorithm, which references previous uncompressed data from the current position of the uncompressed stream. One toolset, although relies on the XnaNative.dll rather than creating their own implementation, comments that it's an LZX algorithm, which I've discovered is invented by Microsoft. Another person created some decompression tools for the Xbox 360 version of LA Noire said that they used "some source code" from the open source cabextract project, though he did not include them with his project as they were "messy." The cabextract project had some source files that seem to implement the LZX decompression algorithm but not interface in a similar way to the functions in XnaNative.dll. I've contacted the aforementioned author through a forum PM as that was the only way I could.

I call this post "Falling into the Rabbit Hole" because the other solution is to just use the decompression function on all the XNB files for Bastion. For this all I require is to create some tool that will unpack/pack PKG files, which would be simple. I'll probably create some package explorer program as well.