/wcwp/bin/masm32/tutorial/dlltute/testapp/testapp.asm

http://wcwp.googlecode.com/ · Assembly · 137 lines · 80 code · 38 blank · 19 comment · 7 complexity · 8fd84b063f2e5fa0714b5896460d5256 MD5 · raw file

  1. ; ?????????????????????????????????????????????????????????????????????
  2. .486 ; create 32 bit code
  3. .model flat, stdcall ; 32 bit memory model
  4. option casemap :none ; case sensitive
  5. ; include files
  6. ; ~~~~~~~~~~~~~
  7. include \masm32\include\windows.inc
  8. include \masm32\include\masm32.inc
  9. include \masm32\include\gdi32.inc
  10. include \masm32\include\user32.inc
  11. include \masm32\include\kernel32.inc
  12. include \masm32\include\Comctl32.inc
  13. include \masm32\include\comdlg32.inc
  14. include \masm32\include\shell32.inc
  15. include \masm32\include\oleaut32.inc
  16. include \masm32\include\dialogs.inc
  17. include \masm32\macros\macros.asm
  18. ; libraries
  19. ; ~~~~~~~~~
  20. includelib \masm32\lib\masm32.lib
  21. includelib \masm32\lib\gdi32.lib
  22. includelib \masm32\lib\user32.lib
  23. includelib \masm32\lib\kernel32.lib
  24. includelib \masm32\lib\Comctl32.lib
  25. includelib \masm32\lib\comdlg32.lib
  26. includelib \masm32\lib\shell32.lib
  27. includelib \masm32\lib\oleaut32.lib
  28. FUNC MACRO parameters:VARARG
  29. invoke parameters
  30. EXITM <eax>
  31. ENDM
  32. dlgproc PROTO :DWORD,:DWORD,:DWORD,:DWORD
  33. MessageBoxSTD PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
  34. MessageBoxCC PROTO C :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
  35. MessageBoxFC PROTO STDCALL :DWORD,:DWORD
  36. includelib dlltute.lib
  37. .data?
  38. hInstance dd ?
  39. hIcon dd ?
  40. .code
  41. ; ?????????????????????????????????????????????????????????????????????
  42. start:
  43. mov hInstance, FUNC(GetModuleHandle,NULL)
  44. mov hIcon, FUNC(LoadIcon,hInstance,1)
  45. call main
  46. invoke ExitProcess,eax
  47. ; ?????????????????????????????????????????????????????????????????????
  48. main proc
  49. Dialog "Test DLLtute.dll", \ ; caption
  50. "MS Sans Serif",8, \ ; font,pointsize
  51. WS_OVERLAPPED or \ ; styles for
  52. WS_SYSMENU or DS_CENTER, \ ; dialog window
  53. 4, \ ; number of controls
  54. 50,50,150,90, \ ; x y co-ordinates
  55. 1024 ; memory buffer size
  56. DlgButton "Test STDCALL" ,WS_TABSTOP,25,10,80,13,101
  57. DlgButton "Test C call" ,WS_TABSTOP,25,25,80,13,102
  58. DlgButton "Test FASTCALL",WS_TABSTOP,25,40,80,13,103
  59. DlgButton "Close",WS_TABSTOP,25,55,80,13,IDCANCEL
  60. CallModalDialog hInstance,0,dlgproc,NULL
  61. ret
  62. main endp
  63. ; ?????????????????????????????????????????????????????????????????????
  64. dlgproc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
  65. .if uMsg == WM_INITDIALOG
  66. invoke SendMessage,hWin,WM_SETICON,1,
  67. FUNC(LoadIcon,hInstance,1)
  68. .elseif uMsg == WM_COMMAND
  69. .if wParam == 101
  70. ; ----------------------------------------------------------------------
  71. ; this procedure call from the DLL demonstrates the normal STDCALL call
  72. ; ----------------------------------------------------------------------
  73. invoke MessageBoxSTD,hWin,SADD("STDCALL Here"),SADD("DLL Tute procedure"),MB_OK,1
  74. .elseif wParam == 102
  75. ; ----------------------------------------------------
  76. ; this procedure call uses the "C" calling convention
  77. ; ----------------------------------------------------
  78. invoke MessageBoxCC,hWin,SADD("C call Here"),SADD("DLL Tute procedure"),MB_OK,1
  79. .elseif wParam == 103
  80. ; -------------------------------------------------------------------------
  81. ; this procedure call demonstrates a simulation of the FASTCALL convention
  82. ; note that 3 registers are used to pass the 1st 3 parameters
  83. ; -------------------------------------------------------------------------
  84. mov eax, hWin
  85. mov ecx, CTXT("FASTCALL Here")
  86. mov edx, CTXT("DLL Tute procedure")
  87. invoke MessageBoxFC,MB_OK,1
  88. .elseif wParam == IDCANCEL
  89. jmp quit_dialog
  90. .endif
  91. .elseif uMsg == WM_CLOSE
  92. quit_dialog:
  93. invoke EndDialog,hWin,0
  94. .endif
  95. xor eax, eax
  96. ret
  97. dlgproc endp
  98. ; ?????????????????????????????????????????????????????????????????????
  99. end start