Advertisement
Guest User

Untitled

a guest
Dec 25th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace MemoryScanner.Tests
  8. {
  9.     class PrintText
  10.     {
  11.         MemoryReader memRead;
  12.         IntPtr TibiaHandle;
  13.         public PrintText(MemoryReader _memread)
  14.         {
  15.             memRead = _memread;
  16.             TibiaHandle = memRead.Handle;
  17.  
  18.         }
  19.         public void CreateCodeCave(int r, int g, int b, int x, int y, byte font, string text,string name)
  20.         {
  21.             byte[] bytes = System.Text.ASCIIEncoding.Default.GetBytes(text);
  22.             IntPtr stringAdr = WinApi.VirtualAllocEx(TibiaHandle, IntPtr.Zero, (uint)bytes.Length, WinApi.AllocationType.Commit | WinApi.AllocationType.Reserve, WinApi.MemoryProtection.ExecuteReadWrite);
  23.                    
  24.             memRead.WriteBytes(stringAdr.ToInt32(), bytes, (uint)bytes.Length);
  25.  
  26.             CodeCaveHelper cv = new CodeCaveHelper();
  27.             cv.AddLine((byte)0x6A, (byte)0x00); //push 0
  28.             cv.AddLine((byte)0x68, (UInt32)stringAdr.ToInt32()); //mov ecx string
  29.  
  30.             cv.AddLine((byte)0x68, (UInt32)b); //push blue int32
  31.  
  32.             cv.AddLine((byte)0x68, (UInt32)g); //push green int32
  33.  
  34.             cv.AddLine((byte)0x68, (UInt32)r); //push red int32
  35.  
  36.             cv.AddLine((byte)0x6A, (byte)font); //push font byte
  37.  
  38.             cv.AddLine((byte)0x68, (UInt32)y); //push x int32
  39.  
  40.             cv.AddLine((byte)0xBA, (UInt32)x); //push y int32
  41.  
  42.             cv.AddLine((byte)0xb9, (UInt32)0x1); //push 1                      
  43.  
  44.             cv.AddLine((byte)0xB8, (UInt32)Addresses.MyAddresses.PrintText.Address); // mov eax dword PrintName
  45.  
  46.             cv.AddLine((byte)0xff, (byte)0xD0); // call eax Thanks Darkstar
  47.  
  48.             cv.AddLine((byte)0x83, (byte)0xc4, (byte)0x1c); //add esp,20
  49.             cv.AddByte(0xC3);
  50.  
  51.             IntPtr CaveAddress = WinApi.VirtualAllocEx(TibiaHandle, IntPtr.Zero, (uint)cv.Data.Length, WinApi.AllocationType.Commit | WinApi.AllocationType.Reserve, WinApi.MemoryProtection.ExecuteReadWrite);
  52.             memRead.WriteBytes(CaveAddress.ToInt32(), cv.Data, (uint)cv.Data.Length);
  53.             ChangePrintFpsCall(CaveAddress);
  54.             System.Windows.Forms.Clipboard.SetText(CaveAddress.ToString("X"));
  55.                    
  56.         }
  57.         private void ChangePrintFpsCall(IntPtr CaveAddress)
  58.         {
  59.             byte[] ReplaceBytes = new byte[]{
  60.                   0xE8, 0xff, 0xff, 0xff,0xff,
  61.  
  62.             };
  63.             Int32 offset2 = CaveAddress.ToInt32() - (int)Addresses.MyAddresses.PrintFPS.Address - 5;
  64.  
  65.             Array.Copy(BitConverter.GetBytes(offset2), 0, ReplaceBytes, 1, 4);
  66.          
  67.             memRead.WriteBytes(Addresses.MyAddresses.PrintFPS.Address, ReplaceBytes, (uint)ReplaceBytes.Length);
  68.             memRead.WriteByte(Addresses.MyAddresses.ShowFPS.Address, 1);
  69.         }
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement