mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
b02427417c
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@5614 21ef857c-d57f-4fe0-8362-d861dc6d29cd
36 lines
788 B
C#
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; }
|
|
}
|
|
}
|
|
}
|