You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

5 years ago
#include <iostream>
#include "hook.hpp"
5 years ago
using namespace std;
BOOL HookWriteFile(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped
)
{
//this will change the output to "shithooked!\n"
5 years ago
memset((void *)lpBuffer, NULL, nNumberOfBytesToWrite);
memcpy((void*)lpBuffer, "shithooked!?\n", sizeof("shithooked!\n"));
hook::disable(&WriteFile);
5 years ago
BOOL result = WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped);
hook::enable(&WriteFile);
5 years ago
return result;
}
int main()
{
5 years ago
hook::install(
&WriteFile,
&HookWriteFile
5 years ago
);
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);
}
}