Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- private static GameUI GetCGameUI(Int32 construct, Int32 destruct)
- {
- // Manual implementation of __fastcall.
- // Moves the two first arguments to the registers.
- var code = new byte[16];
- var stream = new MemoryStream(code);
- var writer = new BinaryWriter(stream);
- var codePtr = Kernel32.VirtualAlloc(IntPtr.Zero, code.Length, AllocationType.Commit, MemoryProtection.ExecuteReadWrite);
- // (BA) mov edx, destruct boolean
- writer.Write((Byte)0xBA);
- writer.Write((UInt32)destruct);
- // (B9) mov ecx, construct boolean
- writer.Write((Byte)0xB9);
- writer.Write((UInt32)construct);
- // (E8) call, GetCGameUI relative offset
- writer.Write((Byte)0xE8);
- writer.Write((UInt32)((Int32)Addresses.GetCGameUI - (Int32)codePtr - (Int32)writer.BaseStream.Position - 4));
- // (C3) retn
- writer.Write((Byte)0xC3);
- Marshal.Copy(code, 0, codePtr, code.Length);
- var ui = ((EmptyGetCGameUIPrototype)Marshal.GetDelegateForFunctionPointer(codePtr, typeof(EmptyGetCGameUIPrototype)))();
- Kernel32.VirtualFree(codePtr, code.Length, 0x8000);
- return ui;
- }
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement