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.

144 lines
3.3 KiB

  1. title "LdrInitializeThunk"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; ldrthunk.s
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements the thunk for the LdrpInitialize APC routine.
  13. ;
  14. ; Author:
  15. ;
  16. ; Steven R. Wood (stevewo) 27-Apr-1990
  17. ;
  18. ; Environment:
  19. ;
  20. ; Any mode.
  21. ;
  22. ; Revision History:
  23. ;
  24. ;--
  25. .386p
  26. .xlist
  27. include ks386.inc
  28. include callconv.inc ; calling convention macros
  29. .list
  30. EXTRNP _LdrpInitialize,3
  31. _TEXT SEGMENT DWORD PUBLIC 'CODE'
  32. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  33. page , 132
  34. ;++
  35. ;
  36. ; VOID
  37. ; LdrInitializeThunk(
  38. ; IN PVOID NormalContext,
  39. ; IN PVOID SystemArgument1,
  40. ; IN PVOID SystemArgument2
  41. ; )
  42. ;
  43. ; Routine Description:
  44. ;
  45. ; This function computes a pointer to the context record on the stack
  46. ; and jumps to the LdrpInitialize function with that pointer as its
  47. ; parameter.
  48. ;
  49. ; Arguments:
  50. ;
  51. ; NormalContext - User Mode APC context parameter (ignored).
  52. ;
  53. ; SystemArgument1 - User Mode APC system argument 1 (ignored).
  54. ;
  55. ; SystemArgument2 - User Mode APC system argument 2 (ignored).
  56. ;
  57. ; Return Value:
  58. ;
  59. ; None.
  60. ;
  61. ;--
  62. cPublicProc _LdrInitializeThunk , 4
  63. NormalContext equ [esp + 4]
  64. SystemArgument1 equ [esp + 8]
  65. SystemArgument2 equ [esp + 12]
  66. Context equ [esp + 16]
  67. lea eax,Context ; Calculate address of context record
  68. mov NormalContext,eax ; Pass as first parameter to
  69. if DEVL
  70. xor ebp,ebp ; Mark end of frame pointer list
  71. endif
  72. jmp _LdrpInitialize@12 ; LdrpInitialize
  73. stdENDP _LdrInitializeThunk
  74. ;++
  75. ;
  76. ; VOID
  77. ; LdrpCallInitRoutine(
  78. ; IN PDLL_INIT_ROUTINE InitRoutine,
  79. ; IN PVOID DllHandle,
  80. ; IN ULONG Reason,
  81. ; IN PCONTEXT Context OPTIONAL
  82. ; )
  83. ;
  84. ; Routine Description:
  85. ;
  86. ; This function calls an x86 DLL init routine. It is robust
  87. ; against DLLs that don't preserve EBX or fail to clean up
  88. ; enough stack.
  89. ;
  90. ; The only register that the DLL init routine cannot trash is ESI.
  91. ;
  92. ; Arguments:
  93. ;
  94. ; InitRoutine - Address of init routine to call
  95. ;
  96. ; DllHandle - Handle of DLL to call
  97. ;
  98. ; Reason - one of the DLL_PROCESS_... or DLL_THREAD... values
  99. ;
  100. ; Context - context pointer or NULL
  101. ;
  102. ; Return Value:
  103. ;
  104. ; FALSE if the init routine fails, TRUE for success.
  105. ;
  106. ;--
  107. cPublicProc _LdrpCallInitRoutine , 4
  108. InitRoutine equ [ebp + 8]
  109. DllHandle equ [ebp + 12]
  110. Reason equ [ebp + 16]
  111. Context equ [ebp + 20]
  112. stdENDP _LdrpCallInitRoutine
  113. push ebp
  114. mov ebp, esp
  115. push esi ; save esi across the call
  116. push edi ; save edi across the call
  117. push ebx ; save ebx on the stack across the call
  118. mov esi,esp ; save the stack pointer in esi across the call
  119. push Context
  120. push Reason
  121. push DllHandle
  122. call InitRoutine
  123. mov esp,esi ; restore the stack pointer in case callee forgot to clean up
  124. pop ebx ; restore ebx
  125. pop edi ; restore edi
  126. pop esi ; restore esi
  127. pop ebp
  128. stdRET _LdrpCallInitRoutine
  129. _TEXT ends
  130. end