Riremito

Hook Address Finder

Mar 4th, 2015
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. DWORD AirMemory::AutoVMHook(DWORD Address, void *Function, DWORD *RetAddr, DWORD MinAddr){
  2.     DWORD i, VMSection, VMSection_Ret;
  3.  
  4.     Address = GetAbsoluteAddress(Address);
  5.  
  6.     for(i=Address; ;i++){
  7.         if(*(BYTE *)i == JMP){
  8.             VMSection = *(DWORD *)(i + 1) + i + 5;
  9.             if((VMSection > Memory_Start) && (VMSection < Memory_End)){
  10.                 break;
  11.             }
  12.         }
  13.     }
  14.  
  15.     for(i=VMSection; ;i++){
  16.         switch(*(BYTE *)i){
  17.         case JMP:
  18.             VMSection_Ret =  *(DWORD *)(i + 1) + i + 5;
  19.             if((VMSection_Ret > Memory_Start) && (VMSection_Ret < Memory_End)){
  20.                 if(MinAddr && i < MinAddr){
  21.                     i = VMSection_Ret;
  22.                     break;
  23.                 }
  24.                 WriteHook(i, JMP, Function);
  25.                 *RetAddr = VMSection_Ret;
  26.                 return i;
  27.             }
  28.             break;
  29.  
  30.         case CALL:
  31.             VMSection_Ret =  *(DWORD *)(i + 1) + i + 5;
  32.             if((VMSection_Ret > Memory_Start) && (VMSection_Ret < Memory_End)){
  33.                 if(MinAddr && i < MinAddr){
  34.                     i = VMSection_Ret;
  35.                     break;
  36.                 }
  37.                 WriteHook(i, CALL, Function);
  38.                 *RetAddr = VMSection_Ret;
  39.                 return i;
  40.             }
  41.             break;
  42.  
  43.         default:
  44.             break;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment