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.

109 lines
2.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: clstub16.cxx
  7. //
  8. // Contents: 32->16 bit call forwarding stub
  9. //
  10. // History: 25-Feb-93 DrewB Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <headers.cxx>
  14. #pragma hdrstop
  15. //+---------------------------------------------------------------------------
  16. //
  17. // Function: CallStub16, public
  18. //
  19. // Synopsis: Invokes a 16-bit routine on behalf of the 32-bit code
  20. //
  21. // Arguments: [pcd] - Data describing the call to be made
  22. //
  23. // Returns: Appropriate status code
  24. //
  25. // History: 18-Feb-94 DrewB Created
  26. //
  27. //----------------------------------------------------------------------------
  28. DWORD __loadds FAR PASCAL CallStub16(LPCALLDATA pcd)
  29. {
  30. DWORD dwRes;
  31. DWORD pfn;
  32. WORD cbStack;
  33. DWORD pvStack;
  34. thkAssert(pcd != NULL);
  35. pfn = pcd->vpfn;
  36. cbStack = (WORD)pcd->cbStack;
  37. pvStack = pcd->vpvStack16;
  38. thkDebugOut((DEB_ITRACE, "In CallStub16(%08lX, %u, %08lX)\n",
  39. pfn, cbStack, pvStack));
  40. // Check for wildly out-of-range stack sizes
  41. thkAssert(cbStack < 0x100);
  42. // Make sure that the stack size is even to
  43. // maintain alignment and allow free use of movsw
  44. thkAssert((cbStack & 1) == 0);
  45. __asm
  46. {
  47. // Make space on the real stack for the stack given to us from 32-bits
  48. sub sp, cbStack
  49. // Simple sanity checks on new stack pointer
  50. jc StackOverflow
  51. cmp sp, 512
  52. jb StackOverflow
  53. // Copy pvStack to the real stack
  54. push ds
  55. push si
  56. push es
  57. push di
  58. mov ds, WORD PTR pvStack+2
  59. mov si, WORD PTR pvStack
  60. mov ax, ss
  61. mov es, ax
  62. mov di, sp
  63. // Skip over saved registers
  64. add di, 8
  65. mov cx, cbStack
  66. shr cx, 1
  67. cld
  68. rep movsw
  69. pop di
  70. pop es
  71. pop si
  72. pop ds
  73. // Call the routine
  74. call DWORD PTR pfn
  75. jmp End
  76. StackOverflow:
  77. // E_OUTOFMEMORY
  78. mov dx, 8000h
  79. mov ax, 0002h
  80. End:
  81. mov WORD PTR dwRes, ax
  82. mov WORD PTR dwRes+2, dx
  83. add sp, cbStack
  84. }
  85. thkDebugOut((DEB_ITRACE, "Out CallStub16: return %ld\n",dwRes));
  86. return dwRes;
  87. }