Therepower Posted February 7, 2021 Report Posted February 7, 2021 hey, i try to fetch CSGO in-game store prices via CMsgStoreGetUserData. message CMsgStoreGetUserData { optional fixed32 price_sheet_version = 1; optional int32 currency = 2; } message CMsgStoreGetUserDataResponse { optional int32 result = 1; optional int32 currency_deprecated = 2; optional string country_deprecated = 3; optional fixed32 price_sheet_version = 4; optional bytes price_sheet = 8; } When i receive the "CMsgStoreGetUserDataResponse" i can read result, price_sheet_version without problems but "price_sheet" itself is provided as bytes. When i try to read it i get some unreadable text. I also tried to parse it with binarykvparser which gives an error "KV type 48 encountered at offset 207" How could i read the data provided by price_sheet? thank you in advance Quote
Dr. McKay Posted February 9, 2021 Report Posted February 9, 2021 I have no idea what format price_sheet is encoded in. Quote
Therepower Posted February 9, 2021 Author Report Posted February 9, 2021 1 hour ago, Dr. McKay said: I have no idea what format price_sheet is encoded in. thanks for your response. any idea how i could find the encoding type? this is how it looks like: https://prnt.sc/ytol2e Quote
Dr. McKay Posted February 9, 2021 Report Posted February 9, 2021 I don't know. My best guess would be that it's either protobuf or binary KV, but that doesn't look like either. It could possibly be compressed. Quote
Valvoja Posted March 3, 2021 Report Posted March 3, 2021 I'm trying to do the same thing, I'm using python though. For me the price_sheet starts with b"LZMA\", so I'm guessing it's compressed with LZMA but I wasn't able to decompress it Quote
Dr. McKay Posted March 4, 2021 Report Posted March 4, 2021 That sounds like a reasonable assumption. Game content downloads are sometimes compressed with LZMA, so Valve using it somewhere else makes perfect sense. Quote
Booms Posted January 26 Report Posted January 26 I can't decode it with lzma.decompress, because it gets: LZMA_FORMAT_ERROR: File format not recognized.... Any idea what should I do? Quote
skr1pt Posted Tuesday at 10:32 PM Report Posted Tuesday at 10:32 PM On 1/26/2025 at 10:48 PM, Booms said: I can't decode it with lzma.decompress, because it gets: LZMA_FORMAT_ERROR: File format not recognized.... Any idea what should I do? https://github.com/ValveSoftware/source-sdk-2013/blob/0759e2e8e179d5352d81d0d4aaded72c1704b7a9/src/game/client/econ/store/store_panel.cpp#L610 Quote
skr1pt Posted Wednesday at 11:27 AM Report Posted Wednesday at 11:27 AM (edited) const { LZMA } = require('lzma-native'); function decompressValveLZMA(buffer) { if (buffer.length < 13) { throw new Error("Buffer too short to be Valve LZMA"); } const magic = buffer.readUInt32BE(0); // Big-Endian if (magic !== 0x4C5A4D41) { // 'LZMA' throw new Error("Not a Valve LZMA container (magic mismatch)"); } const uncompressedLength = buffer.readUInt32LE(4); const compressedLength = buffer.readUInt32LE(8); const expectedTotal = 12 + 5 + compressedLength; // header (12) + props(5) + data if (buffer.length < expectedTotal) { throw new Error(`Buffer too short: expected ${expectedTotal}, have ${buffer.length}`); } const props = buffer.slice(12, 12 + 5); const lzmaData = buffer.slice(12 + 5, 12 + 5 + compressedLength); return new Promise((resolve, reject) => { const lzma = new LZMA(); const lzmaHeader = Buffer.alloc(5 + 8); props.copy(lzmaHeader, 0); // копируем 5 байт props lzmaHeader.writeUInt32LE(uncompressedLength, 5); const fullLzmaStream = Buffer.concat([lzmaHeader, lzmaData]); lzma.decompress(fullLzmaStream, (result, error) => { if (error) { reject(error); } else { resolve(Buffer.from(result)); } }); }); } Edited Wednesday at 11:27 AM by skr1pt Booms 1 Quote
benji Posted Wednesday at 08:16 PM Report Posted Wednesday at 08:16 PM Could you also kindly share how do you parse this buffer into a readable json or text? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.