|
[讨论]关于“问道”的怪物生命值的获取的问题
终于把最难啃的那段代码搞定了 |
|
[讨论]关于“问道”的怪物生命值的获取的问题
没有人做问道的外挂的吗 |
|
[建议]说好的每天5Kx封顶 在线1小时奖励1Kx 为什么不兑现
这真是SB了,谁有时间整天给他刷网页啊。娘希匹的 |
|
[求助]内存监视的方法?
关于内存监视,本人目前使用的方法是采用page_guard属性;首先设置需要监视的内存区块的page_guard,然后等待EXCEPTION_DEBUG_EVENT/EXCEPTION_ACCESS_VIOLATION; 当然这么做之前,调用DebugActiveProcess加载目标进程,自己写一个简单的调试器。 |
|
[讨论]关于hot patch的问题
这个代码是最初的写法,但是由于类成员变量在_asm里面使用不当,编译有问题,所以走了弯路;经过大家的讨论,仔细调整了下,就成如此了。 |
|
[讨论]关于hot patch的问题
实际上代码是这么写的,谢谢大家讨论 BOOL CApiHookWSAStartup::Hook() { return CApiHook::Hook(_T("ws2_32.dll"), "WSAStartup"); } typedef int (PASCAL FAR *fnWSAStartup)(WORD wVersionRequired, LPWSADATA lpWSAData); int PASCAL FAR CApiHookWSAStartup::_WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData) { DWORD_PTR retv = 0; DWORD_PTR _NextStepAddress = (DWORD_PTR)NextStepAddress; <------------ _asm { pushad; mov eax, dword ptr [lpWSAData]; push eax; movzx ecx, word ptr [wVersionRequired]; push ecx; call near real_WSAStartup; <------------------ mov retv, eax; popad; jmp func_ok; real_WSAStartup: push 14h; jmp _NextStepAddress; ret; // 实际上不会执行 func_ok: ; } if (retv == 0) begin_lurker_handler(); //retv = ((fnWSAStartup)NextStepAddress)(wVersionRequired, lpWSAData); return retv; } static int PASCAL FAR __WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData) { return CApiHookWSAStartup::hooker._WSAStartup(wVersionRequired, lpWSAData); } PVOID CApiHookWSAStartup::GetMyApiAddress() { return (PVOID)__WSAStartup; } |
|
[讨论]关于hot patch的问题
感谢楼上的积极参与,可能你对非标准hot patch的api缺乏关注。目测WSAStartup_Stub 这个函数是不能正确运行的,就算正确运行,它也会直接return到wsastartup调用的下一条指令了,根本不会有后续处理的机会。请注意naked关键字。 实际可行的是本人给出的代码,各位可以实际测试。 |
|
[讨论]关于hot patch的问题
针对楼上的说法,本人不给回应。先去实际测试再来说问题。 |
|
[讨论]关于hot patch的问题
这个简单跳转可以这么实现: static void __declspec(naked) __WSAStartup() { { // 在这里做私人的事情 // 获取下一步的地址 next_step_addr = CApiHookWSAStartup::hooker.GetNextStepAddress(); _asm { push 14h; // 模拟WSAStartup入口点的指令 jmp next_step_addr; // 这里无法到达无法到达无法到达无法到达无法到达 ret; } } } 这个跳转是可以正常使用的,但是由于jmp next_step_addr;之后就直接返回到wsastartup调用之后的下一条指令了,所以达不到想要的效果,即:根据实际wsastartup调用结果来判断是否进行私人的处理。 |
|
[讨论]关于hot patch的问题
楼上的可以实际去测试。intel的software developer's manual的6.3 calling procedures using call adn ret对这做了说明 |
|
[讨论]关于hot patch的问题
DWORD ver = 0; DWORD dat = 0; DWORD regEIP = 0; PVOID next_step_addr = NULL; static void __declspec(naked) __MyHook_WSAStartup() { { _asm { // 将调用WSAStartup时入栈的参数弹出保存 pop regEIP; <---------针对call是far或者near,应该有不同的措施 pop ver; pop dat; push regEIP; } // 获取下一步的地址 next_step_addr = CApiHookWSAStartup::hooker.GetNextStepAddress(); _asm { // 先调用实际的WSAStartup函数,再调用相关的工作函数 push dat; <----移到这里 push ver; <----移到这里 call near orig_routine; call begin_lurker_handler; // 个人的处理函数,希望在real wsastartup返回之后被调用 ret; orig_routine: push 14h; // 模拟WSAStartup入口点的指令 jmp next_step_addr; } } } 实际上代码可简化成这样 |
|
[讨论]关于hot patch的问题
_asm { push lpWSAData push wVersionRequested push 14h <--------------- call next_step_addr <--------------- mov ReturnValue,eax } 楼上的哥们注意看这两个箭头所指的地方: 一、当call的时候,1)如果是far调用,实际上在push 14h和next_step_addr之间多了两个寄存器入栈(CS和EIP);2)如果是near调用,实际上在push 14h和next_step_addr之间多了一个寄存器入栈(EIP)。 二、不考虑call带来的寄存器入栈的副作用,即便是call next_step_addr成功之后,就已经直接ret到调用wsastartup的下一个指定的地方,也即mov returnvalue, eax不可能被调用 鉴于此,楼上的代码是不能成功运行的。 而我指出的判断call是far或者near,正是要解决call指令的入栈操作的问题。楼上的哥们可以仔细体会下我的解决方案的原理。 |
|
[讨论]关于hot patch的问题
好吧,我自己说下实现非标准hot patch的api hook的解决方法,针对wsastartup: wsastartup的入口点如下: nop nop nop nop nop push 14h <---------------wsastartup入口 push ws2_32.76c53c08 call ws2_32.76c51370 我的hook函数的实现: DWORD ver = 0; DWORD dat = 0; DWORD regEIP[2] = {0, 0}; PVOID next_step_addr = NULL; static void __declspec(naked) __MyHook_WSAStartup() { { _asm { // 将调用WSAStartup时入栈的参数弹出保存 pop regEIP[0]; pop ver; pop dat; push regEIP[0]; } // 获取下一步的地址 next_step_addr = CApiHookWSAStartup::hooker.GetNextStepAddress(); _asm { // 先调用实际的WSAStartup函数,再调用相关的工作函数 call near orig_routine; call begin_lurker_handler; // 个人的处理函数,希望在real wsastartup返回之后被调用 ret; orig_routine: pop regEIP[1]; push dat; push ver; push regEIP[1]; push 14h; // 模拟WSAStartup入口点的指令 jmp next_step_addr; } } } 这个实现,正在正常使用,达到了我的目的。但是call有far和near之分,怎么在__MyHook_WSAStartup里面判断WSAStartup被调用的时候是call far的还是call near。希望有兄弟解惑,并给出更好一点的解决方案。 |
|
|
操作理由
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 }}
勋章
兑换勋章
证书
证书查询 >
能力值