分析汇编任务

.text:0040151B mov ebx, offset unk_403040 //将标签unk_403040地址存入ebx寄存器
.text:00401520 mov edx, 1Dh //将1dh数据存入edx寄存器
.text:00401525 mov edi, eax //将eax寄存器的值存入edi寄存器
.text:00401527 mov esi, ebx //将ebx寄存器的值存入esi寄存器,其实就是unk_403040地址
.text:00401529 mov ecx, edx //将edx寄存器的值存入ecx寄存器
.text:0040152B rep movsd //rep重复指令每次ecx!=0便执行movsd ,然后ecx=ecx-1, 直到 ecx 为0。

movsd:将从 esi 指向的地址开始的数据复制到 edi 指向的地址,传送一个双字,之后ESI和EDI加/减4。

.text:0040152D lea eax, [esp+50h] //将esp加上 50h后的地址存入ea 寄存器。
.text:00401531 mov ebx, offset unk_4030C0 //将标签unk_4030C0 的地址存入ebx寄存器
.text:00401536 mov edx, 1Ah //将1Ah存入edx寄存器
.text:0040153B mov edi, eax //再次将eax寄存器的值存入edi寄存器
.text:0040153D mov esi, ebx //将unk_4030C0的地址存入esi寄存器
.text:0040153F mov ecx, edx //将新的数据长度存入 ecx 寄存器作为循环计数器
.text:00401541 rep movsd //重复执行字符串传送操作
.text:00401543 mov dword ptr [esp+12Ch], 0 //将0存入esp 加上12Ch处的内存位置
.text:0040154E jmp short loc_40158F //跳转到标签 loc_40158F 处

.text:00401550 ; —————————————————————-

.text:00401550
.text:00401550 loc_401550: ; CODE XREF: _main+97↓j //一个跳转类型的交叉引用,表示在 _main 函数的某个偏移量为97 字节的地方)有一个跳转到当前代码行(loc_401550),意味着 loc_401550 是一个循环体。
.text:00401550 mov eax, [esp+12Ch] //将 esp 加上 12Ch 处的内存值存入 eax 寄存器。
.text:00401557 mov edx, [esp+eax*4+0B8h] //将eax 乘以 4,然后加上 0xB8,读取该地址的值到edx。
.text:0040155E mov eax, [esp+12Ch] //相同
.text:00401565 mov eax, [esp+eax*4+0B8h] //将 eax的值乘以 4 后加上 0xB8,从栈中读取值到eax
.text:0040156C imul eax, edx //将 edx 中的值与 eax相乘,结果将存回 eax。
.text:0040156F mov edx, [esp+12Ch] //又来,数据给edx
.text:00401576 mov ecx, [esp+edx*4+50h] //将 edx 乘以 4 后加上 0x50,从栈中读取值到 ecx
.text:0040157A cdq //将 eax扩展到 edx:eax
.text:0040157B idiv ecx //edx:eax除以 ecx,结果存储在 eax 中,余数存储在 edx 中
.text:0040157D mov eax, [esp+12Ch] //。
.text:00401584 mov [esp+eax*4], edx //将 edx的值存回栈中,偏移为 eax * 4
.text:00401587 add dword ptr [esp+12Ch], 1 // 将栈中地址 0x12C 处的值加 1,用来循环计数
.text:0040158F
.text:0040158F loc_40158F: ; CODE XREF: _main+4E↑j //从_main的开始处向后78个单位的位置向前跳转
.text:0040158F cmp dword ptr [esp+12Ch], 13h //比较计数器的值是否小于等于 13h。
.text:00401597 jle short loc_401550 //如果是,则跳转到 loc_401550,继续执行循环。

……这玩意真的好难,还没学指针,实在不会了。・゚゚・(>д<)・゚゚・,先ai吧。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
int* unk_403040;
int* unk_4030C0;

void function() {
int *esi, *edi;
int ecx, edx, eax, ebx;
ebx = (int)unk_403040;
edx = 0x1D;
edi = eax;
esi = ebx;
ecx = edx;
while (ecx--) {
*((int *)(edi)) = *((int *)(esi));
edi += 4;
esi += 4;
}
eax = (int)((char *)esp + 0x50);
ebx = (int)unk_4030C0;
edx = 0x1A;
edi = eax;
esi = ebx;
ecx = edx;
while (ecx--) {
*((int *)(edi)) = *((int *)(esi));
edi += 4;
esi += 4;
}
*((int *)(esp + 0x12C)) = 0;
goto loc_40158F;

loc_401550:
eax = *((int *)(esp + 0x12C));
edx = *((int *)((char *)esp + eax * 4 + 0xB8));
eax = *((int *)(esp + 0x12C));
eax = *((int *)((char *)esp + eax * 4 + 0xB8));
eax = (int)((long long)eax * edx);
edx = *((int *)(esp + 0x12C));
ecx = *((int *)((char *)esp + edx * 4 + 0x50));
edx = (eax < 0) ? -1 : 0;
eax /= ecx;
edx = (long long)eax % ecx;
*((int *)((char *)esp + eax * 4)) = edx;
*((int *)(esp + 0x12C)) += 1;

loc_40158F:
if (*((int *)(esp + 0x12C)) <= 0x13) {
goto loc_401550;
}
}