Rei_anami

Lock/Unlock decorators

Sep 26th, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public unsafe static byte* FindPattern(string pattern, string mask)
  2.     {
  3.         ProcessModule module = Process.GetCurrentProcess().MainModule;
  4.  
  5.         ulong address = (ulong)module.BaseAddress.ToInt64();
  6.         ulong endAddress = address + (ulong)module.ModuleMemorySize;
  7.  
  8.         for (; address < endAddress; address++)
  9.         {
  10.             for (int i = 0; i < pattern.Length; i++)
  11.             {
  12.                 if (mask[i] != '?' && ((byte*)address)[i] != pattern[i])
  13.                 {
  14.                     break;
  15.                 }
  16.                 else if (i + 1 == pattern.Length)
  17.                 {
  18.                     return (byte*)address;
  19.                 }
  20.             }
  21.         }
  22.  
  23.         return null;
  24.     }
  25.     void UnlockDecorator()
  26.     {
  27.  
  28.         unsafe
  29.         {
  30.             IntPtr addr = (IntPtr)FindPattern("\x40\x53\x48\x83\xEC\x20\x80\x3D\x00\x00\x00\x00\x00\x8B\xDA\x75\x29",
  31.                             "xxxxxxxx????xxxxx");
  32.             if (addr != IntPtr.Zero)
  33.             {
  34.                 byte* g_bIsDecorRegisterLockedPtr = (byte*)(addr + *(int*)(addr + 8) + 13);
  35.                 *g_bIsDecorRegisterLockedPtr = 0;
  36.             }
  37.  
  38.         }
  39.     }
  40.     void LockDecotator()
  41.     {
  42.         unsafe
  43.         {
  44.             IntPtr addr = (IntPtr)FindPattern("\x40\x53\x48\x83\xEC\x20\x80\x3D\x00\x00\x00\x00\x00\x8B\xDA\x75\x29",
  45.                             "xxxxxxxx????xxxxx");
  46.             if (addr != IntPtr.Zero)
  47.             {
  48.                 byte* g_bIsDecorRegisterLockedPtr = (byte*)(addr + *(int*)(addr + 8) + 13);
  49.                 *g_bIsDecorRegisterLockedPtr = 1;
  50.             }
  51.  
  52.         }
  53.     }
Add Comment
Please, Sign In to add comment