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

title "Thread Startup"
;++
;
; Copyright (c) 1989 Microsoft Corporation
;
; Module Name:
;
; threadbg.asm
;
; Abstract:
;
; This module implements the code necessary to startup a thread in kernel
; mode.
;
; Author:
;
; Bryan Willman (bryanwi) 22-Feb-1990, derived from DaveC's code.
;
; Environment:
;
; Kernel mode only, IRQL APC_LEVEL.
;
; Revision History:
;
;--
.386p
.xlist
include ks386.inc
include i386\kimacro.inc
include callconv.inc
include irqli386.inc
.list
EXTRNP _KeBugCheck,1
extrn _KiServiceExit2:PROC
page ,132
subttl "Thread Startup"
_TEXT$00 SEGMENT DWORD PUBLIC 'CODE'
ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
;++
;
; Routine Description:
;
; This routine is called at thread startup. Its function is to call the
; initial thread procedure. If control returns from the initial thread
; procedure and a user mode context was established when the thread
; was initialized, then the user mode context is restored and control
; is transfered to user mode. Otherwise a bug check will occur.
;
;
; Arguments:
;
; (TOS) = SystemRoutine - address of initial system routine.
; (TOS+4) = StartRoutine - Initial thread routine.
; (TOS+8) = StartContext - Context parm for initial thread routine.
; (TOS+12) = UserContextFlag - 0 if no user context, !0 if there is one
; (TOS+16) = Base of KTrapFrame if and only if there's a user context.
;
; Return Value:
;
; None.
;
;--
cPublicProc _KiThreadStartup ,1
xor ebx,ebx ; clear registers
xor esi,esi ;
xor edi,edi ;
xor ebp,ebp ;
LowerIrql APC_LEVEL ; KeLowerIrql(APC_LEVEL)
pop eax ; (eax)->SystemRoutine
call eax ; SystemRoutine(StartRoutine, StartContext)
pop ecx ; (ecx) = UserContextFlag
or ecx, ecx
jz short kits10 ; No user context, go bugcheck
mov ebp,esp ; (bp) -> TrapFrame holding UserContext
jmp _KiServiceExit2
kits10: stdCall _KeBugCheck, <NO_USER_MODE_CONTEXT>
stdENDP _KiThreadStartup
_TEXT$00 ends
end