Force a thread to enter the alertable state and execute the queued APC
来源:互联网 发布:淘宝店铺招牌图片尺寸 编辑:程序博客网 时间:2024/05/22 07:43
对网上相关知识的整理
http://www.codeguru.com/forum/archive/index.php/t-429599.html
目的: Force a thread to enter the alertable state and execute the queued APC?
Normal:
I want to queue a user APC to a thread in the other running process (code injection issue resolved), but it is never executed. I guess the problem is the thread never enter the alertable state.
One special case:
However, if I create that foreign process with CREATE_SUSPEND, queue the APC to the primary thread, resume it, the APC will be executed correctly, no problem.
Explanation:
That's a special case. The kernel launches a user-mode thread by queuing a user APC to run loader code in ntdll and then coercing an alertable state. If you queue any other user APC before the thread starts it will execute as well.
具体做的事情:
I am looking for a userland solution. Maybe using some native APIs in NTDLL.DLL, but I've not got any luck.
(1)
SuspendThread(hThread);
QueueUserAPC(apcFunc, hThread, NULL);
NtAlertResumeThread(hThread, &suspendCount);
(2)
QueueUserAPC(apcFunc, hThread, NULL);
NtAlertThread(hThread);
Neither of the above two method works. Do I miss something?
Explanation:You missed your own recognition that user APCS were not designed for asynchronous thread interruption and can't be used that way.
Suggestion:I believe that the way the POSIX subsystem (R.I.P.??) implements signals is to suspend the thread and then change its context using SetThreadContext()/NtSetContextThread(). Use this idea at your own risk...
Answer:This is interesting, but my purpose is to execute the user APC in the context of a target thread in "another" process.
- Force a thread to enter the alertable state and execute the queued APC
- Thread State and the Global Interpreter Lock
- bring (force) a Window to the foreground?
- VMware启动solaris10 x86错误:A fault has occurred causing a virtual CPU to enter the shutdown state
- 133 - The Dole Queued
- failed to sync branch You might need to open a shell and debug the state of this repo.
- failed to sync branch You might need to open a shell and debug the state of this repo.
- failed to sync branch You might need to open a shell and debug the state of this repo
- failed to sync branch You might need to open a shell and debug the state of this repo.
- the limit to the amount of thread from a process
- What is the difference between a thread and a process?
- What's the difference between a thread and a process?
- What is the difference between a process and a thread?
- How to execute the jar
- How do you force a java swt program to “move itself to the foreground”?
- Colored SQL--How to force the AWR to capture a specified SQL even if it is not the top one
- Log 分析:Due to heavy load, the latest workflow operation has been queued...
- Work around by " Due to heavy load, the latest workflow operation has been queued. "
- Genesis2000 Script 编程
- 字符数组
- China's ruthless criminals TOP3!
- 网站地址多出jdfwkey=的原因及解决方法
- csh简单语法
- Force a thread to enter the alertable state and execute the queued APC
- 预编译头文件:效率还是内聚性?
- 如何投资美国股票
- 什么是CC?CC攻击原理及防御方法
- DataRow复制功能
- 未来的路还很长
- Mysql数据库安装配置及常用命令(不断更新)
- 牵念
- MFC新控件(二)