source insigh在代码中进行日文搜索有时候会出现程序出错,以下是解 决方 法,有需要的同学可以参考下:
用UltraEdit 以16进制模式打开Insight3.exe ,将偏移为00005790h开始的5个字节 从原来的 80 64 05 F4 00 改为 90 90 90 90 90 即可
调查方法:
1.程序崩溃后,使用实时调试器debug,这里使用个人比较习惯的ollydbg,查看出错现场,分析调试一下前后代码 发现下面这段比较可疑
0040576E |. 6A 09 push 9 ; /Count = 9 00405770 |. 8D45 F4 lea eax, dword ptr [ebp-C] ; | 00405773 |. 50 push eax ; |Buffer 00405774 |. FF75 0C push dword ptr [ebp+C] ; |/Arg2 00405777 |. FF75 08 push dword ptr [ebp+8] ; ||Arg1 0040577A |. E8 760D0000 call 004064F5 ; |\Insight3.004064F5 0040577F |. 05 E8030000 add eax, 3E8 ; | 00405784 |. 50 push eax ; |ControlID 00405785 |. 8B45 08 mov eax, dword ptr [ebp+8] ; | 00405788 |. FF30 push dword ptr [eax] ; |hWnd 0040578A |. FF15 F0845200 call dword ptr [<&USER32.GetDlgItemTe>; \GetDlgItemTextA 00405790 |. 806405 F4 00 and byte ptr [ebp+eax-C], 0 --------------------------->越界写入,破坏了堆栈 00405795 |? 0FB645 F4 movzx eax, byte ptr [ebp-C]
结合出错的情况大致还原下情况就是
source insigh3在搜索时,获取文本框中文本长度错误导致越界写入,堆栈被破坏了
伪代码:
.... char buff[9]; buff[GetDlgItemTextA(hWnd,ControlID,Buffer,9)]=0; ... GetDlgItemTextA在获取UNIcode字符时,函数的返回值并不是获取字符串的长度了,所以导致问题的产生
因此,直接将
00405795 |? 0FB645 F4 movzx eax, byte ptr [ebp-C]
注掉,用nop代替即可
00405790 90 nop 00405791 90 nop 00405792 90 nop 00405793 90 nop
--以上