hello
i want to use lzo_1z decompress function from lzo1.07.dll file in C#
The syntax for the function is
lzo_decomp (char* inp_buff, unsigned int* inp_len, char* buffer_decomp,
unsigned int *output_len, unsigned short *errorCode)
where,
Inp_buff- Specifies the input buffer (Compressed Buffer)
Inp_len- Specifies the length of input buffer (Compressed Length)
Buffer_decomp- Specifies the Buffer after decompression
output_len- Specifies the length after decompression ( Out put length )
errorCode- Specifies the error code
and call can be made as
lzo1z_decompress (out, decomp_inlen, in, & decomp_outlen, NULL)
i wanted to use above function in C#
unsafe class lzoCompress {
[DllImport(@"C:\Documents and Settings\Developer1\My Documents\Visual Studio 2010\Projects\lzoCTCLDecompression\lzoCTCLDecompression\bin\Debug\lzo107.dll",CallingConvention=CallingConvention.StdCall)]
public static extern int lzo1z_decompress([MarshalAs(UnmanagedType.LPArray)] char[] inp_buff, ref ushort inp_len, [MarshalAs(UnmanagedType.LPArray)] char[] out_buff, ref int out_len, ref ushort errorCode);
public static char[] Decompress(byte[] src)
{
int origlen = BitConverter.ToInt32(src, src.Length - 4);
char[] ch = new char[origlen];
string str = BitConverter.ToString(src);
ch = str.ToCharArray();
char[] dst = new char[origlen];
int outlen = origlen;
int Srclength = src.Length - 4;
ushort inp_len = (ushort)src.Length;
int out_len = dst.Length;
ushort error = 0;
try
{
int i =lzo1z_decompress(ch, ref inp_len, dst, ref out_len, ref error);
} catch (Exception e) { }
}
i am getting an error as pinvoke
stackimbalance error
in try block