Program to get user's details, calculate age and display all information

偶尔善良 提交于 2019-12-02 03:32:57

Irvine's ReadString needs two arguments in EDX and ECX. It fills the memory pointed by EDX and returns in the size of the input. Since the string in [EDX] will be zero-terminated, you have to reserve space for the string and the terminating null. With AskName1 DWORD ? you reserved only 4 bytes - that's surely not enough.

As I saw debugging, ECX should be the size of the string with null (not as mentioned: "max number of non-null chars" = size-1).

Do it so:

INCLUDE Irvine32.inc
.data
    ...
    AskName1 BYTE 16 DUP (0)        ; Reserve 16 bytes and fill them with 0
    ...

.code
...
lea edx, AskName1                   ; EDX = address of AskName1
mov ecx, Sizeof AskName1            ; ECX = size of AskName1
call ReadString
...

; and don't forget:
push 0
call ExitProcess
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!