accept函数返回10022错(无效参数?),请帮忙看看,以下是代码
.586p
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\ws2_32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\ws2_32.lib
.data
szCap db "测试程序!",0
szErrorMsg db "出错了!返回代码:%0d",0
fmt db "Kernel32的基址是:%08X",0
sendbuf db "*****************************************",0dh,0ah
db " 连接成功! ",0dh,0ah
db "*****************************************",0
buff db 256 dup(0)
ThreadID dw 0
wsadata WSADATA <>
sinaddr sockaddr_in <>
cliaddr sockaddr_in <>
port dw 0
socketlen dw 0
.code
_start:
invoke GetCommandLine
call OpenProc
;============OpenProc===========
; 线 程
;参数==>:无参数
;=================================
OpenProc proc
LOCAL m_socket :dword
LOCAL asocket :dword
invoke WSAStartup, 101h, addr wsadata
.if eax!=NO_ERROR
jmp Error
.endif
invoke socket, AF_INET, SOCK_STREAM, 0
.if eax==SOCKET_ERROR
jmp Error
.endif
mov m_socket, eax
mov sinaddr.sin_family, AF_INET
invoke htonl,INADDR_ANY
mov sinaddr.sin_addr, eax
xor eax,eax
invoke htons,5129
mov sinaddr.sin_port, ax
invoke bind,m_socket,addr sinaddr,sizeof sinaddr
.if eax == SOCKET_ERROR
jmp Error
.endif
invoke listen,m_socket,3
.if eax == SOCKET_ERROR
jmp Error
.endif
push sizeof cliaddr
pop socketlen
lea eax,socketlen
.while TRUE
invoke accept,m_socket,NULL,NULL
.if eax == SOCKET_ERROR
jmp Error
.endif
mov asocket,eax
invoke send,asocket,sendbuf,100,0
.break
.endw
invoke WSACleanup
Succ:
mov eax,1
ret
Error:
invoke GetLastError
invoke wsprintf,addr buff,addr szErrorMsg,ecx
invoke MessageBox,NULL,addr buff,addr szCap,1040h
xor eax,eax
ret
OpenProc endp
end _start
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)