Advertisement
SEMO_Pa3x

c++

May 18th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1.     #include <windows.h>
  2.     #include "detours.h"
  3.      
  4.     DETOUR_TRAMPOLINE(bool WINAPI DeviceIoControl_t(HANDLE hDevice,  
  5.                                                     DWORD dwIoControlCode,
  6.                                                     LPVOID lpInBuffer,
  7.                                                     DWORD nInBufferSize,
  8.                                     LPVOID lpOutBuffer,
  9.                                                     DWORD nOutBufferSize,            
  10.                                                     LPDWORD lpBytesReturned,
  11.                                                     LPOVERLAPPED lpOverlapped),
  12.                                                     DeviceIoControl);
  13.      
  14.     bool WINAPI pDeviceIoControl(HANDLE hDevice,
  15.                                  DWORD dwIoControlCode,
  16.                                  LPVOID lpInBuffer,
  17.                                  DWORD nInBufferSize,
  18.                                  LPVOID lpOutBuffer,
  19.                                  DWORD nOutBufferSize,
  20.                                  LPDWORD lpBytesReturned,
  21.                                  LPOVERLAPPED lpOverlapped)
  22.     {
  23.      
  24.       bool bRet = DeviceIoControl_t(hDevice,
  25.                                     dwIoControlCode,
  26.                                     lpInBuffer,
  27.                                     nInBufferSize,
  28.                                     lpOutBuffer,
  29.                                     nOutBufferSize,
  30.                             lpBytesReturned,
  31.                                     lpOverlapped);
  32.      
  33.       // Magic could go here
  34.      
  35.      
  36.      
  37.       return bRet;
  38.      
  39.     }
  40.      
  41.      
  42.     void WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
  43.     {
  44.            
  45.       if(ul_reason_for_call == DLL_PROCESS_ATTACH)       
  46.       DetourFunctionWithTrampoline((PBYTE)DeviceIoControl_t, (PBYTE)pDeviceIoControl);
  47.       else if(ul_reason_for_call == DLL_PROCESS_DETACH)
  48.       DetourRemove((PBYTE)DeviceIoControl_t, (PBYTE)pDeviceIoControl);
  49.      
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement