我有以下装配线:
PUSH 0
PUSH 4 ; CreationFlags = CREATE_SUSPENDED
PUSH 0
PUSH program.0040163B ; start address of thread
PUSH 0
PUSH 0
CALL DWORD PTR DS:[402428] ; kernel32.CreateThread
MOV DWORD PTR DS:[4023F8], EAX ; store handle to created thread to [4023F8]
....
....
LEA ESI, DWORD PTR DS:[402000]
PUSH ESI ; [402000] will be the location where we store the context of the thread
PUSH DWORD PTR DS:[4023F8] ; handle to created thread
CALL DWORD PTR DS:[402424] ; kernel32.GetThreadContext
MOV [ESI+B0], program.004010E9 ; [ESI+B0] = [4020B0] = 0040163B (starting address of the created thread will be replaced by 004010E9, I guess)
PUSH ESI ; ESI points to 402000 where the thread context is stored, but now with a modified starting address of the thread
PUSH DWORD PTR DS:[4023F8] ; handle to thread
CALL DWORD PTR DS:[402418] ; kernel32.SetThreadContext
PUSH DWORD PTR DS:[4023F8]
CALL DWORD PTR DS:[402410] ; kernel32.ResumeThread
....
....
RETN
所以,总结一下:我们创建了一个处于挂起状态的线程。它的起始地址是 0040163B。然后我们得到线程上下文,存入402000,通过将B0的偏移量加上402000,就到了上下文结构体中存放线程起始地址的地方。我们将其更改为 004010E9 并使用 SetThreadContext 设置修改后的上下文。
所以,我的问题是:当我到达/调用 ResumeThread() 时,线程的起始地址将是 0040163B 还是 004010E9 ?因为Get-和SetThreadContext的结合,所以我的线程的起始地址必须是004010E9是有道理的,但我想确定一下。
编辑:
总之我的问题是 (1) 如果我创建一个挂起的线程 (2) 通过 SetThreadContext 改变其入口点 (3) 恢复挂起的线程
线程会在原始入口点CreateThread或新修改的入口点处开始执行吗?