Advertisement
ru124

StatHook Help

May 22nd, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. //Source By Ru124 XD
  2.  
  3. //RCMain.h My Windows Form
  4.  
  5. #define jmp(frm, to) (int)(((int)to - (int)frm) - 5) // needed for some hacks.
  6.  
  7. unsigned long ulStat = 0x0089307F;
  8. unsigned long ulStatReturn = 0x0089307F;
  9.  
  10. long int HP = 0,
  11.     MP = 0,
  12.     MaxHP = 0,
  13.     MaxMP = 0,
  14.     Exp = 0,
  15.     MaxExp = 0;
  16.  
  17. void MakePageWritable(unsigned long ulAddress, unsigned long ulSize)
  18.         {
  19.             MEMORY_BASIC_INFORMATION* mbi = new MEMORY_BASIC_INFORMATION;
  20.             VirtualQuery((void*)ulAddress, mbi, ulSize);
  21.             if (mbi->Protect != PAGE_EXECUTE_READWRITE)
  22.             {
  23.                 unsigned long* ulProtect = new unsigned long;
  24.                 VirtualProtect((void*)ulAddress, ulSize, PAGE_EXECUTE_READWRITE, ulProtect);
  25.                 delete ulProtect;
  26.             }
  27.             delete mbi;
  28.         }
  29.  
  30. void Jump(  unsigned long ulAddress,   //Address at which a long jump/call is placed
  31.             void* Function,      //A pointer to the destination of the long jump or call
  32.             unsigned Nops     )  //If the original opcode is longer than 5 bytes, you must nop the rest.
  33.         {
  34.             MakePageWritable(ulAddress, Nops + 5); //Make memory writable before any modifications are attempted
  35.  
  36.             *(unsigned char*)ulAddress = 0xE9; //E9 is the opcode for a long jump
  37.             *(unsigned long*)(ulAddress + 1) = jmp(ulAddress, Function);//The next 4 bytes indicate the DISPLACEMENT of the destination
  38.             memset((void*)(ulAddress + 5), 0x90, Nops); //nop the rest of the opcode
  39.         }
  40.  
  41. private: System::Void checkBoxStatHook_CheckedChanged(System::Object^  sender, System::EventArgs^  e) //CheckBox Toggle StatHook
  42.          {
  43.              if (checkBoxStatHook->CheckState == CheckState::Checked)
  44.              {
  45.                  Jump(ulStat, StatHook, 0);
  46.              }
  47.              else
  48.              {
  49.              }
  50.          }
  51.  
  52. //ASMFunc.h My Header With ASM Code
  53.  
  54. extern unsigned long ulStat;
  55. extern unsigned long ulStatReturn;
  56. extern long int HP;
  57. extern long int MP;
  58. extern long int MaxHP;
  59. extern long int MaxMP;
  60. extern long int Exp;
  61. extern long int MaxExp;
  62.  
  63. void StatHook()
  64. {
  65.     __asm
  66.     {
  67.         push eax
  68.             mov eax,[ebp+0x08]
  69.         mov [HP],eax
  70.             mov eax,[ebp+0x0c]
  71.         mov [MaxHP],eax
  72.             mov eax,[ebp+0x10]
  73.         mov [MP],eax
  74.             mov eax,[ebp+0x14]
  75.         mov [MaxMP],eax
  76.             mov eax,[ebp+0x18]
  77.         mov [Exp],eax
  78.             mov eax,[ebp+0x1c]
  79.         mov [MaxExp],eax
  80.             pop eax
  81.             lea ecx,[eax+eax*4]
  82.         test ecx,ecx
  83.             jmp ulStatReturn+5
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement