修改 IDA边界线插件
作者:jingulong 转自:exetools中文社区
IDA升级后提供的 api已经经过序列号调用,再无MakeBorder如许的 id ,这为以前 upx大侠的插件法修改 IDA 边界线带来不便。于是试着编了一个有相似功效的插件(主要头脑是替换 ExtTextOutA),不妥之处请各位大侠多
多指正。就算是抛砖引玉吧。
以下是这个插件的主要代码,包括:
自编两个函数 Checker 和 BorderPatcher,两个修改了内容的函数 init 和 term
static char *strSeg={"; ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ "};
static char *strSub={"; 〓〓〓〓〓〓〓 S U B R O U T I N E 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓 "};
static char *strBor={"; ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ "};
static char *strStar={" ; ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ "};
static bool idaapi Checker(int Para)
{
bool t;
t=FALSE;
_asm{
lodsd
cmp ax,203Bh
jnz short retur
lodsd
cmp eax,Para
jnz short retur
lodsd
cmp eax,Para
jnz short retur
}
t=TRUE;
retur:
return t;
}
static void idaapi BorderPatcher(HDC, int, int, UINT, CONST RECT *,LPCSTR lpstr, UINT len, CONST INT *)
{
_asm{ push esi
push edi
push ecx
sub esp,20h
lea esi,[ebp+8]
mov edi,esp
mov ecx,8
rep movsd //传递原调用Ext参数
mov esi, lpstr
cmp len,50h
jbe short next_1
mov [esi+12h],20h
jmp short Call_ExtTextOut
next_1:
cmp len,40h
jl Call_ExtTextOut
lodsd
cmp ax, 3B20h
jnz short CheckSub
rol eax,8
cmp al,0BAh
jnz short next_2
mov byte ptr [esi-1],20h
jmp Call_ExtTextOut
next_2:
lodsd
cmp eax, 0cdcdcdcdh
jnz short CheckSub
mov eax,strStar //Title border 替换
jmp Patche
CheckSub:
mov esi, lpstr
push 0DBDBDBDBh
call Checker
test al,al
mov esi, lpstr
jz short CheckBor
mov eax,strSub //函数border 替换
jmp Patche
CheckBor:
push 0C4C4C4C4h
call Checker
test al,al
jz short CheckSeg
mov eax,strBor //逻辑边界替换
jmp Patche
CheckSeg:
mov esi, lpstr
push 0CDCDCDCDh
call Checker
test al,al
jz short Call_ExtTextOut
mov eax,strSeg //段边界替换
Patche:
mov [esp+14h],eax
Call_ExtTextOut:
call ExtTextOutEntry
pop ecx
pop edi
pop esi
}
}
int idaapi init(void)
{
_asm{
push esi
push edi
push edx
push ecx
push eax
mov edi,[ebp+4] //失掉调用返回地址(idag中)
mov ecx,-1
mov al,0e8h
cld
again:
repnz scasb //查找 call
jnz over
mov edx,[edi]
cmp edx,200000h
jae short again
cmp edx,0
jb short again
lea edx,[edi+edx-2] //获取调用目标地址
cmp word ptr[edx],25ffh //是 jmp [xxxxxxx] ?
jnz short again
mov edi,[edx+2] //失掉 IAT
and edi,0fffff000h
jmp short $+7
call ExtTextOutA
call $+5
pop eax
sub eax,9
add eax,[eax]
mov eax,[eax+4] //失掉 ExtTextOutA RAV
mov ecx,800h
repnz scasd //搜刮 ExtTextOutA RAV 在 IAT中的地位
jnz short over
sub edi,4
mov ExtTextOutEntry,eax //保存 ExtTextOutA RAV
mov ExtTextOutIAT,edi //保存其指针
mov eax,offset BorderPatcher
stosd //移花接木:用 BorderPatcher替换指针
over:
pop eax
pop edx
pop ecx
pop edi
pop esi
}
return PLUGIN_KEEP;
}
void idaapi term(void)
{
unhook_from_notification_point(HT_UI, sample_callback);
set_user_defined_prefix(0, NULL);
_asm{
push edi
push eax
mov eax,ExtTextOutEntry
mov edi,ExtTextOutIAT
stosd //恢复指针
pop eax
pop edi
}
}
- 文章作者: 福州军威计算机技术有限公司
军威网络是福州最专业的电脑维修公司,专业承接福州电脑维修、上门维修、IT外包、企业电脑包年维护、局域网网络布线、网吧承包等相关维修服务。
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处 、作者信息和声明。否则将追究法律责任。
TAG:
评论加载中...
|