Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. namespace DragDrop_DLL
  2. {
  3. public class Main : EasyHook.IEntryPoint
  4. {
  5.  
  6. DragDrop_Console.RemoteMon Interface;
  7.  
  8. public LocalHook dragDropHook;
  9.  
  10. public Main(RemoteHooking.IContext InContext, String InChannelName)
  11. {
  12. try
  13. {
  14. Interface = RemoteHooking.IpcConnectClient<DragDrop_Console.RemoteMon>(InChannelName);
  15.  
  16. File.AppendAllText(@"F:DragDropLog.txt", "Main : Channel Name passed" + Environment.NewLine);
  17. }
  18. catch (Exception ex)
  19. {
  20. Interface.ErrorHandle(ex);
  21.  
  22. File.AppendAllText(@"F:DragDropLog.txt", "Main Exception :" + ex.ToString() + Environment.NewLine);
  23. }
  24. }
  25.  
  26. public void Run(RemoteHooking.IContext InContext, String InChannelName)
  27. {
  28. try
  29. {
  30. dragDropHook = LocalHook.Create(LocalHook.GetProcAddress("Ole32.dll", "DoDragDrop"), new DragDropDelegate(DoDragDropHook), null);
  31.  
  32. dragDropHook.ThreadACL.SetInclusiveACL(new Int32[] { 0 });
  33. //Also tried with setExclusiveACL
  34. //dragDropHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
  35.  
  36. File.AppendAllText(@"F:DragDropLog.txt", "Run : LocalHook Created" + Environment.NewLine);
  37. }
  38. catch (Exception ex)
  39. {
  40. Interface.ErrorHandle(ex);
  41.  
  42. File.AppendAllText(@"F:DragDropLog.txt", "Run Exception :" + ex.ToString() + Environment.NewLine);
  43.  
  44. return;
  45. }
  46.  
  47. Interface.IsInstalled(RemoteHooking.GetCurrentProcessId());
  48.  
  49. RemoteHooking.WakeUpProcess();
  50.  
  51. while (true)
  52. {
  53. Thread.Sleep(1000);
  54. }
  55. }
  56.  
  57. [DllImport("Ole32.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
  58. static extern int DoDragDrop(
  59. IDataObject pDataObj,
  60. IDropSource pDropSource,
  61. UInt32 dwOKEffects,
  62. UInt32[] pdwEffect);
  63.  
  64. [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi, SetLastError = true)]
  65. [return: MarshalAs(UnmanagedType.I4)]
  66. delegate int DragDropDelegate(
  67. IDataObject pDataObj,
  68. IDropSource pDropSource,
  69. UInt32 dwOKEffects,
  70. UInt32[] pdwEffect);
  71.  
  72. static int DoDragDropHook(
  73. IDataObject pDataObj,
  74. IDropSource pDropSource,
  75. UInt32 dwOKEffects,
  76. UInt32[] pdwEffect)
  77. {
  78. try
  79. {
  80. ((Main)HookRuntimeInfo.Callback).Interface.GotDragFileObject(pDataObj);
  81.  
  82. File.AppendAllText(@"F:DragDropLog.txt", "DoDragDrop Hit :" + pDataObj.ToString() + Environment.NewLine);
  83. }
  84. catch (Exception ex)
  85. {
  86. File.AppendAllText(@"F:DragDropLog.txt", "DoDragDropHook Exception :" + ex.ToString() + Environment.NewLine);
  87. }
  88.  
  89. return DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect);
  90. }
  91. }
  92.  
  93. internal interface IDropSource
  94. {
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement