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.

95 lines
2.4 KiB

  1. title "Thread Startup"
  2. ;++
  3. ;
  4. ; Copyright (c) 1989 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. ; Bryan Willman (bryanwi) 22-Feb-1990, derived from DaveC's code.
  18. ;
  19. ; Environment:
  20. ;
  21. ; Kernel mode only, IRQL APC_LEVEL.
  22. ;
  23. ; Revision History:
  24. ;
  25. ;--
  26. .386p
  27. .xlist
  28. include ks386.inc
  29. include i386\kimacro.inc
  30. include callconv.inc
  31. include irqli386.inc
  32. .list
  33. EXTRNP _KeBugCheck,1
  34. extrn _KiServiceExit2:PROC
  35. page ,132
  36. subttl "Thread Startup"
  37. _TEXT$00 SEGMENT DWORD PUBLIC 'CODE'
  38. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  39. ;++
  40. ;
  41. ; Routine Description:
  42. ;
  43. ; This routine is called at thread startup. Its function is to call the
  44. ; initial thread procedure. If control returns from the initial thread
  45. ; procedure and a user mode context was established when the thread
  46. ; was initialized, then the user mode context is restored and control
  47. ; is transfered to user mode. Otherwise a bug check will occur.
  48. ;
  49. ;
  50. ; Arguments:
  51. ;
  52. ; (TOS) = SystemRoutine - address of initial system routine.
  53. ; (TOS+4) = StartRoutine - Initial thread routine.
  54. ; (TOS+8) = StartContext - Context parm for initial thread routine.
  55. ; (TOS+12) = UserContextFlag - 0 if no user context, !0 if there is one
  56. ; (TOS+16) = Base of KTrapFrame if and only if there's a user context.
  57. ;
  58. ; Return Value:
  59. ;
  60. ; None.
  61. ;
  62. ;--
  63. cPublicProc _KiThreadStartup ,1
  64. xor ebx,ebx ; clear registers
  65. xor esi,esi ;
  66. xor edi,edi ;
  67. xor ebp,ebp ;
  68. LowerIrql APC_LEVEL ; KeLowerIrql(APC_LEVEL)
  69. pop eax ; (eax)->SystemRoutine
  70. call eax ; SystemRoutine(StartRoutine, StartContext)
  71. pop ecx ; (ecx) = UserContextFlag
  72. or ecx, ecx
  73. jz short kits10 ; No user context, go bugcheck
  74. mov ebp,esp ; (bp) -> TrapFrame holding UserContext
  75. jmp _KiServiceExit2
  76. kits10: stdCall _KeBugCheck, <NO_USER_MODE_CONTEXT>
  77. stdENDP _KiThreadStartup
  78. _TEXT$00 ends
  79. end
  80.