public void assign(out SOUND_INFO publicInfo) { publicInfo = new SOUND_INFO(); publicInfo.mode = this.mode; publicInfo.exinfo = this.exinfo; publicInfo.exinfo.inclusionlist = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int))); Marshal.WriteInt32(publicInfo.exinfo.inclusionlist, this.subsoundIndex); publicInfo.exinfo.inclusionlistnum = 1; publicInfo.subsoundIndex = this.subsoundIndex; if (this.name_or_data != IntPtr.Zero) { int num; int num2; if ((this.mode & (MODE.OPENMEMORY | MODE.OPENMEMORY_POINT)) != MODE.DEFAULT) { publicInfo.mode = ((publicInfo.mode & ~MODE.OPENMEMORY_POINT) | MODE.OPENMEMORY); num = (int)this.exinfo.fileoffset; publicInfo.exinfo.fileoffset = 0u; num2 = (int)this.exinfo.length; } else { num = 0; num2 = MarshallingHelper.stringLengthUtf8(this.name_or_data) + 1; } publicInfo.name_or_data = new byte[num2]; Marshal.Copy(new IntPtr(this.name_or_data.ToInt64() + (long)num), publicInfo.name_or_data, 0, num2); } else { publicInfo.name_or_data = null; } }
public static string stringFromNativeUtf8(IntPtr nativeUtf8) { int num = MarshallingHelper.stringLengthUtf8(nativeUtf8); if (num == 0) { return(string.Empty); } byte[] array = new byte[num]; Marshal.Copy(nativeUtf8, array, 0, array.Length); return(Encoding.UTF8.GetString(array, 0, num)); }