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.

148 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. IFDEF STD_CALL
  73. jmp _LdrpInitialize@12 ; LdrpInitialize
  74. ELSE
  75. jmp _LdrpInitialize ; LdrpInitialize
  76. ENDIF
  77. stdENDP _LdrInitializeThunk
  78. ;++
  79. ;
  80. ; VOID
  81. ; LdrpCallInitRoutine(
  82. ; IN PDLL_INIT_ROUTINE InitRoutine,
  83. ; IN PVOID DllHandle,
  84. ; IN ULONG Reason,
  85. ; IN PCONTEXT Context OPTIONAL
  86. ; )
  87. ;
  88. ; Routine Description:
  89. ;
  90. ; This function calls an x86 DLL init routine. It is robust
  91. ; against DLLs that don't preserve EBX or fail to clean up
  92. ; enough stack.
  93. ;
  94. ; The only register that the DLL init routine cannot trash is ESI.
  95. ;
  96. ; Arguments:
  97. ;
  98. ; InitRoutine - Address of init routine to call
  99. ;
  100. ; DllHandle - Handle of DLL to call
  101. ;
  102. ; Reason - one of the DLL_PROCESS_... or DLL_THREAD... values
  103. ;
  104. ; Context - context pointer or NULL
  105. ;
  106. ; Return Value:
  107. ;
  108. ; FALSE if the init routine fails, TRUE for success.
  109. ;
  110. ;--
  111. cPublicProc _LdrpCallInitRoutine , 4
  112. InitRoutine equ [ebp + 8]
  113. DllHandle equ [ebp + 12]
  114. Reason equ [ebp + 16]
  115. Context equ [ebp + 20]
  116. stdENDP _LdrpCallInitRoutine
  117. push ebp
  118. mov ebp, esp
  119. push esi ; save esi across the call
  120. push edi ; save edi across the call
  121. push ebx ; save ebx on the stack across the call
  122. mov esi,esp ; save the stack pointer in esi across the call
  123. push Context
  124. push Reason
  125. push DllHandle
  126. call InitRoutine
  127. mov esp,esi ; restore the stack pointer in case callee forgot to clean up
  128. pop ebx ; restore ebx
  129. pop edi ; restore edi
  130. pop esi ; restore esi
  131. pop ebp
  132. stdRET _LdrpCallInitRoutine
  133. _TEXT ends
  134. end