Source code of Windows XP (NT5)
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.

125 lines
2.6 KiB

  1. title "x86-only Helper routine for generic thunk interface CallProc32[Ex]W"
  2. ;++
  3. ;
  4. ; Copyright (c) 1996 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; callpr32.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; WK32ICallProc32MakeCall is a helper routine for wkgthunk.c's
  13. ; WK32ICallProc32, the common thunk for CallProc32W and
  14. ; CallProc32ExW, the two generic thunk routines which allow
  15. ; 16-bit code to call any 32-bit function.
  16. ;
  17. ; Author:
  18. ;
  19. ; Dave Hart (davehart) 23-Jan-96
  20. ;--
  21. .386p
  22. include callconv.inc
  23. if DBG
  24. DEBUG equ 1
  25. endif
  26. ifdef DEBUG
  27. DEBUG_OR_WOWPROFILE equ 1
  28. endif
  29. ifdef WOWPROFILE
  30. DEBUG_OR_WOWPROFILE equ 1
  31. endif
  32. ;include wow.inc
  33. _TEXT SEGMENT PARA PUBLIC 'CODE'
  34. ASSUME DS:FLAT, ES:FLAT, SS:FLAT, FS:NOTHING, GS:NOTHING
  35. ; EXTRNP _DispatchInterrupts,0
  36. _TEXT ENDS
  37. _DATA SEGMENT DWORD PUBLIC 'DATA'
  38. ; extrn _aw32WOW:Dword
  39. _DATA ENDS
  40. _TEXT SEGMENT
  41. page ,132
  42. subttl "WK32ICallProc32MakeCall"
  43. ;++
  44. ;
  45. ; Routine Description:
  46. ;
  47. ; WK32ICallProc32MakeCall is a helper routine for wkgthunk.c's
  48. ; WK32ICallProc32, the common thunk for CallProc32W and
  49. ; CallProc32ExW, the two generic thunk routines which allow
  50. ; 16-bit code to call any 32-bit function.
  51. ;
  52. ; Like Win95's implementation, this code allows the called
  53. ; routine to fail to restore esp (for example, if we are
  54. ; told the routine is STDCALL but it's really CDECL).
  55. ; A number of Works 95's Wizards don't work otherwise.
  56. ;
  57. ; Arguments:
  58. ;
  59. ; pfn procedure to call
  60. ; cArgs count of DWORDs
  61. ; pArgs Argument array
  62. ;
  63. ; Returns:
  64. ;
  65. ; return value of called routine.
  66. ;
  67. assume DS:_DATA,ES:Nothing,SS:_DATA
  68. ALIGN 16
  69. cPublicProc _WK32ICallProc32MakeCall,3
  70. .FPO (0,3,2,2,0,0) ; 3 params, 2 byte prolog, 2 saved registers
  71. push edi
  72. push esi
  73. pfn equ [esp+0ch]
  74. cbArgs equ [esp+10h]
  75. pArgs equ [esp+14h]
  76. mov ecx,cbArgs
  77. mov edx,pfn
  78. mov edi,esp ; Save ESP if no args
  79. or ecx,ecx
  80. mov eax,ecx
  81. jz DoneArgs
  82. shr ecx,2 ; convert bytes to dwords
  83. mov esi,pArgs
  84. sub esp,eax ; parm macros are invalid
  85. cld ; "push" the arguments
  86. mov edi,esp
  87. rep movsd
  88. ; edi is left at correct post-call ESP
  89. DoneArgs:
  90. call edx
  91. mov esp,edi
  92. pop esi
  93. pop edi
  94. stdRET _WK32ICallProc32MakeCall
  95. stdENDP _WK32ICallProc32MakeCall
  96. _TEXT ends
  97. end
  98.