zoukankan      html  css  js  c++  java
  • 劫持系统进程禁止打开任何进程(5)

    劫持系统进程禁止打开任何进程(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();
    }

    劫持成功:

       


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





  • 相关阅读:
    Noip2012 开车旅行
    「NOI2018」归程
    2019.10.30 队测(晚上)
    洛谷P1138 第k小整数
    洛谷P2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold
    Noip-pj2018游记
    洛谷P4994 终于结束的起点
    《退役的你》
    《膜你抄》
    洛谷P5087 数学
  • 原文地址:https://www.cnblogs.com/ZhangJinkun/p/4531484.html
Copyright © 2011-2022 走看看