home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.sberbank.sumy.ua
/
2014.11.ftp.sberbank.sumy.ua.tar
/
ftp.sberbank.sumy.ua
/
incoming
/
1
/
WSK19173.asm
< prev
next >
Wrap
Assembly Source File
|
2014-02-08
|
8KB
|
310 lines
.386
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\wsock32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\wsock32.lib
return MACRO arg
mov eax, arg
ret
ENDM
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
TableCreateControls PROTO :DWORD, :DWORD, :DWORD
GetButtonProc PROTO :DWORD, :DWORD
MultiEdit PROTO :DWORD, :DWORD
.data
szClassName db "Evgeney-Victorovich-Kupin-27-April-1982",0
szDisplayName db "Net bones Daytime protocol 13",0
CommandLine dd 0
hWnd dd 0
hInstance dd 0
hIcon dd 0
PosX dd 0
PosY dd 0
dWidth dd 450
dHeight dd 380
hSock dd 0
strWsaData WSADATA <0>
stError db "Socket error",0
stWspritf db "%s%d.%d.%d.%d",0dh,0ah,0
stBuffer db 256 dup(0)
stBufferOne db 256 dup(0)
tButtonStyle equ WS_VISIBLE or WS_CHILD or BS_DEFPUSHBUTTON
tMultiEditStyle equ WS_VISIBLE or WS_CHILD or WS_VSCROLL or ES_MULTILINE or WS_HSCROLL or ES_AUTOHSCROLL
tEditStyle equ WS_VISIBLE or WS_CHILDWINDOW or ES_AUTOHSCROLL or ES_NOHIDESEL
stButtonClass db "BUTTON",0
stEditClass db "EDIT",0
stGetButton db "Get",0
stSetButton db "Set",0
stWWWaddress db "time.nist.gov",0
tControl dd offset stButtonClass, stGetButton, 320, 0, 100, 30, tButtonStyle, GetButtonProc,\
offset stButtonClass, stSetButton, 320, 35, 100, 30, tButtonStyle, GetButtonProc,\
offset stEditClass, offset stWWWaddress, 0, 0, 300, 30, tEditStyle, MultiEdit,\
offset stEditClass, 0, 0, 35, 300, 300, tMultiEditStyle, MultiEdit
tControlBase dd 10
tControlID dd 10
tHandles dd 100 dup(0)
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain, hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst :DWORD, hPrevInst :DWORD, CmdLine :DWORD, CmdShow :DWORD
LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW \
or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground, COLOR_BACKGROUND
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset szClassName
push hIcon
pop wc.hIcon
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor, eax
push hIcon
pop wc.hIconSm
invoke RegisterClassEx, ADDR wc
invoke GetSystemMetrics,SM_CXSCREEN
sub eax, dWidth
shr eax,1
mov PosX, eax
invoke GetSystemMetrics,SM_CYSCREEN
sub eax, dHeight
shr eax,1
mov PosY, eax
invoke CreateWindowEx,WS_EX_LEFT,
ADDR szClassName,
ADDR szDisplayName,
WS_OVERLAPPEDWINDOW or WS_SYSMENU,
PosX, PosY,dWidth,dHeight,
NULL,NULL,
hInst,NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
return msg.wParam
WinMain endp
WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
.if uMsg == WM_CREATE
mov eax, 0202h
invoke WSAStartup, eax, addr strWsaData
invoke TableCreateControls, addr tControl, hWin, 4
return 0
.elseif uMsg == WM_COMMAND
mov ecx, offset tControl
mov eax, wParam
and eax, 0ffffh
sub eax, tControlBase
shl eax, 5
add ecx, eax
shr eax, 3
cmp tHandles[eax],0
je WndProc_WM_COMMAND_exit
push tHandles[eax]
push hWin
call DWORD PTR[ecx+28]
WndProc_WM_COMMAND_exit:
return 0
.elseif uMsg == WM_DESTROY
invoke WSACleanup
invoke PostQuitMessage,NULL
return 0
.endif
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
WndProc endp
TableCreateControls proc pTable:DWORD, hWin:DWORD, dNumber:DWORD
xor eax, eax
TableCreateControls_loop:
push eax
mov ecx, pTable
shl eax, 2
shl eax, 3
add ecx, eax
invoke CreateWindowEx,WS_EX_CLIENTEDGE, [ecx], [ecx+4],\
[ecx+24],[ecx+8],[ecx+12],[ecx+16],[ecx+20],\
hWin, tControlID, hInstance, NULL
pop ecx
shl ecx, 2
mov tHandles[ecx],eax
shr ecx, 2
mov eax,ecx
inc tControlID
inc eax
cmp eax, dNumber
jb TableCreateControls_loop
ret
TableCreateControls endp
GetButtonProc proc hWin:DWORD, hControl:DWORD
LOCAL lpHostent:DWORD
LOCAL aIP,bIP,cIP,dIP:DWORD
LOCAL sockAddr:sockaddr_in
invoke GetWindowText, tHandles[4*2], addr stBuffer, 255
invoke gethostbyname, addr stBuffer
cmp eax,0
je GetButtonProc_display_ip_list_exit
mov lpHostent, eax
mov stBuffer[0],0
mov edx, 0
GetButtonProc_display_ip_list:
mov eax, lpHostent
mov ecx, [eax+12]
mov ecx, [ecx+edx]
cmp ecx, 0
je GetButtonProc_display_ip_list_exit
push [ecx]
pop aIP
and aIP, 0ffh
push [ecx]
pop bIP
shr bIP, 8
and bIP, 0ffh
push [ecx]
pop cIP
shr cIP, 16
and cIP, 0ffh
push [ecx]
pop dIP
shr dIP, 24
and dIP, 0ffh
push edx
invoke wsprintf, addr stBuffer, addr stWspritf, addr stBuffer, aIP, bIP, cIP, dIP
pop edx
add edx, 4
jmp GetButtonProc_display_ip_list
GetButtonProc_display_ip_list_exit:
invoke SetWindowText, tHandles[4*3], addr stBuffer
invoke socket, AF_INET, SOCK_STREAM, IPPROTO_TCP
mov hSock, eax
mov sockAddr.sin_family, AF_INET
xor ax,ax
mov ah, 13
mov sockAddr.sin_port, ax
mov eax, lpHostent
mov ecx, [eax+12]
mov ecx, [ecx]
push [ecx]
pop sockAddr.sin_addr
invoke connect, hSock, addr sockAddr, sizeof sockaddr_in
.if eax == SOCKET_ERROR
invoke MessageBox, hWin, addr stError, addr stError,0
.endif
invoke recv, hSock, addr stBufferOne, 256, 0
invoke closesocket, hSock
mov stBufferOne[0], ">"
invoke lstrcat, addr stBuffer, addr stBufferOne
invoke SetWindowText, tHandles[4*3], addr stBuffer
mov DWORD PTR stBufferOne[0],0
ret
GetButtonProc endp
MultiEdit proc hWin:DWORD, hControl:DWORD
invoke GetWindowText, hControl, addr stBuffer, 255
ret
MultiEdit endp
end start