See the question and my original answer on StackOverflow

ID3D11Buffer* is a pointer. If you want to get back a pointer, you'll have to pass a pointer to a pointer, so define your C++ method like this:

HRESULT getValues(int * debug, ID3D11Buffer** bufOut)

    *bufOut = triangleVertBuffer;


And C# like this:

[DllImport("CreateID3D11Buffer.dll", CallingConvention = CallingConvention.StdCall)]
private static extern int getValues([In, Out] int[] debug, out IntPtr bufIn);

And this part should work.