You would appear to be going about this the wrong way. It's a worrying sign to see that you switch behaviour depending on whether or not the code is 32 or 64 bit. That is a clear sign that you've got something wrong. The unmanaged declaration looks like this, I believe:
int lzo1x_decompress(const unsigned char *in, size_t in_len,
unsigned char *out, size_t *out_len, unsigned char *wrkmem);
The matching p/invoke declaration is, for both 32 and 64 bit code, is:
[DllImport(LzoDll, CallingConvention=CallingConvention.Cdecl)
static extern int lzo1x_decompress(byte[] in, IntPtr in_len,
[Out] byte[] out, ref IntPtr out_len, byte[] wrkmem);
Your code is erroneously using int
for the two size_t
parameters. Now, size_t
is pointer sized on Windows and so the matching type is IntPtr
.