Sie sind auf Seite 1von 15

td_win32asm_222.

asm
;==============================================================================
;
Test Department's WINDOWS 32 BIT x86 ASSEMBLY EXAMPLES'S
222
;==============================================================================
;==============================================================================
; ==> Part 222 : Another multimedia player using other technique's
;-----------------------------------------------------------------------------; Thanks flys to Ron (http://www.rbthomas.freeserve.co.uk) for the idea.
; This program plays near everything your system supports.
; It is prepared for VCR and VIDEODISC device at a beta level.
; If you own one of thus including the required hardware / software,
; please (!) give me a note and we enhance the program.
;
; Ommm, if you wish to access the Program Menu left click the Jolly Roger.
;
; The WinXP codec's must be installed to view videos.
; This program may not work proper under WinXP.
;
; Test Department
td@crahkob.com
;==============================================================================
; Assembler directives
;-----------------------------------------------------------------------------.386
; specifies the processor our program want run on
.Model Flat ,StdCall
; Flat for Win95 (32 Bit), calling convention
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 gdi32.lib
includelib winmm.lib
includelib vfw32.lib
;==============================================================================
; Declaration of used API functions,take a look into WIN32.HLP and *.inc files
;-----------------------------------------------------------------------------GetModuleHandleA
PROTO :DWORD
LoadIconA
PROTO :DWORD,:DWORD
LoadLibraryA
PROTO :DWORD
GetProcAddress
PROTO :DWORD,:DWORD
LoadBitmapA
PROTO :DWORD,:DWORD
SetMenuItemBitmaps
PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
DeleteObject
PROTO :DWORD
SendMessageA
PROTO :DWORD,:DWORD,:DWORD,:DWORD
SetWindowLongA
PROTO :DWORD,:DWORD,:DWORD
GetOpenFileNamePreviewA PROTO :DWORD
lstrcmp
PROTO :DWORD,:DWORD
lstrcpy
PROTO :DWORD,:DWORD
GetSystemMenu
PROTO :DWORD,:DWORD
Page 1

AppendMenuA
MessageBoxA
GetMessageA
TranslateMessage
DispatchMessageA
PostQuitMessage
ShowWindow
MoveWindow
CallWindowProcA
FreeLibrary
ExitProcess

PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO
PROTO

td_win32asm_222.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,:DWORD,:DWORD,: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
IconName
db "TDIcon",0
;icon name in rc file
Library_Name
db "msvfw32.dll",0
;filename of the library
f_MCIWndCreate
db "MCIWndCreate",0
;function name inside library
MediaFileName
db "dummy.wav",0
;
MenuItemString0
db "File",0
;
MenuItemString1
db "Audio CD",0
;
MenuItemString2
db "Video Laser Disc",0 ;
MenuItemString3
db "Video Cassette Recorder",0;
MenuItemString16
db "Play Full Screen Video",0;
MenuItemString17
db "About",0
;
LoadFileFilte
db "Media Files (*.*)",0,"*.*",0,0;
LoadFileTitle
db "Select a File",0
;
play
db "PLAY",0
;
playfull
db "PLAY FULLSCREEN NOTIFY",0;
stop
db "STOP",0
;
close
db "CLOSE",0
;
cdaudioExt
db "cda",0
;
cdaudioDev
db "cdaudio",0
;
vcrExt
db "UNKNOWN",0
;
vcrDev
db "vcr",0
;
videodiscExt
db "UNKNOWN",0
;
videodiscDev
db "videodisc",0
;
MB1_Title
db "Test Department - http://surf.to/TestD",0
MB1_Text
db "Supported Formats : everything your system supports.",0
flag_fullscreen
dd 0h
;disable fullscreen, default value
Page 2

td_win32asm_222.asm
;==============================================================================
; .Data? = the data? area starts here, not defined and not fixed
;-----------------------------------------------------------------------------.data?
LoadFileBuffer
db 104h dup (?) ;buffer for load filename
hInstance
dd ?
;
handleFile
dd ?
;
hIcon
dd ?
;
hLibrary
dd ?
;
p_MCIWndCreate
dd ?
;pointer function inside DLL
mcihWnd
dd ?
;handle of mci window
handleMenu
dd ?
;
handleBMP0
dd ?
;
handleBMP1
dd ?
;
handleBMP2
dd ?
;
handleBMP3
dd ?
;
handleBMP16
dd ?
;
handleBMP17
dd ?
;
prevWindow
dd ?
;previous window procedure
align 4
; - Msg Structure ( API=GetMessageA ) - member POINT = POINT structure
hWnd
dd ?
;handle of window who receives message
message
dd ?
;the message number
wParam
dd ?
;extra info about the message
lParam
dd ?
;extra info about the message
time
dd ?
;time the message was posted
xpt
dd ?
;cursor x-position, POINT struc
ypt
dd ?
;cursor x-position, POINT struc
align 4
; - OPENFILENAME Structure
lStructSize
dd
hWndOwner
dd
hInstance1
dd
lpstrFilter
dd
lpstrCustomFilter
dd
nMaxCustFilter
dd
nFilterIndex
dd
lpstrFile
dd
nMaxFile
dd
lpstrFileTitle
dd
nMaxFileTitle
dd
lpstrInitialDir
dd
lpstrTitle
dd
Flags
dd
nFileOffset
dw
nFileExtension
dw
lpstrDefExt
dd
lCustData
dd
lpfnHook
dd
lpTemplateName
dd

( API=GetOpenFileNamePreviewA ) ?
;the length in bytes of structure
?
;handle of the window that owns dialog box
?
;handle, our program handle
?
;pointer to string + filter
?
;pointer to user defined filter
?
;size bytes/characters of above
?
;filter index of lpstrFilter
?
;pointer initialize filename, 0=no
?
;size bytes/characters of above
?
;pointer title of the selected file
?
;size of the lpstrFileTitle buffer
?
;pointer init file dir,0=default
?
;pointer title of the box
?
;the dialog box creation flags
?
;offset filename in string lpstrFile
?
;offset extension in string lpstrFile
?
;pointer to default extension of file
?
;?
?
;used if flag is OFN_ENABLETEMPLATE
?
;used if flag is OFN_ENABLETEMPLATE
Page 3

td_win32asm_222.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
;==============================================================================
; API LoadLibraryA maps the specified exe or dll module into the address space
; of the calling process.
;-----------------------------------------------------------------------------push
OFFSET Library_Name
;lpLibFileName, pointer filename module
call
LoadLibraryA
;- API Function cmp
eax,0h
;check if return value 0h=ERROR !
je
ExitPrg
mov
hLibrary,eax
;store handle of library in variable
;-----------------------------------------------------------------------------; API "GetProcAddress" gets the address of the specified function !
;-----------------------------------------------------------------------------push
OFFSET f_MCIWndCreate
;pProcName, name of function
push
hLibrary
;hModule, handle to DLL module
call
GetProcAddress
;- API Function cmp
eax,0h
;check if return value 0h=ERROR !
je
FreeLib
mov
p_MCIWndCreate,eax
;store given pointer to the function
;==============================================================================
; API "MCIWndCreate" registers the MCI window class and creates an MCI window.
; It can also open an MCI device or file and associate it with the MCI window.
; For this API we push 4 doublewords to the stack, we MUST clear the stack !
;-----------------------------------------------------------------------------push
OFFSET MediaFileName
;szFile, name MCI device or data file
push
140FC772h
;dwStyle, defines the window style
;10000000h = WS_VISIBLE
; 4000000h = WS_CLIBSIBLINGS
;
80000h = WS_SYSMENU
;
40000h = WS_SIZEBOX
;
20000h = WS_MINIMIZEBOX
;
10000h = WS_MAXIMIZEBOX
;
8000h = MCIWNDF_NOOPEN !
;
4000h = MCIWNDF_NOERRORDLG !
;
400h = MCIWNDF_NOTIFYSIZE
;
200h = MCIWNDF_NOTIFYPOS
;
100h = MCIWNDF_NOTIFYMODE
;
80h = MCIWNDF_NOTIFYANSI
;
40h = MCIWNDF_SHOWMODE
;
20h = MCIWNDF_SHOWPOS
Page 4

push
push
call
mov
pop
pop
pop
pop

hInstance
0h
p_MCIWndCreate
mcihWnd,eax
eax
eax
eax
eax

td_win32asm_222.asm
;
10h = MCIWNDF_SHOWNAME
;
2h = MCIWNDF_NOPLAYBAR
;hInstance, handle of module instance
;hwndParent, handle parent window 0=no
;- API Function ;handle of MCI window
;clear stack !

;==============================================================================
; API "LoadIconA" loads an icon defined in the resource file
;-----------------------------------------------------------------------------push
OFFSET IconName
;icon-string or icon resource id
push
hInstance
;our program handle
call
LoadIconA
;- API Function mov
hIcon,eax
;handle of newly loaded icon
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message to the MCI Window.
;-----------------------------------------------------------------------------push
hIcon
;lParam, handle of icon
push
0h
;wParam, first message ( small icon )
push
80h
;uMsg, message to send ( WM_SETICON )
push
mcihWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function ;==============================================================================
; API "GetSystemMenu" allows the application to access the System menu.
;-----------------------------------------------------------------------------push
0h
;bRevert, reset flag
push
mcihWnd
;hWnd, handle of window to own System menu
call
GetSystemMenu
;- API Function mov
handleMenu,eax
;
;-----------------------------------------------------------------------------; API "AppendMenuA" appends a new item to the end of the specified menu.
;-----------------------------------------------------------------------------push
0h
;lpNewItem, here ignored
push
0h
;uIDNewItem, here ignored
push
800h
;uFlags, menu item flags MF_SEPARATOR=800h
push
handleMenu
;hMenu, handle menu
call
AppendMenuA
;- API Function push
OFFSET MenuItemString0
;lpNewItem, menu item content
push
1000h
;uIDNewItem, menu item id
push
0h
;uFlags, menu item flags, MF_STRING = 0h
push
handleMenu
;hMenu, handle menu
call
AppendMenuA
;- API Function push
OFFSET MenuItemString1
push
1001h
push
0h
push
handleMenu
call
AppendMenuA
push
OFFSET MenuItemString2
Page 5

td_win32asm_222.asm
push
1002h
push
0h
push
handleMenu
call
AppendMenuA
push
OFFSET MenuItemString3
push
1003h
push
0h
push
handleMenu
call
AppendMenuA
push
0h
push
0h
push
800h
push
handleMenu
call
AppendMenuA
push
OFFSET MenuItemString16
push
1100h
push
0h
push
handleMenu
call
AppendMenuA
push
OFFSET MenuItemString17
push
1101h
push
0h
push
handleMenu
call
AppendMenuA
;-----------------------------------------------------------------------------; API "LoadBitmapA" loads a bitmap from the resource
;-----------------------------------------------------------------------------push
80h
;lpBitmapName, bitmap resource ID
push
hInstance
;hInstance, handle of modul instance
call
LoadBitmapA
;- API Function mov
handleBMP0,eax
;hObject, handle of graphic object
push
81h
push
hInstance
call
LoadBitmapA
mov
handleBMP1,eax
push
82h
push
hInstance
call
LoadBitmapA
mov
handleBMP2,eax
push
83h
push
hInstance
call
LoadBitmapA
mov
handleBMP3,eax
push
90h
push
hInstance
call
LoadBitmapA
mov
handleBMP16,eax
push
91h
push
hInstance
call
LoadBitmapA
mov
handleBMP17,eax
;-----------------------------------------------------------------------------; API "SetMenuItemBitmaps" associates the specified bitmap with a menu item.
Page 6

td_win32asm_222.asm
; Whether the menu item is checked or unchecked, Windows displays the
; appropriate bitmap next to the menu item.
;-----------------------------------------------------------------------------push
handleBMP0
;hbmChecked, handle of checked bitmap
push
handleBMP0
;hbmUnchecked, handle of unchecked bitmap
push
0h
;fuFlags, menuitem flags, MF_BYCOMMAND = 0h
push
1000h
;uItem, menu item to receive new BMP
push
handleMenu
;hmenu, handle of menu
call
SetMenuItemBitmaps
;- API Function push
handleBMP1
push
handleBMP1
push
0h
push
1001h
push
handleMenu
call
SetMenuItemBitmaps
push
handleBMP2
push
handleBMP2
push
0h
push
1002h
push
handleMenu
call
SetMenuItemBitmaps
push
handleBMP3
push
handleBMP3
push
0h
push
1003h
push
handleMenu
call
SetMenuItemBitmaps
push
handleBMP16
push
handleBMP16
push
0h
push
1100h
push
handleMenu
call
SetMenuItemBitmaps
push
handleBMP17
push
handleBMP17
push
0h
push
1101h
push
handleMenu
call
SetMenuItemBitmaps
;==============================================================================
; API "SetWindowLongA" changes an attribute of the specified window !!!
;-----------------------------------------------------------------------------push
100h
;lNewLong, new value, WS_EX_WINDOWEDGE
push
-20
;nIndex, offset value to set, GWL_EXSTYLE
push
mcihWnd
;hwnd, handle of window
call
SetWindowLongA
;- API Function push
OFFSET WP1
;lNewLong, new value
push
-4
;nIndex, offset value to set, GWL_WNDPROC
push
mcihWnd
;hwnd, handle of window
call
SetWindowLongA
;- API Function mov
prevWindow,eax
;return value = previous window procedure
Page 7

td_win32asm_222.asm
LoopGetMessage:
;==============================================================================
; API "GetMessageA" retrieves a message + places it in the specified structure.
;-----------------------------------------------------------------------------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
FreeLib
;if return value is 0 goto LABEL
;-----------------------------------------------------------------------------; API "TranslateMessage" translates virtual-key messages in character messages
;-----------------------------------------------------------------------------push
OFFSET hWnd
;lpMSG, pointer to msg structure
call
TranslateMessage
;- 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
FreeLib:
;==============================================================================
; API "FreeLibrary" unmaps the modul from address space of the calling process.
;-----------------------------------------------------------------------------push
hLibrary
;hLibModule, handle loaded lib. module
call
FreeLibrary
;- API Function ExitPrg:
;==============================================================================
; Next we terminate our program (API=ExitProcess)
;-----------------------------------------------------------------------------push
hInstance
;push our programm handle to exit
call
ExitProcess
;- API Function ;##############################################################################
; This is the Window Procedure for this registered window.
;-----------------------------------------------------------------------------WP1:
push
ebp
;create stack frame
mov
ebp,esp
;
mov
eax,WP1_uMsg
;move the message number to eax
;==============================================================================
; WM_DESTROY (value=02h) message received ?
;-----------------------------------------------------------------------------WP1_uMsg_02h:
cmp
eax,2h
;check if value=2h (WM_DESTROY)
jne
WP1_uMsg_112h
;if not 2h go to LABEL
call
My_CleanSystem
;- SubRoutine ;-----------------------------------------------------------------------------Page 8

td_win32asm_222.asm
; API "PostQuitMessage" indicates to Windows a request to terminate
;-----------------------------------------------------------------------------push
0h
;nExitCode, exit code=wParam
call
PostQuitMessage
;- API Function 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_SYSCOMMAND (value=112h) message recieved ?
;-----------------------------------------------------------------------------WP1_uMsg_112h:
cmp
eax,112h
;check if WM_SYSCOMMAND message recieved
jne
WP1_uMsg_03B9h
;if not goto label
mov
eax,WP1_wParam
;extra info about the message in ax
cmp
eax,0F060h
;SC_CLOSE=0F060h received ?
jne
CheckSysMenu
;
call
My_CleanSystem
;- SubRoutine jmp
WP1_return
CheckSysMenu:
cmp
ax,1000h
;menu item ID, File
jne
WP1_uMsg_112h_wParam_1001h ;
;-----------------------------------------------------------------------------; API "GetOpenFileNamePreviewA" selects a file by using the Open dialog box.
; The dialog box also allows the user to preview the currently specified file.
; Look for parameter names into WIN32.HLP + parameter values into windows.inc.
;-----------------------------------------------------------------------------mov
lStructSize,4Ch
;length in bytes of structure
mov
eax,WP1_hWnd
mov
hWndOwner,eax
;id window that owns dialog box
mov
eax,hInstance
mov
hInstance1,eax
;handle, our program id
mov
lpstrFilter,OFFSET LoadFileFilte;pointer to string + filter, 0= no
mov
lpstrCustomFilter,0h
;pointer to user defined filter
mov
nMaxCustFilter,0h
;size bytes/characters of above
mov
nFilterIndex,0h
;filter index of lpstrFilter
mov
lpstrFile,OFFSET LoadFileBuffer ;pointer to filename buffer
mov
nMaxFile,104h
;max size bytes/characters of above
mov
lpstrFileTitle,0h
;pointer title of the selected file
mov
nMaxFileTitle,0h
;size of the lpstrFileTitle buffer
mov
lpstrInitialDir,0h
;pointer init file dir,0=default
mov
lpstrTitle,OFFSET LoadFileTitle ;pointer title of the box
mov
Flags,00281804h
;the dialog box creation flags
mov
nFileOffset,0h
;offset filename in string lpstrFile
mov
nFileExtension,0h
;offset extension in string lpstrFile
mov
lCustData,0h
;?
mov
lpfnHook,0h
;? used if flag is OFN_ENABLETEMPLATE
mov
lpTemplateName,0h
;? used if flag is OFN_ENABLETEMPLATE
mov
lpstrDefExt,0h
;pointer default extension file, 0=no
push
OFFSET lStructSize
;lpofn, pointer OPENFILENAME structure
call
GetOpenFileNamePreviewA
;- API Function cmp
eax,0h
;check if an error occurs
Page 9

td_win32asm_222.asm
je
WP1_return
;exit on error
mov
handleFile,eax
;handle of new file
;-----------------------------------------------------------------------------; API "lstrcmp" compares two character strings. Check if audio cd (cda).
;-----------------------------------------------------------------------------mov
ax,nFileExtension
;given from OPENFILENAME structure
cwde
;convert word AX into doubleword EAX
add
eax,lpstrFile
;calculate OFFSET filename extender
push
eax
;lpString2, address of second string
push
OFFSET cdaudioExt
;lpString1, address of first string
call
lstrcmp
;- API Function cmp
eax,0h
;result = 0 if strings equal
jne
Filename_OK
;
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer.
;-----------------------------------------------------------------------------push
OFFSET cdaudioDev
;lpString2, address of string to copy
push
OFFSET LoadFileBuffer
;lpString1, address of buffer
call
lstrcpy
;- API Function Filename_OK:
call
My_Prepare_Play
;- SubRoutine jmp
WP1_return
WP1_uMsg_112h_wParam_1001h:
cmp
ax,1001h
;menu item ID, Audio CD
jne
WP1_uMsg_112h_wParam_1002h ;
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer.
;-----------------------------------------------------------------------------push
OFFSET cdaudioDev
;lpString2, address of string to copy
push
OFFSET LoadFileBuffer
;lpString1, address of buffer
call
lstrcpy
;- API Function call
My_Prepare_Play
;- Subroutine jmp
WP1_return
WP1_uMsg_112h_wParam_1002h:
cmp
ax,1002h
;menu item ID, Video Laser Disc
jne
WP1_uMsg_112h_wParam_1003h ;
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer.
;-----------------------------------------------------------------------------push
OFFSET videodiscDev
;lpString2, address of string to copy
push
OFFSET LoadFileBuffer
;lpString1, address of buffer
call
lstrcpy
;- API Function call
My_Prepare_Play
;- Subroutine jmp
WP1_return
WP1_uMsg_112h_wParam_1003h:
cmp
ax,1003h
;menu item ID, Video Cassette Recorder
jne
WP1_uMsg_112h_wParam_1100h ;
;-----------------------------------------------------------------------------; API "lstrcpy" copies a string to a buffer.
;-----------------------------------------------------------------------------Page 10

push
push
call
call
jmp

OFFSET vcrDev
OFFSET LoadFileBuffer
lstrcpy
My_Prepare_Play
WP1_return

td_win32asm_222.asm
;lpString2, address of string to copy
;lpString1, address of buffer
;- API Function ;- Subroutine -

WP1_uMsg_112h_wParam_1100h:
cmp
ax,1100h
;menu item ID, Play Full Screen Video
jne
WP1_uMsg_112h_wParam_1101h ;
cmp
flag_fullscreen,1h
;check flag
jne
WP1_return
;full screen disabled
;-----------------------------------------------------------------------------; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
1h
;nCmdShow, show state, SW_SHOWNORMAL
push
WP1_hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
OFFSET playfull
;lParam, send ( PLAY FULLSCREEN NOTIFY )
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function cmp
eax,0h
;
jne
WP1_return
;
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
8h
;lParam, new value, disable menu
push
8h
;wParam, mask, MCIWNDF_NOMENU
push
1159
;uMsg, msg. to send (MCIWNDM_CHANGESTYLES)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function jmp
WP1_return
WP1_uMsg_112h_wParam_1101h:
cmp
ax,1101h
;menu item ID, About
jne
WP1_return
;
;-----------------------------------------------------------------------------; API "MessageBoxA" creates a message box, displaying the supported formats
;-----------------------------------------------------------------------------push
0h
;uType, style, 0=MB_OK Button
push
OFFSET MB1_Title
;lpCaption,pointer to title text
push
OFFSET MB1_Text
;lpText,pointer to text message box
push
WP1_hWnd
;handle of owner window
call
MessageBoxA
;- API Function jmp
WP1_return
;==============================================================================
; MM_MCINOTIFY (value=3B9h) message recieved ?
;-----------------------------------------------------------------------------Page 11

td_win32asm_222.asm
WP1_uMsg_03B9h:
cmp
eax,03B9h
;MM_MCINOTIFY
jne
WP1_return
;
;-----------------------------------------------------------------------------; API "ShowWindow" function sets the specified window's show state !
;-----------------------------------------------------------------------------push
6h
;nCmdShow, show state, SW_MINIMIZE
push
WP1_hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;-----------------------------------------------------------------------------; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
1h
;nCmdShow, show state, SW_SHOWNORMAL
push
WP1_hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
0h
;lParam, new value, enable menu
push
8h
;wParam, mask, MCIWNDF_NOMENU
push
1159
;uMsg, msg. to send (MCIWNDM_CHANGESTYLES)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
OFFSET stop
;lParam, string to send ( STOP )
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function jmp
WP1_return
WP1_return:
;==============================================================================
; API "CallWindowProcA" passes msg. information to the specified window.
;-----------------------------------------------------------------------------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
push
prevWindow
;previous window callback proc address
call
CallWindowProcA
;- API Function mov
esp,ebp
;delete stack frame
pop
ebp
;
ret
10h
;return and clear stack
;##############################################################################
;******************************************************************************
; My own subroutine(s) for a compacter code resist here ...
;-----------------------------------------------------------------------------My_CleanSystem:
;-----------------------------------------------------------------------------Page 12

td_win32asm_222.asm
; API "SendMessageA" sends a message to the MCI window.
;-----------------------------------------------------------------------------push
OFFSET stop
;lParam, pointer to string to send ( STOP )
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
mcihWnd
;hWnd, handle of destination window !
call
SendMessageA
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message to the MCI window.
;-----------------------------------------------------------------------------push
OFFSET close
;lParam, pointer to string to send (CLOSE)
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
mcihWnd
;hWnd, handle of destination window !
call
SendMessageA
;- API Function ;-----------------------------------------------------------------------------; API "DeleteObject" deletes a logical pen, brush, font, bitmap, region, or
; palette, freeing all system resources associated with the object.
; After the object is deleted, the specified handle is no longer valid.
;-----------------------------------------------------------------------------push
handleBMP0
;hObject, handle of graphic object
call
DeleteObject
;- API Function push
handleBMP1
call
DeleteObject
push
handleBMP2
call
DeleteObject
push
handleBMP3
call
DeleteObject
push
handleBMP16
call
DeleteObject
push
handleBMP17
call
DeleteObject
ret
My_Prepare_Play:
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
OFFSET stop
;lParam, pointer to string to send ( STOP )
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function ;-----------------------------------------------------------------------------; API "MoveWindow" changes the position and dimensions of the specified window.
;-----------------------------------------------------------------------------push
01h
;bRepaint, repaint flag
push
18h
;nHeight, height
push
120h
;nWidth, width
push
0h
;Y, vertical position
push
0h
;X, horizontal position
push
WP1_hWnd
;hWnd, handle of window
call
MoveWindow
;- API Function Page 13

td_win32asm_222.asm
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
OFFSET LoadFileBuffer
;lParam, pointer to filename
push
0h
;wParam, first message, flag
push
1177
;uMsg, message to send ( MCIWNDM_OPEN )
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function cmp
eax,0h
;error check
jne
NoMediaDevice
;error
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
OFFSET play
;lParam, pointer to string to send ( PLAY )
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function cmp
eax,0h
;error check
jne
NoMediaDevice
;error
;-----------------------------------------------------------------------------; API "ShowWindow" function sets the specified window's show state.
;-----------------------------------------------------------------------------push
1h
;nCmdShow, show state 1=SW_SHOWNORMAL
push
WP1_hWnd
;hwnd, handle of window
call
ShowWindow
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
0h
;lParam, new value, enable playbar
push
2h
;wParam, mask, MCIWNDF_NOPLAYBAR
push
1159
;uMsg, msg. to send (MCIWNDM_CHANGESTYLES)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
100
;lParam, zoom factor, 100 %
push
0h
;wParam,
push
1132
;uMsg, message to send ( MCIWNDM_SETZOOM )
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- API Function mov
flag_fullscreen,1h
;enable fullscreen
ret
NoMediaDevice:
mov
flag_fullscreen,0h
;disable fullscreen
;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
OFFSET close
;lParam, pointer to string to send (CLOSE)
push
0h
;wParam,
push
1125
;uMsg, message to send (MCIWNDM_SENDSTRING)
push
WP1_hWnd
;hWnd, handle of destination window
Page 14

td_win32asm_222.asm
call
SendMessageA
;- API Function ;-----------------------------------------------------------------------------; API "SendMessageA" sends a message.
;-----------------------------------------------------------------------------push
2h
;lParam, new value, disable playbar
push
2h
;wParam, mask, MCIWNDF_NOPLAYBAR
push
1159
;uMsg, msg. to send (MCIWNDM_CHANGESTYLES)
push
WP1_hWnd
;hWnd, handle of destination window
call
SendMessageA
;- 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_222.asm
;asm command
; rc.exe /v rsrc.rc
;rc command
; cvtres.exe /machine:ix86 rsrc.res
; link.exe /subsystem:windows td_win32asm_222.obj rsrc.obj
;link command
;==============================================================================

Page 15

Das könnte Ihnen auch gefallen