本帖最后由 666 于 2021-5-10 13:27 编辑
- .版本 2
- .局部变量 type
- .局部变量 CompressBufferWorkSpaceSize
- .局部变量 CompressFragmentWorkSpaceSize
- .局部变量 CompressBufferWorkSpace
- .局部变量 CompressBuffer
- .局部变量 z
- .局部变量 w
- .局部变量 PCompressBufferlen
- ' type = 位或 (#COMPRESSION_FORMAT_LZNT1, #COMPRESSION_ENGINE_STANDARD)
- type = 位或 (#COMPRESSION_FORMAT_LZNT1, #COMPRESSION_ENGINE_MAXIMUM)
- Nt_Compression_RtlGetCompressionWorkSpaceSize (type, Asm_GetH (CompressBufferWorkSpaceSize), Asm_GetH (CompressFragmentWorkSpaceSize))
- CompressBufferWorkSpace = Nt_Heap_RtlAllocateHeap (g_heap, 位或 (#HEAP_ZERO_MEMORY, #HEAP_GENERATE_EXCEPTIONS), CompressBufferWorkSpaceSize) ' 申请算法所需缓冲长度
- z = Nt_Heap_RtlAllocateHeap (g_heap, #HEAP_GENERATE_EXCEPTIONS, 10240) ' 待压缩数据
- CompressBuffer = Nt_Heap_RtlAllocateHeap (g_heap, 位或 (#HEAP_ZERO_MEMORY, #HEAP_GENERATE_EXCEPTIONS), 10240 + CompressBufferWorkSpaceSize) ' 申请相应所需压缩后缓冲长度
- Nt_Compression_RtlCompressBuffer (type, z, Nt_Heap_RtlSizeHeap (g_heap, 0, z), CompressBuffer, Nt_Heap_RtlSizeHeap (g_heap, 0, CompressBuffer), CompressFragmentWorkSpaceSize, Asm_GetH (PCompressBufferlen), CompressBufferWorkSpace)
- w = Nt_Heap_RtlAllocateHeap (g_heap, 位或 (#HEAP_ZERO_MEMORY, #HEAP_GENERATE_EXCEPTIONS), 10240) ' 待解压缩验证数据
- Nt_Compression_RtlDecompressBuffer (type, w, 10240, CompressBuffer, PCompressBufferlen, Asm_GetH (PCompressBufferlen))
- .判断开始 (Asm_memcmp (z, w, 10240) = 0)
- 输出调试文本 (“解压成功”)
- .默认
- 输出调试文本 (“解压错误”)
- .判断结束
- ' 释放掉内存
- Nt_Heap_RtlFreeHeap (g_heap, 0, CompressBufferWorkSpace)
- Nt_Heap_RtlFreeHeap (g_heap, 0, CompressBuffer)
- Nt_Heap_RtlFreeHeap (g_heap, 0, z)
- Nt_Heap_RtlFreeHeap (g_heap, 0, w)
复制代码
|