|
|
|
#include <iostream>
|
|
|
|
#include "hook.hpp"
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
BOOL HookWriteFile(
|
|
|
|
HANDLE hFile,
|
|
|
|
LPCVOID lpBuffer,
|
|
|
|
DWORD nNumberOfBytesToWrite,
|
|
|
|
LPDWORD lpNumberOfBytesWritten,
|
|
|
|
LPOVERLAPPED lpOverlapped
|
|
|
|
)
|
|
|
|
{
|
|
|
|
|
|
|
|
//this will change the output to "shithooked!\n"
|
|
|
|
|
|
|
|
memset((void *)lpBuffer, NULL, nNumberOfBytesToWrite);
|
|
|
|
memcpy((void*)lpBuffer, "shithooked!?\n", sizeof("shithooked!\n"));
|
|
|
|
hook::disable(&WriteFile);
|
|
|
|
BOOL result = WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped);
|
|
|
|
hook::enable(&WriteFile);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
hook::install(
|
|
|
|
&WriteFile,
|
|
|
|
&HookWriteFile
|
|
|
|
);
|
|
|
|
|
|
|
|
OFSTRUCT ofstruct;
|
|
|
|
OpenFile("output.txt", &ofstruct, OF_CREATE);
|
|
|
|
HFILE result = OpenFile("output.txt", &ofstruct, OF_READWRITE);
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
Sleep(1000);
|
|
|
|
char aString[] = "Hello world!\n";
|
|
|
|
WriteFile((HANDLE)result, aString, sizeof(aString), NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|