public static extern bool StructWithSafeHandleByRef(ref StructWithHandle str, IntPtr expectedValue, IntPtr newValue);
public static extern void StructWithSafeHandleOut(out StructWithHandle str, IntPtr expectedValue);
public static extern bool StructWithSafeHandleByValue(StructWithHandle str, IntPtr expectedValue);