private unsafe void Form1_Load(object sender, EventArgs e) { DLLFromMemory dll = new DLLFromMemory(Properties.Resources.DllInC__); SomeExportedFunctionInTheDll addFunc = dll.GetDelegateFromFuncName <SomeExportedFunctionInTheDll>("AddInteger"); MessageBox.Show(addFunc.DynamicInvoke(10, 10).ToString()); }
static int Main(string[] args) { Console.WriteLine("Process is " + (DLLFromMemory.Is64BitProcess ? "64" : "32") + "bit\n"); DLLFromMemory dll = new DLLFromMemory(GetSampleDLLBytes()); AddDelegate addFunc = dll.GetDelegateFromFuncName <AddDelegate>("Add"); Console.WriteLine("Calling add(1, 2): " + addFunc(1, 2) + "\n"); CallCallbackDelegate callCallbackFunc = dll.GetDelegateFromFuncName <CallCallbackDelegate>("CallCallback"); Console.WriteLine("Calling callCallback(TestCallback, 777)..."); callCallbackFunc(TestCallback, 777); Console.WriteLine("Done!\n"); dll.Close(); return(0); }