zoukankan      html  css  js  c++  java
  • 劫持系统进程禁止创建文件

    劫持系统进程禁止创建文件
    #include<stdio.h>
    #include<windows.h>
    #include<string.h>
    #include"detours.h"
    #pragma comment (lib ,"detours.lib" )

    HANDLE(WINAPI * oldCreateFileW)(
            _In_ LPCWSTR lpFileName,
            _In_ DWORD dwDesiredAccess,
            _In_ DWORD dwShareMode,
            _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
            _In_ DWORD dwCreationDisposition,
            _In_ DWORD dwFlagsAndAttributes,
            _In_opt_ HANDLE hTemplateFile
           ) = CreateFileW;

    HANDLE WINAPI newCreateFileW(
            _In_ LPCWSTR lpFileName,
            _In_ DWORD dwDesiredAccess,
            _In_ DWORD dwShareMode,
            _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes ,
            _In_ DWORD dwCreationDisposition,
            _In_ DWORD dwFlagsAndAttributes,
            _In_opt_ HANDLE hTemplateFile
           ){
           MessageBoxA(0, "劫持成功!" , "系统信息" , 0);
            return 0;
    }

    void Hook()
    {

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

    }

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

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




  • 相关阅读:
    Java 练习(获取两个字符串中最大相同子串)
    STM32F103 实现 简易闹钟小程序
    STM32F103 实现 LCD显示年月日时分秒星期 并可逐值修改的日期 小程序
    Docker报错之“Failed to get D-Bus connection: Operation not permitted”
    数据结构解析
    每天一条DB2命令-004
    每天一条DB2命令-003
    每天一条DB2命令-002
    ElasticSearch系列
    模块三 GO语言实战与应用-BYTES包与字节串操作(下)
  • 原文地址:https://www.cnblogs.com/ZhangJinkun/p/4531478.html
Copyright © 2011-2022 走看看