Hijacking system process prevents file creation

Source: Internet
Author: User

<title>Hijacking system process prevents file creation</title> #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, "Hijacking success!" " , "System Information" , 0);        return 0;}
void Hook (){
Detourrestoreafterwith (); //Return to its original state,Detourtransactionbegin (); //Intercept startDetourupdatethread (GetCurrentThread ()); //Refresh current threadDetourattach (( void * *) &oldcreatefilew, newcreatefilew); //Implement function interceptiondetourtransactioncommit (); //interception takes effect
}
void unhook (){Detourtransactionbegin (); //Intercept startDetourupdatethread (GetCurrentThread ()); //Refresh current threadDetourdetach (( void * *) &oldcreatefilew, newcreatefilew); //Undo Intercept functiondetourtransactioncommit (); //interception takes effect}
_declspec(dllexport) void Go () {messageboxa (0, "System process hijacking succeeded!" " , "System Information" , 0);        int i = 0;        while (1) {Hook ();               if (i = =) {unhook ();                      Break;              }Sleep (+);       }}

From for notes (Wiz)

Hijacking system process prevents file creation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.