Advertisement
Guest User

Untitled

a guest
Dec 5th, 2010
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Runtime.Remoting.Channels.Ipc;
  6. using System.Runtime.Remoting;
  7. using EasyHook;
  8. using System.IO;
  9. using System.Threading;
  10.  
  11. namespace HookManager.NetworkObserver
  12. {
  13.     public class NetworkManager
  14.     {
  15.         private string ipcChannelName = null;
  16.  
  17.         private IpcServerChannel ipcChannel;
  18.  
  19.         private NetworkHook networkIncomingInterface;
  20.  
  21.         public NetworkManager(String startupPath)
  22.         {
  23.             // register dlls
  24.             Config.Register("Hook",
  25.                 Path.Combine(startupPath, "HookManager.dll"),
  26.                 Path.Combine(startupPath, "NetworkIncomingHook.dll"),
  27.                 Path.Combine(startupPath, "NetworkOutgoingHook.dll")
  28.             );
  29.  
  30.             // create ipc-server and get reference to the instance
  31.             this.ipcChannel = RemoteHooking.IpcCreateServer<NetworkHook>(
  32.                 ref this.ipcChannelName,
  33.                 WellKnownObjectMode.Singleton
  34.             );
  35.             this.networkIncomingInterface = (NetworkHook) Activator.GetObject(typeof(NetworkHook), "ipc://" + this.ipcChannelName + "/" + this.ipcChannelName);
  36.         }
  37.  
  38.         public void HookInstance(Int32 pid)
  39.         {
  40.             RemoteHooking.Inject(
  41.                 pid,
  42.                 "NetworkIncomingHook.dll",
  43.                 "NetworkIncomingHook.dll",
  44.                 this.ipcChannelName
  45.             );
  46.  
  47.             RemoteHooking.Inject(
  48.                 pid,
  49.                 "NetworkOutgoingHook.dll",
  50.                 "NetworkOutgoingHook.dll",
  51.                 this.ipcChannelName
  52.             );
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement