Files
wj32 7bd28e4357 moved branches, tags, trunk to 1.x branch
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@2304 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-10-25 02:22:46 +00:00

36 lines
788 B
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using ProcessHacker.Common.Objects;
namespace ProcessHacker.Native
{
public sealed class PinnedObject<T> : BaseObject
{
private T _object;
private GCHandle _handle;
public PinnedObject(T obj)
{
_object = obj;
_handle = GCHandle.Alloc(obj, GCHandleType.Pinned);
}
protected override void DisposeObject(bool disposing)
{
_handle.Free();
}
public IntPtr Address
{
get { return _handle.AddrOfPinnedObject(); }
}
public T Object
{
get { return _object; }
}
}
}