MASM cmpsb 问题

发布于 2024-09-26 14:34:53 字数 6575 浏览 3 评论 0原文

我在比较两个字符串时遇到问题,一个字符串从 irc 服务器接收数据,一次一行,另一个字符串保存硬编码数据(“PING :”) 但每次我尝试比较字符串时都没有任何反应。你们能帮我一下吗?

比较函数位于 Handleping

这是我当前使用的代码:

.386
.model flat, stdcall
option casemap: none


include \masm32\include\windows.inc 
include \masm32\include\user32.inc 
include \masm32\include\kernel32.inc 
include \masm32\include\shell32.inc
include \masm32\include\wsock32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\user32.lib 
includelib \masm32\lib\kernel32.lib 
includelib \masm32\lib\wsock32.lib
includelib \masm32\lib\masm32.lib
include \masm32\include\msvcrt.inc
includelib  \masm32\lib\msvcrt.lib


.data

txt db "An error occured while calling WSAStartup",0
txt1 db "An error occured while creating a socket",0
txt2 db "An error occured while connecting",0
capt db "SCHiM",0
wsadata WSADATA <>
hostname db "irc.corruptcode.org",0
Port dd 6667 
USER db "USER SCHiMBez 8 * :SCHiMBez",13,10 
CHANNEL db "JOIN #botss",13,10  
NICK db "NICK SCHiMBez",13,10 
trans_buffer db 500 dup (0)
failmatch db "They match!",0
sin sockaddr_in <?>
buff      db 500 dup (0) 
bbuff db (0)
sendbuff db 500 dup (0)
Pong db "PONG :irc.corruptcode.org",13,10,0
Ping db "PING :irc.corruptcode.org"

CLRF    db 13d, 10d
lstring EQU     LENGTHOF Ping


.data?

sock dd ? 
ErrorCode  dd ?


.code



show_error proc caption:ptr byte, err_txt:ptr byte
    invoke WSAGetLastError
    mov ErrorCode, eax
    invoke MessageBoxA, MB_OK, caption, err_txt, 0
    ret
show_error endp

main proc
    invoke  AllocConsole
    invoke WSAStartup, 101h,addr wsadata

    .if eax==0   ; An error occured if eax != 0, because there's no return value for this api, if there's return, there's an error
        invoke socket,AF_INET,SOCK_STREAM,0     ; Create a stream socket for internet use
        .if eax!=INVALID_SOCKET
            mov sock,eax

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Now we have a socket ready for use, we still have to be able to connect to somewere though...
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

            mov sin.sin_family, AF_INET
            invoke htons, Port  ; convert port number into network byte order first
            mov sin.sin_port,ax ; note that this member is a word-size param.
            invoke gethostbyname, addr hostname

            mov eax,[eax+12]    ; move the value of h_list member into eax
            mov eax,[eax]       ; copy the pointer to the actual IP address into eax
            mov eax,[eax]       ; copy IP address into eax
            mov sin.sin_addr,eax

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Now That's done we can connect to a site! (an irc channel in this case)
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

            invoke connect, sock, addr sin, sizeof sin

;invoke lstrcpy, addr sendbuff, addr USER   

;call sndd  ;possible error producer ;p ;if it produces an error, uncomment...

invoke send, sock, addr USER, 29,   0   
invoke send, sock, addr NICK, 15,   0   
invoke send, sock, addr CHANNEL, 13,    0   




            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Receive response from the server
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


  loopspt:  


        call Recvv  ;Receiving data



        call HandlePing
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Do something with the data
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


        invoke MessageBox, 0, addr buff, addr capt, 0


 jmp loopspt 




            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;All data received & check for errors
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

            .else
                invoke show_error, offset capt, offset txt2
            .endif
        .else
            invoke show_error, offset capt, offset txt1
        .endif
     invoke ExitProcess, 0

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Recvv funciong
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Recvv:

invoke RtlZeroMemory, addr buff, sizeof buff
mov bbuff, 0

Gline:

invoke recv,sock,addr bbuff,sizeof bbuff,0

cmp bbuff, 10d
je done

invoke lstrcat, addr buff, addr bbuff   

jmp Gline

done:
ret


            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Recvv funciong
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Ping? Pong! commented for now
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


HandlePing:         


        cld                         ; Work upward
        mov     cx, lstring         ; Load length of string
        mov     esi, offset buff  ; Load offset of string1
        mov     edi, offset Ping  ; Load offset of string2
        repe    cmpsb               ; Compare
        je      allmatch            ; Jump if all match

        jmp zzor
        allmatch:                          
        invoke MessageBoxA, 0, addr failmatch, addr capt, MB_OK

zzor:
ret                             ;return

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Ping? Pong! commented for now
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Send function
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

sndd:

invoke lstrcat, addr sendbuff, 13d   ;this works 
invoke lstrcat, addr sendbuff, 10d   ;this works

invoke lstrlen, sendbuff    ;ERROR HERE, ERROR HERE!!!


invoke send, sock, addr sendbuff, eax,  0



ret

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Send function
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤





main endp
end main

提前致谢 -SCHiM

ps:我现在要去健身房,我可以在大约2或2.5小时内回复任何评论

I'm having a problem comparing two strings with each other, one string receives data from an irc server, one line at a time, and the other holds hard coded data ("PING :")
But every time I try and compare the strings nothing happens. Can you guys help me out?

The compare function is in Handleping

Here's the code I'm currently using:

.386
.model flat, stdcall
option casemap: none


include \masm32\include\windows.inc 
include \masm32\include\user32.inc 
include \masm32\include\kernel32.inc 
include \masm32\include\shell32.inc
include \masm32\include\wsock32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\user32.lib 
includelib \masm32\lib\kernel32.lib 
includelib \masm32\lib\wsock32.lib
includelib \masm32\lib\masm32.lib
include \masm32\include\msvcrt.inc
includelib  \masm32\lib\msvcrt.lib


.data

txt db "An error occured while calling WSAStartup",0
txt1 db "An error occured while creating a socket",0
txt2 db "An error occured while connecting",0
capt db "SCHiM",0
wsadata WSADATA <>
hostname db "irc.corruptcode.org",0
Port dd 6667 
USER db "USER SCHiMBez 8 * :SCHiMBez",13,10 
CHANNEL db "JOIN #botss",13,10  
NICK db "NICK SCHiMBez",13,10 
trans_buffer db 500 dup (0)
failmatch db "They match!",0
sin sockaddr_in <?>
buff      db 500 dup (0) 
bbuff db (0)
sendbuff db 500 dup (0)
Pong db "PONG :irc.corruptcode.org",13,10,0
Ping db "PING :irc.corruptcode.org"

CLRF    db 13d, 10d
lstring EQU     LENGTHOF Ping


.data?

sock dd ? 
ErrorCode  dd ?


.code



show_error proc caption:ptr byte, err_txt:ptr byte
    invoke WSAGetLastError
    mov ErrorCode, eax
    invoke MessageBoxA, MB_OK, caption, err_txt, 0
    ret
show_error endp

main proc
    invoke  AllocConsole
    invoke WSAStartup, 101h,addr wsadata

    .if eax==0   ; An error occured if eax != 0, because there's no return value for this api, if there's return, there's an error
        invoke socket,AF_INET,SOCK_STREAM,0     ; Create a stream socket for internet use
        .if eax!=INVALID_SOCKET
            mov sock,eax

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Now we have a socket ready for use, we still have to be able to connect to somewere though...
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

            mov sin.sin_family, AF_INET
            invoke htons, Port  ; convert port number into network byte order first
            mov sin.sin_port,ax ; note that this member is a word-size param.
            invoke gethostbyname, addr hostname

            mov eax,[eax+12]    ; move the value of h_list member into eax
            mov eax,[eax]       ; copy the pointer to the actual IP address into eax
            mov eax,[eax]       ; copy IP address into eax
            mov sin.sin_addr,eax

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Now That's done we can connect to a site! (an irc channel in this case)
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

            invoke connect, sock, addr sin, sizeof sin

;invoke lstrcpy, addr sendbuff, addr USER   

;call sndd  ;possible error producer ;p ;if it produces an error, uncomment...

invoke send, sock, addr USER, 29,   0   
invoke send, sock, addr NICK, 15,   0   
invoke send, sock, addr CHANNEL, 13,    0   




            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Receive response from the server
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


  loopspt:  


        call Recvv  ;Receiving data



        call HandlePing
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Do something with the data
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


        invoke MessageBox, 0, addr buff, addr capt, 0


 jmp loopspt 




            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;All data received & check for errors
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

            .else
                invoke show_error, offset capt, offset txt2
            .endif
        .else
            invoke show_error, offset capt, offset txt1
        .endif
     invoke ExitProcess, 0

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Recvv funciong
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Recvv:

invoke RtlZeroMemory, addr buff, sizeof buff
mov bbuff, 0

Gline:

invoke recv,sock,addr bbuff,sizeof bbuff,0

cmp bbuff, 10d
je done

invoke lstrcat, addr buff, addr bbuff   

jmp Gline

done:
ret


            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Recvv funciong
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Ping? Pong! commented for now
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


HandlePing:         


        cld                         ; Work upward
        mov     cx, lstring         ; Load length of string
        mov     esi, offset buff  ; Load offset of string1
        mov     edi, offset Ping  ; Load offset of string2
        repe    cmpsb               ; Compare
        je      allmatch            ; Jump if all match

        jmp zzor
        allmatch:                          
        invoke MessageBoxA, 0, addr failmatch, addr capt, MB_OK

zzor:
ret                             ;return

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Ping? Pong! commented for now
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Send function
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

sndd:

invoke lstrcat, addr sendbuff, 13d   ;this works 
invoke lstrcat, addr sendbuff, 10d   ;this works

invoke lstrlen, sendbuff    ;ERROR HERE, ERROR HERE!!!


invoke send, sock, addr sendbuff, eax,  0



ret

            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            ;Send function
            ;¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤





main endp
end main

Thanks in advance
-SCHiM

ps: I'm going to the gym now, I can answer any comments in about 2 or 2.5 hours

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉溺在你眼里的海 2024-10-03 14:34:53

我怀疑问题出在这里:

    mov     cx, lstring         ; Load length of string

在32位模式下,REP前缀使用ECX的完整32位作为计数。可能发生的情况是 ECX 的上半部分有一个非零值,因此 repe cmpsb 扫描得太远,并且不可避免地很快就会遇到不匹配的字节。

I suspect the problem is here:

    mov     cx, lstring         ; Load length of string

In 32-bit mode, REP prefixes use the full 32 bits of ECX as the count. What is probably happening is that there is a non-zero value in the top half of ECX, so the repe cmpsb is scanning too far, and inevitably soon hits bytes which don't match.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文