Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Counter-Strike Online 2 (.VTF) Modified with LZMA

Get your graphics formats figures out here! Got details for others? Post here!
Post Reply
User avatar
cra0
ultra-veteran
ultra-veteran
Posts: 438
Joined: Fri Apr 27, 2012 9:37 am
Has thanked: 29 times
Been thanked: 189 times
Contact:

Counter-Strike Online 2 (.VTF) Modified with LZMA

Post by cra0 »

Hey, I've been trying to figure this out but have had no luck at all I'm not sure if ekeys unpacker is at blame or something is going on weird but Counter-Strike Online 2's VTF textures just refuse to decompress. Well the VTF header + all the mips do successfully decompress however the largest mip LZMA block fails

Here is what the files look like
Image

it uses LZMA in the format of

Code: Select all

byte   LZMA[4]
uint32 size
uint32 zsize
byte   Lzmaprops[5]
So for example the first LZMA block decompresses to this and each MIP of the texture follows which is another LZMA block.
Image
Get to the last LZMA block and it just fails. I dump the buffer before the lzma bad data exception and the result is an image chopped up here is what i mean look.
The first 2 Mips are broken but the rest are fine
Image


The function which decompresses the lzma seems normal I don't understand whats going on why is it failing :(

Code: Select all

vtf_lzma_header *__stdcall LzmaVtfDecode(vtf_lzma_header *lzmaHeader, unsigned __int8 *outputBuffer)
{
  vtf_lzma_header *lzmaHeader2; // ebx@1
  unsigned int uncompressedLength; // ebp@4
  unsigned int *probs; // esi@5
  signed int decodeResult; // edi@5
  vtf_lzma_header *result; // eax@6
  CLzmaDecoderState state; // [sp+10h] [bp-14h]@5

  lzmaHeader2 = lzmaHeader;
  if ( !lzmaHeader
    || !outputBuffer
    || lzmaHeader->lzmaMagic != 0x414D5A4C
    || (uncompressedLength = lzmaHeader->uncompressedLength) == 0 )
    goto LABEL_8;
  LzmaDecodeProperties(&state.Properties, lzmaHeader->decoderProperties);
  probs = (unsigned int *)(*(int (__thiscall **)(_DWORD, _DWORD))(**(_DWORD **)&byte_14F5E214[140] + 4))(
                            *(_DWORD *)&byte_14F5E214[140],
                            4 * (768 << (LOBYTE(state.Properties.lp) + state.Properties.lc)) + 0x1CD8);// allocFunc & LzmaGetNumProbs
  state.Probs = probs;
  decodeResult = LzmaDecode(
                   &state,
                   lzmaHeader2->data,
                   lzmaHeader2->compressedLength,
                   (unsigned int *)&outputBuffer,
                   outputBuffer,
                   uncompressedLength,
                   (unsigned int *)&lzmaHeader);
  (*(void (__stdcall **)(_DWORD))(**(_DWORD **)&byte_14F5E214[140] + 20))(probs);// freeFunc
  if ( decodeResult || (result = lzmaHeader, lzmaHeader != (vtf_lzma_header *)uncompressedLength) )
  {
    (*(void (**)(const char *, ...))&byte_14F5E214[24])("Decompress Fail. %d", decodeResult);
LABEL_8:
    result = 0;
  }
  return result;
}
Sample files (source engine shared files not only found in CSO2 but alienswarm/dota2/tf2 free2play game)
https://www.dropbox.com/sh/f8jmz3ppqefp ... wGUMF0LVJa

Here are more Samples (since CSO2 runs the Source Engine i found some files in CSS that are the same in CSO2)
https://dl.dropboxusercontent.com/u/107 ... samples.7z

PM me if you want the filesystem dll
User avatar
cra0
ultra-veteran
ultra-veteran
Posts: 438
Joined: Fri Apr 27, 2012 9:37 am
Has thanked: 29 times
Been thanked: 189 times
Contact:

Re: Counter-Strike Online 2 (.VTF) Modified with LZMA

Post by cra0 »

Bump
alyxblock.dat 1 of the lzma blocks

https://www.dropbox.com/s/zgnpqpdpngs0vvi/alyxblock.dat

//Read 0->18932 (zsize)
//Can decode 25892bytes (Glitched output size) about 142 bytes worth of glitch pixels

Image
rackio
ultra-n00b
Posts: 4
Joined: Thu Nov 27, 2014 11:29 pm

Re: Counter-Strike Online 2 (.VTF) Modified with LZMA

Post by rackio »

---------------------------
VTFEdit
---------------------------
Error loading VTF texture:

Error:
File signature does not match 'VTF'.
---------------------------
Aceptar
---------------------------

help!!
User avatar
tschumann
advanced
Posts: 57
Joined: Sat Jun 03, 2017 9:35 am
Location: Australia
Has thanked: 7 times
Been thanked: 4 times
Contact:

Re: Counter-Strike Online 2 (.VTF) Modified with LZMA

Post by tschumann »

Did you ever get any further with this? I know that Source on the Xbox 360 uses LZMA too but the normal decompression seems to work.
Post Reply