need to learn how XMemDecompress works...
-
- Posts: 4
- Joined: Sat Jul 31, 2021 9:48 am
need to learn how XMemDecompress works...
Anyone know where the respective code is in source? also need any links or anything that'll further my understanding of this comtype.
-
- Posts: 1383
- Joined: Sat Aug 09, 2014 2:34 pm
-
- Site Admin
- Posts: 12984
- Joined: Wed Jul 30, 2014 9:32 pm
Re: need to learn how XMemDecompress works...
XMemDecompress is part of the Xbox SDK (xcompress.lib) but there is also an open source version that is compatible (even if not supporting all the various features).
This is the code:
Probably you want to understand what are those MYALLOC_ZEROES... long story short the API is bugged and the only way to make it working correctly was to allocate 16 additional zeroes in the input file and therefore specifying a bigger input size. Failure to do so will result in random errors of the API. Yeah misteries...
By the way, the unxmemlzx function in unz.c of quickbms is really magical. It's an all-in-one beast able to work with all the known types of xmem inputs and formats.
This is the code:
Code: Select all
#define MYALLOC_ZEROES 16
XMEMDECOMPRESSION_CONTEXT ctx = NULL;
HRESULT hr;
hr = XMemCreateDecompressionContext(XMEMCODEC_DEFAULT, NULL, 0, &ctx);
if(hr != S_OK) exit(1);
SIZE_T ret = out_size;
hr = XMemDecompress(ctx, out, &ret, in, in_size + MYALLOC_ZEROES);
if(hr != S_OK) exit(1);
XMemDestroyDecompressionContext(ctx);
Probably you want to understand what are those MYALLOC_ZEROES... long story short the API is bugged and the only way to make it working correctly was to allocate 16 additional zeroes in the input file and therefore specifying a bigger input size. Failure to do so will result in random errors of the API. Yeah misteries...
By the way, the unxmemlzx function in unz.c of quickbms is really magical. It's an all-in-one beast able to work with all the known types of xmem inputs and formats.