花指令
g++内联(x64)
int add1(int x,int y)
{
return x+y;
}
int main()
{
int x =0,y=0;
scanf("%d %d",&x,&y);
asm(
".globl _start\n\t"
"_start:"
"call _sec\n\t");
asm(
".globl _sec\n\t"
"_sec:"
"call _thr\n\t"//下方都是无意义的代码
"call 0xef\n\t"//只增加一个call时ida无变化
"mov 4,%%rax\n\t"//增加对rax修改时ida无变化
"add $4,%1\n\t"//增加对参数修改时ida无变化
"push %%rsp\n\t"//多个push只提示堆栈不平衡ida无变化
"push %%rsp\n\t"
"push %%rsp\n\t"
"push %%rsp\n\t"
"ret"//增加无意义的ret ida无法识别
:"+r"(x)
);
asm( ".globl _sec\n\t"
"_thr:"
"add $16,%esp\n\t"
);
printf("%d",add1(x,y));
}
cl内联(x86)
#include<stdio.h>
int add1(int x, int y)
{
return x + y;
}
int main()
{
int a = 1, b = 2;
__asm {
call c1;
push eax;
push ebx;
c1:
call c2;
push eax;
pop eax;
c2:
add esp,8;
}
printf("%d", add1(a, b));
}
只进行无意义的push操作时ida直接无法识别