Advertisement
Guest User

Untitled

a guest
Jan 30th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. private static unsafe void smethod_2(bool ver)
  2. {
  3.     IntPtr ptr;
  4.     ulong* numPtr2;
  5.     uint num;
  6.     bool_1 = ver;
  7.     string jitdll
  8.     if (ver)
  9.     {
  10. jitdll = "clrjit.dll";
  11.     }
  12.     else
  13.     {
  14. jitdll = "mscorjit.dll";
  15.     }
  16.     IntPtr lib = LoadLibrary(jitdll);
  17.     intptr_0 = Marshal.ReadIntPtr(((Delegate4) Marshal.GetDelegateForFunctionPointer(GetProcAddress(lib, "getJit")), typeof(Delegate4)))());
  18.     intptr_1 = Marshal.ReadIntPtr(intptr_0);
  19.     //get compileMethod addr
  20.     if (IntPtr.Size == 8)
  21.     {
  22.         ptr = Marshal.AllocHGlobal(0x10);
  23.         numPtr2 = (ulong*) ptr;
  24.         numPtr2[0] = 18446744073709533256L;
  25.         numPtr2[1] = 10416984890032521215L;
  26.         VirtualProtect(ptr, 12, 64, out num);
  27.         //hook with custom
  28.         Marshal.WriteIntPtr(ptr, 2, intptr_1);
  29.     }
  30.     else
  31.     {
  32.         ptr = Marshal.AllocHGlobal(8);
  33.         numPtr2 = (ulong*) ptr;
  34.         numPtr2[0] = 10439625411221520312L;
  35.         VirtualProtect(ptr, 7, (uint) ((0x32da5ab6 ^ 0x67c82111) - 0x55127b67), out num);
  36.         Marshal.WriteIntPtr(ptr, 1, intptr_1);
  37.     }
  38.     delegate0_0 = (Delegate0) Marshal.GetDelegateForFunctionPointer(ptr, typeof(Delegate0));
  39.     RuntimeHelpers.PrepareDelegate(delegate0_0);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement