Sunteți pe pagina 1din 12

td_win32asm_025.

asm
;==============================================================================
;
Test Department's WINDOWS 32 BIT x86 ASSEMBLY example's
025
;==============================================================================
;==============================================================================
; ==> Part 025 : IP Address Controls
;-----------------------------------------------------------------------------; Bonjour,
; the IP address control class is very usefull.
; We can enter an IP address and must not control the correct input.
; We can obtain the IP address via the IPM_GETADDRESS message.
; Now we can use the bswap memnonic to convert the address to the correct
; notation (bswap is avaible on a 486 machine and upward).
; Ready to call API 'gethostbyaddr' to resolve the IP.
; There are some more features avaible, look into the help file shellcc.chm !
;
; The API 'InitCommonControls' is obsolete and do not work with the
; IP address control class !
; So, it is necessary to use API 'InitCommonControlsEx' !!!
;
;
;
; TD
td@crahkob.com
;
;==============================================================================
; Assembler directives
;-----------------------------------------------------------------------------.486
; the processor our program want run on, (bswap=486)
.Model Flat ,StdCall
; always the same for Win9x (32 Bit)
option casemap:none
; case sensitive !!!
;==============================================================================
; Include all files where API functins resist you want use, set correct path
;-----------------------------------------------------------------------------include D:\Masm32\include\windows.inc
includelib kernel32.lib
includelib user32.lib
includelib comctl32.lib
includelib wsock32.lib
;==============================================================================
; Declaration of used API functions,take a look into WIN32.HLP and *.inc files
;-----------------------------------------------------------------------------GetModuleHandleA
PROTO :DWORD
InitCommonControlsEx
PROTO :DWORD
LoadIconA
PROTO :DWORD,:DWORD
LoadCursorA
PROTO :DWORD,:DWORD
RegisterClassExA
PROTO :DWORD
CreateWindowExA
PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,
:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
ShowWindow
PROTO :DWORD,:DWORD
UpdateWindow
PROTO :DWORD
Page 1

td_win32asm_025.asm
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD
:DWORD
:DWORD
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD
:DWORD
:DWORD,:DWORD
:DWORD,:DWORD
:DWORD,:DWORD,:DWORD
:DWORD,:DWORD,:DWORD,:DWORD
:DWORD

GetMessageA
TranslateMessage
DispatchMessageA
PostQuitMessage
DefWindowProcA
ExitProcess
DestroyWindow
EnableWindow
SetWindowTextA
InvalidateRect
SendMessageA
SetFocus

PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO

CreateThread
CloseHandle
ExitThread

PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
PROTO :DWORD
PROTO :DWORD

WSAStartup
WSACleanup
gethostbyaddr

PROTO :DWORD,:DWORD
PROTO
PROTO :DWORD,:DWORD,:DWORD

;==============================================================================
; .const = the constants area starts here,constants are defined and fixed
;-----------------------------------------------------------------------------.const
; - Parameter MAIN WINDOW CallBack Procedure ( API=RegisterClassExA ) WP1_CallBack
equ [ebp+4]
;return address
WP1_hWnd
equ [ebp+8]
;handle of window who receives message
WP1_uMsg
equ [ebp+12]
;the message number
WP1_wParam
equ [ebp+16]
;extra info about the message
WP1_lParam
equ [ebp+20]
;extra info about the message
;==============================================================================
; .Data = the data area starts here, datas are defined but not fixed
;-----------------------------------------------------------------------------.Data
ClassName
db "TDClass_IPAddressControl",0 ;name windows class
WindowName
db "IPAddress Control example",0;titel bar
IPAddressClassName
db "SysIPAddress32",0
;predefined class
EditClassName
db "EDIT",0
;predefined class
ButtonClassName
db "BUTTON",0
;predefined class
szButton
db "Resolve IP",0
;
szError
db "Error",0
;
align 4
Xpos_org
Ypos_org
Xpos_max
Ypos_max

dd
dd
dd
dd

WsVersion
flag_thread

dd 0101h
dd 0h

180h
100h
12Ch
060h

;X orgin point window


;Y orgin point window
;max. window width
;max. window height
;minimum winsock version requested
;flag if thread is active
Page 2

td_win32asm_025.asm
align 4
; - WndClassEx Structure cbSize
dd 0h
style
dd 0h
lpfnWndProc
dd 0h
cbclsExtra
dd 0h
cbWndExtra
dd 0h
hInstance
dd 0h
hIcon
dd 0h
hcursor
dd 0h
hbrBackground
dd 0h
lpszMenuName
dd 0h
lpszClassName
dd 0h
hIconSm
dd 0h

;size in bytes of this structure


;window style
;address of user proc function
;extra bytes to allocate set to 0
;extra bytes class directive, rc file
;program handle(API=GetModuleHandleA)
;handle of icon (API=LoadIconA)
;handle of cursor (API=LoadCursor)
;background color, 0=transparent
;name of menu class in resource file
;name of windows this window class
;iconhandle 0=search in resource file

; - Msg Structure hWnd


message
wParam
lParam
time
xpt
ypt

;handle of window who receives message


;the message number
;extra info about the message
;extra info about the message
;time the message was posted
;cursor x-position, POINT struc
;cursor x-position, POINT struc

dd
dd
dd
dd
dd
dd
dd

0h
0h
0h
0h
0h
0h
0h

;==============================================================================
; .Data? = the data? area starts here, not defined and not fixed
;-----------------------------------------------------------------------------.data?
align 4
hWnd_ipadress
dd ?
;handle ipaddress control window
hWnd_edit
dd ?
;handle edit window
hWnd_button
dd ?
;handle button window
hThread
ThreadID

dd ?
dd ?

;handle thread
;Thread ID

IP

dd ?

;IP

; - INITCOMMONCONTROLSEX structure ICC_dwSize


dd ?
ICC_dwICC
dd ?

;size of the structure, in bytes


;set of bit flags that indicate which
;common control classes will be loaded

; - WSADATA structure wsa_wVersion


dw ?
wsa_wHighVersion
dw ?
wsa_szDescription
db 101h dup (?)
wsa_szSystemStatus
db 81h dup (?)
wsa_iMaxSockets
dw ?
wsa_iMaxUdpDg
dw ?
wsa_lpVendorInfo
dd ?
;==============================================================================
Page 3

td_win32asm_025.asm
; .CODE = our code area starts here
Main=label of our program code
;-----------------------------------------------------------------------------.Code
Main:
;==============================================================================
; Always get your program ID first (API=GetModuleHandleA)
;-----------------------------------------------------------------------------push
0h
;lpModuleHandle, 0=get program handle
call
GetModuleHandleA
;- API Function mov
hInstance,eax
;return value in eax=handle of program
;==============================================================================
; IPAdress control class seems to be part of common controls, force to init...
;-----------------------------------------------------------------------------mov
ICC_dwSize,8h
;size of the structure
mov
ICC_dwICC,0h
;
or
ICC_dwICC,0800h
;set ICC_INTERNET_CLASSES bit flag
push
OFFSET ICC_dwSize
;pointer to INITCOMMONCONTROLSEX structure
call
InitCommonControlsEx
;- API Function ;==============================================================================
; The API function "RegisterClassExA" registers a window class
; This API needs a "WNDCLASSEX" structure so we fill it with correct values
;-----------------------------------------------------------------------------mov
cbSize,30h
;size in bytes of WNDCLASSEX structure
mov
style,3h
;style, CS_HREDRAW, CS_VREDRAW
mov
lpfnWndProc,OFFSET WP1
;address of user lpfnWndProc function
mov
cbclsExtra,0h
;extra bytes to allocate set to 0
mov
cbWndExtra,0h
;class directive in rc file
mov
hbrBackground,5
;handle brush,backg. color,COLOR_WINDOW
mov
lpszMenuName,0h
;menu name in resource file
mov
lpszClassName,OFFSET ClassName ;name of windows class
;-----------------------------------------------------------------------------; API "LoadIconA" loads an icon defined in the resource file and store the
; handle in the "WNDCLASSEX" structure
;-----------------------------------------------------------------------------push
1000
;icon-string or icon resource id
push
hInstance
;our program handle
call
LoadIconA
;- API Function mov
hIcon,eax
;handle of newly loaded icon
mov
hIconSm,eax
;iconhandle 0=search in rc file
;-----------------------------------------------------------------------------; API "LoadCursorA" loads a default system cursor, in this case we must set
; hInstance to 0 and lpCursorName to a default system cursor value, here 32512
; Then we store the cursor handle in the "WNDCLASSEX" structure
;-----------------------------------------------------------------------------push
32512
;lpCursorName, default value in dezimal
push
0h
;hInstance, 0=default system cursor
call
LoadCursorA
;- API Function mov
hcursor,eax
;store handle of the cursor
;-----------------------------------------------------------------------------; Now, after filled the "WNDCLASSEX" structure we call API "RegisterClassEx"
Page 4

td_win32asm_025.asm
;-----------------------------------------------------------------------------push
OFFSET cbSize
;pointer to WNDCLASSEX structure
call
RegisterClassExA
;- API Function ;==============================================================================
; API "CreateWindowExA" creates an overlapped, pop-up, or child window with an
; extended style. The return value in EAX is the handle of the new window.
; This API sends a WM_CREATE message to the window procedure (WP1).
;-----------------------------------------------------------------------------push
0h
;lpParam, extra pointer data 0=no data
push
hInstance
;hInstance, handle of our program
push
0h
;hMenu, handle window menu 0=class menu
push
0h
;hWndParent, handle parent window 0=no
push
Ypos_max
;intnHeight, window height pixel
push
Xpos_max
;intnWidth, window width pixel
push
Ypos_org
;inty, vertical position window
push
Xpos_org
;intx, horizontal position window
push
02CA0000h
;dwStyle, look into WIN32.HLP and window.inc
push
OFFSET WindowName
;lpWindowName, pointer to window name
push
OFFSET ClassName
;lpClassName, pointer to class name
push
0h
;dwExStyle, extra window style 0=no
call
CreateWindowExA
;- API Function mov
hWnd,eax
;hwnd, return value=handle of window
;==============================================================================
; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
1h
;nCmdShow, show state 1=SW_SHOWNORMAL
push
hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;==============================================================================
; API "UpdateWindow" updates the area of the specified window by sending a
; WM_PAINT message to the window if the window's update region is not empty.
;-----------------------------------------------------------------------------push
hWnd
;hwnd, handle of window
call
UpdateWindow
;- API Function ;==============================================================================
; API "GetMessageA" retrieves a message & places it in the specified structure.
;-----------------------------------------------------------------------------LoopGetMessage:
push
0h
;wMsgFilterMax, highest message value
push
0h
;wMsgFilterMin, lowest message value
push
0h
;hWnd, handle of window who gets msg.
push
OFFSET hWnd
;lpMsg, pointer to MSG structure
call
GetMessageA
;- API Function cmp
eax,0h
;check if return value=0 (exit)
je
ExitPrg
;if return value is 0 goto LABEL
;==============================================================================
; API "TranslateMessage" translates key code into ASCII character messages
;-----------------------------------------------------------------------------Page 5

push
call

OFFSET hWnd
TranslateMessage

td_win32asm_025.asm
;lpMSG, pointer to msg structure
;- API Function - keyboard code

;==============================================================================
; API "DispatchMessageA" function dispatches a message to a window procedure.
;-----------------------------------------------------------------------------push
OFFSET hWnd
;lpMSG, pointer to msg structure
call
DispatchMessageA
;- API Function jmp
LoopGetMessage
;check for message again, goto LABEL
ExitPrg:
;==============================================================================
; Next we terminate our program (API=ExitProcess)
;-----------------------------------------------------------------------------push
hInstance
;push our programm handle to exit
call
ExitProcess
;- API Function ;##############################################################################
; The Window Procedure lpfnWndProc (API=RegisterClassExA) for this window.
;-----------------------------------------------------------------------------WP1:
push
ebp
;create stack frame
mov
ebp,esp
;
pushad
;push all register to the stack
mov
eax,WP1_uMsg
;move the message number to eax
;==============================================================================
; WM_CREATE (value=01h) message received ?
;-----------------------------------------------------------------------------WP1_uMsg_01h:
cmp
eax,1h
;check if WM_CREATE message recieved
jne
WP1_uMsg_02h
;if not goto label
;-----------------------------------------------------------------------------; API "WSAStartup" can thus be used for initialization purposes. (Wsock32.dll)
;-----------------------------------------------------------------------------push
OFFSET wsa_wVersion
;lpWSAData, pointer WSADATA data structure
push
WsVersion
;wVersionRequested, version Windows Sockets
call
WSAStartup
;- API Function mov
ebx,0h
;get highest version DLL supports
mov
bx,wsa_wHighVersion
;
;-----------------------------------------------------------------------------; API "WSACleanup" terminates use of the Windows Sockets DLL.
;-----------------------------------------------------------------------------call
WSACleanup
;- API Function ;-----------------------------------------------------------------------------; API "WSAStartup" can thus be used for initialization purposes. (Wsock32.dll)
;-----------------------------------------------------------------------------push
OFFSET wsa_wVersion
;lpWSAData, pointer WSADATA data structure
push
ebx
;wVersionRequested, version Windows Sockets
call
WSAStartup
;- API Function ;-----------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (IPAdress)
;-----------------------------------------------------------------------------Page 6

td_win32asm_025.asm
push
0h
;lpParam, extra pointer data 0=no data
push
hInstance
;hInstance, handle of our program
push
100h
;hMenu, the child-window ID
push
WP1_hWnd
;hWndParent, handle parent window 0=no
push
14h
;intnHeight, window height pixel
push
0A0h
;intnWidth, window width pixel
push
08h
;inty, vertical position window
push
08h
;intx, horizontal position window
push
54000000h
;dwStyle,
push
0h
;lpWindowName, pointer to window name
push
OFFSET IPAddressClassName;lpClassName, pointer to class name
push
0h
;dwExStyle,
call
CreateWindowExA
;- API Function mov
hWnd_ipadress,eax
;hwnd, store handle of window
;-----------------------------------------------------------------------------; API "CreateWindowExA" creates a window with a predefined class name (EDIT).
;-----------------------------------------------------------------------------push
0h
;lpParam, extra pointer data 0=no data
push
hInstance
;hInstance, handle of our program
push
110h
;hMenu, the child-window ID
push
WP1_hWnd
;hWndParent, handle parent window 0=no
push
14h
;intnHeight, window height pixel
push
118h
;intnWidth, window width pixel
push
28h
;inty, vertical position window
push
08h
;intx, horizontal position window
push
54000880h
;dwStyle, ES_READONLY=800h, ES_AUTOHSCROLL=80h
push
0h
;lpWindowName, pointer to window name
push
OFFSET EditClassName
;lpClassName, pointer to class name
push
300h
;dwExStyle, look WIN32.HLP + windows.inc
call
CreateWindowExA
;- API Function mov
hWnd_edit,eax
;hwnd, store handle of window
;-----------------------------------------------------------------------------; API "CreateWindowExA" here creates a window with a predefined class (BUTTON)
;-----------------------------------------------------------------------------push
0h
;lpParam, extra pointer data 0=no data
push
hInstance
;hInstance, handle of our program
push
120h
;hMenu, the child-window ID
push
WP1_hWnd
;hWndParent, handle parent window 0=no
push
1Ch
;intnHeight, window height pixel
push
70h
;intnWidth, window width pixel
push
04h
;inty, vertical position window
push
0B0h
;intx, horizontal position window
push
54000000h
;dwStyle, style ( BS_PUSHBUTTON )
push
OFFSET szButton
;lpWindowName, pointer to window name
push
OFFSET ButtonClassName ;lpClassName, pointer to class name
push
300h
;dwExStyle,
call
CreateWindowExA
;- API Function mov
hWnd_button,eax
;return value=handle of window
;-----------------------------------------------------------------------------; API "SetFocus" sets the keyboard focus to the specified window.
;-----------------------------------------------------------------------------push
hWnd_ipadress
;hwnd, handle of window to receive focus
call
SetFocus
;- API Function Page 7

td_win32asm_025.asm
jmp

WP1_return

;==============================================================================
; WM_DESTROY (value=02h) message received ?
;-----------------------------------------------------------------------------WP1_uMsg_02h:
cmp
eax,2h
;check if value=2h (WM_DESTROY)
jne
WP1_uMsg_0Fh
;if not 2h go to LABEL
cmp
flag_thread,1h
;skip if thread is active
je
WP1_return
;
xyz:
call
My_CleanSystem
;- SubRoutine ;-----------------------------------------------------------------------------; API "PostQuitMessage" indicates to Windows a request to terminate
;-----------------------------------------------------------------------------push
0h
;nExitCode, exit code=wParam
call
PostQuitMessage
;- API Function popad
;pop all register back from stack
xor
eax,eax
;set eax to 0 to exit our program
mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;==============================================================================
; WM_PAINT (value=0Fh) message, used to repaint the window area
;-----------------------------------------------------------------------------WP1_uMsg_0Fh:
cmp
eax,0Fh
;check if WM_PAINT message recieved
jne
WP1_uMsg_4Eh
;if not goto label
jmp

WP1_return

;==============================================================================
; WM_NOTIFY (value=4Eh) message, gives us a pointer to a NMHDR structure.
;-----------------------------------------------------------------------------WP1_uMsg_4Eh:
cmp
eax,4Eh
;check if WM_NOTIFY message recieved
jne
WP1_uMsg_7Eh
;if not goto label
mov
ebx,WP1_lParam
;pointer to structure, given by windows !
;-----------------------------------------------------------------------------; The NMHDR structure contains information about a notification message.
; The POINTER to this structure is specified as lParam member of WM_NOTIFY.
; This POINTER is given to us with the WM_NOTIFY message by Windows.
; - NMHDR structure ; hwndFrom
= [WP1_lParam+00]
;handle to control sending message
; idFrom
= [WP1_lParam+04]
;identifier of control sending message
; code
= [WP1_lParam+08]
;notification code
; - NMIPADDRESS structure ; hdr
= placeholder NMHDR ;required for all WM_NOTIFY messages
; iField
= [WP1_lParam+12]
;zero-based number of field that was changed
; iValue
= [WP1_lParam+16]
;new value of field specified in iField member
;-----------------------------------------------------------------------------mov
eax,[ebx+0]
;get the handle of the control sending msg.
Page 8

cmp
jne
mov
cmp
jne

eax,hWnd_ipadress
WP1_return
eax,[ebx+8]
eax,0FFFFFCA4h
WP1_return

jmp

WP1_return

td_win32asm_025.asm
;is control = ipadress control ?
;move code ( NMHDR structure ) into eax
;is code IPN_FIELDCHANGED, IPN_FIRST(0-860)-0
;if not skip

;==============================================================================
; WM_DISPLAYCHANGE (value=7Eh) message, used to repaint the window area
;-----------------------------------------------------------------------------WP1_uMsg_7Eh:
cmp
eax,7Eh
;check if WM_DISPLAYCHANGE message recieved
jne
WP1_uMsg_111h
;if not goto label
;-----------------------------------------------------------------------------; API "InvalidateRect" adds a rectangle to specified window's update region.
; This function performs a WM_PAINT message.
;-----------------------------------------------------------------------------push
0h
;bErase, erase-background flag
push
0h
;lpRect, rect structure, 0h=client area
push
WP1_hWnd
;hWnd, handle window update region
call
InvalidateRect
;- API Function jmp
WP1_return
;==============================================================================
; WM_COMMAND (value=111h) message recieved ?
;-----------------------------------------------------------------------------WP1_uMsg_111h:
cmp
eax,111h
;check if WM_COMMAND message recieved
jne
WP1_uMsg_112h
;if not goto label
mov
eax,WP1_wParam
;extra info about the message in ax
cmp
ax,120h
;Button clicked ?
jne
WP1_return
;
;-----------------------------------------------------------------------------; API "CreateThread" creates a thread to execute
;-----------------------------------------------------------------------------push
OFFSET ThreadID
;lpThreadId, address of returned thread id
push
0h
;dwCreationFlags, creation flags
push
WP1_hWnd
;lpParameter, argument for new thread
push
OFFSET My_Thread
;lpStartAddress, address of thread function
push
0h
;dwStackSize, init thread stack size, in db
push
0h
;lpThreadAttributes, address security attr.
call
CreateThread
;- API Function mov
hThread,eax
;thread handle
;-----------------------------------------------------------------------------; API "CloseHandle" closes an open object handle
;-----------------------------------------------------------------------------push
ThreadID
;hObject, handle of object to close
call
CloseHandle
;- API Function jmp
WP1_return
;==============================================================================
; WM_SYSCOMMAND (value=112h) message recieved ?
Page 9

td_win32asm_025.asm
;-----------------------------------------------------------------------------WP1_uMsg_112h:
cmp
eax,112h
;check if WM_COMMAND message recieved
jne
WP1_return
;if not goto label
mov
eax,WP1_wParam
;extra info about the message
cmp
eax,0F060h
;SC_CLOSE=0F060h received ?
jne
WP1_return
;
cmp
flag_thread,1h
;skip if thread is active
je
WP1_return_0
;
call
My_CleanSystem
;- SubRoutine jmp
WP1_return
;==============================================================================
; API "DefWindowProcA" calls the window procedure to provide default processing
; for any window messages that an application does not process.
; This function ensures that every message is processed.
; It is called with the same parameters received by the window procedure.
;-----------------------------------------------------------------------------WP1_return:
popad
;pop all register from stack
push
WP1_lParam
;extra info about the message
push
WP1_wParam
;extra info about the message
push
WP1_uMsg
;the message number
push
WP1_hWnd
;handle of window who receives message
call
DefWindowProcA
;- API Function mov
esp,ebp
;delete stack frame
pop
ebp
ret
10h
;return and clear stack
;==============================================================================
; Leaving the window procedure returning TRUE (1) or FALSE (0) in EAX.
;-----------------------------------------------------------------------------WP1_return_0:
popad
;pop all register from stack
mov
eax,0h
;set EAX to FALSE (0)
mov
esp,ebp
;delete stack frame
pop
ebp
ret
10h
;return and clear stack
WP1_return_1:
popad
;pop all register from stack
mov
eax,1h
;set EAX to TRUE (1)
mov
esp,ebp
;delete stack frame
pop
ebp
ret
10h
;return and clear stack
;##############################################################################
;##############################################################################
; My Threads resist here
;-----------------------------------------------------------------------------My_Thread:
;-----------------------------------------------------------------------------; Resolve the IP. Perform it in a thread so windos don't freeze.
;-----------------------------------------------------------------------------Page 10

td_win32asm_025.asm
push
ebp
;create stack frame
mov
ebp,esp
;
pushad
;save all register
mov
flag_thread,1h
;set flag
;-----------------------------------------------------------------------------; API "EnableWindow" enables or disables input to specified window or control.
;-----------------------------------------------------------------------------push
0h
;bEnable,flag enabling(1) disabling(0) input
push
hWnd_button
;hWnd, handle of window
call
EnableWindow
;- API Function ;-----------------------------------------------------------------------------; API "SendMessage" sends the specified message to a window.
;-----------------------------------------------------------------------------push
OFFSET IP
;lParam, pdwAddr, DWORD value receives address
push
0h
;wParam,
push
1126
;uMsg, IPM_GETADDRESS (WM_USER=1024)+102
push
hWnd_ipadress
;hwnd, handle of destination window
call
SendMessageA
;- API Function mov
eax,IP
;damned notation shit
bswap
eax
;byte3=byte0,byte2=byte1,byte1=byte0,byte0=byte3
mov
IP,eax
;save it
;-----------------------------------------------------------------------------; API "gethostbyaddr" gets host information corresponding to an address.
;-----------------------------------------------------------------------------push
2h
;type, type address, which must be PF_INET
push
4h
;len, length address, must be 4 for PF_INET
push
OFFSET IP
;addr, pointer address, network byte order
call
gethostbyaddr
;- API Function mov
ebx,OFFSET szError
;pointer to error string
cmp
eax,0h
;error ?
je
My_Thread_Result
;
mov
ebx,[eax]
;get h_name from hostent structure
My_Thread_Result:
;-----------------------------------------------------------------------------; API "SetWindowTextA" set's the text of the specified window's title bar.
;-----------------------------------------------------------------------------push
ebx
;lpsz, address of string
push
hWnd_edit
;hwnd, handle of window or control
call
SetWindowTextA
;- API Function ;-----------------------------------------------------------------------------; API "EnableWindow" enables or disables input to specified window or control.
;-----------------------------------------------------------------------------push
1h
;bEnable,flag enabling(1) disabling(0) input
push
hWnd_button
;hWnd, handle of window
call
EnableWindow
;- API Function mov
flag_thread,0h
;clear flag
;-----------------------------------------------------------------------------; API "ExitThread" ends a thread
;-----------------------------------------------------------------------------push
0h
;dwExitCode, exit code for this thread
call
ExitThread
;- API Function popad
;restore all register
xor
eax,eax
;set EAX to 0
Page 11

td_win32asm_025.asm
mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
4h
;##############################################################################
;******************************************************************************
; My own subroutine(s) for a compacter code resist here ...
;-----------------------------------------------------------------------------My_CleanSystem:
;-----------------------------------------------------------------------------; API "WSACleanup" terminates use of the Windows Sockets DLL.
;-----------------------------------------------------------------------------call
WSACleanup
;- API Function ret
;******************************************************************************
;==============================================================================
; end Main = end of our program code
;-----------------------------------------------------------------------------end Main
;end of our program code, entry point
;==============================================================================
; To create the exe file use this commands with your Microsoft Assembler/Linker
;-----------------------------------------------------------------------------; ml.exe /c /coff td_win32asm_025.asm
;asm command
; rc.exe /v rsrc.rc
;rc command
; cvtres.exe /machine:ix86 rsrc.res
; link.exe /subsystem:windows td_win32asm_025.obj rsrc.obj
;link command
;==============================================================================

Page 12

S-ar putea să vă placă și