home *** CD-ROM | disk | FTP | other *** search
/ ftp.sberbank.sumy.ua / 2014.11.ftp.sberbank.sumy.ua.tar / ftp.sberbank.sumy.ua / incoming / 1 / WSK18173.asm < prev    next >
Assembly Source File  |  2014-02-08  |  7KB  |  271 lines

  1.       .386
  2.       .model flat, stdcall  ; 32 bit memory model
  3.       option casemap :none  ; case sensitive
  4.  
  5.  
  6.       include \masm32\include\windows.inc
  7.       include \masm32\include\user32.inc
  8.       include \masm32\include\kernel32.inc
  9.       include \masm32\include\gdi32.inc
  10.       include \masm32\include\wsock32.inc
  11.       
  12.       includelib \masm32\lib\user32.lib
  13.       includelib \masm32\lib\kernel32.lib
  14.       includelib \masm32\lib\gdi32.lib
  15.       includelib \masm32\lib\wsock32.lib
  16.       
  17.  
  18.       return MACRO arg
  19.         mov eax, arg
  20.         ret
  21.       ENDM
  22.   
  23.  
  24.   WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
  25.   WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
  26.   TableCreateControls PROTO :DWORD, :DWORD, :DWORD
  27.   GetButtonProc PROTO :DWORD, :DWORD
  28.   MultiEdit PROTO :DWORD, :DWORD
  29.  
  30.  
  31. .data
  32.  
  33.  szClassName   db "Evgeney-Victorovich-Kupin-27-April-1982",0
  34.  szDisplayName db "Net bones",0
  35.  
  36.  CommandLine   dd 0
  37.  hWnd          dd 0
  38.  hInstance     dd 0
  39.  
  40.  hIcon         dd 0
  41.  
  42. PosX          dd 0
  43. PosY          dd 0 
  44. dWidth        dd 450
  45. dHeight       dd 380
  46.  
  47. hSock dd 0   
  48. strWsaData  WSADATA <0> 
  49.  
  50. stWspritf db "%s%d.%d.%d.%d",0dh,0ah,0
  51. stBuffer db 256 dup(0)
  52.  
  53.  
  54. tButtonStyle  equ WS_VISIBLE or WS_CHILD or BS_DEFPUSHBUTTON
  55. tMultiEditStyle  equ WS_VISIBLE or WS_CHILD or WS_VSCROLL or ES_MULTILINE or WS_HSCROLL or ES_AUTOHSCROLL
  56. tEditStyle equ WS_VISIBLE or WS_CHILDWINDOW or ES_AUTOHSCROLL or ES_NOHIDESEL
  57.  
  58.  
  59. stButtonClass   db "BUTTON",0
  60. stEditClass   db "EDIT",0
  61. stGetButton   db "Get",0
  62. stSetButton   db "Set",0
  63. stWWWaddress  db "www.google.com",0
  64.  
  65.  
  66. tControl  dd offset stButtonClass, stGetButton, 320, 0, 100, 30, tButtonStyle, GetButtonProc,\
  67.              offset stButtonClass, stSetButton, 320, 35, 100, 30, tButtonStyle, GetButtonProc,\
  68.              offset stEditClass, offset stWWWaddress, 0, 0, 300, 30, tEditStyle, MultiEdit,\ 
  69.              offset stEditClass, 0, 0, 35, 300, 300, tMultiEditStyle, MultiEdit 
  70.  
  71. tControlBase dd 10
  72. tControlID dd 10   
  73. tHandles   dd 100 dup(0)
  74.  
  75.  
  76. .code
  77.  
  78. start:
  79.       invoke GetModuleHandle, NULL
  80.       mov hInstance, eax
  81.  
  82.       invoke GetCommandLine
  83.       mov CommandLine, eax
  84.  
  85.       invoke WinMain, hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  86.       invoke ExitProcess,eax
  87.  
  88. WinMain proc hInst     :DWORD, hPrevInst :DWORD, CmdLine   :DWORD, CmdShow   :DWORD
  89.  
  90.       LOCAL wc   :WNDCLASSEX
  91.       LOCAL msg  :MSG
  92.  
  93.       mov wc.cbSize,          sizeof WNDCLASSEX
  94.       mov wc.style,           CS_HREDRAW or CS_VREDRAW \
  95.                               or CS_BYTEALIGNWINDOW
  96.       mov  wc.lpfnWndProc,    offset WndProc
  97.       mov  wc.cbClsExtra,     NULL
  98.       mov  wc.cbWndExtra,     NULL
  99.       push hInst
  100.       pop  wc.hInstance
  101.       mov  wc.hbrBackground,  COLOR_BACKGROUND
  102.       mov  wc.lpszMenuName,   NULL
  103.       mov  wc.lpszClassName,  offset szClassName
  104.       push hIcon
  105.       pop  wc.hIcon
  106.       invoke LoadCursor,NULL,IDC_ARROW
  107.       mov  wc.hCursor,        eax
  108.       push hIcon 
  109.       pop  wc.hIconSm
  110.  
  111.       invoke RegisterClassEx, ADDR wc
  112.  
  113.       invoke GetSystemMetrics,SM_CXSCREEN
  114.       sub eax, dWidth
  115.       shr eax,1
  116.       mov PosX, eax
  117.  
  118.       invoke GetSystemMetrics,SM_CYSCREEN
  119.       sub eax, dHeight
  120.       shr eax,1
  121.       mov PosY, eax
  122.  
  123.       invoke CreateWindowEx,WS_EX_LEFT,
  124.                             ADDR szClassName,
  125.                             ADDR szDisplayName,
  126.                             WS_OVERLAPPEDWINDOW or WS_SYSMENU,
  127.                             PosX, PosY,dWidth,dHeight,
  128.                             NULL,NULL,
  129.                             hInst,NULL
  130.       mov   hWnd,eax
  131.  
  132.       invoke ShowWindow,hWnd,SW_SHOWNORMAL
  133.       invoke UpdateWindow,hWnd
  134.  
  135.     StartLoop:
  136.       invoke GetMessage,ADDR msg,NULL,0,0
  137.       cmp eax, 0
  138.       je ExitLoop
  139.       invoke TranslateMessage, ADDR msg
  140.       invoke DispatchMessage,  ADDR msg
  141.       jmp StartLoop
  142.     ExitLoop:
  143.  
  144.       return msg.wParam
  145.  
  146. WinMain endp
  147.  
  148.  
  149. WndProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
  150.  
  151.  
  152.     .if uMsg == WM_CREATE
  153.  
  154.         mov eax, 0202h
  155.         invoke WSAStartup, eax, addr strWsaData
  156.  
  157.         invoke TableCreateControls, addr tControl, hWin, 4 
  158.         return 0
  159.  
  160.     .elseif uMsg == WM_COMMAND
  161.    ;   .if wParam == 500
  162.        
  163.         mov ecx, offset tControl
  164.         mov eax, wParam
  165.         and eax, 0ffffh
  166.         sub eax, tControlBase
  167.         shl eax, 5
  168.         add ecx, eax
  169.         shr eax, 3  
  170.  
  171.         push tHandles[eax]
  172.         push hWin
  173.         call DWORD PTR[ecx+28]
  174.  
  175.    ;   .endif 
  176.        return 0
  177.  
  178.     .elseif uMsg == WM_DESTROY
  179.         invoke WSACleanup
  180.         invoke PostQuitMessage,NULL
  181.         return 0 
  182.     .endif
  183.  
  184.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  185.  
  186.     ret
  187.  
  188. WndProc endp
  189.  
  190. TableCreateControls proc pTable:DWORD, hWin:DWORD, dNumber:DWORD
  191.      
  192.     xor eax, eax
  193.  
  194. TableCreateControls_loop:
  195.     push eax
  196.     mov ecx, pTable     
  197.     shl eax, 2
  198.     shl eax, 3
  199.     add ecx, eax        
  200.  
  201.     invoke CreateWindowEx,WS_EX_CLIENTEDGE, [ecx], [ecx+4],\
  202.            [ecx+24],[ecx+8],[ecx+12],[ecx+16],[ecx+20],\
  203.            hWin, tControlID, hInstance, NULL
  204.     pop ecx  
  205.     shl ecx, 2
  206.     mov tHandles[ecx],eax
  207.     shr ecx, 2 
  208.     mov eax,ecx 
  209.     inc tControlID
  210.     inc eax
  211.     cmp eax, dNumber
  212.     jb TableCreateControls_loop
  213.       
  214.     ret
  215. TableCreateControls endp
  216.  
  217. GetButtonProc proc hWin:DWORD, hControl:DWORD
  218.  LOCAL lpHostent:DWORD
  219.  LOCAL aIP,bIP,cIP,dIP:DWORD
  220.  
  221.     invoke GetWindowText, tHandles[4*2], addr stBuffer, 255
  222.  
  223.     invoke gethostbyname, addr stBuffer
  224.     cmp eax,0
  225.     je GetButtonProc_display_ip_list_exit
  226.     mov lpHostent, eax
  227.  
  228.     mov stBuffer[0],0 
  229.  
  230.     mov edx, 0
  231. GetButtonProc_display_ip_list:    
  232.     mov eax, lpHostent
  233.     mov ecx, [eax+12]
  234.     mov ecx, [ecx+edx]
  235.     cmp ecx, 0
  236.     je GetButtonProc_display_ip_list_exit
  237.     push [ecx]
  238.     pop aIP
  239.     and aIP, 0ffh
  240.     push [ecx]
  241.     pop bIP
  242.     shr bIP, 8
  243.     and bIP, 0ffh
  244.     push [ecx]
  245.     pop cIP
  246.     shr cIP, 16
  247.     and cIP, 0ffh
  248.     push [ecx]
  249.     pop dIP
  250.     shr dIP, 24
  251.     and dIP, 0ffh
  252.  
  253.     push edx
  254.     invoke wsprintf, addr stBuffer, addr stWspritf, addr stBuffer, aIP, bIP, cIP, dIP
  255.     pop edx
  256.     add edx, 4
  257.     jmp GetButtonProc_display_ip_list
  258. GetButtonProc_display_ip_list_exit:    
  259.  
  260.     invoke SetWindowText, tHandles[4*3], addr stBuffer 
  261.     ret
  262. GetButtonProc endp
  263.  
  264. MultiEdit proc hWin:DWORD, hControl:DWORD
  265.  
  266.  
  267.     invoke GetWindowText, hControl, addr stBuffer, 255 
  268.     ret
  269. MultiEdit endp
  270. end start
  271.