Advertisement
Guest User

Untitled

a guest
Dec 5th, 2010
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. public class NetworkHook : MarshalByRefObject
  2.     {
  3.         public event EventHandler<HookInstalledEventArgs> Installed;
  4.  
  5.         public event EventHandler<HookDataRecievedEventArgs> DataRecieved;
  6.  
  7.         public event EventHandler<HookPingEventArgs> Ping;
  8.  
  9.         public event EventHandler<HookExceptionEventArgs> Exception;
  10.  
  11.         public void onIsInstalled(int pid, MessageDirection direction)
  12.         {
  13.             EventHandler<HookInstalledEventArgs> handler = Installed;
  14.             if (null != handler)
  15.             {
  16.                 handler(this, new HookInstalledEventArgs(pid, direction));
  17.             }
  18.         }
  19.  
  20.         public void onDataRecieved(int pid, MessageDirection direction, byte[][] data)
  21.         {
  22.             EventHandler<HookDataRecievedEventArgs> handler = this.DataRecieved;
  23.             if (null != handler)
  24.             {
  25.                 foreach(byte[] singledata in data)
  26.                 {
  27.                     handler(this, new HookDataRecievedEventArgs(pid, direction, singledata));
  28.                 }
  29.             }
  30.         }
  31.  
  32.         public void onException(int pid, MessageDirection direction, Exception exception)
  33.         {
  34.             EventHandler<HookExceptionEventArgs> handler = this.Exception;
  35.             if (null != handler)
  36.             {
  37.                 handler(this, new HookExceptionEventArgs(pid, direction, exception));
  38.             }
  39.         }
  40.  
  41.         public void onPing(int pid, MessageDirection direction)
  42.         {
  43.             EventHandler<HookPingEventArgs> handler = this.Ping;
  44.             if (null != handler)
  45.             {
  46.                 handler(this, new HookPingEventArgs(pid, direction));
  47.             }
  48.         }
  49.  
  50.         public override object InitializeLifetimeService()
  51.         {
  52.             // Make sure the object doesn't end up in garbage collection after 5 minutes
  53.             return null;
  54.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement