; 挂起和恢复指定的线程。

SuspendThread(ThreadID) {
  if !(hThread := DllCall("OpenThread", "uint", 0x0002, "int", 0, "uint", ThreadID, "ptr"))
    throw Exception("OpenThread", -1)
  if (DllCall("SuspendThread", "ptr", hThread) = -1)
    throw Exception("SuspendThread", -1), DllCall("CloseHandle", "ptr", hThread)
  return true, DllCall("CloseHandle", "ptr", hThread)
}


Wow64SuspendThread(ThreadID) {
  if !(hThread := DllCall("OpenThread", "uint", 0x0002, "int", 0, "uint", ThreadID, "ptr"))
    throw Exception("OpenThread", -1)
  if (DllCall("Wow64SuspendThread", "ptr", hThread) = -1)
    throw Exception("Wow64SuspendThread", -1), DllCall("CloseHandle", "ptr", hThread)
  return true, DllCall("CloseHandle", "ptr", hThread)
}


ResumeThread(ThreadID) {
  if !(hThread := DllCall("OpenThread", "uint", 0x0002, "int", 0, "uint", ThreadID, "ptr"))
    throw Exception("OpenThread", -1)
  if (DllCall("ResumeThread", "ptr", hThread) = -1)
    throw Exception("ResumeThread", -1), DllCall("CloseHandle", "ptr", hThread)
  return true, DllCall("CloseHandle", "ptr", hThread)
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。