|
|
|
VC6的错误
麻烦的是这样写也不出错: int len; len=sizeof(int) GetCurrentProcessId(); 但后面的GetCurrentProcessId();函数调用给忽略了。 |
|
[主题讨论]如何判断一个全局钩子的调用者
从网络上搜来一篇。权当一个开始吧。静观中。 防止全局钩子的侵入 Author: pjf(jfpan20000@sina.com) Windows消息钩子一般都很熟悉了。它的用处很多,耳熟能详的就有――利用键盘钩子获取目标进程的键盘输入,从而获得各类密码以达到不可告人的目的。朋友想让他的软件不被别人的全局钩子监视,有没有办法实现呢?答案是肯定的,不过缺陷也是有的。 首先简单看看全局钩子如何注入别的进程。 消息钩子是由Win32子系统提供,其核心部分通过NtUserSetWindowsHookEx为用户提供了设置消息钩子的系统服务,用户通过它注册全局钩子。当系统获取某些事件,比如用户按键,键盘driver将扫描码等传入win32k的KeyEvent处理函数,处理函数判断有无相应hook,有则callhook。此时,系统取得Hook对象信息,若目标进程没有装载对应的Dll,则装载之(利用KeUserModeCallback“调用”用户例程,它与Apc调用不同,它是仿制中断返回环境,其调用是“立即”性质的)。 进入用户态的KiUserCallbackDispatcher后,KiUserCallbackDispatcher根据传递的数据获取所需调用的函数、参数等,随后调用。针对上面的例子,为装载hook dll,得到调用的是LoadLibraryExW,随后进入LdrLoadDll,装载完毕后返回,后面的步骤就不叙述了。 从上面的讨论我们可以得出一个最简单的防侵入方案:在加载hook dll之前hook相应api使得加载失败,不过有一个缺陷:系统并不会因为一次的失败而放弃,每次有消息产生欲call hook时系统都会试图在你的进程加载dll,这对于性能有些微影响,不过应该感觉不到。剩下一个问题就是不是所有的LoadLibraryExW都应拦截,这个容易解决,比如判断返回地址。下面给出一个例子片断,可以添加一些判断使得某些允许加载的hook dll被加载。 这里hook api使用了微软的detours库,可自行修改。 以下内容为程序代码: typedef HMODULE (__stdcall *LOADLIB)( LPCWSTR lpwLibFileName, HANDLE hFile, DWORD dwFlags); extern "C" { DETOUR_TRAMPOLINE(HMODULE __stdcall Real_LoadLibraryExW( LPCWSTR lpwLibFileName, HANDLE hFile, DWORD dwFlags), LoadLibraryExW); } ULONG user32 = 0; HMODULE __stdcall Mine_LoadLibraryExW( LPCWSTR lpwLibFileName, HANDLE hFile, DWORD dwFlags) { ULONG addr; _asm mov eax, [ebp+4] _asm mov addr, eax if ((user32 & 0xFFFF0000) == (addr & 0xFFFF0000)) { return 0; } HMODULE res = (LOADLIB(Real_LoadLibraryExW)) ( lpwLibFileName, hFile, dwFlags); return res; } BOOL ProcessAttach() { DetourFunctionWithTrampoline((PBYTE)Real_LoadLibraryExW, (PBYTE)Mine_LoadLibraryExW); return TRUE; } BOOL ProcessDetach() { DetourRemove((PBYTE)Real_LoadLibraryExW, (PBYTE)Mine_LoadLibraryExW); return TRUE; } CAnti_HookApp::CAnti_HookApp() //在使用用户界面服务前调用ProcessAttach { user32 = (ULONG)GetModuleHandle("User32.dll"); ProcessAttach(); } |
|
[主题讨论]如何判断一个全局钩子的调用者
编程好像没那么简单。没搞清楚到底是要弄清楚钩子的底层机制还是仅仅找出谁调用带钩子函数的那个dll |
|
[主题讨论]如何判断一个全局钩子的调用者
我想如果你找到那个dll这个不难。 |
|
ACprotect v1.41奇幻旅程
抱歉,看不懂 |
|
|
|
怎么不来一个系统核心编程板块呢
做过dos程序就知道了。不是很难的。 |
|
让我们一起进步
灌水 |
|
memcpy应该怎样写,同时庆祝新版开张
你上面那个在VC6中输出的结果是: buf[0] = 'k'; buf[1] = 'k'; 其余为0。 下面你给出的实现方法我个人认为不合理。VC中的memcpy的实现要复杂的多。我想是有道理的。如果源和目标空间重合的话。你的实现可能会有一部分数据丢失。 |
|
[下载]X-Ways.WinHex.v12.2.SR-11
倒。回复中放不了附件。 |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值