在不知道未压缩数据大小的情况下如何使用 RtlDecompressBuffer?
我想在用户模式下使用 WINAPI RtlDecompressBuffer 来解压缩先前使用 RtlcompressBuffer 压缩的缓冲区。我有压缩代码,但似乎为了解压缩,我需要知道未压缩数据的大小,因为函数需要它作为参数。
在不知道未压缩数据的大小的情况下如何做到这一点? 也许我应该使用 RtlDecompressFragment。
代码示例会很棒!
提前致谢。
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 RtlDecompressFragment.
A code sample would be great!
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要知道未压缩数据的大小。您所要做的就是保留足够的内存来保存所有未压缩的数据并将其传递给 API。
如果您的缓冲区不够大,API 将返回
STATUS_BAD_COMPRESSION_BUFFER
,然后您必须为未压缩数据分配更大的缓冲区。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.为什么不向具有未压缩大小的缓冲区添加(压缩时)一个简单的标头(前 4 个字节)?
Why not adding (while compressing) a simple header (first 4 bytes) to the buffer with the uncompressed size?