利用windows自带的gzip.dll进行压缩(VB版本)可以修改为VC
来源:互联网 发布:帮助网络犯罪活动罪 编辑:程序博客网 时间:2024/06/05 15:31
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function InitDecompression Lib "gzip.dll" () As Long
Private Declare Function CreateDecompression Lib "gzip.dll" (ByRef context As Long, ByVal Flags As Long) As Long
Private Declare Function DestroyDecompression Lib "gzip.dll" (ByRef context As Long) As Long
Private Declare Function Decompress Lib "gzip.dll" (ByVal context As Long, inBytes As Any, ByVal input_size As Long, outBytes As Any, ByVal output_size As Long, ByRef input_used As Long, ByRef output_used As Long) As Long
Private Const OFFSET As Long = &H8
'解压缩数组
Public Function UnCompressByte(ByteArray() As Byte) As Boolean
Dim BufferSize As Long
Dim buffer() As Byte
Dim lReturn As Long
Dim outUsed As Long
Dim inUsed As Long
'创建解压缩后的缓存
CopyMemory BufferSize, ByteArray(0), OFFSET
BufferSize = BufferSize + (BufferSize * 0.01) + 12
ReDim buffer(BufferSize) As Byte
'创建解压缩进程
Dim contextHandle As Long: InitDecompression
CreateDecompression contextHandle, 1 '创建
'解压缩数据
lReturn = Decompress(ByVal contextHandle, ByteArray(0), UBound(ByteArray) + 1, buffer(0), BufferSize, inUsed, outUsed)
DestroyDecompression contextHandle
'删除重复的数据
ReDim Preserve ByteArray(0 To outUsed - 1)
CopyMemory ByteArray(0), buffer(0), outUsed
End Function
#include <windows.h>
#include <stdio.h>
int main()
{
HINSTANCE hGetProcIDDLL = LoadLibrary("C://WINNT//system32//gzip.dll");
printf("dll loaded");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"Decompress");
FARPROC lpfnGetProcessID1 = GetProcAddress(HMODULE (hGetProcIDDLL),"<strong class="highlight">InitDecompression</strong>");
FARPROC lpfnGetProcessID2 = GetProcAddress(HMODULE (hGetProcIDDLL),"CreateDecompression");
FARPROC lpfnGetProcessID3 = GetProcAddress(HMODULE (hGetProcIDDLL),"InitCompression");
FARPROC lpfnGetProcessID4 = GetProcAddress(HMODULE (hGetProcIDDLL),"CopyMemory");
// Call CopyMemory(arrDestination(destbeginPos), arrSource(srcbeginPos), length)
// printf("Hello World long decompress!/n");
//printf(1);
typedef long (__stdcall * pICFUNC)(long, BYTE[],long,BYTE[],long,long,long);
typedef long (__stdcall * pICFUNC1)();
typedef long (__stdcall * pICFUNC2)(long,int);
typedef long (__stdcall * pICFUNC3)();
typedef long (__stdcall * pICFUNC4)(BYTE[],BYTE[],long);
typedef UINT (CALLBACK* CopyMemory)(BYTE[],BYTE[],long);
CopyMemory ptrCopyMemory;
ptrCopyMemory = (CopyMemory)GetProcAddress(hGetProcIDDLL,"CopyMemory");
typedef UINT (CALLBACK* <strong class="highlight">InitDecompression</strong>)();
<strong class="highlight">InitDecompression</strong> ptrInitDecompression;
ptrInitDecompression = (<strong class="highlight">InitDecompression</strong>)GetProcAddress(hGetProcIDDLL,"<strong class="highlight">InitDecompression</strong>");
//ReturnVal = ptrLockWorkStation();
ptrInitDecompression();
printf("Hello World long decompress!/n");
pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);
pICFUNC1 MyFunction1;
MyFunction1 = pICFUNC1(lpfnGetProcessID1);
pICFUNC2 MyFunction2;
MyFunction2 = pICFUNC2(lpfnGetProcessID2);
pICFUNC3 MyFunction3;
MyFunction3 = pICFUNC3(lpfnGetProcessID3);
pICFUNC4 MyFunction4;
MyFunction4 = pICFUNC4(lpfnGetProcessID4);
//BYTE[] a=NewByteArray(jb);
unsigned long handle=0;long max=1024;long inu=0;long outu=0;int GZIP_LVL=1;
BYTE *AB={(unsigned char *)"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"};
// int li= strlen( (char*)AB);
int orglen=100;
//printf("%l", li);
BYTE *oB=new BYTE[43822];
CopyMemory(AB,oB,234);
printf("function defined and parameters ready"+orglen,"%l",orglen);
printf("function defined and parameters ready");
/* The actual call to the function contained in the dll */
handle=MyFunction1();
//handle=MyFunction4(AB,oB,inu);
handle=MyFunction3();
printf("<strong class="highlight">InitDecompression</strong> & InitCompression");
MyFunction2(handle,GZIP_LVL);//Call CreateDecompression(handle, GZIP_LVL);
//handle=MyFunction2(handle,GZIP_LVL);
printf("CreateDecompression");
long intMyReturnVal =0;
do
{// int
intMyReturnVal=MyFunction(handle, AB, orglen, oB, max, inu, outu);
orglen = orglen - inu;
}
while(intMyReturnVal=0);
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
printf("Hello World long decompress!/n");
/* The return val from the dll */
return intMyReturnVal;
}
- 利用windows自带的gzip.dll进行压缩(VB版本)可以修改为VC
- 【Windows】利用windows自带的压缩卷功能随意进行磁盘大小的分配
- LoadRunner中,利用zlib.dll对字符串进行gzip压缩
- [VB.net]调用系统自带的 zLib.dll 实现 ZIP 压缩
- 利用Windows自带gdi32.dll实现抓取屏幕
- 使用windows自带的命令进行文件或文件夹的压缩
- 使用JDK自带的方法进行文件压缩
- 使用java进行内容的压缩操作(gzip)
- Net WebService 同步、异步、同步压缩解压和异步压缩解压实例详解(自带的Gzip)
- 利用windows自带VPN
- 用Gzip进行js的超强压缩
- 用Gzip进行js的超强压缩
- 用Gzip进行js的超强压缩
- VB中利用WinRAR进行文件压缩
- 【spring】通过GZIP压缩提高网络传输效率(可以实现任何资源的gzip压缩、包括AJAX)
- 通过GZIP压缩提高网络传输效率(可以实现任何资源的gzip压缩、包括AJAX)
- 【spring】通过GZIP压缩提高网络传输效率(可以实现任何资源的gzip压缩、包括AJAX)
- 利用VS2008自带的安装部署软件进行打包!
- 数字转化为字符串函数
- 读书笔记之java反编译(2)
- 程序员常用开发工具介绍一、UltraEdit
- GCC编译方法
- 生命中不可丢的十种东西 && 生命中最容易丢失的两种东西
- 利用windows自带的gzip.dll进行压缩(VB版本)可以修改为VC
- JDBC 2
- ubuntu9.04 系统的使用
- 11-06-09
- 一些经典问题,大家学习讨论--摘自uuussseeennn
- Android UI界面目前做的最好的一个:索尼爱立信Xperia X10
- 日语语法实践篇八——新编日语第一册第九课之总结篇
- Game Programming with DirectX -- 00[序言]
- 综述(1)--《网格计算》