public CcmErrorCode GetSessionAttributes(int sessionId, out CcmNameValuePair[] attributes) { var ptrSize = Marshal.SizeOf(typeof(CcmNameValuePair)); var ptr = IntPtr.Zero; var result = Environment.Is64BitProcess ? CcmSdk64.CCMGetSessionAttributes(sessionId, out var count, ref ptr) : CcmSdk32.CCMGetSessionAttributes(sessionId, out count, ref ptr); attributes = new CcmNameValuePair[count]; for (int i = 0; i < count; i++) { var nPtr = IntPtr.Add(ptr, i * ptrSize); attributes[i] = Marshal.PtrToStructure <CcmNameValuePair>(nPtr); } _ = Environment.Is64BitProcess ? CcmSdk64.CCMFreeNameValuePair(count, ptr) : CcmSdk32.CCMFreeNameValuePair(count, ptr); return((CcmErrorCode)result); }