Declaring this API in C#? (C++ example)

G

Guest

This is in a file called "UOEncryption.dll"
Here is the info that the documentation gives:

void Decompress(char *dest, const char *src, int *dest_size, int *src_size,
HuffmanObj *obj)

char *dest – A pointer to a buffer to dump the decompressed data
const char *src – A pointer to a buffer with the data to be decompressed
int *dest_size – A pointer to the integer with the size of ‘dest’ in bytes
int *src_size – A pointer to the integer with the amount of bytes to be
decompressed in ‘src’

Decompresses data by using UO’s Huffman table. The ‘obj’ pointer can be set
to NULL if the user does not intend to use the incomplete codeword support.
But if he does, DecompressClean should be called in the start of the socket.



I want to declare it in C# and I just cannot figure it out!

I don't know any C++ so I don't know how the data types convert.. From what
I've read, I got the following, but it still doesn't work:

[DllImport("UOEncryption.dll")]
public static extern void Decompress([MarshalAs(UnmanagedType.LPStr)] ref
System.Text.StringBuilder dest,[MarshalAs(UnmanagedType.LPStr)] string src,
ref int dest_size, ref int src_size, object obj);
 
M

Mattias Sjögren

[DllImport("UOEncryption.dll")]
public static extern void Decompress([MarshalAs(UnmanagedType.LPStr)] ref
System.Text.StringBuilder dest,[MarshalAs(UnmanagedType.LPStr)] string src,
ref int dest_size, ref int src_size, object obj);

I would try it this way

public static extern void Decompress(byte[] dest, byte[] src,
ref int dest_size, ref int src_size, IntPtr obj);


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top