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.

131 lines
3.6 KiB

  1. title "Thread Startup"
  2. ;++
  3. ;
  4. ; Copyright (c) 2000 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; threadbg.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements the code necessary to startup a thread in kernel
  13. ; mode.
  14. ;
  15. ; Author:
  16. ;
  17. ; David N. Cutler (davec) 10-Jun-2000
  18. ;
  19. ; Environment:
  20. ;
  21. ; Kernel mode only, IRQL APC_LEVEL.
  22. ;
  23. ;--
  24. include ksamd64.inc
  25. altentry KiStartSystemThread
  26. altentry KiStartUserThread
  27. altentry KiStartUserThreadReturn
  28. extern KeBugCheck:proc
  29. extern KiExceptionExit:proc
  30. subttl "System Thread Startup"
  31. ;++
  32. ;
  33. ; Routine Description:
  34. ;
  35. ; This routine is called to start a system thread. This function calls the
  36. ; initial thread procedure after having extracted the startup parameters
  37. ; from the specified start frame. If control returns from the initial
  38. ; thread procedure, then a bug check will occur.
  39. ;
  40. ; Implicit Arguments:
  41. ;
  42. ; N.B. This function begins execution at its alternate entry point with
  43. ; a start frame on the stack. This frame contains the start context,
  44. ; the start routine, and the system routine.
  45. ;
  46. ; Return Value:
  47. ;
  48. ; None - no return.
  49. ;
  50. ;--
  51. NESTED_ENTRY KxStartSystemThread, _TEXT$00
  52. .allocstack (KSTART_FRAME_LENGTH - 8) ; allocate stack frame
  53. END_PROLOGUE
  54. ALTERNATE_ENTRY KiStartSystemThread
  55. mov ecx, APC_LEVEL ; set IRQL to APC level
  56. SetIrql ;
  57. mov rdx, SfP1Home[rsp] ; get startup context parameter
  58. mov rcx, SfP2Home[rsp] ; get startup routine address
  59. call qword ptr SfP3Home[rsp] ; call system routine
  60. mov rcx, NO_USER_MODE_CONTEXT ; set bug check parameter
  61. call KeBugCheck ; call bug check - no return
  62. nop ; do not remove
  63. NESTED_END KxStartSystemThread, _TEXT$00
  64. subttl "User Thread Startup"
  65. ;++
  66. ;
  67. ; Routine Description:
  68. ;
  69. ; This routine is called to start a user thread. This function calls the
  70. ; initial thread procedure after having extracted the startup parameters
  71. ; from the specified exception frame. If control returns from the initial
  72. ; thread routine, then the user mode context is restored and control is
  73. ; transfered to the exception exit code.
  74. ;
  75. ; Implicit Arguments:
  76. ;
  77. ; N.B. This functiion begins execution with a trap frame and an exception
  78. ; frame on the stack that represents the user mode context. The start
  79. ; context, start routine, and the system routine parameters are stored
  80. ; in the exception record.
  81. ;
  82. ; Return Value:
  83. ;
  84. ; None.
  85. ;
  86. ;--
  87. NESTED_ENTRY KyStartUserThread, _TEXT$00
  88. GENERATE_TRAP_FRAME ; generate trap frame
  89. call KxStartUserThread ; call dummy startup routine
  90. ALTERNATE_ENTRY KiStartUserThreadReturn
  91. nop ; do not remove
  92. NESTED_END KyStartUserThread, _TEXT$00
  93. NESTED_ENTRY KxStartUserThread, _TEXT$00
  94. GENERATE_EXCEPTION_FRAME ; generate exception frame
  95. ALTERNATE_ENTRY KiStartUserThread
  96. mov ecx, APC_LEVEL ; set IRQL to APC level
  97. SetIrql ;
  98. mov rdx, ExP1Home[rsp] ; get startup context parameter
  99. mov rcx, ExP2Home[rsp] ; get startup routine address
  100. call qword ptr ExP3Home[rsp] ; call system routine
  101. jmp KiExceptionExit ; finish in exception exit code
  102. NESTED_END KxStartUserThread, _TEXT$00
  103. end