Smss.exe 进程分析--NT 源码--当机方法
来源:http://blog.vckbase.com/windowssky/archive/2007/04/17/25544.html
传说中的会话管理服务器进程,它是windows操作系统启动时引导的最重要的系统进程,它负责启动csrss.exe和winlogon.exe进程,并对它们进行监控,如果发现其中一个挂掉,它马上叫你当机,所以要想结束csrss.exe/winlogon.exe,先结束Smss.exe,源码前一目了然(摘自windows nt 4.0代码)
//1 Module Info : 变量定义,提高当前进程的优先级(11级)
NTSTATUS Status;
KPRIORITY SetBasePriority;
UNICODE_STRING InitialCommand, DebugInitialCommand, UnicodeParameter;
HANDLE ProcessHandles[ 2 ];
ULONG Parameters[ 4 ];
ULONG Response;
PROCESS_BASIC_INFORMATION ProcessInfo;
BOOLEAN WasEnabled;
SetBasePriority = FOREGROUND_BASE_PRIORITY+2;//#define FOREGROUND_BASE_PRIORITY 9
Status = NtSetInformationProcess( NtCurrentProcess(),
ProcessBasePriority,
(PVOID) &SetBasePriority,
sizeof( SetBasePriority )
);
ASSERT(NT_SUCCESS(Status));
if (ARGUMENT_PRESENT( DebugParameter )) {
SmpDebug = DebugParameter;
}
//2 Module Info : 获取Csrss.exe和winlogon.exe进程的句柄,并对它们进行监控
try {
Status = SmpInit( &InitialCommand, &ProcessHandles[ 0 ] );//返回crsss.exe进程的句柄
if (!NT_SUCCESS( Status )) {
KdPrint(( "SMSS: SmpInit return failure - Status == %x/n" ));
RtlInitUnicodeString( &UnicodeParameter, L"Session Manager Initialization" );
Parameters[ 1 ] = (ULONG)Status;
}
else {
SYSTEM_FLAGS_INFORMATION FlagInfo;
NtQuerySystemInformation( SystemFlagsInformation,
&FlagInfo,
sizeof( FlagInfo ),
NULL
);
if (FlagInfo.Flags & (FLG_DEBUG_INITIAL_COMMAND | FLG_DEBUG_INITIAL_COMMAND_EX) ) {
DebugInitialCommand.MaximumLength = InitialCommand.Length + 64;
DebugInitialCommand.Length = 0;
DebugInitialCommand.Buffer = RtlAllocateHeap( RtlProcessHeap(),
MAKE_TAG( INIT_TAG ),
DebugInitialCommand.MaximumLength
);
if (FlagInfo.Flags & FLG_ENABLE_CSRDEBUG) {
RtlAppendUnicodeToString( &DebugInitialCommand, L"ntsd -p -1 -d " );
}
else {
RtlAppendUnicodeToString( &DebugInitialCommand, L"ntsd -d " );
}
if (FlagInfo.Flags & FLG_DEBUG_INITIAL_COMMAND_EX ) {
RtlAppendUnicodeToString( &DebugInitialCommand, L"-g -x " );
}
RtlAppendUnicodeStringToString( &DebugInitialCommand, &InitialCommand );
InitialCommand = DebugInitialCommand;
}
Status = SmpExecuteInitialCommand( &InitialCommand, &ProcessHandles[ 1 ] );//返回winlogon进程句柄
if (NT_SUCCESS( Status )) {
Status = NtWaitForMultipleObjects( 2,
ProcessHandles,
WaitAny,
FALSE,
NULL
);
}
if (Status == STATUS_WAIT_0) {
RtlInitUnicodeString( &UnicodeParameter, L"Windows SubSystem" );
Status = NtQueryInformationProcess( ProcessHandles[ 0 ],
ProcessBasicInformation,
&ProcessInfo,
sizeof( ProcessInfo ),
NULL
);
KdPrint(( "SMSS: Windows subsystem terminated when it wasn't supposed to./n" ));
}
else {
RtlInitUnicodeString( &UnicodeParameter, L"Windows Logon Process" );
if (Status == STATUS_WAIT_1) {
Status = NtQueryInformationProcess( ProcessHandles[ 1 ],
ProcessBasicInformation,
&ProcessInfo,
sizeof( ProcessInfo ),
NULL
);
}
else {
ProcessInfo.ExitStatus = Status;
Status = STATUS_SUCCESS;
}
KdPrint(( "SMSS: Initial command '%wZ' terminated when it wasn't supposed to./n", &InitialCommand ));
}
if (NT_SUCCESS( Status )) {
Parameters[ 1 ] = (ULONG)ProcessInfo.ExitStatus;
}
else {
Parameters[ 1 ] = (ULONG)STATUS_UNSUCCESSFUL;
}
}
}
except( SmpUnhandledExceptionFilter( GetExceptionInformation() ) ) {
RtlInitUnicodeString( &UnicodeParameter, L"Unhandled Exception in Session Manager" );
Parameters[ 1 ] = (ULONG)GetExceptionCode();
}
//3 Module Info : 当机代码!呵呵,其实就是通知操作系统,发生了一个硬件中断
Status = RtlAdjustPrivilege( SE_SHUTDOWN_PRIVILEGE,
(BOOLEAN)TRUE,
TRUE,
&WasEnabled
);//提高当前的权限,可以执行shutdown指令
if (Status == STATUS_NO_TOKEN) {
//
// No thread token, use the process token
//
Status = RtlAdjustPrivilege( SE_SHUTDOWN_PRIVILEGE,
(BOOLEAN)TRUE,
FALSE,
&WasEnabled
);
}
Parameters[ 0 ] = (ULONG)&UnicodeParameter;
Status = NtRaiseHardError( STATUS_SYSTEM_PROCESS_TERMINATED,
2,
1,
Parameters,
OptionShutdownSystem,
&Response
);//看看,字面意思就知道发生什么了,唤起硬件错误
//
// If this returns, giveup
//
NtTerminateProcess( NtCurrentProcess(), Status );
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1740363
Smss.exe 进程分析--NT 源码--当机方法相关推荐
- Smss.exe进程分析
传说中的会话管理服务器进程,它是windows操作系统启动时引导的最重要的系统进程,它负责启动csrss.exe和winlogon.exe进程,并对它们进行监控,如果发现其中一个挂掉,它马上叫你当机, ...
- Android源码分析--MediaServer源码分析(二)
在上一篇博客中Android源码分析–MediaServer源码分析(一),我们知道了ProcessState和defaultServiceManager,在分析源码的过程中,我们被Android的B ...
- 一 分析easyswoole源码(启动服务)
分析easyswoole源码1以启动为例 //检查是否已经安装 installCheck();//检查锁文件是否存在,不存在结束 //启动服务 serverStart showLogo();//显示l ...
- 【Linux 内核】进程管理 ( 系统调用简介 | 进程相关系统调用源码 )
文章目录 一.系统调用简介 二.进程相关系统调用源码 一.系统调用简介 在开发应用程序时 , 进行 " 进程创建 " , 调用的 fork() , vfork() , clone( ...
- 【Android 热修复】热修复原理 ( 类加载分析 | 分析 PathClassLoader 源码 | 分析 BaseDexClassLoader 源码 | 分析 PathDexList 源码 )
文章目录 一.分析 PathClassLoader 源码 二.分析 BaseDexClassLoader 源码 三.分析 PathDexList 源码 四. 源码资源 一.分析 PathClassLo ...
- 【Android 电量优化】JobScheduler 源码分析 ( JobServiceContext 源码分析 | 闭环操作总结 | 用户提交任务 | 广播接收者接受相关广播触发任务执行 )★
文章目录 一.JobServiceContext 引入 二.JobServiceContext 源码分析 三.用户在应用层如何使用 JobScheduler 四.用户提交任务 五.广播接收者监听广播触 ...
- Qt学习笔记,再次分析EVA源码之后得出的结论-QListView,QListViewItem(Qt3);Q3ListView,Q3ListViewItem(Qt4)...
Qt学习笔记,再次分析EVA源码之后得出的结论-QListView,QListViewItem(Qt3);Q3ListView,Q3ListViewItem(Qt4) 今天再次分析了Eva的源码,也看 ...
- 分析jQuery源码时记录的一点感悟
分析jQuery源码时记录的一点感悟 1. 链式写法 这是jQuery语法上的最大特色,也许该改改POJO里的set方法,和其他的非get方法什么的,可以把多行代码合并,减去 ...
- python爬取天气预报源代码_python抓取天气并分析 实例源码
[实例简介] Python代码抓取获取天气预报信息源码讲解.这是一个用Python编写抓取天气预报的代码示例,用python写天气查询软件程序很简单.这段代码可以获取当地的天气和.任意城市的天气预报, ...
最新文章
- 织梦手机站下一篇变上一篇而且还出错Request Error!
- mysql创建表的时候,字段尽量不要为NULL
- pelco-d协议数据解析示例
- html设置文字超过字数_html文本控制显示字数超出用省略号的方法
- Ubuntu编写开机自启动脚本(转载)
- zeal刷新不出来_饥荒:游戏中的这些事物都是无中生有,几乎可以无限制刷新!...
- 【使用C语言的7的步骤】
- PL/SQL 结构与实例
- 数据3分钟丨Gartner宣布明年12大战略性技术趋势;PolarDB-X正式开源;OceanBase 3.2发布...
- os如何读取图片_CV:基于face库利用cv2调用摄像头根据人脸图片实现找人
- python print退格_python退格输入
- Cache数据库之ECP搭建
- 6.11 通过文件描述符来获取信号
- SDN有哪些优势呢?
- PPOCRv3模型转pytorch
- R语言之-caret包应用
- wangeditor: 上传图片+上传视频+上传附件(自定义)完整使用
- 算出指定日期在当年的第几周
- JavaScript 教程「6」:数组
- 关于fancybox打开动态加载的图片
热门文章
- Git 找回删除的分支
- 如何用java实现水仙花数
- Fiddler 抓包HTTPS包,抓手机包
- 七种方法教你如何获取以太坊测试网Token
- 各种书籍免费下载地址(持续更新中)
- 2021-11-12 Android 11 长按按键进入恢复出厂设置的实现方法-PhoneWindowManager里面用发广播的模式
- MySQL数据库视频教程之扛得住的MySQL数据库架构
- matlab的imresize函数,为什么python cv2.resize函数对RGB图像给出的结果与MATLAB imresize函数不同?...
- Keil5 安装使用
- 微信小程序:本地存储数据