Windows Cmd钩子不工作

Windows Cmd钩子不工作,cmd,hook,easyhook,Cmd,Hook,Easyhook,我试图在cmd.exe下钩住CreateProcess。 我设法将dll注入cmd进程,但在注入之后,dll进程分离消息接收,我无法钩住createprocess函数调用。 我用的是easyhook。 我的代码: #包括 #包括 #包括 #包括 #包括 #包括 BOOL-WINAPI-myCreateProcess( _在_opt_uctstrlpapplicationname中, _Inout_opt_Utstrlpcommandline, _在_opt_LPSECURITY_属性lpProc

我试图在cmd.exe下钩住CreateProcess。 我设法将dll注入cmd进程,但在注入之后,dll进程分离消息接收,我无法钩住createprocess函数调用。 我用的是easyhook。 我的代码:

#包括
#包括
#包括
#包括
#包括
#包括
BOOL-WINAPI-myCreateProcess(
_在_opt_uctstrlpapplicationname中,
_Inout_opt_Utstrlpcommandline,
_在_opt_LPSECURITY_属性lpProcessAttributes中,
_在_opt_LPSECURITY _attributeslpthreadattributes中,
_在_uboolBinherithandles,
_在uudword dwCreationFlags中,
_在_opt LPVOID lp环境中,
_在_opt_uctstrlpcurrent目录中,
_在uuLPStartupInfo LPSTARTUPINFO中,
_输出处理信息处理信息
){
OutputDebugString(L“\n!!!!!在CreateProcess钩子中\n!!!!!!!”;
返回CreateProcessW(lpApplicationName、lpCommandLine、lpProcessAttributes、lpThreadAttributes、bInheritHandles、dwCreationFlags、lpEnvironment、lpCommandLine、lpStartupInfo、lpProcessInformation);
}
BOOL APICENT DllMain(模块HMODULE,
德沃德·乌尔打电话的理由,
LPVOID lpReserved
)
{
BOOL-berrorsflag=FALSE;
DWORD dwBytesToWrite=(DWORD)strlen(数据缓冲);
DWORD DWBYTESSWRITED=0;
开关(ul\u呼叫原因\u)
{
案例DLL\u进程\u附加:
{
HOOK\u TRACE\u INFO hHook={NULL};//跟踪我们的钩子
//安装挂钩
NTSTATUS结果=lInstallHook(
GetProcAddress(GetModuleHandle(文本(“内核32”),“CreateProcessW”),
myCreateProcess,
无效的
&hHook);
如果(失败(结果))
{
OutputDebugString(L“!!!!!!!!!!!!!!!失败!!!!!!!”;
返回1;
}
ULONG acentries[1]={0};
LHSETInclusiveAll(入口、1和hHook);
OutputDebugString(L“!!!!!!!!!!!!!!!!!注入成功!!!!!!!!!!!”;
打破
}
案例DLL\u线程\u连接:{
OutputDebugString(L“!!!!!!!!!!!!!!!!!dll线程连接!!!!!!!!!!!!!!!”;
打破
}
案例DLL\u线程\u分离:
{
OutputDebugString(L“!!!!!!!!!!!!!!!!!dll线程分离!!!!!!!!!!!!!!!”;
打破
}
案例DLL\u进程\u分离:
{
OutputDebugString(L“!!!!!!!!!!!!!!!!!dll进程分离!!!!!!!!!!!!!!!”;
打破
}
}
}
我收到“注入成功”消息,紧接着是“dll进程分离”消息。 有什么想法吗?

尝试改变:

    LhSetInclusiveACL(ACLEntries, 1, &hHook);
致:

    LhSetInclusiveACL(ACLEntries, 1, &hHook);
    LhSetExclusiveACL(ACLEntries, 1, &hHook);