花了点时间,整理一下SockClient.cpp,转成汇编.....可惜功底不深,很多东西都无法完成,只能C/ASM混合编程了.......SockServer.cpp 我还没写,所以SockClient.asm就无法调式了....郁闷 哪位大大帮忙写一下SockServer.cpp?
SockClient.asm:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include wsock32.inc
include Ws2_32.inc
includelib user32.lib
includelib kernel32.lib
includelib wsock32.lib
includelib Ws2_32.lib
MAJOR_VERSION equ 1
MINOR_VERSION equ 12
WM_SOCK equ 280
US_MAXSIZ equ 1024
US_FLAG equ 9999
US_MOUSEMOVE equ 2000
US_MOUSELD equ 3100
US_MOUSELU equ 3200
US_MOUSERD equ 4100
US_MOUSERU equ 4200
US_DESKTOPBIT equ 5000
US_LOCK equ 6100
US_UNLOCK equ 6200
MouseMove proto :DWORD
MouseLD proto :DWORD
MouseLU proto :DWORD
MouseRD proto :DWORD
MouseRU proto :DWORD
.data?
ClientSock SOCKET ?
@stAddr sockaddr_in<?>
lpWSADATA WSADATA<?>
SysWidth dd ?
SysHeight dd ?
FALG DWORD ?
NewSock SOCKET ?
iMsg DWORD ?
point POINT<?>
x1 db 156 dup(?)
y1 db 156 dup(?)
hPoint POINT<?>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
InISock proc
invoke WSAStartup,202,addr lpWSADATA
.if eax!=NULL
mov eax,FALSE
.elseif
mov eax,TRUE
.endif
InISock endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ConnectSock proc
invoke socket,AF_INET,SOCK_STREAM,0
.if eax==INVALID_SOCKET
mov eax,FALSE
.endif
mov ClientSock,eax
mov ax,AF_INET
mov @stAddr.sin_family,ax
mov @stAddr.sin_addr,INADDR_ANY
invoke htons,7016
mov @stAddr.sin_port,ax
invoke bind,ClientSock,addr @stAddr,sizeof @stAddr
.if eax==NULL
mov eax,FALSE
.endif
invoke listen,ClientSock,1
.if eax!=NULL
mov eax,FALSE
.elseif
mov eax,TRUE
.endif
ret
ConnectSock endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
AcceptData proc
invoke accept,ClientSock,addr @stAddr,sizeof @stAddr
.if eax<0
invoke closesocket,ClientSock
mov eax,FALSE
.endif
mov NewSock,eax
invoke GetSystemMetrics,SM_CXSCREEN
mov SysWidth,eax
invoke GetSystemMetrics,SM_CYSCREEN
mov SysHeight,eax
mov eax,TRUE
ret
AcceptData endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GetMousePoint proc hPoint1:DWORD
invoke recv,NewSock,addr x1,sizeof x1,0
invoke recv,NewSock,addr y1,sizeof y1,0
invoke lstrcpy,addr point.x,addr x1
invoke lstrcpy,addr point.y,addr y1
invoke lstrcpy,addr hPoint1,addr point
ret
GetMousePoint endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
GetData proc
mov FALG,US_FLAG
invoke send,NewSock,addr FALG,sizeof FALG,MSG_OOB
invoke recv,NewSock,addr iMsg,sizeof iMsg,0
.if eax<NULL
invoke closesocket,NewSock
invoke closesocket,ClientSock
mov eax,FALSE
.endif
.if iMsg<4500
invoke send,NewSock,addr SysWidth,sizeof SysWidth,MSG_OOB
invoke send,NewSock,addr SysHeight,sizeof SysHeight,MSG_OOB
invoke GetMousePoint,addr hPoint
.if iMsg==US_DESKTOPBIT
;invoke SendDesktop ;这里采用C/ASM混合编程.
.elseif iMsg==US_MOUSEMOVE
invoke MouseMove,addr hPoint
.elseif iMsg==US_MOUSELD
invoke MouseLD,addr hPoint
.elseif iMsg==US_MOUSELU
invoke MouseLU,addr hPoint
.elseif iMsg==US_MOUSERD
invoke MouseRD,addr hPoint
.elseif iMsg==US_MOUSERU
invoke MouseRU,addr hPoint
.elseif iMsg==US_LOCK
;invoke SysEvent,US_LOCK ;这里采用C/ASM混合编程
.elseif iMsg==US_UNLOCK
;invoke SysEvent,US_UNLOCK ;这里采用C/ASM混合编程
.endif
.endif
mov eax,TRUE
ret
GetData endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MouseMove proc _lpPoint:DWORD
push esi
mov esi,_lpPoint
assume esi:ptr POINT
invoke SetCursorPos,addr [esi].x,addr [esi].y
assume esi:nothing
pop esi
ret
MouseMove endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MouseLD proc _lpPoint:DWORD
push esi
mov esi,_lpPoint
assume esi:ptr POINT
invoke mouse_event,MOUSEEVENTF_LEFTDOWN,addr [esi].x,addr [esi].y,0,0
assume esi:nothing
pop esi
ret
MouseLD endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MouseLU proc _lpPoint:DWORD
push esi
mov esi,_lpPoint
assume esi:ptr POINT
invoke mouse_event,MOUSEEVENTF_LEFTUP,addr [esi].x,addr [esi].y,0,0
assume esi:nothing
pop esi
ret
MouseLU endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MouseRD proc _lpPoint:DWORD
push esi
mov esi,_lpPoint
assume esi:ptr POINT
invoke mouse_event,MOUSEEVENTF_RIGHTDOWN,addr [esi].x,addr [esi].y,0,0
assume esi:nothing
pop esi
ret
MouseRD endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MouseRU proc _lpPoint:DWORD
push esi
mov esi,_lpPoint
assume esi:ptr POINT
invoke mouse_event,MOUSEEVENTF_RIGHTUP,addr [esi].x,addr [esi].y,0,0
assume esi:nothing
pop esi
ret
MouseRU endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke InISock
.if !eax
mov eax,FALSE
.endif
invoke ConnectSock
.if !eax
mov eax,FALSE
.endif
.while TRUE
invoke AcceptData
.if !eax
invoke WSACleanup
.endif
.endw
end start