-1
「OLE32」,「的DoDragDrop」功能掛鉤的探險家是 成功,但每當我在資源管理器將文件拖到我的 DoDragDropHook功能是不是打電話,是新的鉤的概念,我想從過去3個月,但到現在沒有 正確的結果。請幫我我要去哪裏錯了試圖掛鉤的DoDragDrop資源管理器,但委託方法並沒有叫
namespace DragDrop_DLL
{
public class Main : EasyHook.IEntryPoint
{
DragDrop_Console.RemoteMon Interface;
public LocalHook dragDropHook;
public Main(RemoteHooking.IContext InContext, String InChannelName)
{
try
{
Interface = RemoteHooking.IpcConnectClient<DragDrop_Console.RemoteMon>(InChannelName);
File.AppendAllText(@"F:\DragDropLog.txt", "Main : Channel Name passed" + Environment.NewLine);
}
catch (Exception ex)
{
Interface.ErrorHandle(ex);
File.AppendAllText(@"F:\DragDropLog.txt", "Main Exception :"+ ex.ToString() + Environment.NewLine);
}
}
public void Run(RemoteHooking.IContext InContext, String InChannelName)
{
try
{
dragDropHook = LocalHook.Create(LocalHook.GetProcAddress("Ole32.dll", "DoDragDrop"), new DragDropDelegate(DoDragDropHook), null);
dragDropHook.ThreadACL.SetInclusiveACL(new Int32[] { 0 });
//Also tried with setExclusiveACL
//dragDropHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
File.AppendAllText(@"F:\DragDropLog.txt", "Run : LocalHook Created" + Environment.NewLine);
}
catch (Exception ex)
{
Interface.ErrorHandle(ex);
File.AppendAllText(@"F:\DragDropLog.txt", "Run Exception :" + ex.ToString() + Environment.NewLine);
return;
}
Interface.IsInstalled(RemoteHooking.GetCurrentProcessId());
RemoteHooking.WakeUpProcess();
while (true)
{
Thread.Sleep(1000);
}
}
[DllImport("Ole32.dll",CharSet=CharSet.Unicode,SetLastError =true,CallingConvention =CallingConvention.StdCall)]
static extern int DoDragDrop(
IDataObject pDataObj,
IDropSource pDropSource,
UInt32 dwOKEffects,
UInt32[] pdwEffect);
[UnmanagedFunctionPointer(CallingConvention.StdCall,CharSet =CharSet.Ansi, SetLastError = true)]
[return: MarshalAs(UnmanagedType.I4)]
delegate int DragDropDelegate(
IDataObject pDataObj,
IDropSource pDropSource,
UInt32 dwOKEffects,
UInt32[] pdwEffect);
static int DoDragDropHook(
IDataObject pDataObj,
IDropSource pDropSource,
UInt32 dwOKEffects,
UInt32[] pdwEffect)
{
try
{
((Main)HookRuntimeInfo.Callback).Interface.GotDragFileObject(pDataObj);
File.AppendAllText(@"F:\DragDropLog.txt", "DoDragDrop Hit :" + pDataObj.ToString() + Environment.NewLine);
}
catch(Exception ex)
{
File.AppendAllText(@"F:\DragDropLog.txt", "DoDragDropHook Exception :" + ex.ToString() + Environment.NewLine);
}
return DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect);
}
}
internal interface IDropSource
{
}
}
這個事件會引發一旦文件被丟棄到應用程序中的權利,但這不是我期待我要在DragDrop和DragEnter之前知道dragsource對象 – Krish