G
Guest
Hello,
I have the following C functions exported from a DLL:
void copyString2(const char * sSrcBuf, long nSrcBufSize, char ** sDestBuf);
void freeString(char * sBuf);
The idea is to copy the source buffer into the dynamically allocated
destination buffer returning the pointer to the buffer to C# then pushing the
pointer back to the DLL for deallocation.
I'm having a tough time declaring the appropriate type for the char **
sDestBuf parameter. I've been trying to use various combination of IntPtr
declarations but no matter what I define at runtime the pointer passed to the
C library is NULL for the sDestBuf.
For example:
[DllImport("nativelibtest.dll", CharSet = CharSet.Ansi)]
public static extern unsafe
bool copyString2(string sSrcStr, long nSrcSize, IntPtr * sDestBuf);
IntPtr pPtr = new IntPtr();
bool bSuccess = NativeLibTest.copyString2(sMsg, sMsg.Length, &pPtr);
In the debugger, &pPtr certainly has an address but that address is not
passed to the DLL.
Any help would be appreciated.
I have the following C functions exported from a DLL:
void copyString2(const char * sSrcBuf, long nSrcBufSize, char ** sDestBuf);
void freeString(char * sBuf);
The idea is to copy the source buffer into the dynamically allocated
destination buffer returning the pointer to the buffer to C# then pushing the
pointer back to the DLL for deallocation.
I'm having a tough time declaring the appropriate type for the char **
sDestBuf parameter. I've been trying to use various combination of IntPtr
declarations but no matter what I define at runtime the pointer passed to the
C library is NULL for the sDestBuf.
For example:
[DllImport("nativelibtest.dll", CharSet = CharSet.Ansi)]
public static extern unsafe
bool copyString2(string sSrcStr, long nSrcSize, IntPtr * sDestBuf);
IntPtr pPtr = new IntPtr();
bool bSuccess = NativeLibTest.copyString2(sMsg, sMsg.Length, &pPtr);
In the debugger, &pPtr certainly has an address but that address is not
passed to the DLL.
Any help would be appreciated.