我处理的组装可能数组,但我想不通的启动值是什么 [英] I am dealing with a possible array in assembly, but I cannot figure out what the starter value is
问题描述
尺寸包含数字86。
var_10= dword ptr -10h
var_C= dword ptr -0Ch
size= dword ptr 8
push ebp
mov ebp, esp
sub esp, 28h
mov eax, [ebp+size]
mov [esp], eax ; size
call _malloc
mov ds:x, eax
mov [ebp+var_C], 0
jmp short loc_804889E
loc_804889E: ~~~~~~~~~~~~~~~~~~~~~
mov eax, [ebp+size]
sub eax, 1
cmp eax, [ebp+var_C]
jg short loc_8048887
loc_8048887: ~~~~~~~~~~~~~~~~~~~~~
mov edx, ds:x
mov eax, [ebp+var_C]
add edx, eax
mov eax, [ebp+var_C]
add eax, 16h
mov [edx], al
add [ebp+var_C], 1
我有扭转了项目我工作的这部分困难。还有的地方 DS的code的一部分:X
移动到 EDX
,并加有 var_c
,而且我不确定哪里去这一点。
I am having difficulties reversing this portion of a project I am working on. There's a portion of the code where ds:x
is moved into edx
and is added with var_c
and I am unsure where to go with that.
要我的程序看起来像它调用的malloc
,然后将移动到 DS:X
,然后移动 0
到 var_c
。
To me the program looks like it calls malloc
and then moves that into ds:x
and then moves 0
to var_c
.
之后,它只是减去 1
从我的指针数组的大小和数量比较 0
,然后跳转到它增加了 DS部分:X
到 EDX
,因此它可以添加 EAX
到 EDX
。
After that it simply subtracts 1
from the size of my pointer array and compares that number to 0
, then jumps to a portion where it adds ds:x
into edx
so it can add eax
to edx
.
我是不是处理一些阵列在这里?那是什么回事进入 EDX
在 loc_8048887
的第一个值?另一种方式,这可能有助于将看到一个C相当于它......但是那会是什么,我试图完成,而宁愿通过学习不同的方式来解决。
Am I dealing with some sort of array here? What is the first value that's going to go into edx
in loc_8048887
? Another way this could help would be to see a C equivalent of it... But that would be what I am trying to accomplish and would rather learn the solution through a different means.
感谢您!
推荐答案
在x86汇编有存储在内存中的变量,并在内存中的数组没有严格的区分。它只取决于你如何访问内存区域。你已经是code和数据。无论如何,我会说, DS:X
是一个数组的,因为这code在这里:
In x86 assembly there's no strict distinction between a variable stored in memory and an array in memory. It only depends on how you access the memory region. All you have is code and data. Anyway, I'd say that ds:x
is an array as because of this code here:
mov edx, ds:x ; edx = [x]
mov eax, [ebp+var_C] ; eax = something
add edx, eax ; edx = [x] + something
mov eax, [ebp+var_C] ; eax = something
add eax, 16h ; eax = something + 0x16
mov [edx], al ; [[x] + something ] = al . Yes, ds:x is an array!
什么是 EDX
在 loc_8048887
的价值?为了找到它,你只需要一些非常基本的调试技巧。我假设你有 GDB
在眼前,如果没有,把它尽快。然后编译code。与调试符号,并将其链接,然后运行 GDB
的可执行文件,设置为 loc_8048887 ,运行与
研究
,最后检查 EDX
。
What is the value of edx
in loc_8048887
? To find it out you only need some very basic debugging skills. I assume you have gdb
at hand, if not, get it ASAP. Then compile the code with debug symbols and link it, then run gdb
with the executable, set a code breakpoint at loc_8048887
, run the program with r
, and finally check the value of edx
.
这是你所需要的命令:
gdb myexecutable
(gdb) b loc_8048887
(gdb) r
(gdb) info registers edx
这篇关于我处理的组装可能数组,但我想不通的启动值是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!