I had GreyMagic working a while ago, but it involved compiling 2 other things (1 dll, 1 executable and the injected classes DLL). I have since lost the code, and forgotten how to inject a managed .net DLL into the application.
I've been trying all of the options available, and none seem to work. This is the code I have:
Code:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
using GreyMagic;
using System.Windows.Forms;
namespace WoWHack
{
public class Class1
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int FrameScript_ExecuteBufferDelegate(byte a, IntPtr addr, IntPtr addrStr);
public FrameScript_ExecuteBufferDelegate FrameScript_ExecuteBuffer;
public void main()
{
Process p = Process.GetCurrentProcess();
InProcessMemoryReader Memory = new InProcessMemoryReader(p);
FrameScript_ExecuteBuffer = Memory.CreateFunction<FrameScript_ExecuteBufferDelegate>((IntPtr)0x4F9EC, true);
string str = "print('test');";
IntPtr buff = Marshal.AllocHGlobal(str.Length + 0x100);
Memory.WriteString(buff, str, Encoding.UTF8);
FrameScript_ExecuteBuffer(0, buff, buff);
Marshal.FreeHGlobal(buff);
}
public static int DllMain(string p)
{
MessageBox.Show(p, "Managed MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
new Class1().main();
return -1;
}
}
}
However, No messagebox is shown, and generally there is some kind of error.
What should I do? Are there any pre-made applications to inject a .net dll into a native process?
Thanks for reading.