Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
4.8 KiB

  1. title "Callback Routines"
  2. ;++
  3. ;
  4. ; Copyright (c) 1985 - 1999, Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; callproc.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements stack cleanup to gaurd against cdecl
  13. ; declared wndprocs.
  14. ; Bug 234292
  15. ;
  16. ; Author:
  17. ;
  18. ; Joseph Jones (joejo) 12/4/98
  19. ;
  20. ;
  21. ; Revision History:
  22. ;
  23. ;--
  24. .386p
  25. .xlist
  26. include ks386.inc
  27. include callconv.inc ; calling convention macros
  28. .list
  29. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  30. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  31. page , 132
  32. ;++
  33. ;
  34. ;LRESULT
  35. ;InternalCallWinProc(
  36. ; WNDPROC winproc,
  37. ; HWND hwnd,
  38. ; UINT message,
  39. ; WPARAM wParam,
  40. ; LPARAM lParam
  41. ; )
  42. ;
  43. ; Routine Description:
  44. ;
  45. ; this function cals an x86 window procedure. It protects against
  46. ; window procedures that don't preserve EBX or fail to clean up
  47. ; enough stack.
  48. ;
  49. ; The only register that the window proc cannot trash is ESI.
  50. ;
  51. ; Arguments:
  52. ;
  53. ; winproc - x86 Procedure to call
  54. ;
  55. ; hwnd - window handle that sent the message
  56. ;
  57. ; message - message being sent
  58. ;
  59. ; wParam - wParam argument to window procedure
  60. ;
  61. ; lParam - lParam argument to window proc
  62. ;
  63. ; Return Value:
  64. ;
  65. ; LRESULT return value from called window procedure
  66. ;
  67. ;--
  68. cPublicProc _InternalCallWinProc , 5
  69. winproc equ [ebp + 8]
  70. hwnd equ [ebp + 12]
  71. message equ [ebp + 16]
  72. wParam equ [ebp + 20]
  73. lParam equ [ebp + 24]
  74. StackGuard equ 0DCBAABCDh
  75. push ebp
  76. mov ebp, esp
  77. push esi
  78. push edi
  79. push ebx
  80. push StackGuard ; push guard on the stack
  81. push esi ; push another DWORD on the stack
  82. ; so that bogus apps that treat &lParam
  83. ; as an LPPOINT don't corrupt the StackGuard
  84. push lParam
  85. push wParam
  86. push message
  87. push hwnd
  88. call winproc
  89. cmp DWORD PTR [esp+4], StackGuard
  90. je goodCalling
  91. ;--
  92. ; Bug 386625: fix for Corel Presentation 9.0 that restores the stack
  93. ; for 5 parameters instead of 4
  94. ;--
  95. cmp DWORD PTR [esp], StackGuard
  96. jne fixupTheStack
  97. sub esp, 04h
  98. jmp goodCalling
  99. fixupTheStack:
  100. add esp, 010h ; fix up the stack
  101. goodCalling:
  102. add esp, 08h ; pop the extra DWORD
  103. ; pop the second StackGuard
  104. pop ebx
  105. pop edi
  106. pop esi
  107. pop ebp
  108. stdRET _InternalCallWinProc
  109. stdENDP _InternalCallWinProc
  110. ;/*
  111. ; * Bug 246472 - joejo
  112. ; * fixup all DDE Callbacks since some apps make their callbacks
  113. ; * C-Style instead of PASCAL.
  114. ; */
  115. ;++
  116. ;
  117. ;HDDEDATA
  118. ;UserCallDDECallback(
  119. ; UINT wType,
  120. ; UINT wFmt,
  121. ; HCONV hConv,
  122. ; HSZ hsz1,
  123. ; HSZ hsz2,
  124. ; HDDEDATA hData,
  125. ; ULONG_PTR dwData1,
  126. ; ULONG_PTR dwData2
  127. ; )
  128. ;
  129. ; Routine Description:
  130. ;
  131. ; this function cals an x86 DDE Callback procedure. It protects against
  132. ; callback procedures that don't preserve EBX or fail to clean up
  133. ; enough stack.
  134. ;
  135. ; The only register that the window proc cannot trash is ESI.
  136. ;
  137. ; Arguments:
  138. ;
  139. ; pfnDDECallback - DDE Callback function pointer
  140. ; wType
  141. ; wFmt
  142. ; hConv
  143. ; hsz1
  144. ; hsz2
  145. ; hData
  146. ; dwData1
  147. ; dwData2
  148. ;
  149. ; Return Value:
  150. ;
  151. ; HDDEDATA - Handle to a returnded DDE Data object
  152. ;
  153. ;--
  154. cPublicProc _UserCallDDECallback , 9
  155. pfnDDECallback equ [ebp + 8]
  156. wType equ [ebp + 12]
  157. wFmt equ [ebp + 16]
  158. hConv equ [ebp + 20]
  159. hsz1 equ [ebp + 24]
  160. hsz2 equ [ebp + 28]
  161. hData equ [ebp + 32]
  162. dwData1 equ [ebp + 36]
  163. dwData2 equ [ebp + 40]
  164. push ebp
  165. mov ebp, esp
  166. push esi ; save esi across the call
  167. push edi ; save edi across the call
  168. push ebx ; save ebx on the stack across the call
  169. mov esi,esp ; save the stack pointer in esi across the call
  170. push dwData2
  171. push dwData1
  172. push hData
  173. push hsz2
  174. push hsz1
  175. push hConv
  176. push wFmt
  177. push wType
  178. call pfnDDECallback
  179. mov esp,esi ; restore the stack pointer in case callee forgot to clean up
  180. pop ebx ; restore ebx
  181. pop edi ; restore edi
  182. pop esi ; restore esi
  183. pop ebp
  184. stdRET _UserCallDDECallback
  185. stdENDP _UserCallDDECallback
  186. _TEXT ends
  187. end