Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:20:00+00:00 2026-06-02T14:20:00+00:00

i have the dllimport [DllImport(../../zlib-1.2.5/zlib1.dll, CallingConvention = CallingConvention.Cdecl)] static extern int uncompress(byte[] destBuffer, ref

  • 0

i have the dllimport

[DllImport("../../zlib-1.2.5/zlib1.dll", CallingConvention = CallingConvention.Cdecl)]   
static extern int uncompress(byte[] destBuffer, ref uint destLen, byte[] sourceBuffer, uint sourceLen);

and call it like

 uint _dLen = (uint) 8192;
 byte[] data = compressed_data;
 byte[] _d = new byte[_dLen];

 if (uncompress(_d,  ref _dLen, data, (uint)data.Length) != 0)
     return null;

the uncompress function in zlib looks like

unsigned int ZEXPORT uncompress (dest, destLen, source, sourceLen)
unsigned char *dest;
Uint32 destLen;
unsigned char *source;
Uint32 sourceLen;
{
z_stream stream;
int err;

stream.next_in = source;
stream.avail_in = sourceLen;
/* Check for source > 64K on 16-bit machine: */
if ((Uint32)stream.avail_in != sourceLen) return Z_BUF_ERROR;

stream.next_out = dest;
stream.avail_out = destLen;
if ((Uint32)stream.avail_out != destLen) return Z_BUF_ERROR;

stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;

err = inflateInit(&stream);
if (err != Z_OK) return err;


err = inflate(&stream, Z_FINISH);

if (err != Z_STREAM_END) {
    inflateEnd(&stream);
    if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
        return Z_DATA_ERROR;
    return err;
}

err = inflateEnd(&stream);
return stream.total_out;
}

but i always end up receiving a null in the c# side.
edit: The error is the z_data_error.
edit2: Z_DATA_ERROR if the input data was corrupted.

do i need to marshall the byte[] array to unmanaged pointers?
Or what could be the problem? Is my input array not valid?

best regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:20:05+00:00Added an answer on June 2, 2026 at 2:20 pm

    After more and more research i get the feeling that everything is right here,
    and the error must be elsewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function: [DllImport(user32.dll, CharSet=CharSet.Auto)] static extern int SendMessage(IntPtr hWnd, int wMsg,
I have the following code in my application: [DllImport(user32.dll)] private static extern int GetWindowLong(IntPtr
I have this dll call: [DllImport(FreqCntPcIntf.dll, CallingConvention = CallingConvention.StdCall)] public static extern Intf_ErrorType FreqCntIntf_Init(
in a C# file i have a class Archiver { [DllImport(Archiver.dll)] public static extern
I have the following declaration for SHChangeNotify : [DllImport(Shell32.dll)] public static extern void SHChangeNotify(HChangeNotifyEventID
I have a class which uses a method in user32.dll: [System.Runtime.InteropServices.DllImport(user32.dll)] private static extern
i have a method registered like this: [DllImport(MyApi.dll, CharSet = CharSet.Ansi)] private static extern
I have: [SuppressUnmanagedCodeSecurity] [DllImport(Kernel32.dll, CharSet = CharSet.Auto, SetLastError = true)] static extern bool MoveFileWithProgress(
I have a dll that exports extern C __declspec(dllexport) int __stdcall Foo( void );
I have the following code : [DllImport(shell32.dll, CharSet = CharSet.Unicode, PreserveSig = false)] static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.