开发者

How to use RtlDecompressBuffer without knowing the size of the uncompressed data?

开发者 https://www.devze.com 2023-03-07 05:47 出处:网络
I would like to use the WINAPI RtlDecompressBuffer in User Mode to decompress a buffer previously compressed using RtlCompressBuffer. I have the code for compression but it seems that in order to deco

I would like to use the WINAPI RtlDecompressBuffer in User Mode to decompress a buffer previously compressed using RtlCompressBuffer. I have the code for compression but it seems that in order to decompress I need to know the size of the uncompressed data as the function needs it as a parameter.

How can I do this without knowing the size of the uncompressed data? Perhaps I should use RtlD开发者_运维百科ecompressFragment.

A code sample would be great!

Thanks in advance.


You don't need to know the size of the uncompressed data. All you have to do is reserve enough memory to hold all the uncompressed data and pass that to the API. If your buffer isn't big enough, the API will return STATUS_BAD_COMPRESSION_BUFFER and you then have to allocate a bigger buffer for the uncompressed data.


Why not adding (while compressing) a simple header (first 4 bytes) to the buffer with the uncompressed size?

0

精彩评论

暂无评论...
验证码 换一张
取 消