|
[求助]关于全局APIHOOK(JMP前5字节方式经常出错),求教关于传说的指针操作方式
你可以借用csdn上一位编程师傅的HOOK代码:(我以前在学的时候给加上了注释了,希望对你有帮助!因为我曾经得到那位师傅的很多提点和帮助,很理解求知的心,在这里谢谢他,也很想尽力的帮助你) typedef struct _HOOKSTRUCT { FARPROC pfFunAddr; //用于保存API函数地址 BYTE OldCode[5]; //保存原API前5个字节 BYTE NewCode[5]; //JMP XXXX其中XXXXJMP的地址 }HOOKSTRUCT; class CHookInfo { public: CHookInfo(char *strDllName, char *strFunName, DWORD dwMyFunAddr); //HOOK 钩子的构造处理函数 //strDllName用于传入模块文件名 //strFunName用于传入模块里的函数名 //dwMyFunAddr用于传入处理函数的地址(代理函数的地址) virtual ~CHookInfo(); //HOOK 钩子的析构函数 HOOKSTRUCT *pHook; //HOOK结构 void HookStatus(BOOL blnHook); //关闭/打开HOOK状态 }; CHookInfo::CHookInfo(char *strDllName, char *strFunName, DWORD dwMyFunAddr) { pHook = new HOOKSTRUCT; HMODULE hModule = LoadLibrary(strDllName); //载入strDllName模块 //纪录函数地址 pHook-> pfFunAddr = GetProcAddress(hModule,strFunName); //在strDllName模块里检索strFunName函数的地址,GetProcAddress就是返回strFunName函数的地址 FreeLibrary(hModule); //卸载strDllName模块 if(pHook-> pfFunAddr == NULL) return ; //备份原函数的前5个字节,一般的WIN32 API以__stdcall声明的API理论上都可以这样进行HOOK (师傅的注释) memcpy(pHook-> OldCode, pHook-> pfFunAddr, 5); //memcpy:功能:由pHook-> pfFunAddr所指内存区域复制5个字节到pHook-> OldCode所指内存区域。说明:pHook-> pfFunAddr和pHook-> OldCode所指内存区域不能重叠,函数返回指向pHook-> OldCode的指针。 pHook-> NewCode[0] = 0xe9; //构造JMP ,JMP(字节值:0xe9)是汇编指令:程序无条件转移指令 DWORD dwJmpAddr = dwMyFunAddr - (DWORD)pHook-> pfFunAddr - 5; //计算JMP地址(我想这里是技术点!) memcpy(&pHook-> NewCode[1], &dwJmpAddr, 4); HookStatus(TRUE);//开始进行HOOK } CHookInfo::~CHookInfo() { //关闭HOOK恢复原函数 HookStatus(FALSE); } void CHookInfo::HookStatus(BOOL blnHook) { if(blnHook) WriteProcessMemory((HANDLE)-1, pHook-> pfFunAddr, pHook-> NewCode, 5, 0);//替换函数地址 : (HANDLE)-1进程的句柄,pHook-> pfFunAddr进程地址,pHook-> NewCode数据存放地址,5数据的长度,0实际数据的长度 else WriteProcessMemory((HANDLE)-1, pHook-> pfFunAddr, pHook-> OldCode, 5, 0);//还原函数地址 } |
|
[求助]windows内存表示
也可以这样理解: 执行:mov edi,edi指令后:eip的值是:eip+2 执行:push ebp指令后:eip的值是:eip+1 执行:mov ebp,esp指令后:eip的值是:eip+2 执行:jmp xxxxxxxx 指令后:eip的值是:eip+xxxxxxxx+5 呵呵!我还是菜鸟,我是这样理解的,如果我的理解有错误的地方就请指教。 |
|
[求助]windows内存表示
需要E9 jmp xxxxxxxx的地址! 比如: 虚拟地址 机器码 汇编指令 0x00000000 8BFF mov edi,edi 0x00000002 55 push ebp 0x00000003 8BEC mov ebp,esp 0x00000005 E949b29477 jmp xxxxxxxx 这里需要计算 那么xxxxxxxx的值是:0x00000005(虚拟地址)+5(机器码:E949b29477用了5字节,所以加5。计算到这里就是获取jmp指令的下一个指令的虚拟地址)+0x7794b249(虚拟地址0x00000006的一个4字节数据,c语言可以这样获取:*(int*)0x00000006) 其实xxxxxxxx的值是:jmp xxxxxxxx 指令完成地址结束地址到将要跳转的地址的偏移量!只要理解:jmp xxxxxxxx 里的xxxxxxxx是一个偏移量,然后理解这个偏移量是什么跟什么的偏移量,就可以了! |
|
[求助]请各位高手指明方向
我想:《windows程序设计》是一个选择。 |
|
[分享]windows内核分析(英文)
pdf的文件我还需要工具打开。e问的不懂啊! |
|
[求助]能从LDR_DATA_TABLE_ENTRY里取得PDRIVER_OBJECT吗?
用:DEVICE_OBJECT.DeviceQueue.DeviceListHead是否可以遍历所有设备对象啊? |
|
[求助]能从LDR_DATA_TABLE_ENTRY里取得PDRIVER_OBJECT吗?
请大虾帮忙解释解释:DEVICE_OBJECT.DeviceQueue.DeviceListHead是一个什么链表?先谢谢了! |
|
一个通过直接读写硬盘扇区的程序 (写的不好还请多多指正)
直接利用I/O 打开硬盘?? 是ide硬盘还是stat硬盘,或是其他的硬盘 |
|
[求助]发现一种修改文件时间属性的病毒
我猜是想感染pe文件吧! |
|
[讨论]pediy的可贵技术文档还没有收集有关网络编程的文档吗?
说中了,我不是计算机专业的,是业余自学编程的!希望大吓来帮忙帮忙! |
|
一个通过直接读写硬盘扇区的程序 (写的不好还请多多指正)
我在xp下读取第1块磁盘的1扇区数据是错误的! |
|
[求助]xp系统驱动程序下,如何读磁盘数据
也就是读写逻辑扇区,这里要设置eax的值为多少? |
操作理由
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 }}
勋章
兑换勋章
证书
证书查询 >
能力值