public unsafe void GetAttribute([In] AmsiAttribute attribute, [In] uint dataSize, [Out] byte *buffer, out uint writtenData) { switch (attribute) { case AmsiAttribute.AppName: writtenData = WriteWString(AmsiConstants.AppName, dataSize, buffer); return; case AmsiAttribute.Session: *(IntPtr *)buffer = session; writtenData = (uint)sizeof(IntPtr); return; case AmsiAttribute.ContentName: writtenData = WriteWString(contentName, dataSize, buffer); return; case AmsiAttribute.ContentSize: *(ulong *)buffer = (ulong)data.Length; writtenData = sizeof(ulong); return; case AmsiAttribute.ContentAddress: // because our data is pinned, it can't move while this object exists so we can pass out the fixed address fixed(byte *dataAddr = data) { *(byte **)buffer = dataAddr; } writtenData = (uint)sizeof(IntPtr); return; default: throw new NotImplementedException(); // return e_notimpl }
public unsafe void GetAttribute([In] AmsiAttribute attribute, [In] uint dataSize, [Out] byte *buffer, out uint writtenData) { switch (attribute) { case AmsiAttribute.AppName: writtenData = WriteWString(AmsiConstants.AppName, dataSize, buffer); return; case AmsiAttribute.Session: *(IntPtr *)buffer = session; writtenData = (uint)sizeof(IntPtr); return; case AmsiAttribute.ContentName: writtenData = WriteWString(file.FullName, dataSize, buffer); return; case AmsiAttribute.ContentSize: *(ulong *)buffer = (ulong)file.Length; writtenData = sizeof(ulong); return; default: throw new NotImplementedException(); // return e_notimpl }