1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include "C:\Users\Androide\Desktop\minhook\Dynamic\MinHook_133_src\include\MinHook.h"//MHook header
#include <iostream>
#include <windows.h>
#include <Commctrl.h>
#include <conio.h>//For getch
using namespace std;
typedef void (*SENDMESSAGEW)();//Typedef for the hooked function
static SENDMESSAGEW Basewritefoobar;//Backup of the originak fonction
LRESULT WINAPI SendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
static const wchar_t *hiddenprocess=L"tusitio";
LRESULT WINAPI BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
if ( msg == LVM_INSERTITEMW || msg == LVM_SETITEMW)//Intercepts LVM_INSERTITEM and LVM_SETITEM messages
{
if (!lstrcmpW(((LVITEMW*)lparam)->pszText, hiddenprocess))//The lparam is a LVITEM* struct.
{
return 0;//If the item name is the same as process we want to hide, we simply return 0 (and we do not call the real SendMessage function.
}
return 0;
}
return SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
}
static bool Hook();
template <typename T>
inline MH_STATUS MH_CreateHookEx(void* target, void* const base, T** original)
{
return MH_CreateHook(target, base, reinterpret_cast<void**>(original));
}
int main()
{
if (!Hook())//Hook "Writefoobar"
{
cout << "Hook failed" << endl;
return 1;
}
cout << "Press a key to exit" << endl;
_getch();
return 0;
}
bool Hook()
{
if (MH_Initialize() != MH_OK)
{
return false;
}
if (MH_CreateHookEx((void*)&SendMessageW, (void*)&BSSSendMessageW, &Basewritefoobar) != MH_OK)
{
return FALSE;
}
return MH_EnableHook((void*)&SendMessageW) == MH_OK;
}
|