<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