码迷,mamicode.com
首页 > 系统相关 > 详细

劫持系统进程禁止打开任何进程(5)

时间:2015-05-26 20:46:45      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

劫持系统进程禁止打开任何进程(5)
windows创建进程的函数:

技术分享

把这个函数劫持之后注射到 explore.exe进程中即可。

现在注射到印象笔记中测试:

#include<stdio.h>
#include<windows.h>
#include<string.h>
#include"detours.h"
#pragma comment (lib ,"detours.lib" )

BOOL(WINAPI * oldCreateProcessW)(
        LPCWSTR lpApplicationName,
        LPWSTR lpCommandLine,
        LPSECURITY_ATTRIBUTES lpProcessAttributes,
        LPSECURITY_ATTRIBUTES lpThreadAttributes,
        BOOL bInheritHandles,
        DWORD dwCreationFlags,
        LPVOID lpEnvironment,
        LPCWSTR lpCurrentDirectory,
        LPSTARTUPINFOW lpStartupInfo,
        LPPROCESS_INFORMATION lpProcessInformation
       ) = CreateProcessW;

BOOL WINAPI newCreateProcessW(
        LPCWSTR lpApplicationName,
        LPWSTR lpCommandLine,
        LPSECURITY_ATTRIBUTES lpProcessAttributes ,
        LPSECURITY_ATTRIBUTES lpThreadAttributes ,
        BOOL bInheritHandles,
        DWORD dwCreationFlags,
        LPVOID lpEnvironment,
        LPCWSTR lpCurrentDirectory,
        LPSTARTUPINFOW lpStartupInfo ,
        LPPROCESS_INFORMATION lpProcessInformation
       ) {
       MessageBoxA(0, "系统进程已被劫持!" , "系统警告" , 0);
        return 0;
}

void Hook()
{

       DetourRestoreAfterWith(); //恢复原来状态,
       DetourTransactionBegin(); //拦截开始
       DetourUpdateThread(GetCurrentThread()); //刷新当前线程
       DetourAttach(( void **)&oldCreateProcessW, newCreateProcessW); //实现函数拦截
       DetourTransactionCommit(); //拦截生效

}

void UnHook()
{
       DetourTransactionBegin(); //拦截开始
       DetourUpdateThread(GetCurrentThread()); //刷新当前线程
       DetourDetach(( void **)&oldCreateProcessW, newCreateProcessW); //撤销拦截函数
       DetourTransactionCommit(); //拦截生效
}

_declspec(dllexport ) void go(){
       MessageBoxA(0, "系统进程劫持成功!" , "系统信息" , 0);
       int i = 0;
       while (i++ < 60){
              Hook();
              Sleep(1000);
       }
       UnHook();
}

劫持成功:

   技术分享


打开帮助的入门指南的时候:

技术分享




劫持系统进程禁止打开任何进程(5)

标签:

原文地址:http://www.cnblogs.com/ZhangJinkun/p/4531484.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!