【问题标题】:Read String without defining length读取字符串而不定义长度
【发布时间】:2016-04-19 19:57:46
【问题描述】:

是否可以在不定义要读取的字符串长度的情况下使用(调用 ReadString)读取字符串?在调用 ReadString 之前,我必须说明字符串的长度:

mov edx, offset StringOffset
mov ecx, maxLenght
call ReadString                             
mov countOfChars, eax

有什么方法可以在不定义最大长度的情况下读取字符串?

【问题讨论】:

  • “是否可以在没有定义字符串长度的情况下使用(调用 ReadString)读取字符串女巫将被读取?” 这听起来很危险。如果您读取的数据超出缓冲区的容量怎么办?

标签: assembly x86 masm 32-bit irvine32


【解决方案1】:

我从来没有使用 ReadString 调用,但您可以使用字符串末尾的 \0 来获得 maxLength 或手动读取它?

    xor     eax, eax
    cmp     edi, 0
    jz      end
deb:
    cmp     BYTE[edi+eax], 0
    jz      end
    inc     eax
    jmp     deb
end:
    ...

【讨论】:

    猜你喜欢
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    • 2013-01-23
    • 1970-01-01
    • 1970-01-01
    • 2011-03-23
    • 1970-01-01
    相关资源
    最近更新 更多