Windows9x下隐藏进程
Windows 9x中进程隐藏的目的就是让用户在任务管理器中
不能查看与关闭程序,从而实现一些关键性的任务。
在Windows 9x下实现进程隐藏比较简单,主要是调用一个32位的API函数:
RegisterServiceProcess,其函数原形为:
BOOL RegisterServiceProcess( DWORD dwPID, DWORD dwType )
参数:
dwPID:进程ID, NULL代表当前进程
dwType: RSP_SIMPLE_SERVICE为进程隐藏, RSP_UNREGISTER_SERVICE为取消进程隐藏
返回值: TRUE: 调用成功, FALSE: 调用失败
另外, 为了让进程随系统开机启动而自动加载,需要在注册表中的启动项中
加入您的应用程序,位置:
\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run或RunServices
由于RegisterServiceProcess函数是Windows 9x下未公开的函数,
所以只能动态加载,具体细节如下:
CODE// Function types for GetProcAddress
typedef bool __stdcall (*pRegisterService)(DWORD,DWORD);
//get the os version information
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osversion);
if(osversion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
hKernel = LoadLibrary("kernel32.dll");
if(hKernel)
{
RegisterService =(pRegisterService)GetProcAddress(hKernel,"RegisterServiceProcess");
if(RegisterService)
{
RegisterService(::GetCurrentProcessId(),RSP_SIMPLE_SERVICE);
}
FreeLibrary(hKernel);
hKernel = NULL;