很简单的测试程序,代码如下:
// test.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
int getMax(int * p, int counts)
{
if (p == 0)
{
return -1;
}
int max = 0;
for (int i = 0; i < counts; i++)
{
if (p[i] > max)
{
max = p[i];
}
}
return max;
}
int _tmain(int argc, _TCHAR* argv[])
{
int counts = 6;
int * p = new int[counts];
p[0] = 9;
p[1] = 1;
p[2] = 3;
p[3] = 100;
p[4] = 8;
p[5] = 6;
int max = 0;
max = getMax(p, counts);
printf("max = %d\n", max);
return max;
}
生成的执行文件用IDA反汇编后:
.text:00401000 wmain proc near ; CODE XREF: __tmainCRTStartup+F8p
.text:00401000 xor ecx, ecx
.text:00401002 mov eax, 6
.text:00401007 mov edx, 4
.text:0040100C mul edx
.text:0040100E seto cl
.text:00401011 neg ecx
.text:00401013 or ecx, eax
.text:00401015 push ecx
.text:00401016 call ds:__imp_??2@YAPAXI@Z ; operator new(uint)
.text:0040101C push 64h
.text:0040101E push offset Format ; "max = %d\n"
.text:00401023 mov dword ptr [eax], 9
.text:00401029 mov dword ptr [eax+4], 1
.text:00401030 mov dword ptr [eax+8], 3
.text:00401037 mov dword ptr [eax+0Ch], 64h
.text:0040103E mov dword ptr [eax+10h], 8
.text:00401045 mov dword ptr [eax+14h], 6
.text:0040104C call ds:__imp__printf
.text:00401052 add esp, 0Ch
.text:00401055 mov eax, 64h
.text:0040105A retn
.text:0040105A wmain endp
getMax这个方法好像被省略掉了,真的是这样么?
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)