mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
50a4eea4a3
-Documented APIs (where documented in PH source) -Fixed managed signatures of native struts and functions. -Added Handlers (Unload, Options, MenuItems) -Removed unnecessary code git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4186 21ef857c-d57f-4fe0-8362-d861dc6d29cd
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace ProcessHacker.Api
|
|
{
|
|
public unsafe class CallbackRegistration : IDisposable
|
|
{
|
|
private PhCallback* _callback;
|
|
private PhCallbackRegistration* _registration;
|
|
private PhCallbackFunction _function;
|
|
|
|
public CallbackRegistration(PhCallback* callback, PhCallbackFunction function)
|
|
{
|
|
_callback = callback;
|
|
_function = function;
|
|
|
|
_registration = (PhCallbackRegistration*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PhCallbackRegistration)));
|
|
|
|
NativeApi.PhRegisterCallback(_callback, function, IntPtr.Zero, _registration);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (_registration != null)
|
|
{
|
|
NativeApi.PhUnregisterCallback(_callback, _registration);
|
|
|
|
Marshal.FreeHGlobal((IntPtr)_registration);
|
|
|
|
_registration = null;
|
|
}
|
|
}
|
|
}
|
|
}
|