如果跳得太远,检查和调试的最佳方法是什么?
所以我有一个变量inBuffer,它包含一个BYTE长度为115。我将其移动到bufSize中,并尝试对一组3密钥对xor‘进行解密。我的代码编译,但我无法构建,除了这个部分,它说我跳得太远了。
bufSize DWORD ?
mov eax,115
mov bufSize,eax
;-------------------------------------------------
AnalyzeBuffer PROC
;receives nothing
;returns nothing
;-------------------------------------------------
pushad ; pushes all data in this method into a stack
mov ecx,bufSize ; loop count
mov esi,0 ; start at index 0 in translated buffer
top:
cmp buffer[esi],20h ; checks if character is space which is ok
je yes
cmp buffer[esi],2ch ; checks if character is comma wich is okay
je yes
cmp buffer[esi],2eh ; checks if character is period which is okay
je yes
cmp buffer[esi],41h ; checks if character is above A in the ascii chart
jb no
;the following are all unacceptable characters
cmp buffer[esi],5bh ;checks if character is [
je no
cmp buffer[esi],5ch ; checks if character is \
je no
cmp buffer[esi],5dh ;checks if character is ]
je no
cmp buffer[esi],5eh ; checks if character is ^
je no
cmp buffer[esi],5fh ; checks if character is _
je no
cmp buffer[esi],60h ; checks if character is `
je no
cmp buffer[esi],7bh ; checks if characre is {
je no
cmp buffer[esi],7ch ; checks if character is |
je no
cmp buffer[esi],7dh ; checks if }
je no
cmp buffer[esi],7eh ; checks if ~
je no
cmp buffer[esi],7fh ; checks if
je no
yes:
inc esi ; going to next character
loop top
;getting to this step means these keys worked for all characters in buffer
mov edx,OFFSET goodMsg
call WriteString
call DisplayAllKeys ; shows 3 keys used
call Crlf
call Crlf
mov edx,OFFSET buffer ; displays decrypted message
call WriteString
call Crlf
call Crlf
no:
;the current character wasnt good so trying next key
popad
ret
AnalyzeBuffer ENDP发布于 2014-04-24 21:11:08
下次您应该知道是哪一行导致了错误。我猜它是loop指令,因为它只存在一个8位偏移量。由于优化的原因,它是建议避免使用它无论如何,这将解决您的跳转范围问题。所以,只需用一个dec ecx; jnz top替换它。
您也可以优化您的检查,但这是另一个故事。
https://stackoverflow.com/questions/23278909
复制相似问题